public class ElementImpl extends NodeImpl implements NamespaceResolver
NodeFactory
registered with the LinkedTreeBuilder
used to construct the tree.NODE_LETTER
ALL_NAMESPACES, IS_DTD_TYPE, IS_NILLED, LOCAL_NAMESPACES, NO_NAMESPACES
Constructor and Description |
---|
ElementImpl()
Construct an empty ElementImpl
|
Modifier and Type | Method and Description |
---|---|
void |
addAttribute(NodeName nameCode,
SimpleType attType,
java.lang.CharSequence value,
int properties)
Add an attribute to this element node.
|
protected void |
addChild(NodeImpl node,
int index)
Add a child node to this node.
|
void |
addNamespace(NamespaceBinding nscode,
boolean inherit)
Add a namespace binding (that is, a namespace node) to this element.
|
void |
compact(int size)
Compact the space used by this node
|
void |
copy(Receiver out,
int copyOptions,
Location location)
Copy this node to a given Receiver.
|
void |
delete()
Delete this node (that is, detach it from its parent)
|
protected void |
fixupInsertedNamespaces(boolean inherit)
Ensure that a child element being inserted into a tree has the right namespace declarations.
|
void |
generateId(FastStringBuffer buffer)
Get a character string that uniquely identifies this node
|
AttributeCollection |
getAttributeList()
Get the attribute list for this element.
|
java.lang.String |
getAttributeValue(java.lang.String uri,
java.lang.String localName)
Get the value of a given attribute of this node
|
java.lang.String |
getBaseURI()
Get the base URI of this element node.
|
int |
getColumnNumber()
Get the line number of the node within its source document entity
|
NamespaceBinding[] |
getDeclaredNamespaces(NamespaceBinding[] buffer)
Get all namespace undeclarations and undeclarations defined on this element.
|
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 the node within its source document entity
|
NamespaceBinding[] |
getNamespaceList()
Get the namespace list for this element.
|
int |
getNodeKind()
Return the kind of node.
|
NodeName |
getNodeName()
Get the name of the 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
|
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).
|
java.lang.String |
getStringValue()
Return the string-value of the node, that is, the concatenation
of the character content of all descendent elements and text nodes.
|
java.lang.CharSequence |
getStringValueCS()
Get the value of the item as a CharSequence.
|
java.lang.String |
getSystemId()
Get the system ID of the entity containing this element node.
|
java.lang.String |
getURIForPrefix(java.lang.String prefix,
boolean useDefault)
Get the namespace URI corresponding to a given prefix.
|
AttributeCollection |
gsetAttributeCollection()
Get the attribute list.
|
boolean |
hasChildNodes()
Determine if the node has any children.
|
void |
initialise(NodeName elemName,
SchemaType elementType,
AttributeCollectionImpl atts,
NodeInfo parent,
int sequenceNumber)
Initialise a new ElementImpl with an element name
|
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 |
isId()
Determine whether this node has the is-id property
|
boolean |
isInScopeNamespace(java.lang.String uri)
Search the in-scope namespaces to see whether a given namespace is in scope.
|
boolean |
isNilled()
Determine whether the node has the is-nilled property
|
protected AxisIterator |
iterateChildren(NodeTest test)
Get an enumeration of the children of this node
|
java.util.Iterator<java.lang.String> |
iteratePrefixes()
Get an iterator over all the prefixes declared in this namespace context.
|
void |
removeAttribute(NodeInfo attribute)
Remove an attribute from this element node
|
protected void |
removeChild(NodeImpl child)
Remove a given child
|
void |
removeTypeAnnotation()
Remove type information from this node (and its ancestors, recursively).
|
void |
rename(NodeName newName)
Rename this node
|
protected void |
replaceChildrenAt(NodeInfo[] source,
int index,
boolean inherit)
Replace child at a given index by new children
|
void |
replaceStringValue(java.lang.CharSequence stringValue)
Replace the string-value of this node
|
void |
setAttributeList(AttributeCollection atts)
Set the attribute list
|
protected void |
setChildren(java.lang.Object children)
Set the children of this node
|
void |
setLocation(java.lang.String systemId,
int line,
int column)
Set location information for this node
|
void |
setNamespaceDeclarations(NamespaceBinding[] namespaces,
int namespacesUsed)
Set the namespace declarations for the element
|
void |
setNamespaceList(NamespaceBinding[] namespaces)
Set the namespace list
|
void |
setNilled()
Say that the element has the nilled property
|
void |
setNodeName(NodeName name)
Set the node name
|
protected void |
setRawSequenceNumber(int seq) |
void |
setSystemId(java.lang.String uri)
Set the system ID of this node.
|
void |
setTypeAnnotation(SchemaType type)
Set the type annotation on a node.
|
atomize, compareOrder, comparePosition, equals, getConfiguration, getDisplayName, getFingerprint, getLocalPart, getNamePool, getNextInDocument, getNextSibling, getParent, getPhysicalRoot, getPrefix, getPreviousInDocument, getPreviousSibling, getPublicId, getRawParent, getSiblingPosition, getSuccessorElement, getTreeInfo, getURI, hasFingerprint, head, insertSiblings, isDeleted, isIdref, isSameNodeInfo, isStreamed, iterate, iterateAxis, iterateAxis, newBuilder, replace, saveLocation, setRawParent, setSiblingPosition
public void setAttributeList(AttributeCollection atts)
atts
- the list of attributes of this element (not including namespace attributes)public void setNamespaceList(NamespaceBinding[] namespaces)
namespaces
- an integer array of namespace codespublic void setNodeName(NodeName name)
name
- the node namepublic void initialise(NodeName elemName, SchemaType elementType, AttributeCollectionImpl atts, NodeInfo parent, int sequenceNumber)
elemName
- Integer representing the element name, with namespaces resolvedelementType
- the schema type of the element nodeatts
- The attribute list: always nullparent
- The parent nodesequenceNumber
- Integer identifying this element within the documentpublic NodeName getNodeName()
getNodeName
in class NodeImpl
public void setLocation(java.lang.String systemId, int line, int column)
systemId
- the base URIline
- the line number if knowncolumn
- the column number if knownpublic void setSystemId(java.lang.String uri)
setSystemId
in interface javax.xml.transform.Source
setSystemId
in class NodeImpl
public NodeInfo getRoot()
public final java.lang.String getSystemId()
getSystemId
in interface javax.xml.transform.Source
getSystemId
in interface javax.xml.transform.SourceLocator
getSystemId
in interface Location
getSystemId
in interface NodeInfo
getSystemId
in interface org.xml.sax.Locator
getSystemId
in class NodeImpl
public java.lang.String getBaseURI()
getBaseURI
in interface NodeInfo
getBaseURI
in class NodeImpl
public AttributeCollection gsetAttributeCollection()
public boolean isNilled()
public void setTypeAnnotation(SchemaType type)
setTypeAnnotation
in interface MutableNodeInfo
setTypeAnnotation
in class NodeImpl
type
- the type annotationpublic void setNilled()
public SchemaType getSchemaType()
getSchemaType
in interface NodeInfo
getSchemaType
in class NodeImpl
public int getLineNumber()
getLineNumber
in interface javax.xml.transform.SourceLocator
getLineNumber
in interface Location
getLineNumber
in interface NodeInfo
getLineNumber
in interface org.xml.sax.Locator
getLineNumber
in class NodeImpl
public int getColumnNumber()
getColumnNumber
in interface javax.xml.transform.SourceLocator
getColumnNumber
in interface Location
getColumnNumber
in interface NodeInfo
getColumnNumber
in interface org.xml.sax.Locator
getColumnNumber
in class NodeImpl
public void generateId(FastStringBuffer buffer)
generateId
in interface NodeInfo
generateId
in class NodeImpl
buffer
- to contain the generated IDpublic final int getNodeKind()
getNodeKind
in interface NodeInfo
Type
public void copy(Receiver out, int copyOptions, Location location) 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
location
- If non-null, identifies the location of the instruction
that requested this copy. If zero, indicates that the location information
is not availableXPathException
- if any downstream error occurspublic void delete()
delete
in interface MutableNodeInfo
delete
in class NodeImpl
public void rename(NodeName newName)
rename
in interface MutableNodeInfo
rename
in class NodeImpl
newName
- the new namepublic void addNamespace(NamespaceBinding nscode, boolean inherit)
addNamespace
in interface MutableNodeInfo
addNamespace
in class NodeImpl
nscode
- The namespace code representing the (prefix, uri) pair of the namespace binding to be
added. If the target element already has a namespace binding with this (prefix, uri) pair, the call has
no effect. If the target element currently has a namespace binding with this prefix and a different URI, an
exception is raised.inherit
- If true, the new namespace binding will be inherited by any children of the target element
that do not already have a namespace binding for the specified prefix, recursively.
If false, the new namespace binding will not be inherited.java.lang.IllegalArgumentException
- if the target element already has a namespace binding for this prefix,
or if the namespace code represents a namespace undeclarationpublic void replaceStringValue(java.lang.CharSequence stringValue)
replaceStringValue
in interface MutableNodeInfo
stringValue
- the new string valuepublic void addAttribute(NodeName nameCode, SimpleType attType, java.lang.CharSequence value, int properties)
If this node is not an element, or if the supplied node is not an attribute, the method takes no action. If the element already has an attribute with this name, the method throws an exception.
This method does not perform any namespace fixup. It is the caller's responsibility to ensure that any namespace prefix used in the name of the attribute (or in its value if it has a namespace-sensitive type) is declared on this element.
addAttribute
in interface MutableNodeInfo
addAttribute
in class NodeImpl
nameCode
- the name of the new attributeattType
- the type annotation of the new attributevalue
- the string value of the new attributeproperties
- properties including IS_ID and IS_IDREF propertiesjava.lang.IllegalStateException
- if the element already has an attribute with the given name.public void removeAttribute(NodeInfo attribute)
If this node is not an element, or if the specified node is not an attribute of this element, this method takes no action.
The attribute object itself becomes unusable; any attempt to use this attribute object, or any other object representing the same node, is likely to result in an exception.
removeAttribute
in interface MutableNodeInfo
removeAttribute
in class NodeImpl
attribute
- the attribute node to be removedpublic void removeTypeAnnotation()
removeTypeAnnotation
in interface MutableNodeInfo
removeTypeAnnotation
in class NodeImpl
public void setNamespaceDeclarations(NamespaceBinding[] namespaces, int namespacesUsed)
namespaces
- the list of namespace codesnamespacesUsed
- the number of entries in the list that are usedpublic java.lang.String getURIForPrefix(java.lang.String prefix, boolean useDefault)
getURIForPrefix
in interface NamespaceResolver
prefix
- the namespace prefix. May be the zero-length string, indicating
that there is no prefix. This indicates either the default namespace or the
null namespace, depending on the value of useDefault.useDefault
- true if the default namespace is to be used when the
prefix is "". If false, the method returns "" when the prefix is "".public java.util.Iterator<java.lang.String> iteratePrefixes()
iteratePrefixes
in interface NamespaceResolver
public boolean isInScopeNamespace(java.lang.String uri)
uri
- The URI to be matched.public NamespaceBinding[] getDeclaredNamespaces(NamespaceBinding[] buffer)
getDeclaredNamespaces
in interface NodeInfo
getDeclaredNamespaces
in class NodeImpl
buffer
- If this is non-null, and the result array fits in this buffer, then the result
may overwrite the contents of this array, to avoid the cost of allocating a new array on the heap.For a node other than an element, the method returns null.
protected void fixupInsertedNamespaces(boolean inherit)
inherit
- true if the child is to inherit the inscope namespaces of its new parentpublic AttributeCollection getAttributeList()
public NamespaceBinding[] getNamespaceList()
public java.lang.String getAttributeValue(java.lang.String uri, java.lang.String localName)
getAttributeValue
in interface NodeInfo
getAttributeValue
in class NodeImpl
uri
- the namespace URI of the attribute name, or "" if the attribute is not in a namepsacelocalName
- the local part of the attribute namepublic boolean isId()
protected final long getSequenceNumber()
getSequenceNumber
in class NodeImpl
protected final int getRawSequenceNumber()
protected final void setRawSequenceNumber(int seq)
protected final void setChildren(java.lang.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<NodeImpl>
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 java.lang.String getStringValue()
Item.getStringValueCS()
public java.lang.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 undeclaredjava.lang.IllegalArgumentException
- 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 parentjava.lang.IllegalArgumentException
- 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-2018 Saxonica Limited. All rights reserved.