public final class DocumentImpl extends NodeImpl implements DocumentInfo, MutableDocumentInfo
A DocumentImpl object may either represent a real document node, or it may represent an imaginary container for a parentless element.
NODE_LETTER
ALL_NAMESPACES, IS_DTD_TYPE, IS_NILLED, LOCAL_NAMESPACES, NO_NAMESPACES
Constructor and Description |
---|
DocumentImpl()
Create a DocumentImpl
|
Modifier and Type | Method and Description |
---|---|
protected void |
addChild(NodeImpl node,
int index)
Add a child node to this node.
|
void |
compact(int size)
Compact the space used by this node
|
void |
copy(Receiver out,
int copyOptions,
int locationId)
Copy this node to a given outputter
|
void |
deIndex(NodeImpl node)
Remove a node from any indexes when it is detached from the tree
|
protected void |
deregisterID(String id)
Remove the entry for a given ID (when nodes are deleted).
|
void |
generateId(FastStringBuffer buffer)
Get a character string that uniquely identifies this node
|
String |
getBaseURI()
Get the base URI of this root node.
|
Configuration |
getConfiguration()
Get the configuration previously set using setConfiguration
|
ElementImpl |
getDocumentElement()
Get the root (outermost) element.
|
long |
getDocumentNumber()
Get the unique document number
|
DocumentInfo |
getDocumentRoot()
Get the root (document) node
|
NodeImpl |
getFirstChild()
Get the first child node of the element
|
NodeImpl |
getLastChild()
Get the last child node of the element
|
int |
getLineNumber()
Get the line number of this root node.
|
NamePool |
getNamePool()
Get the name pool used for the names in this document
|
NodeImpl |
getNextSibling()
Get next sibling - always null
|
int |
getNodeKind()
Return the type of node.
|
protected NodeImpl |
getNthChild(int n)
Get the nth child node of the element (numbering from 0)
|
int |
getNumberOfChildren()
Determine how many children the node has
|
DocumentImpl |
getPhysicalRoot()
Get the physical root of the tree.
|
NodeImpl |
getPreviousSibling()
Get previous sibling - always null
|
protected int |
getRawSequenceNumber() |
NodeInfo |
getRoot()
Get the root node
|
SchemaType |
getSchemaType()
Get the type annotation
|
protected long |
getSequenceNumber()
Get the node sequence number (in document order).
|
String |
getStringValue()
Return the string-value of the node, that is, the concatenation
of the character content of all descendent elements and text nodes.
|
CharSequence |
getStringValueCS()
Get the value of the item as a CharSequence.
|
String |
getSystemId()
Get the system id of this root node
|
int |
getTypeAnnotation()
Get the type annotation of this node, if any.
|
String[] |
getUnparsedEntity(String name)
Get the unparsed entity with a given name
|
Iterator<String> |
getUnparsedEntityNames()
Get the list of unparsed entities defined in this document
|
Object |
getUserData(String key)
Get user data held in the document node.
|
void |
graftLocationMap(DocumentImpl original)
Copy the system ID and line number map from another document
(used when grafting a simplified stylesheet)
|
boolean |
hasChildNodes()
Determine if the node has any children.
|
void |
insertChildren(NodeInfo[] source,
boolean atStart,
boolean inherit)
Insert a sequence of nodes as children of this node.
|
protected void |
insertChildrenAt(NodeInfo[] source,
int index,
boolean inherit)
Insert children before or after a given existing child
|
boolean |
isImaginary()
Ask whether this is an imaginary document node
|
boolean |
isTyped()
Ask whether the document contains any nodes whose type annotation is anything other than
UNTYPED
|
protected AxisIterator |
iterateChildren(NodeTest test)
Get an enumeration of the children of this node
|
Builder |
newBuilder()
Get a Builder suitable for building nodes that can be attached to this document.
|
protected void |
registerID(NodeInfo e,
String id)
Register a unique element ID.
|
protected void |
removeChild(NodeImpl child)
Remove a given child
|
protected void |
replaceChildrenAt(NodeInfo[] source,
int index,
boolean inherit)
Replace child at a given index by new children
|
void |
replaceStringValue(CharSequence stringValue)
Replace the string-value of this node
|
void |
resetIndexes()
This method is called before performing a batch of updates; it allows all cached data that
might be invalidated by such updates to be cleared
|
NodeInfo |
selectID(String id,
boolean getParent)
Get the element with a given ID.
|
void |
setBaseURI(String uri)
Set the base URI of this document node
|
protected void |
setChildren(Object children)
Set the children of this node
|
void |
setConfiguration(Configuration config)
Set the Configuration that contains this document
|
void |
setImaginary(boolean imaginary)
Set whether this is an imaginary document node
|
void |
setLineNumbering()
Set line numbering on
|
protected void |
setRawSequenceNumber(int seq) |
void |
setSystemId(String uri)
Set the system id (base URI) of this node
|
void |
setUserData(String key,
Object value)
Set user data on the document node.
|
addAttribute, addNamespace, atomize, compareOrder, comparePosition, delete, equals, getAttributeValue, getAttributeValue, getColumnNumber, getDeclaredNamespaces, getDisplayName, getFingerprint, getLocalPart, getNameCode, getNextInDocument, getParent, getPrefix, getPreviousInDocument, getPublicId, getRawParent, getSiblingPosition, getSuccessorElement, getURI, head, insertSiblings, isDeleted, isId, isIdref, isNilled, isSameNodeInfo, iterate, iterateAxis, iterateAxis, removeAttribute, removeTypeAnnotation, rename, replace, setRawParent, setSiblingPosition, setTypeAnnotation
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
atomize, compareOrder, comparePosition, equals, getAttributeValue, getColumnNumber, getDeclaredNamespaces, getDisplayName, getFingerprint, getLocalPart, getNameCode, getParent, getPrefix, getStringValue, getURI, hasChildNodes, hashCode, isId, isIdref, isNilled, isSameNodeInfo, iterateAxis, iterateAxis
getStringValueCS
public void setConfiguration(Configuration config)
config
- the Saxon configurationpublic Configuration getConfiguration()
getConfiguration
in interface NodeInfo
getConfiguration
in class NodeImpl
public NamePool getNamePool()
getNamePool
in interface NodeInfo
getNamePool
in class NodeImpl
public Builder newBuilder()
newBuilder
in interface MutableNodeInfo
newBuilder
in class NodeImpl
public void setImaginary(boolean imaginary)
imaginary
- if true, this is an imaginary node - the tree is really rooted at the topmost elementpublic boolean isImaginary()
public boolean isTyped()
isTyped
in interface DocumentInfo
public long getDocumentNumber()
getDocumentNumber
in interface NodeInfo
getDocumentNumber
in class NodeImpl
public void graftLocationMap(DocumentImpl original)
original
- the document whose system ID and line number maps are to be grafted
onto this treepublic void setSystemId(String uri)
setSystemId
in interface Source
setSystemId
in class NodeImpl
public String getSystemId()
getSystemId
in interface Source
getSystemId
in interface SourceLocator
getSystemId
in interface NodeInfo
getSystemId
in class NodeImpl
public void setBaseURI(String uri)
uri
- the new base URIpublic String getBaseURI()
getBaseURI
in interface NodeInfo
getBaseURI
in class NodeImpl
public void setLineNumbering()
public int getLineNumber()
getLineNumber
in interface SourceLocator
getLineNumber
in interface NodeInfo
getLineNumber
in class NodeImpl
public final int getNodeKind()
getNodeKind
in interface NodeInfo
Type
public final NodeImpl getNextSibling()
getNextSibling
in interface SteppingNode
getNextSibling
in class NodeImpl
public final NodeImpl getPreviousSibling()
getPreviousSibling
in interface SteppingNode
getPreviousSibling
in class NodeImpl
public ElementImpl getDocumentElement()
public NodeInfo getRoot()
public DocumentInfo getDocumentRoot()
getDocumentRoot
in interface NodeInfo
getDocumentRoot
in class NodeImpl
public DocumentImpl getPhysicalRoot()
getPhysicalRoot
in class NodeImpl
public void generateId(FastStringBuffer buffer)
generateId
in interface NodeInfo
generateId
in class NodeImpl
buffer
- a buffer into which will be placed a string based on the document numberpublic void deIndex(NodeImpl node)
node
- the node to be removed from all indexesprotected void registerID(NodeInfo e, String id)
e
- The Element having a particular unique ID valueid
- The unique ID valuepublic NodeInfo selectID(String id, boolean getParent)
selectID
in interface DocumentInfo
id
- The unique ID of the required element, previously registered using registerID()getParent
- true if the requirement is for the parent of the node with the given ID,
not the node itself.protected void deregisterID(String id)
id
- The id valuepublic Iterator<String> getUnparsedEntityNames()
getUnparsedEntityNames
in interface DocumentInfo
public String[] getUnparsedEntity(String name)
getUnparsedEntity
in interface DocumentInfo
name
- the name of the entitypublic int getTypeAnnotation()
getTypeAnnotation
in interface NodeInfo
getTypeAnnotation
in class NodeImpl
public SchemaType getSchemaType()
getSchemaType
in interface NodeInfo
getSchemaType
in class NodeImpl
public void copy(Receiver out, int copyOptions, int locationId) throws XPathException
copy
in interface NodeInfo
out
- the Receiver to which the node should be copied. It is the caller's
responsibility to ensure that this Receiver is open before the method is called
(or that it is self-opening), and that it is closed after use.copyOptions
- a selection of the options defined in CopyOptions
locationId
- If non-zero, identifies the location of the instruction
that requested this copy. If zero, indicates that the location informationXPathException
- if any downstream error occurspublic void replaceStringValue(CharSequence stringValue)
replaceStringValue
in interface MutableNodeInfo
stringValue
- the new string valuepublic void resetIndexes()
resetIndexes
in interface MutableDocumentInfo
public void setUserData(String key, Object value)
getUserData(java.lang.String)
setUserData
in interface DocumentInfo
key
- A string giving the name of the property to be set. Clients are responsible
for choosing a key that is likely to be unique. Must not be null. Keys used internally
by Saxon are prefixed "saxon:".value
- The value to be set for the property. May be null, which effectively
removes the existing value for the property.public Object getUserData(String key)
setUserData(java.lang.String, java.lang.Object)
getUserData
in interface DocumentInfo
key
- A string giving the name of the property to be retrieved.protected final long getSequenceNumber()
getSequenceNumber
in class NodeImpl
protected final int getRawSequenceNumber()
protected final void setRawSequenceNumber(int seq)
protected final void setChildren(Object children)
children
- null if there are no children, a single NodeInfo if there is one child, an array of NodeInfo
if there are multiple childrenpublic final boolean hasChildNodes()
hasChildNodes
in interface NodeInfo
hasChildNodes
in class NodeImpl
true
if the node has any children,
false
if the node has no children.public final int getNumberOfChildren()
protected final AxisIterator iterateChildren(NodeTest test)
test
- A NodeTest to be satisfied by the child nodes, or null
if all child node are to be returnedpublic final NodeImpl getFirstChild()
getFirstChild
in interface SteppingNode
getFirstChild
in class NodeImpl
public final NodeImpl getLastChild()
getLastChild
in class NodeImpl
protected final NodeImpl getNthChild(int n)
n
- identifies the required childprotected void removeChild(NodeImpl child)
child
- the child to be removedpublic String getStringValue()
Item.getStringValueCS()
public CharSequence getStringValueCS()
NodeImpl
getStringValueCS
in interface Item
getStringValueCS
in class NodeImpl
Item.getStringValue()
protected void addChild(NodeImpl node, int index)
node
- the node to be added as a child of this node. This must be an instance of
NodeImpl
. It will be modified as a result of this call (by setting its
parent property and sibling position)index
- the position where the child is to be addedpublic void insertChildren(NodeInfo[] source, boolean atStart, boolean inherit)
This method takes no action unless the target node is a document node or element node. It also takes no action in respect of any supplied nodes that are not elements, text nodes, comments, or processing instructions.
The supplied nodes will form the new children. Adjacent text nodes will be merged, and zero-length text nodes removed. The supplied nodes may be modified in situ, for example to change their parent property and to add namespace bindings, or they may be copied, at the discretion of the implementation.
insertChildren
in interface MutableNodeInfo
insertChildren
in class NodeImpl
source
- the nodes to be inserted. The implementation determines what implementation classes
of node it will accept; this implementation will accept text, comment, and processing instruction
nodes belonging to any implementation, but elements must be instances of ElementImpl
.
The supplied nodes will be modified in situ, for example
to change their parent property and to add namespace bindings, if they are instances of
ElementImpl
; otherwise they will be copied. If the nodes are copied, then on return
the supplied source array will contain the copy rather than the original.atStart
- true if the new nodes are to be inserted before existing children; false if they are
to be inserted after existing childreninherit
- true if the inserted nodes are to inherit the namespaces of their new parent; false
if such namespaces are to be undeclaredIllegalArgumentException
- if the supplied nodes use a node implementation that this
implementation does not accept.protected void insertChildrenAt(NodeInfo[] source, int index, boolean inherit)
source
- the children to be inserted. We allow any kind of text, comment, or processing instruction
node, but element nodes must be instances of this NodeInfo implementation.index
- the position before which they are to be inserted: 0 indicates insertion before the
first child, 1 insertion before the second child, and so on.inherit
- true if the inserted nodes are to inherit the namespaces that are in-scope for their
new parent; false if such namespaces should be undeclared on the childrenprotected void replaceChildrenAt(NodeInfo[] source, int index, boolean inherit)
source
- the children to be insertedindex
- the position at which they are to be inserted: 0 indicates replacement of the
first child, replacement of the second child, and so on. The effect is undefined if index
is out of rangeinherit
- set to true if the new child elements are to inherit the in-scope namespaces
of their new parentIllegalArgumentException
- if any of the replacement nodes is not an element, text,
comment, or processing instruction nodepublic void compact(int size)
size
- the number of actual childrenCopyright (c) 2004-2013 Saxonica Limited. All rights reserved.