public final class Orphan extends GenericTreeInfo implements MutableNodeInfo
In general this class does not impose constraints defined in the data model: that is the responsibility of the client. For example, the class does not prevent you from creating a comment or text node that has a name or a non-trivial type annotation.
ALL_NAMESPACES, IS_DTD_TYPE, IS_NILLED, LOCAL_NAMESPACES, NO_NAMESPACES
Constructor and Description |
---|
Orphan(Configuration config)
Create an Orphan node
|
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.
|
void |
addNamespace(NamespaceBinding nscode,
boolean inherit)
Add a namespace binding (that is, a namespace node) to this element.
|
AtomicSequence |
atomize()
Get the typed value.
|
int |
compareOrder(NodeInfo other)
Determine the relative position of this node and another node, in document order.
|
int |
comparePosition(NodeInfo other)
Determine the relative position of this node and another node, in document order,
distinguishing whether the first node is a preceding, following, descendant, ancestor,
or the same node as the second.
|
void |
copy(Receiver out,
int copyOptions,
Location locationId)
Copy this node to a given outputter (deep copy)
|
void |
delete()
Delete this node (that is, detach it from its parent).
|
boolean |
equals(java.lang.Object other)
The equals() method compares nodes for identity.
|
void |
generateId(FastStringBuffer buffer)
Get a character string that uniquely identifies this node.
|
java.lang.String |
getAttributeValue(java.lang.String uri,
java.lang.String local)
Get the string value of a given attribute of this node
|
java.lang.String |
getBaseURI()
Get the Base URI for the node, that is, the URI used for resolving a relative URI contained
in the node.
|
int |
getColumnNumber()
Get column number
|
NamespaceBinding[] |
getDeclaredNamespaces(NamespaceBinding[] buffer)
Get all namespace undeclarations and undeclarations defined on this element.
|
java.lang.String |
getDisplayName()
Get the display name of this node.
|
int |
getFingerprint()
Get fingerprint.
|
int |
getLineNumber()
Get line number
|
java.lang.String |
getLocalPart()
Get the local part of the name of this node.
|
int |
getNodeKind()
Return the kind of node.
|
NodeInfo |
getParent()
Get the NodeInfo object representing the parent of this node
|
java.lang.String |
getPrefix()
Get the prefix of the name of the node.
|
NodeInfo |
getRoot()
Get the root node of this tree (not necessarily a document node).
|
SchemaType |
getSchemaType()
Get the type annotation of this node, if any.
|
java.lang.String |
getStringValue()
Return the string value of the node.
|
java.lang.CharSequence |
getStringValueCS()
Get the value of the item as a CharSequence.
|
TreeInfo |
getTreeInfo()
Get information about the tree to which this NodeInfo belongs
|
java.lang.String |
getURI()
Get the URI part of the name of this node.
|
boolean |
hasChildNodes()
Determine whether the node has any children.
|
boolean |
hasFingerprint()
Ask whether this NodeInfo implementation holds a fingerprint identifying the name of the
node in the NamePool.
|
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()
|
NodeInfo |
head()
To implement
Sequence , this method returns the item itself |
void |
insertChildren(NodeInfo[] source,
boolean atStart,
boolean inherit)
Insert copies of a sequence of nodes as children of this node.
|
void |
insertSiblings(NodeInfo[] source,
boolean before,
boolean inherit)
Insert copies of a sequence of nodes as siblings of this node.
|
boolean |
isDeleted()
Test whether this MutableNodeInfo object represents a node that has been deleted.
|
boolean |
isDisableOutputEscaping()
Ask whether the node has the disable-output-escaping property
|
boolean |
isId()
Ask whether this node has the is-id property
|
boolean |
isIdref()
Ask whether this node has the is-idref property
|
boolean |
isNilled()
Ask whether the node has the is-nilled property
|
boolean |
isSameNodeInfo(NodeInfo other)
Determine whether this is the same node as another node.
|
SequenceIterator |
iterate()
To implement
Sequence , this method returns a singleton iterator
that delivers this item in the form of a sequence |
AxisIterator |
iterateAxis(byte axisNumber)
Return an iteration over the nodes reached by the given axis from this node
|
AxisIterator |
iterateAxis(byte axisNumber,
NodeTest nodeTest)
Return an iteration over the nodes reached by the given axis from this node
|
Builder |
newBuilder()
Get a Builder suitable for building nodes that can be attached to this document.
|
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(NodeName newNameCode)
Rename this node.
|
void |
replace(NodeInfo[] replacement,
boolean inherit)
Replace this node with a given sequence of nodes
|
void |
replaceStringValue(java.lang.CharSequence stringValue)
Replace the string-value of this node.
|
Location |
saveLocation()
Get an immutable copy of this Location object.
|
void |
setDisableOutputEscaping(boolean doe)
Set the disable-output-escaping property
|
void |
setIsId(boolean id)
Set the isId property
|
void |
setIsIdref(boolean idref)
Set the isIdref property
|
void |
setNodeKind(short kind)
Set the node kind
|
void |
setNodeName(NodeName nodeName)
Set the name of the node
|
void |
setStringValue(java.lang.CharSequence stringValue)
Set the string value of the node
|
void |
setTypeAnnotation(SchemaType typeAnnotation)
Set the type annotation of the node
|
getConfiguration, getDocumentNumber, getPublicId, getRootNode, getSystemId, getUnparsedEntity, getUnparsedEntityNames, getUserData, isStreamed, isTyped, selectID, setConfiguration, setDocumentNumber, setRootNode, setSystemId, setUserData
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
getConfiguration, getPublicId, getSystemId, isStreamed
public Orphan(Configuration config)
config
- the Saxon configurationpublic TreeInfo getTreeInfo()
getTreeInfo
in interface NodeInfo
public SequenceIterator iterate()
Sequence
, this method returns a singleton iterator
that delivers this item in the form of a sequencepublic void setNodeKind(short kind)
kind
- the kind of node, for example Type.ELEMENT
or Type.ATTRIBUTE
public void setNodeName(NodeName nodeName)
nodeName
- the name of the node. May be null for unnamed nodes such as text and comment nodespublic void setStringValue(java.lang.CharSequence stringValue)
stringValue
- the string value of the nodepublic void setTypeAnnotation(SchemaType typeAnnotation)
setTypeAnnotation
in interface MutableNodeInfo
typeAnnotation
- the type annotationpublic void setIsId(boolean id)
id
- the isId propertypublic void setIsIdref(boolean idref)
idref
- the isIdref propertypublic void setDisableOutputEscaping(boolean doe)
doe
- true if the property is to be setpublic int getNodeKind()
getNodeKind
in interface NodeInfo
Type
public int getFingerprint()
getFingerprint
in interface NodeInfo
java.lang.UnsupportedOperationException
- if this kind of node does not hold
namepool fingerprints (specifically, if hasFingerprint()
returns false).public boolean hasFingerprint()
getFingerprint()
method must
return the fingerprint of the node. If the answer is false, then the getFingerprint()
method should throw an UnsupportedOperationException
. In the case of unnamed nodes
such as text nodes, the result can be either true (in which case getFingerprint() should
return -1) or false (in which case getFingerprint may throw an exception).hasFingerprint
in interface NodeInfo
FingerprintedNode
as a marker interface.public AtomicSequence atomize() throws XPathException
atomize
in interface Item
atomize
in interface NodeInfo
XPathException
- if the node has no typed value, for example if
it is an element node with element-only contentpublic SchemaType getSchemaType()
Types derived from a DTD are not reflected in the result of this method.
getSchemaType
in interface NodeInfo
public boolean isSameNodeInfo(NodeInfo other)
isSameNodeInfo
in interface NodeInfo
other
- the node to be compared with this nodepublic boolean equals(java.lang.Object other)
equals
in interface NodeInfo
equals
in class java.lang.Object
other
- the node to be compared with this nodepublic int hashCode()
hashCode
in interface NodeInfo
hashCode
in class java.lang.Object
public java.lang.String getBaseURI()
getBaseURI
in interface NodeInfo
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
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
public Location saveLocation()
saveLocation
in interface Location
public int compareOrder(NodeInfo other)
compareOrder
in interface NodeInfo
other
- The other node, whose position is to be compared with this nodepublic int comparePosition(NodeInfo other)
comparePosition
in interface NodeInfo
other
- The other node, whose position is to be compared with this
nodeAxisInfo.PRECEDING
if this node is on the preceding axis of the other node;
AxisInfo.FOLLOWING
if it is on the following axis; AxisInfo.ANCESTOR
if the first node is an
ancestor of the second; AxisInfo.DESCENDANT
if the first is a descendant of the second;
AxisInfo.SELF
if they are the same node.java.lang.UnsupportedOperationException
- if either node is an attribute or namespacepublic java.lang.String getStringValue()
getStringValue
in interface Item
getStringValue
in interface NodeInfo
Item.getStringValueCS()
public java.lang.CharSequence getStringValueCS()
getStringValueCS
in interface Item
Item.getStringValue()
public java.lang.String getLocalPart()
getLocalPart
in interface NodeInfo
public java.lang.String getURI()
public java.lang.String getPrefix()
public java.lang.String getDisplayName()
getDisplayName
in interface NodeInfo
public NodeInfo getParent()
public AxisIterator iterateAxis(byte axisNumber)
iterateAxis
in interface NodeInfo
axisNumber
- the axis to be searched, e.g. Axis.CHILD or Axis.ANCESTORAxisInfo
public AxisIterator iterateAxis(byte axisNumber, NodeTest nodeTest)
iterateAxis
in interface NodeInfo
axisNumber
- the axis to be searched, e.g. Axis.CHILD or Axis.ANCESTORnodeTest
- A pattern to be matched by the returned nodesAxisInfo
public java.lang.String getAttributeValue(java.lang.String uri, java.lang.String local)
getAttributeValue
in interface NodeInfo
uri
- the namespace URI of the attribute name. Supply the empty string for an attribute
that is in no namespacelocal
- the local part of the attribute name.public NodeInfo getRoot()
public boolean hasChildNodes()
hasChildNodes
in interface NodeInfo
public void generateId(FastStringBuffer buffer)
generateId
in interface NodeInfo
buffer
- a buffer, into which will be placed
a string that uniquely identifies this node, within this
document. The calling code prepends information to make the result
unique across all documents.public void copy(Receiver out, int copyOptions, Location locationId) 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
locationId
- 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 NamespaceBinding[] getDeclaredNamespaces(NamespaceBinding[] buffer)
getDeclaredNamespaces
in interface NodeInfo
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 boolean isId()
public boolean isIdref()
public boolean isNilled()
public boolean isDisableOutputEscaping()
public 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
in interface MutableNodeInfo
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 insert nodes are to inherit the namespaces of their new parent; false
if such namespaces are to be undeclaredpublic void insertSiblings(NodeInfo[] source, boolean before, boolean inherit)
This method takes no action unless the target node is an element, text node, comment, or processing instruction, and one that has a parent 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 must use the same data model implementation as the tree into which they will be inserted.
insertSiblings
in interface MutableNodeInfo
source
- the nodes to be insertedbefore
- true if the new nodes are to be inserted before the target node; false if they areinherit
- true if the insert nodes are to inherit the namespaces of their new parent; false
if such namespaces are to be undeclaredpublic void removeAttribute(NodeInfo attribute)
If this node is not an element, or if it has no attribute with the specified name, this method takes no action.
The attribute node itself is not modified in any way.
removeAttribute
in interface MutableNodeInfo
attribute
- the attribute node to be removedpublic 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 existing attribute is replaced.
addAttribute
in interface MutableNodeInfo
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 propertiespublic void delete()
If this node has preceding and following siblings that are both text nodes, the two text nodes will be joined into a single text node (the identity of this node with respect to its predecessors is undefined).
delete
in interface MutableNodeInfo
public boolean isDeleted()
isDeleted
in interface MutableNodeInfo
public void replace(NodeInfo[] replacement, boolean inherit)
replace
in interface MutableNodeInfo
replacement
- the replacement nodesinherit
- true if the replacement nodes are to inherit the namespaces of their new parent; false
if such namespaces are to be undeclaredjava.lang.IllegalArgumentException
- if any of the replacement nodes is of the wrong kind. When replacing
a child node, the replacement nodes must all be elements, text, comment, or PI nodes; when replacing
an attribute, the replacement nodes must all be attributes.java.lang.IllegalStateException
- if this node is deleted or if it has no parent node.public void replaceStringValue(java.lang.CharSequence stringValue)
replaceStringValue
in interface MutableNodeInfo
stringValue
- the new string valuepublic void rename(NodeName newNameCode)
This call has no effect if applied to a nameless node, such as a text node or comment.
If necessary, a new namespace binding will be added to the target element, or to the element parent of the target attribute
rename
in interface MutableNodeInfo
newNameCode
- the namecode of the new name in the name pooljava.lang.IllegalArgumentException
- if the new name code is not present in the name pool, or if
it has a (prefix, uri) pair in which the
prefix is the same as that of an existing in-scope namespace binding and the uri is different from that
namespace binding.public void addNamespace(NamespaceBinding nscode, boolean inherit)
addNamespace
in interface MutableNodeInfo
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 namespace code is not present in the namepool, or if the target
element already has a namespace binding for this prefixpublic void removeTypeAnnotation()
removeTypeAnnotation
in interface MutableNodeInfo
public Builder newBuilder()
newBuilder
in interface MutableNodeInfo
Copyright (c) 2004-2018 Saxonica Limited. All rights reserved.