26 February 2004

Appendix B: Java Language Binding

This appendix contains the complete Java [Java] bindings for the Level 3 Document Object Model XPath.

The Java files are also available as http://www.w3.org/TR/2004/NOTE-DOM-Level-3-XPath-20040226/java-binding.zip

B.1 Other XPath interfaces

org/w3c/dom/xpath/XPathException.java:

package org.w3c.dom.xpath;

public class XPathException extends RuntimeException {
    public XPathException(short code, String message) {
       super(message);
       this.code = code;
    }
    public short   code;
    // XPathExceptionCode
    public static final short INVALID_EXPRESSION_ERR    = 51;
    public static final short TYPE_ERR                  = 52;

}

org/w3c/dom/xpath/XPathEvaluator.java:

package org.w3c.dom.xpath;

import org.w3c.dom.Node;
import org.w3c.dom.DOMException;

public interface XPathEvaluator {
    public XPathExpression createExpression(String expression, 
                                            XPathNSResolver resolver)
                                            throws XPathException, DOMException;

    public XPathNSResolver createNSResolver(Node nodeResolver);

    public Object evaluate(String expression, 
                           Node contextNode, 
                           XPathNSResolver resolver, 
                           short type, 
                           Object result)
                           throws XPathException, DOMException;

}

org/w3c/dom/xpath/XPathExpression.java:

package org.w3c.dom.xpath;

import org.w3c.dom.Node;
import org.w3c.dom.DOMException;

public interface XPathExpression {
    public Object evaluate(Node contextNode, 
                           short type, 
                           Object result)
                           throws XPathException, DOMException;

}

org/w3c/dom/xpath/XPathNSResolver.java:

package org.w3c.dom.xpath;

public interface XPathNSResolver {
    public String lookupNamespaceURI(String prefix);

}

org/w3c/dom/xpath/XPathResult.java:

package org.w3c.dom.xpath;

import org.w3c.dom.Node;
import org.w3c.dom.DOMException;

public interface XPathResult {
    // XPathResultType
    public static final short ANY_TYPE                  = 0;
    public static final short NUMBER_TYPE               = 1;
    public static final short STRING_TYPE               = 2;
    public static final short BOOLEAN_TYPE              = 3;
    public static final short UNORDERED_NODE_ITERATOR_TYPE = 4;
    public static final short ORDERED_NODE_ITERATOR_TYPE = 5;
    public static final short UNORDERED_NODE_SNAPSHOT_TYPE = 6;
    public static final short ORDERED_NODE_SNAPSHOT_TYPE = 7;
    public static final short ANY_UNORDERED_NODE_TYPE   = 8;
    public static final short FIRST_ORDERED_NODE_TYPE   = 9;

    public short getResultType();

    public double getNumberValue()
                                     throws XPathException;

    public String getStringValue()
                                     throws XPathException;

    public boolean getBooleanValue()
                                     throws XPathException;

    public Node getSingleNodeValue()
                                     throws XPathException;

    public boolean getInvalidIteratorState();

    public int getSnapshotLength()
                                     throws XPathException;

    public Node iterateNext()
                            throws XPathException, DOMException;

    public Node snapshotItem(int index)
                             throws XPathException;

}

org/w3c/dom/xpath/XPathNamespace.java:

package org.w3c.dom.xpath;

import org.w3c.dom.Element;
import org.w3c.dom.Node;

public interface XPathNamespace extends Node {
    // XPathNodeType
    public static final short XPATH_NAMESPACE_NODE      = 13;

    public Element getOwnerElement();

}