Package com.icl.saxon.tinytree
Class TinyNodeImpl
- java.lang.Object
-
- com.icl.saxon.om.AbstractNode
-
- com.icl.saxon.tinytree.TinyNodeImpl
-
- All Implemented Interfaces:
NodeInfo,javax.xml.transform.dom.DOMLocator,javax.xml.transform.Source,javax.xml.transform.SourceLocator,org.w3c.dom.Node
- Direct Known Subclasses:
TinyAttributeImpl,TinyCommentImpl,TinyNamespaceImpl,TinyParentNodeImpl,TinyProcInstImpl,TinyTextImpl
abstract class TinyNodeImpl extends AbstractNode
A node in the XML parse tree representing an XML element, character content, or attribute.This is the top-level class in the implementation class hierarchy; it essentially contains all those methods that can be defined using other primitive methods, without direct access to data.
- Author:
- Michael H. Kay
-
-
Field Summary
Fields Modifier and Type Field Description protected TinyDocumentImpldocumentprotected intnodeNrprotected TinyNodeImplparent-
Fields inherited from class com.icl.saxon.om.AbstractNode
NODE_LETTER
-
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
-
-
Constructor Summary
Constructors Constructor Description TinyNodeImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareOrder(NodeInfo other)Determine the relative position of this node and another node, in document order.java.lang.StringgenerateId()Get a character string that uniquely identifies this nodejava.lang.StringgetAttributeValue(int fingerprint)Get the value of a given attribute of this nodejava.lang.StringgetAttributeValue(java.lang.String uri, java.lang.String localName)Find the value of a given attribute of this node.java.lang.StringgetBaseURI()Get the base URI for the node.java.lang.StringgetDisplayName()Get the display name of this node.DocumentInfogetDocumentRoot()Get the root (document) nodeAxisEnumerationgetEnumeration(byte axisNumber, NodeTest nodeTest)Return an enumeration over the nodes reached by the given axis from this nodeintgetFingerprint()Get the fingerprint of the node, used for matching namesintgetLineNumber()Get the line number of the node within its source document entityjava.lang.StringgetLocalName()Get the local name of this node.intgetNameCode()Get the name code of the node, used for matching namesorg.w3c.dom.NodegetOriginatingNode()Get the node corresponding to this javax.xml.transform.dom.DOMLocatorNodeInfogetParent()Find the parent node of this node.java.lang.StringgetPrefix()Get the prefix part of the name of this node.protected longgetSequenceNumber()Get the node sequence number (in document order).java.lang.StringgetSystemId()Get the system ID for the entity containing the node.java.lang.StringgetURI()Get the URI part of the name of this node.booleanhasAttributes()Returns whether this node has any attributes.booleanhasChildNodes()Determine whether the node has any children.booleanisSameNodeInfo(NodeInfo other)Determine whether this is the same node as another nodevoidoutputNamespaceNodes(Outputter out, boolean includeAncestors)Output all namespace nodes associated with this element.voidsetLineNumber(int line)Set the line number of the node within its source document entityprotected voidsetParentNode(TinyNodeImpl parent)Set the parent of this node.voidsetSystemId(java.lang.String uri)Set the system id of this node.-
Methods inherited from class com.icl.saxon.om.AbstractNode
appendChild, appendData, cloneNode, compareDocumentPosition, copyStringValue, createAttribute, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createElement, createElementNS, createEntityReference, createProcessingInstruction, createTextNode, deleteData, disallowUpdate, getAttribute, getAttributeNode, getAttributeNodeNS, getAttributeNS, getAttributes, getChildNodes, getColumnNumber, getData, getDoctype, getDocumentElement, getElementById, getElementsByTagName, getElementsByTagNameNS, getFeature, getFirstChild, getImplementation, getLastChild, getLength, getName, getNamespaceURI, getNextSibling, getNodeName, getNodeValue, getOwnerDocument, getOwnerElement, getParentNode, getPreviousSibling, getPublicId, getSchemaTypeInfo, getSpecified, getTagName, getTextContent, getUserData, getValue, getWholeText, hasAttribute, hasAttributeNS, importNode, insertBefore, insertData, isDefaultNamespace, isElementContentWhitespace, isEqualNode, isId, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeAttribute, removeAttributeNode, removeAttributeNS, removeChild, replaceChild, replaceData, replaceWholeText, setAttributeNode, setAttributeNodeNS, setAttributeNS, setData, setIdAttribute, setIdAttributeNode, setIdAttributeNS, setNodeValue, setPrefix, setTextContent, setUserData, setValue, splitText, substringData, supports
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.icl.saxon.om.NodeInfo
copy, getNodeType, getStringValue
-
-
-
-
Field Detail
-
document
protected TinyDocumentImpl document
-
nodeNr
protected int nodeNr
-
parent
protected TinyNodeImpl parent
-
-
Method Detail
-
setSystemId
public void setSystemId(java.lang.String uri)
Set the system id of this node.
This method is present to ensure that the class implements the javax.xml.transform.Source interface, so a node can be used as the source of a transformation.
-
setParentNode
protected void setParentNode(TinyNodeImpl parent)
Set the parent of this node. Providing this information is useful, if it is known, because otherwise getParent() has to search backwards through the document.
-
isSameNodeInfo
public boolean isSameNodeInfo(NodeInfo other)
Determine whether this is the same node as another node- Specified by:
isSameNodeInfoin interfaceNodeInfo- Specified by:
isSameNodeInfoin classAbstractNode- Returns:
- true if this Node object and the supplied Node object represent the same node in the tree.
-
getSystemId
public java.lang.String getSystemId()
Get the system ID for the entity containing the node.- Specified by:
getSystemIdin interfaceNodeInfo- Specified by:
getSystemIdin interfacejavax.xml.transform.Source- Specified by:
getSystemIdin interfacejavax.xml.transform.SourceLocator- Specified by:
getSystemIdin classAbstractNode- Returns:
- the System Identifier of the entity in the source document containing the node, or null if not known. Note this is not the same as the base URI: the base URI can be modified by xml:base, but the system ID cannot.
-
getBaseURI
public java.lang.String getBaseURI()
Get the base URI for the node. Default implementation for child nodes gets the base URI of the parent node.- Specified by:
getBaseURIin interfaceorg.w3c.dom.Node- Specified by:
getBaseURIin interfaceNodeInfo- Specified by:
getBaseURIin classAbstractNode
-
getOriginatingNode
public org.w3c.dom.Node getOriginatingNode()
Get the node corresponding to this javax.xml.transform.dom.DOMLocator- Specified by:
getOriginatingNodein interfacejavax.xml.transform.dom.DOMLocator- Overrides:
getOriginatingNodein classAbstractNode
-
setLineNumber
public void setLineNumber(int line)
Set the line number of the node within its source document entity
-
getLineNumber
public int getLineNumber()
Get the line number of the node within its source document entity- Specified by:
getLineNumberin interfaceNodeInfo- Specified by:
getLineNumberin interfacejavax.xml.transform.SourceLocator- Overrides:
getLineNumberin classAbstractNode- Returns:
- the line number of the node in its original source document; or -1 if not available
-
getSequenceNumber
protected long getSequenceNumber()
Get the node sequence number (in document order). Sequence numbers are monotonic but not consecutive. The sequence number must be unique within the document (not, as in previous releases, within the whole document collection)
-
compareOrder
public final int compareOrder(NodeInfo other)
Determine the relative position of this node and another node, in document order. The other node will always be in the same document.- Specified by:
compareOrderin interfaceNodeInfo- Specified by:
compareOrderin classAbstractNode- Parameters:
other- The other node, whose position is to be compared with this node- Returns:
- -1 if this node precedes the other node, +1 if it follows the other node, or 0 if they are the same node. (In this case, isSameNode() will always return true, and the two nodes will produce the same result for generateId())
-
getFingerprint
public int getFingerprint()
Get the fingerprint of the node, used for matching names- Specified by:
getFingerprintin interfaceNodeInfo- Specified by:
getFingerprintin classAbstractNode
-
getNameCode
public int getNameCode()
Get the name code of the node, used for matching names- Specified by:
getNameCodein interfaceNodeInfo- Specified by:
getNameCodein classAbstractNode- See Also:
allocate,getFingerprint
-
getPrefix
public java.lang.String getPrefix()
Get the prefix part of the name of this node. This is the name before the ":" if any.- Specified by:
getPrefixin interfaceorg.w3c.dom.Node- Specified by:
getPrefixin interfaceNodeInfo- Specified by:
getPrefixin classAbstractNode- Returns:
- the prefix part of the name. For an unnamed node, return "".
-
getURI
public java.lang.String getURI()
Get the URI part of the name of this node. This is the URI corresponding to the prefix, or the URI of the default namespace if appropriate.- Specified by:
getURIin interfaceNodeInfo- Specified by:
getURIin classAbstractNode- Returns:
- The URI of the namespace of this node. For an unnamed node, or for an element or attribute in the default namespace, return an empty string.
-
getDisplayName
public java.lang.String getDisplayName()
Get the display name of this node. For elements and attributes this is [prefix:]localname. For unnamed nodes, it is an empty string.- Specified by:
getDisplayNamein interfaceNodeInfo- Overrides:
getDisplayNamein classAbstractNode- Returns:
- The display name of this node. For a node with no name, return an empty string.
-
getLocalName
public java.lang.String getLocalName()
Get the local name of this node.- Specified by:
getLocalNamein interfaceorg.w3c.dom.Node- Specified by:
getLocalNamein interfaceNodeInfo- Specified by:
getLocalNamein classAbstractNode- Returns:
- The local name of this node. For a node with no name, return an empty string.
-
getEnumeration
public AxisEnumeration getEnumeration(byte axisNumber, NodeTest nodeTest)
Return an enumeration over the nodes reached by the given axis from this node- Specified by:
getEnumerationin interfaceNodeInfo- Specified by:
getEnumerationin classAbstractNode- Parameters:
axisNumber- Identifies the required axis, eg. Axis.CHILD or Axis.PARENTnodeTest- A pattern to be matched by the returned nodes- Returns:
- a AxisEnumeration that scans the nodes reached by the axis in turn.
-
getParent
public NodeInfo getParent()
Find the parent node of this node.- Specified by:
getParentin interfaceNodeInfo- Specified by:
getParentin classAbstractNode- Returns:
- The Node object describing the containing element or root node.
-
hasChildNodes
public boolean hasChildNodes()
Determine whether the node has any children.- Specified by:
hasChildNodesin interfaceorg.w3c.dom.Node- Specified by:
hasChildNodesin interfaceNodeInfo- Specified by:
hasChildNodesin classAbstractNode- Returns:
trueif this node has any attributes,falseotherwise.
-
hasAttributes
public boolean hasAttributes()
Returns whether this node has any attributes.- Specified by:
hasAttributesin interfaceorg.w3c.dom.Node- Specified by:
hasAttributesin classAbstractNode- Returns:
trueif this node has any attributes,falseotherwise.- Since:
- DOM Level 2
-
getAttributeValue
public java.lang.String getAttributeValue(java.lang.String uri, java.lang.String localName)Find the value of a given attribute of this node.
This method is defined on all nodes to meet XSL requirements, but for nodes other than elements it will always return null.- Specified by:
getAttributeValuein interfaceNodeInfo- Specified by:
getAttributeValuein classAbstractNode- Parameters:
uri- the namespace uri of an attributelocalName- the local name of an attribute- Returns:
- the value of the attribute, if it exists, otherwise null
-
getAttributeValue
public java.lang.String getAttributeValue(int fingerprint)
Get the value of a given attribute of this node- Specified by:
getAttributeValuein interfaceNodeInfo- Specified by:
getAttributeValuein classAbstractNode- Parameters:
fingerprint- The fingerprint of the attribute name- Returns:
- the attribute value if it exists or null if not
-
getDocumentRoot
public DocumentInfo getDocumentRoot()
Get the root (document) node- Specified by:
getDocumentRootin interfaceNodeInfo- Overrides:
getDocumentRootin classAbstractNode- Returns:
- the DocumentInfo representing the containing document
-
outputNamespaceNodes
public void outputNamespaceNodes(Outputter out, boolean includeAncestors) throws javax.xml.transform.TransformerException
Output all namespace nodes associated with this element. Does nothing if the node is not an element.- Specified by:
outputNamespaceNodesin interfaceNodeInfo- Overrides:
outputNamespaceNodesin classAbstractNode- Parameters:
out- The relevant outputterincludeAncestors- True if namespaces declared on ancestor elements must be output; false if it is known that these are already on the result tree- Throws:
javax.xml.transform.TransformerException
-
generateId
public java.lang.String generateId()
Get a character string that uniquely identifies this node- Specified by:
generateIdin interfaceNodeInfo- Specified by:
generateIdin classAbstractNode- Returns:
- a string.
-
-