|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.saxon.tree.NodeImpl
net.sf.saxon.tree.ParentNodeImpl
net.sf.saxon.tree.ElementImpl
public class ElementImpl
ElementImpl implements an element with no attributes or namespace declarations.
This class is an implementation of NodeInfo. For elements with attributes or namespace declarations, class ElementWithAttributes is used.
| Field Summary | |
|---|---|
protected AttributeCollection |
attributeList
|
protected int |
nameCode
|
protected int[] |
namespaceList
|
protected int |
typeCode
|
| Fields inherited from class net.sf.saxon.tree.ParentNodeImpl |
|---|
children, sequence |
| Fields inherited from class net.sf.saxon.tree.NodeImpl |
|---|
index, NODE_LETTER, parent |
| Fields inherited from interface net.sf.saxon.om.NodeInfo |
|---|
ALL_NAMESPACES, EMPTY_NAMESPACE_LIST, IS_DTD_TYPE, IS_NILLED, LOCAL_NAMESPACES, NO_NAMESPACES |
| Constructor Summary | |
|---|---|
ElementImpl()
Construct an empty ElementImpl |
|
| Method Summary | |
|---|---|
void |
addAttribute(int nameCode,
int typeCode,
CharSequence value,
int properties)
Add an attribute to this element node. |
void |
addNamespace(int nscode,
boolean inherit)
Add a namespace binding (that is, a namespace node) to this element. |
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 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. |
String |
getAttributeValue(int fingerprint)
Get the value of a given attribute of this node |
String |
getAttributeValue(String uri,
String localName)
Get the value of a given attribute of this node |
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. |
int[] |
getInScopeNamespaceCodes()
Get the list of in-scope namespaces for this element as an array of namespace codes. |
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. |
String |
getPrefixForURI(String uri)
Search the NamespaceList for a given URI, returning the corresponding prefix. |
NodeInfo |
getRoot()
Get the root node |
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(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 |
String |
getURIForPrefix(String prefix,
boolean useDefault)
Get the namespace URI corresponding to a given prefix. |
void |
initialise(int nameCode,
int typeCode,
AttributeCollectionImpl atts,
NodeInfo parent,
int sequenceNumber)
Initialise a new ElementImpl with an element name |
boolean |
isId()
Determine whether this node has the is-id property |
boolean |
isNilled()
Determine whether the node has the is-nilled property |
Iterator |
iteratePrefixes()
Get an iterator over all the prefixes declared in this namespace context. |
void |
removeAttribute(NodeInfo attribute)
Remove an attribute from this element node |
void |
removeTypeAnnotation()
Remove type information from this node (and its ancestors, recursively). |
void |
rename(int newNameCode)
Rename this node |
void |
replaceStringValue(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(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(String uri)
Set the system ID of this node. |
void |
setTypeAnnotation(int typeCode)
Set the type annotation on a node. |
| Methods inherited from class net.sf.saxon.tree.ParentNodeImpl |
|---|
addChild, compact, enumerateChildren, getFirstChild, getLastChild, getNthChild, getNumberOfChildren, getSequenceNumber, getStringValue, getStringValueCS, hasChildNodes, insertChildren, insertChildrenAt, removeChild, replaceChildrenAt, useChildrenArray |
| Methods inherited from class net.sf.saxon.tree.NodeImpl |
|---|
atomize, compareOrder, equals, getConfiguration, getDisplayName, getDocumentNumber, getFingerprint, getLocalPart, getNamePool, getNextInDocument, getNextSibling, getParent, getPhysicalRoot, getPrefix, getPreviousInDocument, getPreviousSibling, getPublicId, getSiblingPosition, getTypedValue, getURI, insertSiblings, isDeleted, isIdref, isSameNodeInfo, iterateAxis, iterateAxis, newBuilder, replace |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface net.sf.saxon.om.NodeInfo |
|---|
hashCode |
| Field Detail |
|---|
protected int nameCode
protected int typeCode
protected AttributeCollection attributeList
protected int[] namespaceList
| Constructor Detail |
|---|
public ElementImpl()
| Method Detail |
|---|
public void setNameCode(int nameCode)
nameCode - the integer name code representing the element name
public 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 document
public void setLocation(String systemId,
int line,
int column)
systemId - the base URIline - the line number if knowncolumn - the column number if knownpublic void setSystemId(String uri)
setSystemId in interface SourcesetSystemId in class NodeImplpublic NodeInfo getRoot()
getRoot in interface NodeInfogetRoot in class NodeImplpublic DocumentInfo getDocumentRoot()
getDocumentRoot in interface NodeInfogetDocumentRoot in class NodeImplpublic final String getSystemId()
getSystemId in interface SourcegetSystemId in interface SourceLocatorgetSystemId in interface NodeInfogetSystemId in class NodeImplpublic String getBaseURI()
getBaseURI in interface NodeInfogetBaseURI in class NodeImplpublic boolean isNilled()
isNilled in interface NodeInfoisNilled in class NodeImplpublic void setTypeAnnotation(int typeCode)
setTypeAnnotation in interface MutableNodeInfosetTypeAnnotation in class NodeImpltypeCode - the type annotation (possibly including high bits set to indicate the isID, isIDREF, and
isNilled properties)public int getTypeAnnotation()
getTypeAnnotation in interface NodeInfogetTypeAnnotation in class NodeImpl
public void setLineAndColumn(int line,
int column)
line - the line numbercolumn - the column numberpublic int getLineNumber()
getLineNumber in interface SourceLocatorgetLineNumber in interface NodeInfogetLineNumber in class NodeImplpublic int getColumnNumber()
getColumnNumber in interface SourceLocatorgetColumnNumber in interface NodeInfogetColumnNumber in class NodeImplpublic int getNameCode()
getNameCode in interface NodeInfogetNameCode in class NodeImplallocate,
getFingerprintpublic void generateId(FastStringBuffer buffer)
generateId in interface NodeInfogenerateId in class NodeImplbuffer - to contain the generated IDpublic final int getNodeKind()
getNodeKind in interface NodeInfoType
public void copy(Receiver out,
int whichNamespaces,
boolean copyAnnotations,
int locationId)
throws XPathException
copy in interface NodeInfoout - 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 LocationCopier
XPathExceptionpublic void delete()
delete in interface MutableNodeInfodelete in class NodeImplpublic void rename(int newNameCode)
rename in interface MutableNodeInforename in class NodeImplnewNameCode - the NamePool code of the new name
public void addNamespace(int nscode,
boolean inherit)
addNamespace in interface MutableNodeInfoaddNamespace in class NodeImplnscode - 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.
IllegalArgumentException - if the target element already has a namespace binding for this prefix,
or if the namespace code represents a namespace undeclarationpublic void replaceStringValue(CharSequence stringValue)
replaceStringValue in interface MutableNodeInfostringValue - the new string value
public void addAttribute(int nameCode,
int typeCode,
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 MutableNodeInfoaddAttribute in class NodeImplnameCode - 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 properties
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 MutableNodeInforemoveAttribute in class NodeImplattribute - the attribute node to be removedpublic void removeTypeAnnotation()
removeTypeAnnotation in interface MutableNodeInforemoveTypeAnnotation in class NodeImpl
public void setNamespaceDeclarations(int[] namespaces,
int namespacesUsed)
namespaces - the list of namespace codesnamespacesUsed - the number of entries in the list that are used
public String getURIForPrefix(String prefix,
boolean useDefault)
getURIForPrefix in interface NamespaceResolverprefix - 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 Iterator iteratePrefixes()
iteratePrefixes in interface NamespaceResolver
public short getURICodeForPrefix(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 integer
public String getPrefixForURI(String uri)
uri - The URI to be matched.
public int[] getDeclaredNamespaces(int[] buffer)
getDeclaredNamespaces in interface NodeInfogetDeclaredNamespaces in class NodeImplbuffer - 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 String getAttributeValue(int fingerprint)
getAttributeValue in interface NodeInfogetAttributeValue in class NodeImplfingerprint - The fingerprint of the attribute name
public String getAttributeValue(String uri,
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 name
public boolean isId()
isId in interface NodeInfoisId in class NodeImpl
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||