Package net.sf.saxon.tree.tiny
Class TinyAttributeImpl
java.lang.Object
net.sf.saxon.tree.tiny.TinyNodeImpl
net.sf.saxon.tree.tiny.TinyAttributeImpl
- All Implemented Interfaces:
Source
,SourceLocator
,PullEvent
,FingerprintedNode
,Item<NodeInfo>
,NodeInfo
,ValueRepresentation<NodeInfo>
A node in the XML parse tree representing an attribute. Note that this is
generated only "on demand", when the attribute is selected by a select pattern.
- Author:
- Michael H. Kay
-
Field Summary
Fields inherited from class net.sf.saxon.tree.tiny.TinyNodeImpl
NODE_LETTER, nodeNr, parent, tree
Fields inherited from interface net.sf.saxon.om.NodeInfo
ALL_NAMESPACES, IS_DTD_TYPE, IS_NILLED, LOCAL_NAMESPACES, NO_NAMESPACES
Fields inherited from interface net.sf.saxon.om.ValueRepresentation
EMPTY_VALUE_ARRAY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionValue
<? extends AtomicValue> atomize()
Get the typed value.void
Copy this node to a given outputtervoid
generateId
(FastStringBuffer buffer) Generate id.int
Get the column number of the node within its source document entityGet the display name of this node.int
Get the fingerprint of the node, used for matching namesint
Get the line number of the node within its source document entityGet the local name of this node.int
Get the name code of the node, used for finding names in the name poolfinal int
Return the type of node.Get the parent nodeGet the prefix part of the name of this node.getRoot()
Get the root node of the tree (not necessarily a document node)Get the type annotation of this node, if any.protected long
Get the node sequence number (in document order).Return the string value of the node.Return the string value of the node.int
Get the type annotation of this node Returns UNTYPED_ATOMIC if there is no type annotationGet the typed value of the item.final String
getURI()
Get the URI part of the name of this node.int
hashCode()
The hashCode() method obeys the contract for hashCode(): that is, if two objects are equal (represent the same node) then they must have the same hashCode()boolean
isId()
Determine whether this node has the is-id propertyboolean
isIdref()
Determine whether this node has the is-idref propertyboolean
isNilled()
Determine whether the node has the is-nilled propertyvoid
setSystemId
(String uri) Set the system id of this node.Methods inherited from class net.sf.saxon.tree.tiny.TinyNodeImpl
compareOrder, equals, getAttributeValue, getAttributeValue, getBaseURI, getConfiguration, getDeclaredNamespaces, getDocumentNumber, getDocumentRoot, getNamePool, getNodeNumber, getParentNodeNr, getPublicId, getSystemId, getTree, hasChildNodes, isAncestorOrSelf, isSameNodeInfo, iterateAxis, iterateAxis, setParentNode
-
Constructor Details
-
TinyAttributeImpl
-
-
Method Details
-
setSystemId
Description copied from class:TinyNodeImpl
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.- Specified by:
setSystemId
in interfaceSource
- Overrides:
setSystemId
in classTinyNodeImpl
-
getParent
Get the parent node- Specified by:
getParent
in interfaceNodeInfo
- Overrides:
getParent
in classTinyNodeImpl
- Returns:
- The Node object describing the containing element or root node.
-
getRoot
Get the root node of the tree (not necessarily a document node)- Specified by:
getRoot
in interfaceNodeInfo
- Overrides:
getRoot
in classTinyNodeImpl
- Returns:
- the NodeInfo representing the root of this tree
-
getSequenceNumber
protected long getSequenceNumber()Get the node sequence number (in document order). Sequence numbers are monotonic but not consecutive. In this implementation, elements have a zero least-significant word, while attributes and namespaces use the same value in the top word as the containing element, and use the bottom word to hold a sequence number, which numbers namespaces first and then attributes.- Overrides:
getSequenceNumber
in classTinyNodeImpl
- Returns:
- the sequence number
-
getNodeKind
public final int getNodeKind()Return the type of node.- Returns:
- Node.ATTRIBUTE
- See Also:
-
getStringValueCS
Return the string value of the node.- Specified by:
getStringValueCS
in interfaceItem<NodeInfo>
- Specified by:
getStringValueCS
in interfaceValueRepresentation<NodeInfo>
- Overrides:
getStringValueCS
in classTinyNodeImpl
- Returns:
- the attribute value
- See Also:
-
getStringValue
Return the string value of the node.- Returns:
- the attribute value
- See Also:
-
getFingerprint
public int getFingerprint()Get the fingerprint of the node, used for matching names- Specified by:
getFingerprint
in interfaceNodeInfo
- Overrides:
getFingerprint
in classTinyNodeImpl
- Returns:
- an integer fingerprint; two nodes with the same fingerprint have the same expanded QName. For unnamed nodes (text nodes, comments, document nodes, and namespace nodes for the default namespace), returns -1.
-
getNameCode
public int getNameCode()Get the name code of the node, used for finding names in the name pool- Specified by:
getNameCode
in interfaceNodeInfo
- Overrides:
getNameCode
in classTinyNodeImpl
- Returns:
- an integer name code, which may be used to obtain the actual node name from the name pool. For unnamed nodes (text nodes, comments, document nodes, and namespace nodes for the default namespace), returns -1.
- See Also:
-
getPrefix
Get the prefix part of the name of this node. This is the name before the ":" if any.- Specified by:
getPrefix
in interfaceNodeInfo
- Overrides:
getPrefix
in classTinyNodeImpl
- Returns:
- the prefix part of the name. For an unnamed node, return null.
-
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:
getDisplayName
in interfaceNodeInfo
- Overrides:
getDisplayName
in classTinyNodeImpl
- Returns:
- The display name of this node. For a node with no name, return an empty string.
-
getLocalPart
Get the local name of this node.- Specified by:
getLocalPart
in interfaceNodeInfo
- Overrides:
getLocalPart
in classTinyNodeImpl
- Returns:
- The local name of this node. For a node with no name, return an empty string.
-
getURI
Get the URI part of the name of this node.- Specified by:
getURI
in interfaceNodeInfo
- Overrides:
getURI
in classTinyNodeImpl
- Returns:
- The URI of the namespace of this node. For the default namespace, return an empty string
-
getTypeAnnotation
public int getTypeAnnotation()Get the type annotation of this node Returns UNTYPED_ATOMIC if there is no type annotation- Specified by:
getTypeAnnotation
in interfaceNodeInfo
- Overrides:
getTypeAnnotation
in classTinyNodeImpl
- Returns:
- the type annotation of the node, under the mask NamePool.FP_MASK, and optionally the
bit setting IS_DTD_TYPE in the case of a DTD-derived ID or IDREF/S type (which is treated
as untypedAtomic for the purposes of obtaining the typed value).
For elements and attributes, this is the type annotation as defined in XDM. For document nodes, it should be one of XS_UNTYPED if the document has not been validated, or XS_ANY_TYPE if validation has taken place (that is, if any node in the document has an annotation other than Untyped or UntypedAtomic).
-
getSchemaType
Get the type annotation of this node, if any. The type annotation is represented as SchemaType object.Types derived from a DTD are not reflected in the result of this method.
- Specified by:
getSchemaType
in interfaceNodeInfo
- Overrides:
getSchemaType
in classTinyNodeImpl
- Returns:
- For element and attribute nodes: the type annotation derived from schema validation (defaulting to xs:untyped and xs:untypedAtomic in the absence of schema validation). For comments, text nodes, processing instructions, and namespaces: null. For document nodes, either xs:untyped if the document has not been validated, or xs:anyType if it has.
- Since:
- 9.4
-
atomize
Get the typed value. The result of this method will always be consistent with the methodItem.getTypedValue()
. However, this method is often more convenient and may be more efficient, especially in the common case where the value is expected to be a singleton.- Returns:
- the typed value. This will either be a single AtomicValue or a Value whose items are atomic values.
- Throws:
XPathException
- if the node has no typed value, for example if it is an element node with element-only content- Since:
- 8.5
-
getTypedValue
Get the typed value of the item. For a node, this is the typed value as defined in the XPath 2.0 data model. Since a node may have a list-valued data type, the typed value is in general a sequence, and it is returned in the form of a SequenceIterator. If the node has not been validated against a schema, the typed value will be the same as the string value, either as an instance of xs:string or as an instance of xs:untypedAtomic, depending on the node kind. For an atomic value, this method returns an iterator over a singleton sequence containing the atomic value itself.- Returns:
- an iterator over the items in the typed value of the node or atomic value. The items returned by this iterator will always be atomic values.
- Throws:
XPathException
- where no typed value is available, for example in the case of an element with complex content- Since:
- 8.4
-
generateId
Generate id. Returns key of owning element with the attribute namecode as a suffix- Specified by:
generateId
in interfaceNodeInfo
- Overrides:
generateId
in classTinyNodeImpl
- Parameters:
buffer
- Buffer to contain the generated ID value
-
copy
Copy this node to a given outputter- Parameters:
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 inCopyOptions
locationId
- If non-zero, identifies the location of the instruction that requested this copy. If zero, indicates that the location information- Throws:
XPathException
- if any downstream error occurs
-
getLineNumber
public int getLineNumber()Get the line number of the node within its source document entity- Specified by:
getLineNumber
in interfaceNodeInfo
- Specified by:
getLineNumber
in interfaceSourceLocator
- Overrides:
getLineNumber
in classTinyNodeImpl
- Returns:
- the line number of the node in its original source document; or -1 if not available
-
getColumnNumber
public int getColumnNumber()Get the column number of the node within its source document entity- Specified by:
getColumnNumber
in interfaceNodeInfo
- Specified by:
getColumnNumber
in interfaceSourceLocator
- Overrides:
getColumnNumber
in classTinyNodeImpl
- Returns:
- the column number of the node in its original source document; or -1 if not available
-
isNilled
public boolean isNilled()Determine whether the node has the is-nilled property- Specified by:
isNilled
in interfaceNodeInfo
- Overrides:
isNilled
in classTinyNodeImpl
- Returns:
- true if the node has the is-nilled property
-
isId
public boolean isId()Determine whether this node has the is-id property- Specified by:
isId
in interfaceNodeInfo
- Overrides:
isId
in classTinyNodeImpl
- Returns:
- true if the node is an ID
-
isIdref
public boolean isIdref()Determine whether this node has the is-idref property- Specified by:
isIdref
in interfaceNodeInfo
- Overrides:
isIdref
in classTinyNodeImpl
- Returns:
- true if the node is an IDREF or IDREFS element or attribute
-
hashCode
public int hashCode()The hashCode() method obeys the contract for hashCode(): that is, if two objects are equal (represent the same node) then they must have the same hashCode()- Specified by:
hashCode
in interfaceNodeInfo
- Overrides:
hashCode
in classTinyNodeImpl
- Since:
- 8.7 Previously, the effect of the equals() and hashCode() methods was not defined. Callers should therefore be aware that third party implementations of the NodeInfo interface may not implement the correct semantics.
-