30 August 2001

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/2001/WD-DOM-Level-3-XPath-20010830/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    = 1;
    public static final short TYPE_ERR                  = 2;

}

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

package org.w3c.dom.xpath;

import org.w3c.dom.Node;

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

    public XPathResult createResult();

    public XPathNSResolver createNSResolver(Node nodeResolver);

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

    public XPathResult evaluateExpression(XPathExpression expression, 
                                          Node contextNode, 
                                          short type, 
                                          XPathResult result)
                                          throws XPathException;

}

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

package org.w3c.dom.xpath;

public interface XPathExpression {
}

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 NODE_SET_TYPE             = 4;
    public static final short SINGLE_NODE_TYPE          = 5;

    public short getResultType();

    public double getNumberValue()
                                     throws XPathException;

    public String getStringValue()
                                     throws XPathException;

    public boolean getBooleanValue()
                                     throws XPathException;

    public Node getSingleNodeValue()
                                     throws XPathException;

    public XPathSetIterator getSetIterator(boolean ordered)
                                           throws XPathException, DOMException;

    public XPathSetSnapshot getSetSnapshot(boolean ordered)
                                           throws XPathException, DOMException;

}

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

package org.w3c.dom.xpath;

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

public interface XPathSetIterator {
    public Node nextNode()
                         throws DOMException;

}

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

package org.w3c.dom.xpath;

import org.w3c.dom.Node;

public interface XPathSetSnapshot {
    public Node item(int index);

    public int getLength();

}

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();

}