Package org.apache.xpath.objects
Class XObject
java.lang.Object
org.apache.xpath.Expression
org.apache.xpath.objects.XObject
- All Implemented Interfaces:
Serializable
,Cloneable
,SourceLocator
,ExpressionNode
,XPathVisitable
- Direct Known Subclasses:
NodeSequence
,XBoolean
,XNumber
,XRTreeFrag
,XString
,XUnresolvedVariable
,XUnresolvedVariableSimple
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.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Constant for BOOLEAN object typestatic final int
Constant for NODESET object typestatic final int
Constant for NULL object typestatic final int
Constant for NUMBER object typestatic final int
Constant for RESULT TREE FRAGMENT object typestatic final int
Constant for STRING object typestatic final int
Constant for UNKNOWN object typestatic final int
Represents an unresolved variable type as an integer. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
allowDetachToRelease
(boolean allowRelease) Specify if it's OK for detach to release the iterator for reuse.void
Cast result object to a string.boolean
bool()
Cast result object to a boolean.boolean
Cast result object to a boolean, but allow side effects, such as the incrementing of an iterator.void
callVisitors
(ExpressionOwner owner, XPathVisitor visitor) This will traverse the heararchy, calling the visitor for each member.castToType
(int t, XPathContext support) Cast object to type t.static XObject
Create the right XObject based on the type of the object passed.static XObject
create
(Object val, XPathContext xctxt) Create the right XObject based on the type of the object passed.boolean
deepEquals
(Expression expr) Compare this object with another object and see if they are equal, include the sub heararchy.void
destruct()
Forces the object to release it's resources.void
detach()
Detaches theDTMIterator
from the set which it iterated over, releasing any computational resources and placing the iterator in the INVALID state.void
Directly call the characters method on the passed ContentHandler for the string-value.boolean
Tell if two objects are functionally equal.execute
(XPathContext xctxt) For support of literal objects in xpaths.void
fixupVariables
(Vector vars, int globalsSize) XObjects should not normally need to fix up variables.getFresh()
Get a fresh copy of the object.int
getType()
Tell what kind of class this is.Given a request type, return the equivalent string.boolean
greaterThan
(XObject obj2) Tell if one object is greater than the other.boolean
greaterThanOrEqual
(XObject obj2) Tell if one object is greater than or equal to the other.iter()
Cast result object to a nodelist.boolean
Tell if one object is less than the other.boolean
lessThanOrEqual
(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.org.w3c.dom.traversal.NodeIterator
nodeset()
Cast result object to a nodelist.boolean
Tell if two objects are functionally not equal.double
num()
Cast result object to a number.double
Cast 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.void
reset()
Reset for fresh reuse.int
rtf()
For functions to override.int
rtf
(XPathContext support) Cast result object to a result tree fragment.rtree()
For functions to override.rtree
(XPathContext support) Cast result object to a result tree fragment.str()
Cast result object to a string.toString()
Return the string representation of the objectxstr()
Cast result object to a string.Methods inherited from class org.apache.xpath.Expression
asIterator, asIteratorRaw, asNode, assertion, bool, canTraverseOutsideSubtree, error, execute, execute, execute, executeCharsToContentHandler, exprAddChild, exprGetChild, exprGetNumChildren, exprGetParent, exprSetParent, getColumnNumber, getExpressionOwner, getLineNumber, getPublicId, getSystemId, isNodesetExpr, isStableNumber, num, warn, xstr
-
Field Details
-
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:
-
CLASS_UNRESOLVEDVARIABLE
public static final int CLASS_UNRESOLVEDVARIABLERepresents an unresolved variable type as an integer.- 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
-
execute
For support of literal objects in xpaths.- Specified by:
execute
in classExpression
- Parameters:
xctxt
- The XPath execution context.- Returns:
- This object.
- Throws:
TransformerException
-
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 theDTMIterator
from the set which it iterated over, releasing any computational resources and placing the iterator in the INVALID state. Afterdetach
has been invoked, calls tonextNode
orpreviousNode
will raise a runtime exception. -
destruct
public void destruct()Forces the object to release it's resources. This is more harsh than detach(). -
reset
public void reset()Reset for fresh reuse. -
dispatchCharactersEvents
Directly call the characters method on the passed ContentHandler for the string-value. Multiple calls to the ContentHandler's characters methods may well occur for a single call to this method.- Parameters:
ch
- A non-null reference to a ContentHandler.- Throws:
SAXException
-
create
Create the right XObject based on the type of the object passed. This function can not make an XObject that exposes DOM Nodes, NodeLists, and NodeIterators to the XSLT stylesheet as node-sets.- Parameters:
val
- The java object which this object will wrap.- Returns:
- the right XObject based on the type of the object passed.
-
create
Create the right XObject based on the type of the object passed. This functioncan make an XObject that exposes DOM Nodes, NodeLists, and NodeIterators to the XSLT stylesheet as node-sets.- Parameters:
val
- The java object which this object will wrap.xctxt
- The XPath context.- Returns:
- the right XObject based on the type of the object passed.
-
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
-
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
-
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
Return the string representation of the object -
rtf
Cast result object to a result tree fragment.- Parameters:
support
- XPath context to use for the conversion- Returns:
- the objec as a result tree fragment.
-
rtree
Cast result object to a result tree fragment.- Parameters:
support
- XPath context to use for the conversion- Returns:
- the objec as a result tree fragment.
-
rtree
For functions to override.- Returns:
- null
-
rtf
public int rtf()For functions to override.- Returns:
- null
-
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
-
getFresh
Get a fresh copy of the object. For use with variables.- Returns:
- This object, unless overridden by subclass.
-
nodeset
Cast result object to a nodelist. Always issues an error.- Returns:
- null
- Throws:
TransformerException
-
nodelist
Cast result object to a nodelist. Always issues an error.- Returns:
- null
- Throws:
TransformerException
-
mutableNodeset
Cast result object to a nodelist. Always issues an error.- Returns:
- The object as a NodeSetDTM.
- Throws:
TransformerException
-
castToType
Cast object to type t.- Parameters:
t
- Type of object to cast this tosupport
- XPath context to use for the conversion- Returns:
- This object as the given type t
- Throws:
TransformerException
-
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
-
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
-
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
-
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
-
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
- Throws:
TransformerException
-
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
-
fixupVariables
XObjects should not normally need to fix up variables.- Specified by:
fixupVariables
in classExpression
- Parameters:
vars
- List of QNames that correspond to variables. This list should be searched backwards for the first qualified name that corresponds to the variable reference qname. The position of the QName in the vector from the start of the vector will be its position in the stack frame (but variables above the globalsTop value will need to be offset to the current stack frame). NEEDSDOC @param globalsSize
-
appendToFsb
Cast result object to a string. NEEDSDOC @param fsb -
callVisitors
Description copied from interface:XPathVisitable
This will traverse the heararchy, calling the visitor for each member. If the called visitor method returns false, the subtree should not be called.- Specified by:
callVisitors
in interfaceXPathVisitable
- Parameters:
owner
- The owner of the visitor, where that path may be rewritten if needed.visitor
- The visitor whose appropriate method will be called.- See Also:
-
deepEquals
Description copied from class:Expression
Compare this object with another object and see if they are equal, include the sub heararchy.- Specified by:
deepEquals
in 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.
- See Also:
-