public class ElementImpl extends NodeImpl implements NamespaceResolver
This class is an implementation of NodeInfo. For elements with attributes or namespace declarations, class ElementWithAttributes is used.
?????? | ????? |
---|---|
protected AttributeCollection |
attributeList |
protected java.lang.Object |
children |
protected int |
nameCode |
protected int[] |
namespaceList |
protected int |
sequence |
protected int |
typeCode |
index, NODE_LETTER, parent
ALL_NAMESPACES, EMPTY_NAMESPACE_LIST, IS_DTD_TYPE, IS_NILLED, LOCAL_NAMESPACES, NO_NAMESPACES
?????? |
---|
ElementImpl()
Construct an empty ElementImpl
|
?????? | ????? |
---|---|
void |
addChild(NodeImpl node,
int index)
Add a child node to this node.
|
void |
addNamespace(int 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 whichNamespaces,
boolean copyAnnotations,
int locationId)
Copy this node to a given outputter (supporting xsl:copy-of)
|
void |
delete()
Delete this node (that is, detach it from its parent)
|
protected AxisIterator |
enumerateChildren(NodeTest test)
Get an enumeration of the children of this node
|
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(int fingerprint)
Get the value of a given attribute of this node
|
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
|
int[] |
getDeclaredNamespaces(int[] buffer)
Get all namespace undeclarations and undeclarations defined on this element.
|
DocumentInfo |
getDocumentRoot()
Get the root node, if it is a document node.
|
NodeInfo |
getFirstChild()
Get the first child node of the element
|
int[] |
getInScopeNamespaceCodes()
Get the list of in-scope namespaces for this element as an array of
namespace codes.
|
NodeInfo |
getLastChild()
Get the last child node of the element
|
int |
getLineNumber()
Get the line number of the node within its source document entity
|
int |
getNameCode()
Get the nameCode of the node.
|
int |
getNodeKind()
Return the kind 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
|
java.lang.String |
getPrefixForURI(java.lang.String uri)
Search the NamespaceList for a given URI, returning the corresponding prefix.
|
NodeInfo |
getRoot()
Get the root node
|
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.
|
int |
getTypeAnnotation()
Get the type annotation of this node, if any
|
short |
getURICodeForPrefix(java.lang.String prefix)
Search the NamespaceList for a given prefix, returning the corresponding URI.
|
protected short |
getURICodeForPrefixCode(int prefixCode)
Get the URI bound to a given prefix in the in-scope namespaces of this element
|
java.lang.String |
getURIForPrefix(java.lang.String prefix,
boolean useDefault)
Get the namespace URI corresponding to a given prefix.
|
boolean |
hasChildNodes()
Determine if the node has any children.
|
void |
initialise(int nameCode,
int typeCode,
AttributeCollectionImpl atts,
NodeInfo parent,
int sequenceNumber)
Initialise a new ElementImpl with an element name
|
void |
insertChildren(NodeInfo[] source,
boolean atStart,
boolean inherit)
Insert copies of 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 |
isNilled()
Determine whether the node has the is-nilled property
|
java.util.Iterator |
iteratePrefixes()
Get an iterator over all the prefixes declared in this namespace context.
|
void |
putAttribute(int nameCode,
int typeCode,
java.lang.CharSequence value,
int properties)
Add an attribute to this element node.
|
void |
removeAttribute(int nameCode)
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(int newNameCode)
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 |
setLineAndColumn(int line,
int column)
Set the line number of the element within its source document entity
|
void |
setLocation(java.lang.String systemId,
int line,
int column)
Set location information for this node
|
void |
setNameCode(int nameCode)
Set the name code.
|
void |
setNamespaceDeclarations(int[] namespaces,
int namespacesUsed)
Set the namespace declarations for the element
|
void |
setSystemId(java.lang.String uri)
Set the system ID of this node.
|
void |
setTypeAnnotation(int typeCode)
Set the type annotation on a node.
|
protected void |
useChildrenArray(NodeImpl[] array)
Supply an array to be used for the array of children.
|
atomize, compareOrder, equals, getConfiguration, getDisplayName, getDocumentNumber, getFingerprint, getLocalPart, getNamePool, getNextInDocument, getNextSibling, getParent, getPhysicalRoot, getPrefix, getPreviousInDocument, getPreviousSibling, getPublicId, getSiblingPosition, getTypedValue, getURI, insertSiblings, isId, isIdref, isSameNodeInfo, iterateAxis, iterateAxis, newBuilder, replace
protected int nameCode
protected int typeCode
protected AttributeCollection attributeList
protected int[] namespaceList
protected java.lang.Object children
protected int sequence
public void setNameCode(int nameCode)
nameCode
- the integer name code representing the element namepublic void initialise(int nameCode, int typeCode, AttributeCollectionImpl atts, NodeInfo parent, int sequenceNumber)
nameCode
- Integer representing the element name, with namespaces resolvedtypeCode
- Integer representing the schema type of the element nodeatts
- The attribute list: always nullparent
- The parent nodesequenceNumber
- Integer identifying this element within the documentpublic 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
???? javax.xml.transform.Source
setSystemId
??? NodeImpl
public NodeInfo getRoot()
public DocumentInfo getDocumentRoot()
getDocumentRoot
???? NodeInfo
getDocumentRoot
??? NodeImpl
public final java.lang.String getSystemId()
getSystemId
???? javax.xml.transform.Source
getSystemId
???? javax.xml.transform.SourceLocator
getSystemId
???? NodeInfo
getSystemId
??? NodeImpl
public java.lang.String getBaseURI()
getBaseURI
???? NodeInfo
getBaseURI
??? NodeImpl
public boolean isNilled()
public void setTypeAnnotation(int typeCode)
setTypeAnnotation
???? MutableNodeInfo
setTypeAnnotation
??? NodeImpl
typeCode
- the type annotation (possibly including high bits set to indicate the isID, isIDREF, and
isNilled properties)public int getTypeAnnotation()
getTypeAnnotation
???? NodeInfo
getTypeAnnotation
??? NodeImpl
public void setLineAndColumn(int line, int column)
line
- the line numbercolumn
- the column numberpublic int getLineNumber()
getLineNumber
???? javax.xml.transform.SourceLocator
getLineNumber
???? NodeInfo
getLineNumber
??? NodeImpl
public int getColumnNumber()
getColumnNumber
???? javax.xml.transform.SourceLocator
getColumnNumber
???? NodeInfo
getColumnNumber
??? NodeImpl
public int getNameCode()
getNameCode
???? NodeInfo
getNameCode
??? NodeImpl
allocate
,
getFingerprint
public void generateId(FastStringBuffer buffer)
generateId
???? NodeInfo
generateId
??? NodeImpl
buffer
- to contain the generated IDpublic final int getNodeKind()
getNodeKind
???? NodeInfo
Type
public void copy(Receiver out, int whichNamespaces, boolean copyAnnotations, int locationId) throws XPathException
copy
???? NodeInfo
out
- The outputterwhichNamespaces
- indicates which namespaces should be output: all, none, or local
namespaces only (those not declared on the parent element)copyAnnotations
- indicates whether the type annotations
of element and attribute nodes should be copiedlocationId
- If non-zero, identifies the location of the instruction
that requested this copy. If zero, indicates that the location information
for the original node is to be copied; in this case the Receiver must be
a LocationCopierXPathException
public void delete()
delete
???? MutableNodeInfo
delete
??? NodeImpl
public void rename(int newNameCode)
rename
???? MutableNodeInfo
rename
??? NodeImpl
newNameCode
- the NamePool code of the new namepublic void addNamespace(int nscode, boolean inherit)
addNamespace
???? MutableNodeInfo
addNamespace
??? 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
???? MutableNodeInfo
stringValue
- the new string valuepublic void putAttribute(int nameCode, int typeCode, 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 existing attribute is replaced.
putAttribute
???? MutableNodeInfo
putAttribute
??? NodeImpl
nameCode
- the name of the new attributetypeCode
- the type annotation of the new attributevalue
- the string value of the new attributeproperties
- properties including IS_ID and IS_IDREF propertiespublic void removeAttribute(int nameCode)
removeAttribute
???? MutableNodeInfo
removeAttribute
??? NodeImpl
nameCode
- the name of the attribute to be removedpublic void removeTypeAnnotation()
removeTypeAnnotation
???? MutableNodeInfo
removeTypeAnnotation
??? NodeImpl
public void setNamespaceDeclarations(int[] 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
???? 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 iteratePrefixes()
iteratePrefixes
???? NamespaceResolver
public short getURICodeForPrefix(java.lang.String prefix) throws NamespaceException
prefix
- The prefix to be matched. To find the default namespace, supply ""NamespaceException
- if the prefix has not been declared on this NamespaceList.protected short getURICodeForPrefixCode(int prefixCode)
prefixCode
- the prefix code as a 16-bit integerpublic java.lang.String getPrefixForURI(java.lang.String uri)
uri
- The URI to be matched.public int[] getDeclaredNamespaces(int[] buffer)
getDeclaredNamespaces
???? NodeInfo
getDeclaredNamespaces
??? 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.
public int[] getInScopeNamespaceCodes()
protected void fixupInsertedNamespaces(boolean inherit)
inherit
- true if the child is to inherit the inscope namespaces of its new parentpublic AttributeCollection getAttributeList()
public java.lang.String getAttributeValue(int fingerprint)
getAttributeValue
???? NodeInfo
getAttributeValue
??? NodeImpl
fingerprint
- The fingerprint of the attribute namepublic java.lang.String getAttributeValue(java.lang.String uri, java.lang.String localName)
uri
- the namespace URI of the attribute name, or "" if the attribute is not in a namepsacelocalName
- the local part of the attribute nameprotected final long getSequenceNumber()
getSequenceNumber
??? NodeImpl
public final boolean hasChildNodes()
hasChildNodes
???? NodeInfo
hasChildNodes
??? NodeImpl
true
if the node has any children,
false
if the node has no children.public int getNumberOfChildren()
protected final AxisIterator enumerateChildren(NodeTest test)
test
- A NodeTest to be satisfied by the child nodes, or null
if all child node are to be returnedpublic final NodeInfo getFirstChild()
getFirstChild
??? NodeImpl
public final NodeInfo getLastChild()
getLastChild
??? 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
???? Item
getStringValueCS
???? ValueRepresentation
getStringValueCS
??? NodeImpl
Item.getStringValue()
protected void useChildrenArray(NodeImpl[] array)
array
- the array to be usedpublic void addChild(NodeImpl node, int index)
node
- the node to be added as a child of this nodeindex
- 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 be copied to form the new children. Adjacent text nodes will be merged, and zero-length text nodes removed.
insertChildren
???? MutableNodeInfo
insertChildren
??? NodeImpl
source
- the nodes to be insertedatStart
- true if the new nodes are to be inserted before existing children; false if they areinherit
- 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 insertChildrenAt(NodeInfo[] source, int index, boolean inherit)
source
- the children to be insertedindex
- 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 children