001 /* 002 * Copyright (c) 2004 World Wide Web Consortium, 003 * 004 * (Massachusetts Institute of Technology, European Research Consortium for 005 * Informatics and Mathematics, Keio University). All Rights Reserved. This 006 * work is distributed under the W3C(r) Software License [1] in the hope that 007 * it will be useful, but WITHOUT ANY WARRANTY; without even the implied 008 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 009 * 010 * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 011 */ 012 013 package org.w3c.dom.xpath; 014 015 import org.w3c.dom.Node; 016 import org.w3c.dom.DOMException; 017 018 /** 019 * The <code>XPathExpression</code> interface represents a parsed and resolved 020 * XPath expression. 021 * <p>See also the <a href='http://www.w3.org/TR/2004/NOTE-DOM-Level-3-XPath-20040226'>Document Object Model (DOM) Level 3 XPath Specification</a>. 022 */ 023 public interface XPathExpression { 024 /** 025 * Evaluates this XPath expression and returns a result. 026 * @param contextNode The <code>context</code> is context node for the 027 * evaluation of this XPath expression.If the XPathEvaluator was 028 * obtained by casting the <code>Document</code> then this must be 029 * owned by the same document and must be a <code>Document</code>, 030 * <code>Element</code>, <code>Attribute</code>, <code>Text</code>, 031 * <code>CDATASection</code>, <code>Comment</code>, 032 * <code>ProcessingInstruction</code>, or <code>XPathNamespace</code> 033 * node.If the context node is a <code>Text</code> or a 034 * <code>CDATASection</code>, then the context is interpreted as the 035 * whole logical text node as seen by XPath, unless the node is empty 036 * in which case it may not serve as the XPath context. 037 * @param type If a specific <code>type</code> is specified, then the 038 * result will be coerced to return the specified type relying on 039 * XPath conversions and fail if the desired coercion is not possible. 040 * This must be one of the type codes of <code>XPathResult</code>. 041 * @param result The <code>result</code> specifies a specific result 042 * object which may be reused and returned by this method. If this is 043 * specified as <code>null</code>or the implementation does not reuse 044 * the specified result, a new result object will be constructed and 045 * returned.For XPath 1.0 results, this object will be of type 046 * <code>XPathResult</code>. 047 * @return The result of the evaluation of the XPath expression.For XPath 048 * 1.0 results, this object will be of type <code>XPathResult</code>. 049 * @exception XPathException 050 * TYPE_ERR: Raised if the result cannot be converted to return the 051 * specified type. 052 * @exception DOMException 053 * WRONG_DOCUMENT_ERR: The Node is from a document that is not supported 054 * by the XPathEvaluator that created this <code>XPathExpression</code> 055 * . 056 * <br>NOT_SUPPORTED_ERR: The Node is not a type permitted as an XPath 057 * context node or the request type is not permitted by this 058 * <code>XPathExpression</code>. 059 */ 060 public Object evaluate(Node contextNode, 061 short type, 062 Object result) 063 throws XPathException, DOMException; 064 065 }