org.apache.xpath.objects

Class XObject

public class XObject extends Expression implements Serializable, Cloneable

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.

UNKNOWN: general

Field Summary
static intCLASS_BOOLEAN
Constant for BOOLEAN object type
static intCLASS_NODESET
Constant for NODESET object type
static intCLASS_NULL
Constant for NULL object type
static intCLASS_NUMBER
Constant for NUMBER object type
static intCLASS_RTREEFRAG
Constant for RESULT TREE FRAGMENT object type
static intCLASS_STRING
Constant for STRING object type
static intCLASS_UNKNOWN
Constant for UNKNOWN object type
static intCLASS_UNRESOLVEDVARIABLE
Represents an unresolved variable type as an integer.
Constructor Summary
XObject()
Create an XObject.
XObject(Object obj)
Create an XObject.
Method Summary
voidallowDetachToRelease(boolean allowRelease)
Specify if it's OK for detach to release the iterator for reuse.
voidappendToFsb(FastStringBuffer fsb)
Cast result object to a string.
booleanbool()
Cast result object to a boolean.
booleanboolWithSideEffects()
Cast result object to a boolean, but allow side effects, such as the incrementing of an iterator.
voidcallVisitors(ExpressionOwner owner, XPathVisitor visitor)
ObjectcastToType(int t, XPathContext support)
Cast object to type t.
static XObjectcreate(Object val)
Create the right XObject based on the type of the object passed.
static XObjectcreate(Object val, XPathContext xctxt)
Create the right XObject based on the type of the object passed.
booleandeepEquals(Expression expr)
voiddestruct()
Forces the object to release it's resources.
voiddetach()
Detaches the DTMIterator from the set which it iterated over, releasing any computational resources and placing the iterator in the INVALID state.
voiddispatchCharactersEvents(ContentHandler ch)
Directly call the characters method on the passed ContentHandler for the string-value.
booleanequals(XObject obj2)
Tell if two objects are functionally equal.
XObjectexecute(XPathContext xctxt)
For support of literal objects in xpaths.
voidfixupVariables(Vector vars, int globalsSize)
XObjects should not normally need to fix up variables.
XObjectgetFresh()
Get a fresh copy of the object.
intgetType()
Tell what kind of class this is.
StringgetTypeString()
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.
DTMIteratoriter()
Cast result object to a nodelist.
booleanlessThan(XObject obj2)
Tell if one object is less than the other.
booleanlessThanOrEqual(XObject obj2)
Tell if one object is less than or equal to the other.
NodeSetDTMmutableNodeset()
Cast result object to a nodelist.
NodeListnodelist()
Cast result object to a nodelist.
NodeIteratornodeset()
Cast result object to a nodelist.
booleannotEquals(XObject obj2)
Tell if two objects are functionally not equal.
doublenum()
Cast result object to a number.
doublenumWithSideEffects()
Cast result object to a number, but allow side effects, such as the incrementing of an iterator.
Objectobject()
Return a java object that's closest to the representation that should be handed to an extension.
voidreset()
Reset for fresh reuse.
intrtf(XPathContext support)
Cast result object to a result tree fragment.
intrtf()
For functions to override.
DocumentFragmentrtree(XPathContext support)
Cast result object to a result tree fragment.
DocumentFragmentrtree()
For functions to override.
Stringstr()
Cast result object to a string.
StringtoString()
Return the string representation of the object
XMLStringxstr()
Cast result object to a string.

Field Detail

CLASS_BOOLEAN

public static final int CLASS_BOOLEAN
Constant for BOOLEAN object type

CLASS_NODESET

public static final int CLASS_NODESET
Constant for NODESET object type

CLASS_NULL

public static final int CLASS_NULL
Constant for NULL object type

CLASS_NUMBER

public static final int CLASS_NUMBER
Constant for NUMBER object type

CLASS_RTREEFRAG

public static final int CLASS_RTREEFRAG
Constant for RESULT TREE FRAGMENT object type

CLASS_STRING

public static final int CLASS_STRING
Constant for STRING object type

CLASS_UNKNOWN

public static final int CLASS_UNKNOWN
Constant for UNKNOWN object type

CLASS_UNRESOLVEDVARIABLE

public static final int CLASS_UNRESOLVEDVARIABLE
Represents an unresolved variable type as an integer.

Constructor Detail

