Class XObject
java.lang.Object
org.loboevolution.apache.xpath.Expression
org.loboevolution.apache.xpath.objects.XObject
- All Implemented Interfaces:
SourceLocator,ExpressionNode,XPathVisitable
- Direct Known Subclasses:
NodeSequence,XBoolean,XNumber,XString
This class represents an XPath object, and is capable of converting the object to various types,
such as a string. This class acts as the base class to other XPath type objects, such as XString,
and provides polymorphic casting capabilities.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intConstant for BOOLEAN object typestatic final intConstant for NODESET object typestatic final intConstant for NULL object typestatic final intConstant for NUMBER object typestatic final intConstant for RESULT TREE FRAGMENT object typestatic final intConstant for STRING object typestatic final intConstant for UNKNOWN object typeprotected ObjectThe java object which this object wraps. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidallowDetachToRelease(boolean allowRelease) Specify if it's OK for detach to release the iterator for reuse.booleanbool()Cast result object to a boolean.booleanCast result object to a boolean, but allow side effects, such as the incrementing of an iterator.voidcallVisitors(XPathVisitor visitor) This will traverse the hierarchy, calling the visitor for each member.booleandeepEquals(Expression expr) Compare this object with another object and see if they are equal, include the sub heararchy.voiddetach()Detaches theDTMIteratorfrom the set which it iterated over, releasing any computational resources and placing the iterator in the INVALID state.booleanTell if two objects are functionally equal.protected voidTell the user of an error, and probably throw an exception.protected voidTell the user of an error, and probably throw an exception.execute(XPathContext xctxt) Execute an expression in the XPath runtime context, and return the result of the expression.intgetType()Tell what kind of class this is.Given a request type, return the equivalent string.booleangreaterThan(XObject obj2) Tell if one object is greater than the other.booleangreaterThanOrEqual(XObject obj2) Tell if one object is greater than or equal to the other.iter()Cast result object to a nodelist.booleanTell if one object is less than the other.booleanlessThanOrEqual(XObject obj2) Tell if one object is less than or equal to the other.Cast result object to a nodelist.nodelist()Cast result object to a nodelist.nodeset()Cast result object to a nodelist.booleanTell if two objects are functionally not equal.doublenum()Cast result object to a number.doubleCast result object to a number, but allow side effects, such as the incrementing of an iterator.object()Return a java object that's closest to the representation that should be handed to an extension.protected voidstr()Cast result object to a string.toString()xstr()Cast result object to a string.Methods inherited from class org.loboevolution.apache.xpath.Expression
asIterator, asNode, assertion, bool, canTraverseOutsideSubtree, error, execute, execute, execute, exprGetParent, exprSetParent, getColumnNumber, getExpressionOwner, getLineNumber, getPublicId, getSystemId, isSameClass, isStableNumber, num
-
Field Details
-
m_obj
The java object which this object wraps. -
CLASS_NULL
public static final int CLASS_NULLConstant for NULL object type- See Also:
-
CLASS_UNKNOWN
public static final int CLASS_UNKNOWNConstant for UNKNOWN object type- See Also:
-
CLASS_BOOLEAN
public static final int CLASS_BOOLEANConstant for BOOLEAN object type- See Also:
-
CLASS_NUMBER
public static final int CLASS_NUMBERConstant for NUMBER object type- See Also:
-
CLASS_STRING
public static final int CLASS_STRINGConstant for STRING object type- See Also:
-
CLASS_NODESET
public static final int CLASS_NODESETConstant for NODESET object type- See Also:
-
CLASS_RTREEFRAG
public static final int CLASS_RTREEFRAGConstant for RESULT TREE FRAGMENT object type- See Also:
-
-
Constructor Details
-
XObject
public XObject()Create an XObject. -
XObject
Create an XObject.- Parameters:
obj- Can be any object, should be a specific type for derived classes, or null.
-
-
Method Details
-
setObject
-
execute
Execute an expression in the XPath runtime context, and return the result of the expression.- Specified by:
executein classExpression- Parameters:
xctxt- The XPath runtime context.- Returns:
- The result of the expression in the form of a
XObject. - Throws:
TransformerException- if a runtime exception occurs.
-
allowDetachToRelease
public void allowDetachToRelease(boolean allowRelease) Specify if it's OK for detach to release the iterator for reuse. This function should be called with a value of false for objects that are stored in variables. Calling this with a value of false on a XNodeSet will cause the nodeset to be cached.- Parameters:
allowRelease- true if it is OK for detach to release this iterator for pooling.
-
detach
public void detach()Detaches theDTMIteratorfrom the set which it iterated over, releasing any computational resources and placing the iterator in the INVALID state. Afterdetachhas been invoked, calls tonextNodeorpreviousNodewill raise a runtime exception. -
getType
public int getType()Tell what kind of class this is.- Returns:
- CLASS_UNKNOWN
-
getTypeString
Given a request type, return the equivalent string. For diagnostic purposes.- Returns:
- type string "#UNKNOWN" + object class name
-
num
Cast result object to a number. Always issues an error.- Returns:
- 0.0
- Throws:
TransformerException- in case of error in case of error
-
numWithSideEffects
Cast result object to a number, but allow side effects, such as the incrementing of an iterator.- Returns:
- numeric value of the string conversion from the next node in the NodeSetDTM, or NAN if no node was found
- Throws:
TransformerException
-
bool
Cast result object to a boolean. Always issues an error.- Returns:
- false
- Throws:
TransformerException- in case of error in case of error
-
boolWithSideEffects
Cast result object to a boolean, but allow side effects, such as the incrementing of an iterator.- Returns:
- True if there is a next node in the nodeset
- Throws:
TransformerException
-
xstr
Cast result object to a string.- Returns:
- The string this wraps or the empty string if null
-
str
Cast result object to a string.- Returns:
- The object as a string
-
toString
-
object
Return a java object that's closest to the representation that should be handed to an extension.- Returns:
- The object that this class wraps
-
iter
Cast result object to a nodelist. Always issues an error.- Returns:
- null
- Throws:
TransformerException- in case of error in case of error
-
nodeset
Cast result object to a nodelist. Always issues an error.- Returns:
- null
- Throws:
TransformerException- in case of error in case of error
-
nodelist
Cast result object to a nodelist. Always issues an error.- Returns:
- null
- Throws:
TransformerException- in case of error in case of error
-
mutableNodeset
Cast result object to a nodelist. Always issues an error.- Returns:
- The object as a NodeSetDTM.
- Throws:
TransformerException- in case of error in case of error
-
lessThan
Tell if one object is less than the other.- Parameters:
obj2- Object to compare this to- Returns:
- True if this object is less than the given object
- Throws:
TransformerException- in case of error in case of error
-
lessThanOrEqual
Tell if one object is less than or equal to the other.- Parameters:
obj2- Object to compare this to- Returns:
- True if this object is less than or equal to the given object
- Throws:
TransformerException- in case of error
-
greaterThan
Tell if one object is greater than the other.- Parameters:
obj2- Object to compare this to- Returns:
- True if this object is greater than the given object
- Throws:
TransformerException- in case of error
-
greaterThanOrEqual
Tell if one object is greater than or equal to the other.- Parameters:
obj2- Object to compare this to- Returns:
- True if this object is greater than or equal to the given object
- Throws:
TransformerException- in case of error
-
equals
Tell if two objects are functionally equal.- Parameters:
obj2- Object to compare this to- Returns:
- True if this object is equal to the given object
-
notEquals
Tell if two objects are functionally not equal.- Parameters:
obj2- Object to compare this to- Returns:
- True if this object is not equal to the given object
- Throws:
TransformerException- in case of error
-
error
Tell the user of an error, and probably throw an exception.- Parameters:
msg- Error message to issue- Throws:
TransformerException- in case of error
-
error
Tell the user of an error, and probably throw an exception.- Parameters:
msg- Error message to issueargs- Arguments to use in the message- Throws:
TransformerException- in case of error
-
callVisitors
This will traverse the hierarchy, calling the visitor for each member. If the called visitor method returns false, the subtree should not be called.- Parameters:
visitor- The visitor whose appropriate method will be called.
-
deepEquals
Compare this object with another object and see if they are equal, include the sub heararchy.- Specified by:
deepEqualsin classExpression- Parameters:
expr- Another expression object.- Returns:
- true if this objects class and the expr object's class are the same, and the data contained within both objects are considered equal.
-