Logo Search packages:      
Sourcecode: mathpiper version File versions  Download package

EvaluationResponse.java

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.mathpiper.interpreters;

/**
 * This class is used by an {@link Interpreter} to send the results of an evaluation to
 * client code.
 */
00012 public class EvaluationResponse {
    private String result = "";
    private String loadResult = "";
    private String sideEffects = "";
    private String exceptionMessage = "";
    private boolean exceptionThrown = false;
    private Exception exception = null;
    private int lineNumber;
    private String sourceFileName = "";
    private Object object = null;
            
    private EvaluationResponse()
    {
    }

    /**
     * A static factory method which is used to crerate new EvaluationResponse objects.
     *
     * @return a new EvaluationResponse
     */
00032     public static EvaluationResponse newInstance()
    {
        return new EvaluationResponse();
    }

    /**
     * Returns the name of the source file in which an error occurred.
     *
     * @return the name of the source file
     */
00042     public String getSourceFileName()
    {
        return sourceFileName;
    }

    /**
     * Sets the name of the source file in which an error occurred.
     *
     * @param  name of the source file
     */
00052     public void setSourceFileName(String sourceFileName)
    {
        this.sourceFileName = sourceFileName;
    }

    /**
     * Returns the line number near where an error occurred.
     *
     * @return the line number near where an error occurred
     */
00062     public int getLineNumber()
    {
        return lineNumber;
    }

    /**
     * Sets the line number near where an error occurred.
     *
     * @param  lineNumber the line number near where an error occurred
     */
00072     public void setLineNumber(int lineNumber)
    {
        this.lineNumber = lineNumber;
    }

    /**
     * Returns the result of the evaluation.
     *
     * @return the result of the evaluation
     */
00082     public String getResult()
    {
        return result;
    }

    /**
     * Sets the result of the evaluation.
     *
     * @param result the result of the evaluation
     */
00092     public void setResult(String result)
    {
        this.result = result.trim();
    }

    /**
     * Returns any side effects generated by the evaluation.
     * 
     * @return any side effects generated by the evaluation
     */
00102     public String getSideEffects()
    {
        return sideEffects;
    }

    /**
     * Sets any side effects generated by the evaluation.
     * 
     * @param sideEffects any side effects generated by the evaluation
     */
00112     public void setSideEffects(String sideEffects)
    {
        this.sideEffects = sideEffects.trim();
    }

    /**
     * Returns the exception message generated by the evaluation (if present).
     *
     * @return the exception message
     */
00122     public String getExceptionMessage()
    {
        return exceptionMessage;
    }

    /**
     * Sets the exception message generated by the evaluation (if present).
     *
     * @param exceptionMessage the exception message
     */
00132     public void setExceptionMessage(String exceptionMessage)
    {
        if(exceptionMessage != null)
        {
            this.exceptionMessage = exceptionMessage.trim();
        }
    }

     /**
     * Returns the exception object thrown by the evaluation (if present).
     *
     * @return the exception object
     */
00145     public Exception getException()
    {
        return exception;
    }

    /**
     * Sets the exception object thrown by the evaluation (if present).
     *
     * @param exception the exception object
     */
00155     public void setException(Exception exception)
    {
        this.exceptionThrown = true;
        this.exception = exception;
    }

    /**
     * Allows the client to determine if the evaluation threw an exception.
     *
     * @return {@code true} if an exception was thrown and {@code false} otherwise
     */
    public boolean isExceptionThrown()
    {
        return exceptionThrown;
    }

    /**
     * Sets a Java object to be returned to the user..
     *
     * @param exception the exception object
     */
    public void setObject(Object object)
    {
        this.object = object;
    }

    /**
     * Allows the user to obtain a Java object from a function.
     *
     * @return a Java object if one is available to return to the user.
     */
    public Object getObject()
    {
        return object;
    }

}//end class.

Generated by  Doxygen 1.6.0   Back to index