XObject

public XObject()
Create an XObject.

XObject

public XObject(Object obj)
Create an XObject.

Parameters: obj Can be any object, should be a specific type for derived classes, or null.

Method Detail

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.

appendToFsb

public void appendToFsb(FastStringBuffer fsb)
Cast result object to a string. NEEDSDOC @param fsb

Returns: The string this wraps or the empty string if null

bool

public boolean bool()
Cast result object to a boolean. Always issues an error.

Returns: false

Throws: javax.xml.transform.TransformerException

boolWithSideEffects

public boolean 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

callVisitors

public void callVisitors(ExpressionOwner owner, XPathVisitor visitor)

See Also: XPathVisitable

castToType

public Object castToType(int t, XPathContext support)
Cast object to type t.

Parameters: t Type of object to cast this to support XPath context to use for the conversion

Returns: This object as the given type t

Throws: javax.xml.transform.TransformerException

create

public static XObject create(Object val)
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

public static XObject create(Object val, XPathContext xctxt)
Create the right XObject based on the type of the object passed. This function can 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.

deepEquals

public boolean deepEquals(Expression expr)

See Also: deepEquals

destruct

public void destruct()
Forces the object to release it's resources. This is more harsh than detach().

detach

public void detach()
Detaches the DTMIterator from the set which it iterated over, releasing any computational resources and placing the iterator in the INVALID state. After detach has been invoked, calls to nextNode or previousNode will raise a runtime exception.

dispatchCharactersEvents

public void dispatchCharactersEvents(ContentHandler ch)
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: org.xml.sax.SAXException

equals

public boolean equals(XObject obj2)
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: javax.xml.transform.TransformerException

execute

public XObject execute(XPathContext xctxt)
For support of literal objects in xpaths.

Parameters: xctxt The XPath execution context.

Returns: This object.

Throws: javax.xml.transform.TransformerException

fixupVariables

public void fixupVariables(Vector vars, int globalsSize)
XObjects should not normally need to fix up variables.

getFresh

public XObject getFresh()
Get a fresh copy of the object. For use with variables.

Returns: This object, unless overridden by subclass.

getType

public int getType()
Tell what kind of class this is.

Returns: CLASS_UNKNOWN

getTypeString

public String getTypeString()
Given a request type, return the equivalent string. For diagnostic purposes.

Returns: type string "#UNKNOWN" + object class name

greaterThan

public boolean greaterThan(XObject obj2)
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: javax.xml.transform.TransformerException

greaterThanOrEqual

public boolean greaterThanOrEqual(XObject obj2)
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: javax.xml.transform.TransformerException

iter

public DTMIterator iter()
Cast result object to a nodelist. Always issues an error.

Returns: null

Throws: javax.xml.transform.TransformerException

lessThan

public boolean lessThan(XObject obj2)
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: javax.xml.transform.TransformerException

lessThanOrEqual

public boolean lessThanOrEqual(XObject obj2)
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: javax.xml.transform.TransformerException

mutableNodeset

public NodeSetDTM mutableNodeset()
Cast result object to a nodelist. Always issues an error.

Returns: The object as a NodeSetDTM.

Throws: javax.xml.transform.TransformerException

nodelist

public NodeList nodelist()
Cast result object to a nodelist. Always issues an error.

Returns: null

Throws: javax.xml.transform.TransformerException

nodeset

public NodeIterator nodeset()
Cast result object to a nodelist. Always issues an error.

Returns: null

Throws: javax.xml.transform.TransformerException

notEquals

public boolean notEquals(XObject obj2)
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: javax.xml.transform.TransformerException

num

public double num()
Cast result object to a number. Always issues an error.

Returns: 0.0

Throws: javax.xml.transform.TransformerException

numWithSideEffects

public double 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

object

public Object 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

reset

public void reset()
Reset for fresh reuse.

rtf

public int rtf(XPathContext support)
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.

rtf

public int rtf()
For functions to override.

Returns: null

rtree

public DocumentFragment rtree(XPathContext support)
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

public DocumentFragment rtree()
For functions to override.

Returns: null

str

public String str()
Cast result object to a string.

Returns: The object as a string

toString

public String toString()
Return the string representation of the object

Returns: the string representation of the object

xstr

public XMLString xstr()
Cast result object to a string.

Returns: The string this wraps or the empty string if null

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