net.sourceforge.jeval
Class EvaluationResult

java.lang.Object
  extended by net.sourceforge.jeval.EvaluationResult

public class EvaluationResult
extends java.lang.Object

This class can be used to wrap the result of an expression evaluation. It contains useful methods for evaluating the contents of the result.


Constructor Summary
EvaluationResult(java.lang.String result, char quoteCharacter)
          Constructor.
 
Method Summary
 java.lang.Double getDouble()
          Returns a Double for the result value.
 char getQuoteCharacter()
          Returns the quote character.
 java.lang.String getResult()
          Returns the result value.
 java.lang.String getUnwrappedString()
          Returns the unwrapped string for the result value.
 boolean isBooleanFalse()
          Returns true if the result value is equal to the value of a Boolean false string (0.0).
 boolean isBooleanTrue()
          Returns true if the result value is equal to the value of a Boolean true string (1.0).
 boolean isString()
          Returns true if the result value starts with a quote character and ends with a quote character.
 void setQuoteCharacter(char quoteCharacter)
          Sets the quote character.
 void setResult(java.lang.String result)
          Sets the result value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EvaluationResult

public EvaluationResult(java.lang.String result,
                        char quoteCharacter)
Constructor.

Parameters:
result - The value returned from the evaluation of an expression.
quoteCharacter - The quote character specified in the evaluation of the expression.
Method Detail

getQuoteCharacter

public char getQuoteCharacter()
Returns the quote character.

Returns:
Returns the quoteCharacter.

setQuoteCharacter

public void setQuoteCharacter(char quoteCharacter)
Sets the quote character.

Parameters:
quoteCharacter - The quoteCharacter to set.

getResult

public java.lang.String getResult()
Returns the result value.

Returns:
Returns the result.

setResult

public void setResult(java.lang.String result)
Sets the result value.

Parameters:
result - The result to set.

isBooleanTrue

public boolean isBooleanTrue()
Returns true if the result value is equal to the value of a Boolean true string (1.0).

Returns:
True if the result value is equal to the value of a Boolean true string (1.0).

isBooleanFalse

public boolean isBooleanFalse()
Returns true if the result value is equal to the value of a Boolean false string (0.0).

Returns:
True if the result value is equal to the value of a Boolean false string (0.0).

isString

public boolean isString()
Returns true if the result value starts with a quote character and ends with a quote character.

Returns:
True if the result value starts with a quote character and ends with a quote character.

getDouble

public java.lang.Double getDouble()
                           throws java.lang.NumberFormatException
Returns a Double for the result value.

Returns:
A Double for the result value.
Throws:
java.lang.NumberFormatException - Thrown if the result value is not a double.

getUnwrappedString

public java.lang.String getUnwrappedString()
Returns the unwrapped string for the result value. An unwrapped string is a string value without the quote characters that wrap the result value. For a string to be returned, then the first character must be a quote character and the last character must be a quote character. Otherwise, a null value is returned.

Returns:
The normal string for the result value. Null will be returned if the result value is not of a string type.


Copyright (C) 2002-2007 Robert Breidecker.