|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.saxon.tree.util.Orphan
public final class Orphan
A node (implementing the NodeInfo interface) representing an attribute, text node, comment, processing instruction, or namespace that has no parent (and of course no children). Exceptionally it is also used (during whitespace stripping) to represent a standalone element.
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.
Field Summary |
---|
Fields inherited from interface net.sf.saxon.om.NodeInfo |
---|
ALL_NAMESPACES, EMPTY_NAMESPACE_LIST, IS_DTD_TYPE, IS_NILLED, LOCAL_NAMESPACES, NO_NAMESPACES |
Fields inherited from interface net.sf.saxon.om.ValueRepresentation |
---|
EMPTY_VALUE_ARRAY |
Constructor Summary | |
---|---|
Orphan(Configuration config)
Create an Orphan node |
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. |
Value |
atomize()
Get the typed value. |
int |
compareOrder(NodeInfo other)
Determine the relative position of this node and another node, in document order. |
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(int fingerprint)
Get the 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 |
int[] |
getDeclaredNamespaces(int[] 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). |
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 |
SequenceIterator |
getTypedValue()
Get the typed value of the node |
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() |
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. |
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(int 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 |
setNameCode(int nameCode)
Set the name of the node |
void |
setNodeKind(short kind)
Set the node kind |
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 |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Orphan(Configuration config)
config
- the Saxon configurationMethod Detail |
---|
public void setNodeKind(short kind)
kind
- the kind of node, for example Type.ELEMENT
or Type.ATTRIBUTE
public void setNameCode(int nameCode)
nameCode
- the integer code representing the name of the node in the NamePoolpublic void setStringValue(CharSequence stringValue)
stringValue
- the string value of the nodepublic void setTypeAnnotation(int typeAnnotation)
setTypeAnnotation
in interface MutableNodeInfo
typeAnnotation
- the type annotation, and integer code representing the fingerprint of the type namepublic 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 SequenceIterator getTypedValue() throws XPathException
getTypedValue
in interface Item
XPathException
- where no typed value is available, for example in the case of
an element with complex contentpublic Value atomize() throws XPathException
Item.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.
atomize
in interface NodeInfo
XPathException
public 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 boolean isSameNodeInfo(NodeInfo other)
isSameNodeInfo
in interface NodeInfo
other
- the node to be compared with this node
public boolean equals(Object other)
equals
in interface NodeInfo
equals
in class Object
other
- the node to be compared with this node
public 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 node
public String getStringValue()
getStringValue
in interface Item
getStringValue
in interface NodeInfo
getStringValue
in interface ValueRepresentation
Item.getStringValueCS()
public CharSequence getStringValueCS()
getStringValueCS
in interface Item
getStringValueCS
in interface ValueRepresentation
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()
getURI
in interface NodeInfo
public String getPrefix()
getPrefix
in interface NodeInfo
public String getDisplayName()
getDisplayName
in interface NodeInfo
public NodeInfo getParent()
getParent
in interface NodeInfo
public AxisIterator iterateAxis(byte axisNumber)
iterateAxis
in interface NodeInfo
axisNumber
- the axis to be searched, e.g. Axis.CHILD or Axis.ANCESTOR
Axis
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 nodes
Axis
public String getAttributeValue(int fingerprint)
getAttributeValue
in interface NodeInfo
fingerprint
- The fingerprint of the attribute name
public NodeInfo getRoot()
getRoot
in interface NodeInfo
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 information
XPathException
public int[] getDeclaredNamespaces(int[] 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()
isId
in interface NodeInfo
public boolean isIdref()
isIdref
in interface NodeInfo
public boolean isNilled()
isNilled
in interface NodeInfo
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(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 existing attribute is replaced.
addAttribute
in interface MutableNodeInfo
nameCode
- 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 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 undeclared
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.
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(int 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 pool
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(int 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
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |