Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.xpath.domapi
Class XPathResultImpl  view XPathResultImpl download XPathResultImpl.java

java.lang.Object
  extended byorg.apache.xpath.domapi.XPathResultImpl
All Implemented Interfaces:
org.w3c.dom.events.EventListener, org.w3c.dom.xpath.XPathResult

public class XPathResultImpl
extends java.lang.Object
implements org.w3c.dom.xpath.XPathResult, org.w3c.dom.events.EventListener

The class provides an implementation XPathResult according to the DOM L3 XPath Specification, Working Draft 28, March 2002.

See also the Document Object Model (DOM) Level 3 XPath Specification.

The XPathResult interface represents the result of the evaluation of an XPath expression within the context of a particular node. Since evaluation of an XPath expression can result in various result types, this object makes it possible to discover and manipulate the type and value of the result.

This implementation wraps an XObject.


Field Summary
private  org.w3c.dom.Node m_contextNode
          Only used to attach a mutation event handler when specified type is an iterator type.
private  boolean m_isInvalidIteratorState
           
private  org.w3c.dom.traversal.NodeIterator m_iterator
          The iterator, if this is an iterator type.
private  org.w3c.dom.NodeList m_list
          The list, if this is a snapshot type.
private  org.apache.xpath.objects.XObject m_resultObj
          The wrapped XObject
private  short m_resultType
          This the type specified by the user during construction.
 
Fields inherited from interface org.w3c.dom.xpath.XPathResult
ANY_TYPE, ANY_UNORDERED_NODE_TYPE, BOOLEAN_TYPE, FIRST_ORDERED_NODE_TYPE, NUMBER_TYPE, ORDERED_NODE_ITERATOR_TYPE, ORDERED_NODE_SNAPSHOT_TYPE, STRING_TYPE, UNORDERED_NODE_ITERATOR_TYPE, UNORDERED_NODE_SNAPSHOT_TYPE
 
Constructor Summary
(package private) XPathResultImpl(short type, org.apache.xpath.objects.XObject result, org.w3c.dom.Node contextNode)
          Constructor for XPathResultImpl.
 
Method Summary
 boolean getBooleanValue()
          The value of this boolean result.
 boolean getInvalidIteratorState()
          Signifies that the iterator has become invalid.
 double getNumberValue()
          The value of this number result.
 short getResultType()
          A code representing the type of this result, as defined by the type constants.
 org.w3c.dom.Node getSingleNodeValue()
          The value of this single node result, which may be null.
 int getSnapshotLength()
          The number of nodes in the result snapshot.
 java.lang.String getStringValue()
          The value of this string result.
private  short getTypeFromXObject(org.apache.xpath.objects.XObject object)
          Given an XObject, determine the corresponding DOM XPath type
 java.lang.String getTypeString(int type)
          Given a request type, return the equivalent string.
 void handleEvent(org.w3c.dom.events.Event event)
          This method is called whenever an event occurs of the type for which the EventListener interface was registered.
private  boolean isNamespaceNode(org.w3c.dom.Node node)
          Given a node, determine if it is a namespace node.
static boolean isValidType(short type)
          Check if the specified type is one of the supported types.
 org.w3c.dom.Node iterateNext()
          Iterates and returns the next node from the node set or nullif there are no more nodes.
 org.w3c.dom.Node snapshotItem(int index)
          Returns the indexth item in the snapshot collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_resultObj

private org.apache.xpath.objects.XObject m_resultObj
The wrapped XObject


m_resultType

private short m_resultType
This the type specified by the user during construction. Typically the constructor will be called by org.apache.xpath.XPath.evaluate().


m_isInvalidIteratorState

private boolean m_isInvalidIteratorState

m_contextNode

private org.w3c.dom.Node m_contextNode
Only used to attach a mutation event handler when specified type is an iterator type.


m_iterator

private org.w3c.dom.traversal.NodeIterator m_iterator
The iterator, if this is an iterator type.


m_list

private org.w3c.dom.NodeList m_list
The list, if this is a snapshot type.

Constructor Detail

XPathResultImpl

XPathResultImpl(short type,
                org.apache.xpath.objects.XObject result,
                org.w3c.dom.Node contextNode)
Constructor for XPathResultImpl. For internal use only.

Method Detail

getResultType

public short getResultType()
Description copied from interface: org.w3c.dom.xpath.XPathResult
A code representing the type of this result, as defined by the type constants.

Specified by:
getResultType in interface org.w3c.dom.xpath.XPathResult

getNumberValue

public double getNumberValue()
                      throws org.w3c.dom.xpath.XPathException
The value of this number result.

Specified by:
getNumberValue in interface org.w3c.dom.xpath.XPathResult

getStringValue

public java.lang.String getStringValue()
                                throws org.w3c.dom.xpath.XPathException
The value of this string result.

Specified by:
getStringValue in interface org.w3c.dom.xpath.XPathResult

getBooleanValue

public boolean getBooleanValue()
                        throws org.w3c.dom.xpath.XPathException
Description copied from interface: org.w3c.dom.xpath.XPathResult
The value of this boolean result.

Specified by:
getBooleanValue in interface org.w3c.dom.xpath.XPathResult

getSingleNodeValue

public org.w3c.dom.Node getSingleNodeValue()
                                    throws org.w3c.dom.xpath.XPathException
The value of this single node result, which may be null.

Specified by:
getSingleNodeValue in interface org.w3c.dom.xpath.XPathResult

getInvalidIteratorState

public boolean getInvalidIteratorState()
Description copied from interface: org.w3c.dom.xpath.XPathResult
Signifies that the iterator has become invalid. True if resultType is UNORDERED_NODE_ITERATOR_TYPE or ORDERED_NODE_ITERATOR_TYPE and the document has been modified since this result was returned.

Specified by:
getInvalidIteratorState in interface org.w3c.dom.xpath.XPathResult

getSnapshotLength

public int getSnapshotLength()
                      throws org.w3c.dom.xpath.XPathException
The number of nodes in the result snapshot. Valid values for snapshotItem indices are 0 to snapshotLength-1 inclusive.

Specified by:
getSnapshotLength in interface org.w3c.dom.xpath.XPathResult

iterateNext

public org.w3c.dom.Node iterateNext()
                             throws org.w3c.dom.xpath.XPathException,
                                    org.w3c.dom.DOMException
Iterates and returns the next node from the node set or nullif there are no more nodes.

Specified by:
iterateNext in interface org.w3c.dom.xpath.XPathResult

snapshotItem

public org.w3c.dom.Node snapshotItem(int index)
                              throws org.w3c.dom.xpath.XPathException
Returns the indexth item in the snapshot collection. If index is greater than or equal to the number of nodes in the list, this method returns null. Unlike the iterator result, the snapshot does not become invalid, but may not correspond to the current document if it is mutated.

Specified by:
snapshotItem in interface org.w3c.dom.xpath.XPathResult

isValidType

public static boolean isValidType(short type)
Check if the specified type is one of the supported types.


handleEvent

public void handleEvent(org.w3c.dom.events.Event event)
Description copied from interface: org.w3c.dom.events.EventListener
This method is called whenever an event occurs of the type for which the EventListener interface was registered.

Specified by:
handleEvent in interface org.w3c.dom.events.EventListener

getTypeString

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


getTypeFromXObject

private short getTypeFromXObject(org.apache.xpath.objects.XObject object)
Given an XObject, determine the corresponding DOM XPath type


isNamespaceNode

private boolean isNamespaceNode(org.w3c.dom.Node node)
Given a node, determine if it is a namespace node.