Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.xpath.domapi
Class XPathResultImpl

    java.lang.Object
      org.apache.xpath.domapi.XPathResultImpl

All Implemented Interfaces:
  EventListener, XPathResult

public class XPathResultImpl
extends java.lang.Object
implements XPathResult, 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`.

See Also:
  `XObject`, `XPathResult`
Usage:
  **Experimental**

Field Summary

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`

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.
`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.
`java.lang.String` | `getTypeString(int type)` Given a request type, return the equivalent string.
`void` | `handleEvent(Event event)` This method is called whenever an event occurs of the type for which the `EventListener` interface was registered.
`static boolean` | `isValidType(short type)` Check if the specified type is one of the supported types.
`Node` | `iterateNext()` Iterates and returns the next node from the node set or `null`if there are no more nodes.
`Node` | `snapshotItem(int index)` Returns the `index`th item in the snapshot collection.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### getResultType

    public short getResultType()

  Description copied from interface: `XPathResult`
  A code representing the type of this result, as defined by the type constants.

  Specified by:
    `getResultType` in interface `XPathResult`
  See Also:
    `XPathResult.getResultType()`

### getNumberValue

    public double getNumberValue()
                          throws XPathException

  The value of this number result.

  Specified by:
    `getNumberValue` in interface `XPathResult`
  Throws:
    `XPathException` - TYPE_ERR: raised if `resultType` is not `NUMBER_TYPE`.
  See Also:
    `XPathResult.getNumberValue()`

### getStringValue

    public java.lang.String getStringValue()
                                    throws XPathException

  The value of this string result.

  Specified by:
    `getStringValue` in interface `XPathResult`
  Throws:
    `XPathException` - TYPE_ERR: raised if `resultType` is not `STRING_TYPE`.
  See Also:
    `XPathResult.getStringValue()`

### getBooleanValue

    public boolean getBooleanValue()
                            throws XPathException

  Description copied from interface: `XPathResult`
  The value of this boolean result.

  Specified by:
    `getBooleanValue` in interface `XPathResult`
  Throws:
    `XPathException` - TYPE_ERR: raised if `resultType` is not `BOOLEAN_TYPE`.
  See Also:
    `XPathResult.getBooleanValue()`

### getSingleNodeValue

    public Node getSingleNodeValue()
                            throws XPathException

  The value of this single node result, which may be `null`.

  Specified by:
    `getSingleNodeValue` in interface `XPathResult`
  Throws:
    `XPathException` - TYPE_ERR: raised if `resultType` is not `ANY_UNORDERED_NODE_TYPE` or `FIRST_ORDERED_NODE_TYPE`.
  See Also:
    `XPathResult.getSingleNodeValue()`

### getInvalidIteratorState

    public boolean getInvalidIteratorState()

  Description copied from interface: `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 `XPathResult`
  See Also:
    `XPathResult.getInvalidIteratorState()`

### getSnapshotLength

    public int getSnapshotLength()
                          throws 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 `XPathResult`
  Throws:
    `XPathException` - TYPE_ERR: raised if `resultType` is not `UNORDERED_NODE_SNAPSHOT_TYPE` or `ORDERED_NODE_SNAPSHOT_TYPE`.
  See Also:
    `XPathResult.getSnapshotLength()`

### iterateNext

    public Node iterateNext()
                     throws XPathException,
                            DOMException

  Iterates and returns the next node from the node set or `null`if there are no more nodes.

  Specified by:
    `iterateNext` in interface `XPathResult`
  Returns:
    Returns the next node.
  Throws:
    `XPathException` - TYPE_ERR: raised if `resultType` is not `UNORDERED_NODE_ITERATOR_TYPE` or `ORDERED_NODE_ITERATOR_TYPE`.
    `DOMException` - INVALID_STATE_ERR: The document has been mutated since the result was returned.
  See Also:
    `XPathResult.iterateNext()`

### snapshotItem

    public Node snapshotItem(int index)
                      throws XPathException

  Returns the `index`th 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 `XPathResult`
  Parameters:
    `index` - Index into the snapshot collection.
  Returns:
    The node at the `index`th position in the `NodeList`, or `null` if that is not a valid index.
  Throws:
    `XPathException` - TYPE_ERR: raised if `resultType` is not `UNORDERED_NODE_SNAPSHOT_TYPE` or `ORDERED_NODE_SNAPSHOT_TYPE`.
  See Also:
    `XPathResult.snapshotItem(int)`

### isValidType

    public static boolean isValidType(short type)

  Check if the specified type is one of the supported types.

  Parameters:
    `type` - The specified type
  Returns:
    true If the specified type is supported; otherwise, returns false.

### handleEvent

    public void handleEvent(Event event)

  Description copied from interface: `EventListener`
  This method is called whenever an event occurs of the type for which the `EventListener` interface was registered.

  Specified by:
    `handleEvent` in interface `EventListener`
  Parameters:
    `event` - The `Event` contains contextual information about the event. It also contains the `stopPropagation` and `preventDefault` methods which are used in determining the event's flow and default action.
  See Also:
    `EventListener.handleEvent(Event)`

### getTypeString

    public java.lang.String getTypeString(int type)

  Given a request type, return the equivalent string. For diagnostic purposes.

  Returns:
    type string

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2004 Apache XML Project. All Rights Reserved.