All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.dflib.jjava.jupyter.messages.reply.ExecuteReply Maven / Gradle / Ivy

The newest version!
package org.dflib.jjava.jupyter.messages.reply;

import com.google.gson.annotations.SerializedName;
import org.dflib.jjava.jupyter.kernel.ExpressionValue;
import org.dflib.jjava.jupyter.messages.ContentType;
import org.dflib.jjava.jupyter.messages.MessageType;
import org.dflib.jjava.jupyter.messages.ReplyType;
import org.dflib.jjava.jupyter.messages.publish.PublishDisplayData;
import org.dflib.jjava.jupyter.messages.request.ExecuteRequest;

import java.util.Map;

public class ExecuteReply implements ContentType, ReplyType {
    public static final MessageType MESSAGE_TYPE = MessageType.EXECUTE_REPLY;
    public static final MessageType REQUEST_MESSAGE_TYPE = MessageType.EXECUTE_REQUEST;

    @Override
    public MessageType getType() {
        return MESSAGE_TYPE;
    }

    @Override
    public MessageType getRequestType() {
        return REQUEST_MESSAGE_TYPE;
    }

    public enum Status {
        @SerializedName("ok") OK,
        @SerializedName("error") ERROR
    }

    private final Status status;

    @SerializedName("execution_count")
    protected final int executionCount;

    /**
     * The values are either {@link ErrorReply} or {@link PublishDisplayData}
     */
    @SerializedName("user_expressions")
    protected final Map evaluatedUserExpr;

    public ExecuteReply(int executionCount, Map evaluatedUserExpr) {
        this.status = Status.OK;
        this.executionCount = executionCount;
        this.evaluatedUserExpr = evaluatedUserExpr;
    }

    public ExecuteReply(int executionCount) {
        this.status = Status.ERROR;
        this.executionCount = executionCount;
        this.evaluatedUserExpr = null;
    }

    public Status getStatus() {
        return status;
    }

    public int getExecutionCount() {
        return executionCount;
    }

    public Map getEvaluatedUserExpr() {
        return evaluatedUserExpr;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy