KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > saxon > pull > UnconstructedDocument


1 package net.sf.saxon.pull;
2
3 import net.sf.saxon.expr.XPathContext;
4 import net.sf.saxon.instruct.DocumentInstr;
5 import net.sf.saxon.om.DocumentInfo;
6 import net.sf.saxon.om.NodeInfo;
7 import net.sf.saxon.type.Type;
8
9 /**
10  * A document node whose construction is deferred.
11  * </p>
12  * (TODO) NOTE: this class is an exception to the general rule that for document nodes, node identity implies object identity
13  */

14
15 public class UnconstructedDocument extends UnconstructedParent implements DocumentInfo {
16
17     public UnconstructedDocument(DocumentInstr instruction, XPathContext context) {
18         super(instruction, context);
19     }
20
21     /**
22      * Get name code. The name code is a coded form of the node name: two nodes
23      * with the same name code have the same namespace URI, the same local name,
24      * and the same prefix. By masking the name code with &0xfffff, you get a
25      * fingerprint: two nodes with the same fingerprint have the same local name
26      * and namespace URI.
27      *
28      * @return an integer name code, which may be used to obtain the actual node
29      * name from the name pool
30      * @see net.sf.saxon.om.NamePool#allocate allocate
31      * @see net.sf.saxon.om.NamePool#getFingerprint getFingerprint
32      */

33
34     public int getNameCode() {
35         return -1;
36     }
37
38     public int getNodeKind() {
39         return Type.DOCUMENT;
40     }
41
42     /**
43      * Get fingerprint. The fingerprint is a coded form of the expanded name
44      * of the node: two nodes
45      * with the same name code have the same namespace URI and the same local name.
46      * A fingerprint of -1 should be returned for a node with no name.
47      *
48      * @return an integer fingerprint; two nodes with the same fingerprint have
49      * the same expanded QName
50      */

51
52     public int getFingerprint() {
53         return -1;
54     }
55
56     /**
57      * Get the local part of the name of this node. This is the name after the ":" if any.
58      *
59      * @return the local part of the name. For an unnamed node, returns "". Unlike the DOM
60      * interface, this returns the full name in the case of a non-namespaced name.
61      */

62
63     public String JavaDoc getLocalPart() {
64         return "";
65     }
66
67     /**
68      * Get the URI part of the name of this node. This is the URI corresponding to the
69      * prefix, or the URI of the default namespace if appropriate.
70      *
71      * @return The URI of the namespace of this node. For an unnamed node,
72      * or for a node with an empty prefix, return an empty
73      * string.
74      */

75
76     public String JavaDoc getURI() {
77         return "";
78     }
79
80     /**
81      * Get the display name of this node. For elements and attributes this is [prefix:]localname.
82      * For unnamed nodes, it is an empty string.
83      *
84      * @return The display name of this node. For a node with no name, return
85      * an empty string.
86      */

87
88     public String JavaDoc getDisplayName() {
89         return "";
90     }
91
92     /**
93      * Get the prefix of the name of the node. This is defined only for elements and attributes.
94      * If the node has no prefix, or for other kinds of node, return a zero-length string.
95      *
96      * @return The prefix of the name of the node.
97      */

98
99     public String JavaDoc getPrefix() {
100         return "";
101     }
102
103     /**
104      * Get the root node, if it is a document node.
105      *
106      * @return the DocumentInfo representing the containing document. If this
107      * node is part of a tree that does not have a document node as its
108      * root, return null.
109      */

110
111     public DocumentInfo getDocumentRoot() {
112         return this;
113     }
114
115     /**
116      * Get the element with a given ID, if any
117      *
118      * @param id the required ID value
119      * @return the element with the given ID, or null if there is no such ID
120      * present (or if the parser has not notified attributes as being of
121      * type ID)
122      * @since 8.4
123      */

124
125     public NodeInfo selectID(String JavaDoc id) {
126         if (node == null) {
127             tryToConstruct();
128         }
129         return ((DocumentInfo)node).selectID(id);
130     }
131
132     /**
133      * Get the unparsed entity with a given name
134      *
135      * @param name the name of the entity
136      * @return if the entity exists, return an array of two Strings, the first
137      * holding the system ID of the entity, the second holding the public
138      * ID if there is one, or null if not. If the entity does not exist,
139      * the method returns null. Applications should be written on the
140      * assumption that this array may be extended in the future to provide
141      * additional information.
142      * @since 8.4
143      */

144
145     public String JavaDoc[] getUnparsedEntity(String JavaDoc name) {
146         return null;
147     }
148
149 }
150
Popular Tags