public final class Orphan extends Object 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,
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,
int locationId)
Copy this node to a given outputter (deep copy)
|
void |
delete()
Delete this node (that is, detach it from its parent).
|
boolean |
equals(Object other)
The equals() method compares nodes for identity.
|
void |
generateId(FastStringBuffer buffer)
Get a character string that uniquely identifies this node.
|
String |
getAttributeValue(String uri,
String local)
Get the string value of a given attribute of this node
|
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
|
Configuration |
getConfiguration()
Get the configuration
|
NamespaceBinding[] |
getDeclaredNamespaces(NamespaceBinding[] buffer)
Get all namespace undeclarations and undeclarations defined on this element.
|
String |
getDisplayName()
Get the display name of this node.
|
long |
getDocumentNumber()
Get the document number of the document containing this node.
|
DocumentInfo |
getDocumentRoot()
Get the root (document) node
|
int |
getFingerprint()
Get fingerprint.
|
int |
getLineNumber()
Get line number
|
String |
getLocalPart()
Get the local part of the name of this node.
|
int |
getNameCode()
Get name code.
|
NamePool |
getNamePool()
Get the name pool
|
int |
getNodeKind()
Return the kind of node.
|
NodeInfo |
getParent()
Get the NodeInfo object representing the parent of this node
|
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.
|
String |
getStringValue()
Return the string value of the node.
|
CharSequence |
getStringValueCS()
Get the value of the item as a CharSequence.
|
String |
getSystemId()
Get the System ID for the node.
|
int |
getTypeAnnotation()
Get the type annotation
|
String |
getURI()
Get the URI part of the name of this node.
|
boolean |
hasChildNodes()
Determine whether the node has any children.
|
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 |
isId()
Determine whether this node has the is-id property
|
boolean |
isIdref()
Determine whether this node has the is-idref property
|
boolean |
isNilled()
Determine 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(CharSequence stringValue)
Replace the string-value of this node.
|
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(CharSequence stringValue)
Set the string value of the node
|
void |
setSystemId(String systemId)
Set the base URI of the node
|
void |
setTypeAnnotation(int typeAnnotation)
Set the type annotation of the node
|
void |
setTypeAnnotation(SchemaType typeAnnotation)
Set the type annotation of the node
|
public Orphan(Configuration config)
config
- the Saxon configurationpublic 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(CharSequence stringValue)
stringValue
- the string value of the nodepublic void setTypeAnnotation(SchemaType typeAnnotation)
typeAnnotation
- the type annotationpublic void setTypeAnnotation(int typeAnnotation)
setTypeAnnotation
in interface MutableNodeInfo
typeAnnotation
- the type annotationpublic void setSystemId(String systemId)
setSystemId
in interface Source
systemId
- the base URI of the nodepublic void setIsId(boolean id)
id
- the isId propertypublic void setIsIdref(boolean idref)
idref
- the isIdref propertypublic int getNodeKind()
getNodeKind
in interface NodeInfo
Type
public AtomicSequence atomize() throws XPathException
atomize
in interface NodeInfo
XPathException
- if the node has no typed value, for example if
it is an element node with element-only contentpublic Configuration getConfiguration()
getConfiguration
in interface NodeInfo
public NamePool getNamePool()
getNamePool
in interface NodeInfo
public int getTypeAnnotation()
getTypeAnnotation
in interface NodeInfo
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).
public 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(Object other)
equals
in interface NodeInfo
equals
in class Object
other
- the node to be compared with this nodepublic int hashCode()
hashCode
in interface NodeInfo
hashCode
in class Object
public String getSystemId()
getSystemId
in interface Source
getSystemId
in interface NodeInfo
public String getBaseURI()
getBaseURI
in interface NodeInfo
public int getLineNumber()
getLineNumber
in interface NodeInfo
public int getColumnNumber()
getColumnNumber
in interface NodeInfo
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.UnsupportedOperationException
- if either node is an attribute or namespacepublic String getStringValue()
getStringValue
in interface Item
getStringValue
in interface NodeInfo
Item.getStringValueCS()
public CharSequence getStringValueCS()
getStringValueCS
in interface Item
Item.getStringValue()
public int getNameCode()
getNameCode
in interface NodeInfo
allocate
public int getFingerprint()
getFingerprint
in interface NodeInfo
public String getLocalPart()
getLocalPart
in interface NodeInfo
public String getURI()
public String getPrefix()
public 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 String getAttributeValue(String uri, 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 DocumentInfo getDocumentRoot()
getDocumentRoot
in interface NodeInfo
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 long getDocumentNumber()
getDocumentNumber
in interface NodeInfo
public void copy(Receiver out, int copyOptions, int 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-zero, identifies the location of the instruction
that requested this copy. If zero, indicates that the location informationXPathException
- 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 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, 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 undeclaredIllegalArgumentException
- 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.IllegalStateException
- if this node is deleted or if it has no parent node.public void replaceStringValue(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 poolIllegalArgumentException
- 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.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-2014 Saxonica Limited. All rights reserved.