|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.xerces.dom.NodeImpl | +--org.apache.xerces.dom.NodeContainer
NodeContainer inherits from NodeImpl and adds the capability of having child nodes. Not every node in the DOM can have children, so only nodes that can should inherit from this class and pay the price for it.
NodeContainer, just like NodeImpl, also implements NodeList, so it can return itself in response to the getChildNodes() query. This eliminiates the need for a separate ChildNodeList object. Note that this is an IMPLEMENTATION DETAIL; applications should _never_ assume that this identity exists.
Field Summary | |
protected NodeImpl |
firstChild
First child. |
protected static int[] |
kidOK
Table for quick check of child insertion. |
protected NodeImpl |
lastChild
Last child. |
protected int |
nodeListChanges
Last change number for index caching. |
protected int |
nodeListIndex
Last requested node index. |
protected int |
nodeListLength
Cached node list length. |
protected NodeImpl |
nodeListNode
Last requested node. |
protected boolean |
syncChildren
Synchronization of child nodes needed. |
Fields inherited from class org.apache.xerces.dom.NodeImpl |
ELEMENT_DEFINITION_NODE,
fInternalSetNodeValue,
MUTATION_AGGREGATE,
MUTATION_ALL,
MUTATION_LOCAL,
MUTATION_NONE,
MUTATIONEVENTS,
name,
nextSibling,
ownerDocument,
parentNode,
previousSibling,
readOnly,
syncData,
userData,
value |
Constructor Summary | |
|
NodeContainer()
Constructor for serialization. |
protected |
NodeContainer(DocumentImpl ownerDocument,
java.lang.String name,
java.lang.String value)
No public constructor; only subclasses of NodeContainer should be instantiated, and those normally via a Document's factory methods |
Method Summary | |
Node |
appendChild(Node newChild)
Adds a child node to the end of the list of children for this node. |
Node |
cloneNode(boolean deep)
Returns a duplicate of a given node. |
NodeList |
getChildNodes()
Obtain a NodeList enumerating all children of this node. |
Node |
getFirstChild()
The first child of this Node, or null if none. |
Node |
getLastChild()
The first child of this Node, or null if none. |
int |
getLength()
NodeList method: Count the immediate children of this node |
boolean |
hasChildNodes()
Test whether this node has any children. |
Node |
insertBefore(Node newChild,
Node refChild)
Move one or more node(s) to our list of children. |
Node |
item(int index)
NodeList method: Return the Nth immediate child of this node, or null if the index is out of bounds. |
void |
normalize()
Override default behavior to call normalize() on this Node's children. |
Node |
removeChild(Node oldChild)
Remove a child from this Node. |
Node |
replaceChild(Node newChild,
Node oldChild)
Make newChild occupy the location that oldChild used to have. |
void |
setReadOnly(boolean readOnly,
boolean deep)
Override default behavior so that if deep is true, children are also toggled. |
protected void |
synchronizeChildren()
Override this method in subclass to hook in efficient internal data structure. |
Methods inherited from class org.apache.xerces.dom.NodeImpl |
addEventListener,
changed,
dispatchEvent,
finalize,
getAttributes,
getLocalName,
getNamespaceURI,
getNextSibling,
getNodeName,
getNodeType,
getNodeValue,
getOwnerDocument,
getParentNode,
getPrefix,
getPreviousSibling,
getReadOnly,
getUserData,
removeEventListener,
setNodeValue,
setPrefix,
setUserData,
supports,
synchronizeData,
toString |
Methods inherited from class java.lang.Object |
clone,
equals,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
protected NodeImpl firstChild
protected NodeImpl lastChild
protected transient int nodeListChanges
protected transient int nodeListLength
protected transient NodeImpl nodeListNode
protected transient int nodeListIndex
protected transient boolean syncChildren
protected static int[] kidOK
Constructor Detail |
protected NodeContainer(DocumentImpl ownerDocument, java.lang.String name, java.lang.String value)
public NodeContainer()
Method Detail |
public Node appendChild(Node newChild) throws DOMException
insertBefore(Node, Node)
public Node cloneNode(boolean deep)
Example: Cloning a Text node will copy both the node and the text it contains.
Example: Cloning something that has children -- Element or Attr, for example -- will _not_ clone those children unless a "deep clone" has been requested. A shallow clone of an Attr node will yield an empty Attr of the same name.
NOTE: Clones will always be read/write, even if the node being cloned is read-only, to permit applications using only the DOM API to obtain editable copies of locked portions of the tree.
Example: Cloning a Text node will copy both the node and the text it
contains.
Example: Cloning something that has children -- Element or Attr, for
example -- will _not_ clone those children unless a "deep clone"
has been requested. A shallow clone of an Attr node will yield an
empty Attr of the same name.
NOTE: Clones will always be read/write, even if the node being cloned
is read-only, to permit applications using only the DOM API to obtain
editable copies of locked portions of the tree.
public boolean hasChildNodes()
NodeContainer
public NodeList getChildNodes()
NodeLists are "live"; as children are added/removed the NodeList will immediately reflect those changes. Also, the NodeList refers to the actual nodes, so changes to those nodes made via the DOM tree will be reflected in the NodeList and vice versa.
In this implementation, Nodes implement the NodeList interface and provide their own getChildNodes() support. Other DOMs may solve this differently.
public Node getFirstChild()
NodeContainer
public Node getLastChild()
NodeContainer
public Node insertBefore(Node newChild, Node refChild) throws DOMException
newChild
- The Node to be moved to our subtree. As a
convenience feature, inserting a DocumentNode will instead insert
all its children.refChild
- Current child which newChild should be placed
immediately before. If refChild is null, the insertion occurs
after all existing Nodes, like appendChild().public Node removeChild(Node oldChild) throws DOMException
public Node replaceChild(Node newChild, Node oldChild) throws DOMException
public int getLength()
public Node item(int index)
Index
- intpublic void normalize()
public void setReadOnly(boolean readOnly, boolean deep)
Note: this will not change the state of an EntityReference or its
children, which are always read-only.
protected void synchronizeChildren()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |