001: /*
002: * Copyright 2006 Google Inc.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005: * use this file except in compliance with the License. You may obtain a copy of
006: * the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013: * License for the specific language governing permissions and limitations under
014: * the License.
015: */
016: package com.google.gwt.xml.client;
017:
018: /**
019: * This is the base interface for DOM nodes, as obtained from using
020: * <code>XMLParser</code> methods. Methods for iterating over and accessing
021: * values from nodes are supplied here.
022: */
023: public interface Node {
024: /**
025: * The constant 1 denotes DOM nodes of type Element.
026: */
027: public static final short ELEMENT_NODE = 1;
028:
029: /**
030: * The constant 2 denotes DOM nodes of type Attribute.
031: */
032: public static final short ATTRIBUTE_NODE = 2;
033:
034: /**
035: * The constant 3 denotes DOM nodes of type Text.
036: */
037: public static final short TEXT_NODE = 3;
038:
039: /**
040: * The constant 4 denotes DOM nodes of type CdataSection.
041: */
042: public static final short CDATA_SECTION_NODE = 4;
043:
044: /**
045: * The constant 5 denotes DOM nodes of type EntityReference.
046: */
047: public static final short ENTITY_REFERENCE_NODE = 5;
048:
049: /**
050: * The constant 6 denotes DOM nodes of type Entity.
051: */
052: public static final short ENTITY_NODE = 6;
053:
054: /**
055: * The constant 7 denotes DOM nodes of type ProcessingInstruction.
056: */
057: public static final short PROCESSING_INSTRUCTION_NODE = 7;
058:
059: /**
060: * The constant 8 denotes DOM nodes of type Comment.
061: */
062: public static final short COMMENT_NODE = 8;
063:
064: /**
065: * The constant 9 denotes DOM nodes of type Document.
066: */
067: public static final short DOCUMENT_NODE = 9;
068:
069: /**
070: * The constant 10 denotes DOM nodes of type DocumentType.
071: */
072: public static final short DOCUMENT_TYPE_NODE = 10;
073:
074: /**
075: * The constant 11 denotes DOM nodes of type DocumentFragment.
076: */
077: public static final short DOCUMENT_FRAGMENT_NODE = 11;
078:
079: /**
080: * The constant 12 denotes DOM nodes of type Notation.
081: */
082: public static final short NOTATION_NODE = 12;
083:
084: /**
085: * This method appends child <code>newChild</code>.
086: *
087: * @param newChild the <code>Node</code> to be added
088: * @return the child <code>Node</code> appended
089: */
090: public Node appendChild(Node newChild);
091:
092: /**
093: * This method copies this <code>Node</code>.
094: *
095: * @param deep whether to recurse to children
096: * @return <code>Node</code> cloned
097: */
098: public Node cloneNode(boolean deep);
099:
100: /**
101: * This method retrieves the attributes.
102: *
103: * @return the attributes of this <code>Node</code>
104: */
105: public NamedNodeMap getAttributes();
106:
107: /**
108: * This method retrieves the child nodes.
109: *
110: * @return the child nodes of this <code>Node</code>
111: */
112: public NodeList getChildNodes();
113:
114: /**
115: * This method retrieves the first child.
116: *
117: * @return the first child of this <code>Node</code>
118: */
119: public Node getFirstChild();
120:
121: /**
122: * This method retrieves the last child.
123: *
124: * @return the last child of this <code>Node</code>
125: */
126: public Node getLastChild();
127:
128: /**
129: * This method retrieves the namespace URI.
130: *
131: * @return the namespace URI of this <code>Node</code>
132: */
133: public String getNamespaceURI();
134:
135: /**
136: * This method retrieves the next sibling.
137: *
138: * @return the next sibling of this <code>Node</code>
139: */
140: public Node getNextSibling();
141:
142: /**
143: * This method retrieves the name.
144: *
145: * @return the name of this <code>Node</code>
146: */
147: public String getNodeName();
148:
149: /**
150: * This method retrieves the type.
151: *
152: * @return the type of this <code>Node</code>
153: */
154: public short getNodeType();
155:
156: /**
157: * This method retrieves the value.
158: *
159: * @return the value of this <code>Node</code>
160: */
161: public String getNodeValue();
162:
163: /**
164: * This method retrieves the owner document.
165: *
166: * @return the owner document of this <code>Node</code>
167: */
168: public Document getOwnerDocument();
169:
170: /**
171: * This method retrieves the parent.
172: *
173: * @return the parent of this <code>Node</code>
174: */
175: public Node getParentNode();
176:
177: /**
178: * This method retrieves the prefix.
179: *
180: * @return the prefix of this <code>Node</code>
181: */
182: public String getPrefix();
183:
184: /**
185: * This method retrieves the previous sibling.
186: *
187: * @return the previous sibling of this <code>Node</code>
188: */
189: public Node getPreviousSibling();
190:
191: /**
192: * This method determines whether this <code>Node</code> has any attributes.
193: *
194: * @return <code>true</code> if this <code>Node</code> has any attributes
195: */
196: public boolean hasAttributes();
197:
198: /**
199: * This method determines whether this <code>Node</code> has any child
200: * nodes.
201: *
202: * @return <code>true</code> if this <code>Node</code> has any child nodes
203: */
204: public boolean hasChildNodes();
205:
206: /**
207: * This method inserts before <code>newChild</code>.
208: *
209: * @param newChild the <code>Node</code> to be added
210: * @param refChild the <code>Node</code> which determines the position to
211: * insert
212: * @return the before <code>Node</code> inserted
213: */
214: public Node insertBefore(Node newChild, Node refChild);
215:
216: /**
217: * This method may collapse adjacent text nodes into one text node, depending
218: * on the implementation.
219: */
220: public void normalize();
221:
222: /**
223: * This method removes child <code>oldChild</code>.
224: *
225: * @param oldChild the <code>Node</code> to be removed
226: * @return the child <code>Node</code> removed
227: */
228: public Node removeChild(Node oldChild);
229:
230: /**
231: * This method replaces the child <code>oldChild</code> with
232: * <code>newChild</code>.
233: *
234: * @param newChild the <code>Node</code> to be added
235: * @param oldChild the <code>Node</code> to be removed
236: * @return the child <code>Node</code> replaced
237: */
238: public Node replaceChild(Node newChild, Node oldChild);
239:
240: /**
241: * This method sets the value to <code>nodeValue</code>.
242: *
243: * @param nodeValue the new value
244: */
245: public void setNodeValue(String nodeValue);
246:
247: }
|