286N/A/*
286N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
286N/A *
286N/A * This code is free software; you can redistribute it and/or modify it
286N/A * under the terms of the GNU General Public License version 2 only, as
286N/A * published by the Free Software Foundation. Oracle designates this
286N/A * particular file as subject to the "Classpath" exception as provided
286N/A * by Oracle in the LICENSE file that accompanied this code.
286N/A *
286N/A * This code is distributed in the hope that it will be useful, but WITHOUT
286N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
286N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
286N/A * version 2 for more details (a copy is included in the LICENSE file that
286N/A * accompanied this code).
286N/A *
286N/A * You should have received a copy of the GNU General Public License version
286N/A * 2 along with this work; if not, write to the Free Software Foundation,
286N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
286N/A *
286N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
286N/A * or visit www.oracle.com if you need additional information or have any
286N/A * questions.
286N/A */
286N/A
286N/A/*
286N/A * This file is available under and governed by the GNU General Public
286N/A * License version 2 only, as published by the Free Software Foundation.
286N/A * However, the following notice accompanied the original version of this
286N/A * file and, per its terms, should not be removed:
286N/A *
286N/A * Copyright (c) 2002 World Wide Web Consortium,
286N/A * (Massachusetts Institute of Technology, Institut National de
286N/A * Recherche en Informatique et en Automatique, Keio University). All
286N/A * Rights Reserved. This program is distributed under the W3C's Software
286N/A * Intellectual Property License. This program is distributed in the
286N/A * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
286N/A * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
286N/A * PURPOSE.
286N/A * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
286N/A */
286N/A
286N/Apackage org.w3c.dom.xpath;
286N/A
286N/A
286N/Aimport org.w3c.dom.Node;
286N/Aimport org.w3c.dom.DOMException;
286N/A
286N/A/**
286N/A * The <code>XPathResult</code> interface represents the result of the
286N/A * evaluation of an XPath 1.0 expression within the context of a particular
286N/A * node. Since evaluation of an XPath expression can result in various
286N/A * result types, this object makes it possible to discover and manipulate
286N/A * the type and value of the result.
286N/A * <p>See also the <a href='http://www.w3.org/2002/08/WD-DOM-Level-3-XPath-20020820'>Document Object Model (DOM) Level 3 XPath Specification</a>.
286N/A */
286N/Apublic interface XPathResult {
286N/A // XPathResultType
286N/A /**
286N/A * This code does not represent a specific type. An evaluation of an XPath
286N/A * expression will never produce this type. If this type is requested,
286N/A * then the evaluation returns whatever type naturally results from
286N/A * evaluation of the expression.
286N/A * <br>If the natural result is a node set when <code>ANY_TYPE</code> was
286N/A * requested, then <code>UNORDERED_NODE_ITERATOR_TYPE</code> is always
286N/A * the resulting type. Any other representation of a node set must be
286N/A * explicitly requested.
286N/A */
286N/A public static final short ANY_TYPE = 0;
286N/A /**
286N/A * The result is a number as defined by . Document modification does not
286N/A * invalidate the number, but may mean that reevaluation would not yield
286N/A * the same number.
286N/A */
286N/A public static final short NUMBER_TYPE = 1;
286N/A /**
286N/A * The result is a string as defined by . Document modification does not
286N/A * invalidate the string, but may mean that the string no longer
286N/A * corresponds to the current document.
286N/A */
286N/A public static final short STRING_TYPE = 2;
286N/A /**
286N/A * The result is a boolean as defined by . Document modification does not
286N/A * invalidate the boolean, but may mean that reevaluation would not
286N/A * yield the same boolean.
286N/A */
286N/A public static final short BOOLEAN_TYPE = 3;
286N/A /**
286N/A * The result is a node set as defined by that will be accessed
286N/A * iteratively, which may not produce nodes in a particular order.
286N/A * Document modification invalidates the iteration.
286N/A * <br>This is the default type returned if the result is a node set and
286N/A * <code>ANY_TYPE</code> is requested.
286N/A */
286N/A public static final short UNORDERED_NODE_ITERATOR_TYPE = 4;
286N/A /**
286N/A * The result is a node set as defined by that will be accessed
286N/A * iteratively, which will produce document-ordered nodes. Document
286N/A * modification invalidates the iteration.
286N/A */
286N/A public static final short ORDERED_NODE_ITERATOR_TYPE = 5;
286N/A /**
286N/A * The result is a node set as defined by that will be accessed as a
286N/A * snapshot list of nodes that may not be in a particular order.
286N/A * Document modification does not invalidate the snapshot but may mean
286N/A * that reevaluation would not yield the same snapshot and nodes in the
286N/A * snapshot may have been altered, moved, or removed from the document.
286N/A */
286N/A public static final short UNORDERED_NODE_SNAPSHOT_TYPE = 6;
286N/A /**
286N/A * The result is a node set as defined by that will be accessed as a
286N/A * snapshot list of nodes that will be in original document order.
286N/A * Document modification does not invalidate the snapshot but may mean
286N/A * that reevaluation would not yield the same snapshot and nodes in the
286N/A * snapshot may have been altered, moved, or removed from the document.
286N/A */
286N/A public static final short ORDERED_NODE_SNAPSHOT_TYPE = 7;
286N/A /**
286N/A * The result is a node set as defined by and will be accessed as a
286N/A * single node, which may be <code>null</code>if the node set is empty.
286N/A * Document modification does not invalidate the node, but may mean that
286N/A * the result node no longer corresponds to the current document. This
286N/A * is a convenience that permits optimization since the implementation
286N/A * can stop once any node in the in the resulting set has been found.
286N/A * <br>If there are more than one node in the actual result, the single
286N/A * node returned might not be the first in document order.
286N/A */
286N/A public static final short ANY_UNORDERED_NODE_TYPE = 8;
286N/A /**
286N/A * The result is a node set as defined by and will be accessed as a
286N/A * single node, which may be <code>null</code> if the node set is empty.
286N/A * Document modification does not invalidate the node, but may mean that
286N/A * the result node no longer corresponds to the current document. This
286N/A * is a convenience that permits optimization since the implementation
286N/A * can stop once the first node in document order of the resulting set
286N/A * has been found.
286N/A * <br>If there are more than one node in the actual result, the single
286N/A * node returned will be the first in document order.
286N/A */
286N/A public static final short FIRST_ORDERED_NODE_TYPE = 9;
286N/A
286N/A /**
286N/A * A code representing the type of this result, as defined by the type
286N/A * constants.
286N/A */
286N/A public short getResultType();
286N/A
286N/A /**
286N/A * The value of this number result. If the native double type of the DOM
286N/A * binding does not directly support the exact IEEE 754 result of the
286N/A * XPath expression, then it is up to the definition of the binding
286N/A * binding to specify how the XPath number is converted to the native
286N/A * binding number.
286N/A * @exception XPathException
286N/A * TYPE_ERR: raised if <code>resultType</code> is not
286N/A * <code>NUMBER_TYPE</code>.
286N/A */
286N/A public double getNumberValue()
286N/A throws XPathException;
286N/A
286N/A /**
286N/A * The value of this string result.
286N/A * @exception XPathException
286N/A * TYPE_ERR: raised if <code>resultType</code> is not
286N/A * <code>STRING_TYPE</code>.
286N/A */
286N/A public String getStringValue()
286N/A throws XPathException;
286N/A
286N/A /**
286N/A * The value of this boolean result.
286N/A * @exception XPathException
286N/A * TYPE_ERR: raised if <code>resultType</code> is not
286N/A * <code>BOOLEAN_TYPE</code>.
286N/A */
286N/A public boolean getBooleanValue()
286N/A throws XPathException;
286N/A
286N/A /**
286N/A * The value of this single node result, which may be <code>null</code>.
286N/A * @exception XPathException
286N/A * TYPE_ERR: raised if <code>resultType</code> is not
286N/A * <code>ANY_UNORDERED_NODE_TYPE</code> or
286N/A * <code>FIRST_ORDERED_NODE_TYPE</code>.
286N/A */
286N/A public Node getSingleNodeValue()
286N/A throws XPathException;
286N/A
286N/A /**
286N/A * Signifies that the iterator has become invalid. True if
286N/A * <code>resultType</code> is <code>UNORDERED_NODE_ITERATOR_TYPE</code>
286N/A * or <code>ORDERED_NODE_ITERATOR_TYPE</code> and the document has been
286N/A * modified since this result was returned.
286N/A */
286N/A public boolean getInvalidIteratorState();
286N/A
286N/A /**
286N/A * The number of nodes in the result snapshot. Valid values for
286N/A * snapshotItem indices are <code>0</code> to
286N/A * <code>snapshotLength-1</code> inclusive.
286N/A * @exception XPathException
286N/A * TYPE_ERR: raised if <code>resultType</code> is not
286N/A * <code>UNORDERED_NODE_SNAPSHOT_TYPE</code> or
286N/A * <code>ORDERED_NODE_SNAPSHOT_TYPE</code>.
286N/A */
286N/A public int getSnapshotLength()
286N/A throws XPathException;
286N/A
286N/A /**
286N/A * Iterates and returns the next node from the node set or
286N/A * <code>null</code>if there are no more nodes.
286N/A * @return Returns the next node.
286N/A * @exception XPathException
286N/A * TYPE_ERR: raised if <code>resultType</code> is not
286N/A * <code>UNORDERED_NODE_ITERATOR_TYPE</code> or
286N/A * <code>ORDERED_NODE_ITERATOR_TYPE</code>.
286N/A * @exception DOMException
286N/A * INVALID_STATE_ERR: The document has been mutated since the result was
286N/A * returned.
286N/A */
286N/A public Node iterateNext()
286N/A throws XPathException, DOMException;
286N/A
286N/A /**
286N/A * Returns the <code>index</code>th item in the snapshot collection. If
286N/A * <code>index</code> is greater than or equal to the number of nodes in
286N/A * the list, this method returns <code>null</code>. Unlike the iterator
286N/A * result, the snapshot does not become invalid, but may not correspond
286N/A * to the current document if it is mutated.
286N/A * @param index Index into the snapshot collection.
286N/A * @return The node at the <code>index</code>th position in the
286N/A * <code>NodeList</code>, or <code>null</code> if that is not a valid
286N/A * index.
286N/A * @exception XPathException
286N/A * TYPE_ERR: raised if <code>resultType</code> is not
286N/A * <code>UNORDERED_NODE_SNAPSHOT_TYPE</code> or
286N/A * <code>ORDERED_NODE_SNAPSHOT_TYPE</code>.
286N/A */
286N/A public Node snapshotItem(int index)
286N/A throws XPathException;
286N/A
286N/A}