KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > icl > saxon > om > NodeInfo


1 package com.icl.saxon.om;
2 import com.icl.saxon.output.Outputter;
3 import com.icl.saxon.pattern.NodeTest;
4
5 import javax.xml.transform.Source JavaDoc;
6 import javax.xml.transform.TransformerException JavaDoc;
7
8 /**
9   * A node in the XML parse tree representing an XML element, character content, or attribute.<P>
10   * This is the top class in the interface hierarchy for nodes; see NodeImpl for the implementation
11   * hierarchy.
12   * @author <A HREF="mailto:mhkay@iclway.co.uk>Michael H. Kay</A>
13   */

14
15 public interface NodeInfo extends Source JavaDoc {
16
17     // Node types. "NODE" means any type.
18
// These node numbers should be kept aligned with those defined in the DOM.
19

20     public static final short NODE = 0; // matches any kind of node
21
public static final short ELEMENT = 1;
22     public static final short ATTRIBUTE = 2;
23     public static final short TEXT = 3;
24     public static final short PI = 7;
25     public static final short COMMENT = 8;
26     public static final short ROOT = 9;
27     public static final short NAMESPACE = 13;
28     public static final short NUMBER_OF_TYPES = 13;
29     public static final short NONE = 9999; // a test for this node type will never be satisfied
30

31     /**
32     * Return the type of node.
33     * @return one of the values Node.ELEMENT, Node.TEXT, Node.ATTRIBUTE, etc.
34     */

35
36     public short getNodeType();
37     
38     /**
39     * Determine whether this is the same node as another node. <br />
40     * Note: a.isSameNode(b) if and only if generateId(a)==generateId(b)
41     * @return true if this Node object and the supplied Node object represent the
42     * same node in the tree.
43     */

44
45     public boolean isSameNode(NodeInfo other);
46
47     /**
48     * Get the System ID for the node.
49     * @return the System Identifier of the entity in the source document containing the node,
50     * or null if not known. Note this is not the same as the base URI: the base URI can be
51     * modified by xml:base, but the system ID cannot.
52     */

53
54     public String JavaDoc getSystemId();
55     
56     /**
57     * Get the Base URI for the node, that is, the URI used for resolving a relative URI contained
58     * in the node. This will be the same as the System ID unless xml:base has been used.
59     */

60     
61     public String JavaDoc getBaseURI();
62
63     /**
64     * Get line number
65     * @return the line number of the node in its original source document; or -1 if not available
66     */

67
68     public int getLineNumber();
69     
70     /**
71     * Determine the relative position of this node and another node, in document order.
72     * The other node will always be in the same document.
73     * @param other The other node, whose position is to be compared with this node
74     * @return -1 if this node precedes the other node, +1 if it follows the other
75     * node, or 0 if they are the same node. (In this case, isSameNode() will always
76     * return true, and the two nodes will produce the same result for generateId())
77     */

78     
79     public int compareOrder(NodeInfo other);
80     
81     /**
82     * Return the string value of the node. The interpretation of this depends on the type
83     * of node. For an element it is the accumulated character content of the element,
84     * including descendant elements.
85     * @return the string value of the node
86     */

87
88     public String JavaDoc getStringValue();
89
90     /**
91     * Get name code. The name code is a coded form of the node name: two nodes
92     * with the same name code have the same namespace URI, the same local name,
93     * and the same prefix. By masking the name code with &0xfffff, you get a
94     * fingerprint: two nodes with the same fingerprint have the same local name
95     * and namespace URI.
96     * @see com.icl.saxon.om.NamePool#allocate allocate
97     * @see com.icl.saxon.om.NamePool#getFingerprint getFingerprint
98     */

99     
100     public int getNameCode();
101
102     /**
103     * Get fingerprint. The fingerprint is a coded form of the expanded name
104     * of the node: two nodes
105     * with the same name code have the same namespace URI and the same local name.
106     * A fingerprint of -1 should be returned for a node with no name.
107     */

108     
109     public int getFingerprint();
110
111     /**
112     * Get the local part of the name of this node. This is the name after the ":" if any.
113     * @return the local part of the name. For an unnamed node, return an empty string.
114     */

115
116     public String JavaDoc getLocalName();
117
118     /**
119     * Get the prefix part of the name of this node. This is the name before the ":" if any.
120     * @return the prefix part of the name. For an unnamed node, return an empty string.
121     */

122
123     public String JavaDoc getPrefix();
124
125     /**
126     * Get the URI part of the name of this node. This is the URI corresponding to the
127     * prefix, or the URI of the default namespace if appropriate.
128     * @return The URI of the namespace of this node. For an unnamed node, return null.
129     * For a node with an empty prefix, return an empty string.
130     */

131
132     public String JavaDoc getURI();
133
134     /**
135     * Get the display name of this node. For elements and attributes this is [prefix:]localname.
136     * For unnamed nodes, it is an empty string.
137     * @return The display name of this node.
138     * For a node with no name, return an empty string.
139     */

140
141     public String JavaDoc getDisplayName();
142
143     /**
144     * Get the NodeInfo object representing the parent of this node
145     */

146     
147     public NodeInfo getParent();
148
149     /**
150     * Return an enumeration over the nodes reached by the given axis from this node
151     * @param nodeType the type(s) of node to be included, e.g. NodeInfo.ELEMENT, NodeInfo.TEXT.
152     * The value NodeInfo.NODE means include any type of node.
153     * @param nodeTest A pattern to be matched by the returned nodes
154     * @return a NodeEnumeration that scans the nodes reached by the axis in turn.
155     */

156
157     public AxisEnumeration getEnumeration(byte axisNumber, NodeTest nodeTest);
158          
159     /**
160      * Find the value of a given attribute of this node. <BR>
161      * This method is defined on all nodes to meet XSL requirements, but for nodes
162      * other than elements it will always return null.
163      * @param uri the namespace uri of an attribute ("" if no namespace)
164      * @param localname the local name of the attribute
165      * @return the value of the attribute, if it exists, otherwise null
166      */

167
168     public String JavaDoc getAttributeValue(String JavaDoc uri, String JavaDoc localName);
169    
170     /**
171     * Get the value of a given attribute of this node
172     * @param fingerprint The fingerprint of the attribute name
173     * @return the attribute value if it exists or null if not
174     */

175     
176     public String JavaDoc getAttributeValue(int fingerprint);
177
178     /**
179     * Get the root (document) node
180     * @return the DocumentInfo representing the containing document
181     */

182
183     public DocumentInfo getDocumentRoot();
184
185     /**
186     * Determine whether the node has any children. <br />
187     * Note: the result is equivalent to <br />
188     * getEnumeration(Axis.CHILD, AnyNodeTest.getInstance()).hasMoreElements()
189     */

190
191     public boolean hasChildNodes();
192
193     /**
194     * Get a character string that uniquely identifies this node.<br />
195     * Note: a.isSameNode(b) if and only if generateId(a)==generateId(b)
196     * @return a string that uniquely identifies this node, within this
197     * document. The calling code prepends information to make the result
198     * unique across all documents.
199     */

200
201     public String JavaDoc generateId();
202
203     /**
204     * Copy this node to a given outputter
205     */

206
207     public void copy(Outputter out) throws TransformerException JavaDoc;
208
209     /**
210     * Copy the string-value of this node to a given outputter
211     */

212
213     public void copyStringValue(Outputter out) throws TransformerException JavaDoc;
214
215     /**
216     * Output all namespace nodes associated with this element. Does nothing if
217     * the node is not an element.
218     * @param out The relevant outputter
219     * @param includeAncestors True if namespaces declared on ancestor elements must
220     * be output; false if it is known that these are already on the result tree
221     */

222
223     public void outputNamespaceNodes(Outputter out, boolean includeAncestors)
224         throws TransformerException JavaDoc;
225
226 }
227
228 //
229
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
230
// you may not use this file except in compliance with the License. You may obtain a copy of the
231
// License at http://www.mozilla.org/MPL/
232
//
233
// Software distributed under the License is distributed on an "AS IS" basis,
234
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
235
// See the License for the specific language governing rights and limitations under the License.
236
//
237
// The Original Code is: all this file.
238
//
239
// The Initial Developer of the Original Code is
240
// Michael Kay of International Computers Limited (mhkay@iclway.co.uk).
241
//
242
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
243
//
244
// Contributor(s): none.
245
//
246
Popular Tags