Since elements, text nodes, comments, processing instructions, etc. cannot exist outside the context of a Document, the Document interface also contains the factory methods needed to create these objects. The Node objects created have a ownerDocument attribute which associates them with the Document within whose context they were created.
The CoreDocumentImpl class only implements the DOM Core. Additional modules are supported by the more complete DocumentImpl subclass.
Note
When any node in the document is serialized, the entire document is serialized along with it.
Modifier and Type | Field and Description |
---|---|
protected String | actualEncoding
Experimental DOM Level 3 feature: Document actualEncoding |
protected boolean | allowGrammarAccess
Allow grammar access. |
protected boolean | ancestorChecking
Ancestor checking |
protected int | changes
Number of alterations made to this document since its creation. |
protected ElementImpl | docElement
Document element. |
protected DocumentTypeImpl | docType
Document type. |
private int | documentNumber
The following are required for compareDocumentPosition |
pack-priv transient DOMNormalizer | |
protected String | encoding
Experimental DOM Level 3 feature: Document encoding |
protected boolean | errorChecking
Bypass error checking. |
pack-priv transient DOMConfigurationImpl | |
protected String | fDocumentURI
Experimental DOM Level 3 feature: documentURI |
pack-priv transient NodeListCache | fFreeNLCache
NodeListCache free list |
pack-priv transient Object | |
protected Map | identifiers
Identifiers. |
private static final int[] | kidOK
Table for quick check of child insertion. |
private int | |
private Map | |
private Map | nodeUserData
Table for user data attached to this document nodes. |
private static final ObjectStreamField[] | |
pack-priv static final long | serialVersionUID
Hides com. |
protected boolean | standalone
Experimental DOM Level 3 feature: Document standalone |
protected String | version
Experimental DOM Level 3 feature: Document version |
private boolean | |
protected boolean |
Access | Constructor and Description |
---|---|
public | CoreDocumentImpl()
NON-DOM: Actually creating a Document is outside the DOM's spec, since it has to operate in terms of a particular implementation. |
public | |
public | |
public |
Modifier and Type | Method and Description |
---|---|
public void | |
protected void | |
public Node | adoptNode(Node
The node to adopt. source)Implements org. DOM Level 3 WD - Experimental Change the node's ownerDocument, and its subtree, to this Document |
pack-priv void | callUserDataHandlers(Node
The node this operation applies to. n, Node The copy node or null. c, short The operation - import, clone, or delete. operation)Call user data handlers when a node is deleted (finalized) |
pack-priv void | callUserDataHandlers(Node
The node this operation applies to. n, Node The copy node or null. c, short The operation - import, clone, or delete. operation, Map<String, ParentNode.Data associated with n. userDataCall user data handlers when a node is deleted (finalized) |
protected void | changed()
Overrides com. Denotes that this node has changed. |
protected int | changes()
Overrides com. Returns the number of changes to this node. |
protected final void | |
protected final void | checkNamespaceWF(String qname, int colon1, int colon2)
Call user data handlers to let them know the nodes they are related to are being deleted. |
protected final void | checkQName(String
prefix of qualified name prefix, String local part of qualified name local)Checks if the given qualified name is legal with respect to the version of XML to which this document must conform. |
protected final void | |
public Object | |
public Node | Returns: org.w3c.dom.Nodeboolean, iff true replicate children deep)Overrides com. Implements org. Deep-clone a document, including fixing ownerDoc for the cloned children. |
protected void | |
protected void | |
public Attr | createAttribute(String
The name of the attribute. Note that the attribute's value is
_not_ established at the factory; remember to set it! name)Implements org. Factory method; creates an Attribute having this Document as its OwnerDoc. |
public Attr | Returns: Attr A new Attr object.The namespace URI of the attribute to
create. When it is null or an empty string,
this method behaves like createAttribute. namespaceURI, String The qualified name of the attribute to
instantiate. qualifiedName)Implements org. Introduced in DOM Level 2. |
public Attr | Returns: Attr A new Attr object.The namespace URI of the attribute to
create. When it is null or an empty string,
this method behaves like createAttribute. namespaceURI, String The qualified name of the attribute to
instantiate. qualifiedName, String The local name of the attribute to instantiate. localpart)NON-DOM: a factory method used by the Xerces DOM parser to create an element. |
public CDATASection | createCDATASection(String
The initial contents of the CDATA data)Implements org. Factory method; creates a CDATASection having this Document as its OwnerDoc. |
public Comment | createComment(String
The initial contents of the Comment. data)Implements org. Factory method; creates a Comment having this Document as its OwnerDoc. |
public DocumentFragment | createDocumentFragment()
Implements org. Factory method; creates a DocumentFragment having this Document as its OwnerDoc. |
public DocumentType | createDocumentType(String
The name of the Entity we wish to provide a value for. qualifiedName, String publicID, String systemID)NON-DOM Factory method; creates a DocumentType having this Document as its OwnerDoc. |
public Element | createElement(String
The name of the element type to instantiate. For
XML, this is case-sensitive. For HTML, the tagName parameter may
be provided in any case, but it must be mapped to the canonical
uppercase form by the DOM implementation. tagName)Implements org. Factory method; creates an Element having this Document as its OwnerDoc. |
public ElementDefinitionImpl | |
public Element | Returns: Element A new Element object with the following attributes:The namespace URI of the element to
create. namespaceURI, String The qualified name of the element type to
instantiate. qualifiedName)Implements org. Introduced in DOM Level 2. |
public Element | Returns: Element A new Element object with the following attributes:The namespace URI of the element to
create. namespaceURI, String The qualified name of the element type to
instantiate. qualifiedName, String The local name of the attribute to instantiate. localpart)NON-DOM: a factory method used by the Xerces DOM parser to create an element. |
public Entity | createEntity(String
The name of the Entity we wish to provide a value for. name)NON-DOM Factory method; creates an Entity having this Document as its OwnerDoc. |
public EntityReference | createEntityReference(String
The name of the Entity we wish to refer to name)Implements org. Factory method; creates an EntityReference having this Document as its OwnerDoc. |
public Notation | createNotation(String
The name of the Notation we wish to describe name)NON-DOM Factory method; creates a Notation having this Document as its OwnerDoc. |
public ProcessingInstruction | createProcessingInstruction(String
The target "processor channel" target, String Parameter string to be passed to the target. data)Implements org. Factory method; creates a ProcessingInstruction having this Document as its OwnerDoc. |
public Text | createTextNode(String
The initial contents of the Text. data)Implements org. Factory method; creates a Text node having this Document as its OwnerDoc. |
pack-priv void | deletedText(NodeImpl node, int offset, int count)
A method to be called when some text was deleted from a text node, so that live objects can be notified. |
protected boolean | |
pack-priv void | |
public boolean | |
public String | Returns: The absolute base URI of this node or null.Overrides com. Implements org. Returns the absolute base URI of this node or null if the implementation wasn't able to obtain an absolute URI. |
public DocumentType | getDoctype()
Implements org. For XML, this provides access to the Document Type Definition. |
public Element | getDocumentElement()
Implements org. Convenience method, allowing direct access to the child node which is considered the root of the actual document content. |
public String | |
public DOMConfiguration | getDomConfig()
Implements org. DOM Level 3 CR - Experimental
The configuration used when |
public Element | getElementById(String
The unique elementId)id value for an element.Implements org. Introduced in DOM Level 2 Returns the Element whose ID is given by elementId. |
public NodeList | getElementsByTagName(String
The type of Element we want to gather. "*" will be
taken as a wildcard, meaning "all elements in the document." tagname)Implements org. Return a live collection of all descendent Elements (not just immediate children) having the specified tag name. |
public NodeList | Returns: NodeList A new NodeList object containing all the matched Elements.The namespace URI of the elements to match
on. The special value "*" matches all
namespaces. When it is null or an empty
string, this method behaves like
getElementsByTagName. namespaceURI, String The local name of the elements to match on.
The special value "*" matches all local names. localName)Implements org. Introduced in DOM Level 2. |
public String | getEncoding()
Deprecated
This method is internal and only exists for
compatibility with older applications. New applications
should never call this method.
|
public boolean | |
public Object | getFeature(String
The name of the feature requested. Note that any plus
sign "+" prepended to the name of the feature will be ignored since
it is not significant in the context of this method. feature, String This is the version number of the feature to test. version)Overrides com. Implements org. This method returns a specialized object which implements the specialized APIs of the specified feature and version, as specified in . |
public Element | getIdentifier(String idName)
Returns a previously registered element with the specified identifier name, or null if no element is registered. |
public DOMImplementation | getImplementation()
Implements org. Retrieve information describing the abilities of this particular DOM implementation. |
public String | |
pack-priv boolean | |
pack-priv NodeListCache | |
public String | getNodeName()
Implements abstract com. Implements org. Returns the node name. |
protected int | getNodeNumber()
Overrides com. NON-DOM: Get the number associated with this document. |
protected int | getNodeNumber(Node node)
NON-DOM: Get a number associated with a node created with respect to this document. |
public short | getNodeType()
Implements abstract com. Implements org. Returns the node type. |
public final Document | getOwnerDocument()
Overrides com. Implements org. The |
public boolean | getStandalone()
Deprecated
This method is internal and only exists for
compatibility with older applications. New applications
should never call this method.
|
public boolean | getStrictErrorChecking()
Implements org. An attribute specifying whether error checking is enforced or not. |
public String | getTextContent()
Overrides com. Implements org. This attribute returns the text content of this node and its descendants. |
public Object | Returns: Returns theDOMObject associated to the given key
on this node, or null if there was none.The node the object is associated to. n, String The key the object is associated to. key)Retrieves the object associated to a key on a this node. |
protected Object | getUserData(NodeImpl n)
NON-DOM: kept for backward compatibility Retreive user data related to a given node |
protected Map | |
public String | getVersion()
Deprecated
This method is internal and only exists for
compatibility with older applications. New applications
should never call this method.
|
public String | |
public boolean | |
public String | |
public Node | importNode(Node
The node to import. source, boolean If deep)true , recursively import the subtree under
the specified node; if false , import only the node
itself, as explained above. This has no effect on nodes that cannot
have any children, and on Attr , and
EntityReference nodes.Implements org. Copies a node from another document to this document. |
private Node | importNode(Node source, boolean deep, boolean cloningDoc, Map<Node, String> reversedIdentifiers)
Overloaded implementation of DOM's importNode method. |
public Node | insertBefore(Node
The node to insert. newChild, Node The reference node, i.e., the node before which the
new node must be inserted. refChild)Overrides com. Implements org. Since a Document may contain at most one top-level Element child, and at most one DocumentType declaraction, we need to subclass our add-children methods to implement this constraint. |
pack-priv void | insertedNode(NodeImpl node, NodeImpl newInternal, boolean replace)
A method to be called when a node has been inserted in the tree. |
pack-priv void | insertedText(NodeImpl node, int offset, int count)
A method to be called when some text was inserted into a text node, so that live objects can be notified. |
pack-priv void | insertingNode(NodeImpl node, boolean replace)
A method to be called when a node is about to be inserted in the tree. |
protected boolean | |
pack-priv boolean | |
public static final boolean | isValidQName(String
prefix of qualified name prefix, String local part of qualified name local, boolean xml11Version)Checks if the given qualified name is legal with respect to the version of XML to which this document must conform. |
pack-priv boolean | isXML11Version()
We could have more xml versions in future , but for now we could do with this to handle XML 1.0 and 1.1 |
public static final boolean | |
pack-priv boolean | |
public boolean | Returns: If async is set totrue load returns
true if the document load was successfully initiated.
If an error occurred when initiating the document load,
load returns false .If async is set to
false load returns true if
the document was successfully loaded and parsed. If an error
occurred when either loading or parsing the URI, load
returns false .The URI reference for the XML file to be loaded. If this is
a relative URI, the base URI used by the implementation is
implementation dependent. uri)DOM Level 3 WD - Experimental. |
public boolean | |
pack-priv void | modifiedAttrValue(AttrImpl attr, String oldvalue)
A method to be called when an attribute value has been modified |
pack-priv void | modifiedCharacterData(NodeImpl node, String oldvalue, String value, boolean replace)
A method to be called when a character data node has been modified |
pack-priv void | modifyingCharacterData(NodeImpl node, boolean replace)
A method to be called when a character data node is about to be modified |
public void | normalizeDocument()
Implements org. DOM Level 3 WD - Experimental Normalize document. |
public void | putIdentifier(String idName, Element element)
Registers an identifier name with a specified element node. |
private void | readObject(ObjectInputStream in)
Hides com. Deserialize object. |
public Node | removeChild(Node
The node being removed. oldChild)Overrides com. Implements org. Since insertBefore caches the docElement (and, currently, docType), removeChild has to know how to undo the cache Revisit According to the spec it is not allowed to alter neither the document element nor the document type in any way |
pack-priv void | removedAttrNode(AttrImpl attr, NodeImpl oldOwner, String name)
A method to be called when an attribute node has been removed |
pack-priv void | removedNode(NodeImpl node, boolean replace)
A method to be called when a node has been removed from the tree. |
protected void | |
public void | removeIdentifier(String idName)
Removes a previously registered element with the specified identifier name. |
pack-priv Map | Returns: The removed table.The node this operation applies to. n)Remove user data table for the given node. |
pack-priv void | removingNode(NodeImpl node, NodeImpl oldChild, boolean replace)
A method to be called when a node is about to be removed from the tree. |
pack-priv void | renamedAttrNode(Attr oldAt, Attr newAt)
A method to be called when an attribute node has been renamed |
pack-priv void | |
public Node | renameNode(Node
The node to rename. n, String The new namespace URI. namespaceURI, String The new qualified name. name)Implements org. DOM Level 3 WD - Experimental. |
public Node | replaceChild(Node
The new node to put in the child list. newChild, Node The node being replaced in the list. oldChild)Overrides com. Implements org. Since we cache the docElement (and, currently, docType), replaceChild has to update the cache Revisit According to the spec it is not allowed to alter neither the document element nor the document type in any way |
pack-priv void | replacedCharacterData(NodeImpl node, String oldvalue, String value)
method to be called when a character data node has been replaced. |
pack-priv void | |
pack-priv void | replacedText(NodeImpl node)
A method to be called when some text was changed in a text node, so that live objects can be notified. |
pack-priv void | replacingData(NodeImpl node)
A method to be called when a character data node is about to be replaced |
pack-priv void | |
public String | |
public void | |
pack-priv void | setAttrNode(AttrImpl attr, AttrImpl previous)
A method to be called when an attribute node has been set |
public void | setDocumentURI(String documentURI)
Implements org. DOM Level 3 WD - Experimental. |
public void | setEncoding(String value)
Deprecated
This method is internal and only exists for
compatibility with older applications. New applications
should never call this method.
|
public void | setErrorChecking(boolean check)
Sets whether the DOM implementation performs error checking upon operations. |
public void | setInputEncoding(String value)
DOM Internal (Was a DOM L3 Core WD public interface method setActualEncoding ) An attribute specifying the actual encoding of this document. |
pack-priv void | setMutationEvents(boolean set)
Sets whether the DOM implementation generates mutation events upon operations. |
public void | setStandalone(boolean value)
Deprecated
This method is internal and only exists for
compatibility with older applications. New applications
should never call this method.
|
public void | setStrictErrorChecking(boolean check)
Implements org. An attribute specifying whether error checking is enforced or not. |
public void | setTextContent(String textContent)
Overrides com. Implements org. This attribute returns the text content of this node and its descendants. |
public Object | Returns: Returns theDOMObject previously associated to
the given key on this node, or null if there was none.The node to associate the object to. n, String The key to associate the object to. key, Object The object to associate to the given key, or
data, UserDataHandler null to remove any existing association to that key.The handler to associate to that key, or
handler)null .Associate an object to a key on this node. |
protected void | setUserData(NodeImpl n, Object data)
NON-DOM: kept for backward compatibility Store user data related to a given node This is a place where we could use weak references! |
pack-priv void | setUserDataTable(Node
The node this operation applies to. n, Map<String, ParentNode.The user data table. dataSet user data table for the given node. |
public void | setVersion(String value)
Deprecated
This method is internal and only exists for
compatibility with older applications. New applications
should never call this method.
|
public void | setXmlEncoding(String value)
DOM Internal (Was a DOM L3 Core WD public interface method setXMLEncoding ) An attribute specifying, as part of the XML declaration, the encoding of this document. |
public void | setXmlStandalone(boolean value)
Implements org. DOM Level 3 CR - Experimental. |
public void | setXmlVersion(String value)
Implements org. DOM Level 3 CR - Experimental. |
protected void | |
private void | writeObject(ObjectOutputStream out)
Hides com. Serialize object. |