org.apache.xpath.objects

Class XNumber

Implemented Interfaces:
Cloneable, Serializable, ExpressionNode, SourceLocator, XPathVisitable

public class XNumber
extends XObject

This class represents an XPath number, and is capable of converting the number to other types, such as a string.

See Also:
Serialized Form

Field Summary

Fields inherited from class org.apache.xpath.objects.XObject

CLASS_BOOLEAN, CLASS_NODESET, CLASS_NULL, CLASS_NUMBER, CLASS_RTREEFRAG, CLASS_STRING, CLASS_UNKNOWN, CLASS_UNRESOLVEDVARIABLE

Constructor Summary

XNumber(Number num)
Construct a XNodeSet object.
XNumber(double d)
Construct a XNodeSet object.

Method Summary

boolean
bool()
Cast result object to a boolean.
void
callVisitors(ExpressionOwner owner, XPathVisitor visitor)
boolean
equals(XObject obj2)
Tell if two objects are functionally equal.
int
getType()
Tell that this is a CLASS_NUMBER.
String
getTypeString()
Given a request type, return the equivalent string.
boolean
isStableNumber()
Tell if this expression returns a stable number that will not change during iterations within the expression.
double
num()
Cast result object to a number.
double
num(XPathContext xctxt)
Evaluate expression to a number.
Object
object()
Return a java object that's closest to the representation that should be handed to an extension.
String
str()
Cast result object to a string.

Methods inherited from class org.apache.xpath.objects.XObject

allowDetachToRelease, appendToFsb, bool, boolWithSideEffects, callVisitors, castToType, create, create, deepEquals, destruct, detach, dispatchCharactersEvents, equals, execute, fixupVariables, getFresh, getType, getTypeString, greaterThan, greaterThanOrEqual, iter, lessThan, lessThanOrEqual, mutableNodeset, nodelist, nodeset, notEquals, num, numWithSideEffects, object, reset, rtf, rtf, rtree, rtree, str, toString, xstr

Methods inherited from class org.apache.xpath.Expression

asIterator, asIteratorRaw, asNode, assertion, bool, canTraverseOutsideSubtree, deepEquals, error, execute, execute, execute, execute, executeCharsToContentHandler, exprAddChild, exprGetChild, exprGetNumChildren, exprGetParent, exprSetParent, fixupVariables, getColumnNumber, getExpressionOwner, getLineNumber, getPublicId, getSystemId, isNodesetExpr, isStableNumber, num, warn, xstr

Constructor Details

XNumber

public XNumber(Number num)
Construct a XNodeSet object.

Parameters:


XNumber

public XNumber(double d)
Construct a XNodeSet object.

Parameters:
d - Value of the object

Method Details

bool

public boolean bool()
Cast result object to a boolean.
Overrides:
bool in interface XObject

Returns:
false if the value is NaN or equal to 0.0


callVisitors

public void callVisitors(ExpressionOwner owner,
                         XPathVisitor visitor)
Specified by:
callVisitors in interface XPathVisitable
Overrides:
callVisitors in interface XObject

See Also:
XPathVisitable.callVisitors(ExpressionOwner, XPathVisitor)


equals

public boolean equals(XObject obj2)
Tell if two objects are functionally equal.
Overrides:
equals in interface XObject

Parameters:
obj2 - Object to compare this to

Returns:
true if the two objects are equal


getType

public int getType()
Tell that this is a CLASS_NUMBER.
Overrides:
getType in interface XObject

Returns:
node type CLASS_NUMBER


getTypeString

public String getTypeString()
Given a request type, return the equivalent string. For diagnostic purposes.
Overrides:
getTypeString in interface XObject

Returns:
type string "#NUMBER"


isStableNumber

public boolean isStableNumber()
Tell if this expression returns a stable number that will not change during iterations within the expression. This is used to determine if a proximity position predicate can indicate that no more searching has to occur.
Overrides:
isStableNumber in interface Expression

Returns:
true if the expression represents a stable number.


num

public double num()
Cast result object to a number.
Overrides:
num in interface XObject

Returns:
the value of the XNumber object


num

public double num(XPathContext xctxt)
            throws TransformerException
Evaluate expression to a number.
Overrides:
num in interface Expression

Returns:
0.0

Throws:
TransformerException -


object

public Object object()
Return a java object that's closest to the representation that should be handed to an extension.
Overrides:
object in interface XObject

Returns:
The value of this XNumber as a Double object


str

public String str()
Cast result object to a string.
Overrides:
str in interface XObject

Returns:
"NaN" if the number is NaN, Infinity or -Infinity if the number is infinite or the string value of the number.


Copyright B) 2004 Apache XML Project. All Rights Reserved.