adapforms.runtime.state
Class BooleanExpression

java.lang.Object
  extended by adapforms.runtime.state.BooleanExpression

public class BooleanExpression
extends java.lang.Object

Represents a boolean expression that may be either a constant or an XPath expression that will evaluate to a boolean value.

The actual value may be overwritten explicitly at runtime, but in case of an XPath expression, the value is re-overwritten when the expression is re-evaluated.

Author:
Henrik Gammelmark, geemark@cs.au.dk

Constructor Summary
BooleanExpression(boolean constant)
          Create a new constant expression
BooleanExpression(javax.xml.xpath.XPathExpression xpath)
          Create a new XPath expression to be interpreted as a boolean.
 
Method Summary
 BooleanExpression clone()
          Create a complete clone of the instance.
 boolean evaluate(java.lang.Object stateXmlNode)
          Evaluate the value of the expression based on the current form instance state.
static BooleanExpression False()
          Create a new expression with the initial constant value of false
 javax.xml.xpath.XPathExpression getXPath()
          Get the associated XPath expression, or null if none.
 boolean isConstant()
          Determine if the expression is a constant.
 void setValue(boolean value)
          Change the value of the expression.
 java.lang.String toString()
           
static BooleanExpression True()
          Create a new expression with the initial constant value of true
 java.lang.Boolean value()
          The value of the constant, or the most recent evaluation of the XPath expression.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BooleanExpression

public BooleanExpression(boolean constant)
Create a new constant expression

Parameters:
constant - The constant value

BooleanExpression

public BooleanExpression(javax.xml.xpath.XPathExpression xpath)
Create a new XPath expression to be interpreted as a boolean.

Parameters:
xpath - XPath expression
Method Detail

isConstant

public boolean isConstant()
Determine if the expression is a constant.


value

public java.lang.Boolean value()
The value of the constant, or the most recent evaluation of the XPath expression.

If no such recent evaluation exists, null is returned.

See Also:
evaluate(Object)

setValue

public void setValue(boolean value)
Change the value of the expression.

Notice that the value will be overwritten if/when the XPath expression is re-evaluated.

Parameters:
value - New value

evaluate

public boolean evaluate(java.lang.Object stateXmlNode)
Evaluate the value of the expression based on the current form instance state. In case of a constant value, the constant is returned.

Parameters:
stateXmlNode - The specific XML state node (or document) to use for evaluation

getXPath

public javax.xml.xpath.XPathExpression getXPath()
Get the associated XPath expression, or null if none.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

True

public static final BooleanExpression True()
Create a new expression with the initial constant value of true


False

public static final BooleanExpression False()
Create a new expression with the initial constant value of false


clone

public BooleanExpression clone()
Create a complete clone of the instance.

Overrides:
clone in class java.lang.Object