|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.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, 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(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. |
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 |
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 |
SequenceIterator<? extends AtomicValue> |
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(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 |
| 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 configuration| Method Detail |
|---|
public void setNodeKind(short kind)
kind - the kind of node, for example Type.ELEMENT or Type.ATTRIBUTEpublic 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 MutableNodeInfotypeAnnotation - the type annotationpublic void setSystemId(String systemId)
setSystemId in interface SourcesystemId - 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 NodeInfoType
public SequenceIterator<? extends AtomicValue> getTypedValue()
throws XPathException
getTypedValue in interface Item<NodeInfo>XPathException - where no typed value is available, for example in the case of
an element with complex content
public 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 NodeInfoXPathException - if the node has no typed value, for example if
it is an element node with element-only contentpublic Configuration getConfiguration()
getConfiguration in interface NodeInfopublic NamePool getNamePool()
getNamePool in interface NodeInfopublic int getTypeAnnotation()
getTypeAnnotation in interface NodeInfoFor 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 NodeInfopublic boolean isSameNodeInfo(NodeInfo other)
isSameNodeInfo in interface NodeInfoother - the node to be compared with this node
public boolean equals(Object other)
equals in interface NodeInfoequals in class Objectother - the node to be compared with this node
public int hashCode()
hashCode in interface NodeInfohashCode in class Objectpublic String getSystemId()
getSystemId in interface SourcegetSystemId in interface NodeInfopublic String getBaseURI()
getBaseURI in interface NodeInfopublic int getLineNumber()
getLineNumber in interface NodeInfopublic int getColumnNumber()
getColumnNumber in interface NodeInfopublic int compareOrder(NodeInfo other)
compareOrder in interface NodeInfoother - The other node, whose position is to be compared with this node
public String getStringValue()
getStringValue in interface Item<NodeInfo>getStringValue in interface NodeInfogetStringValue in interface ValueRepresentation<NodeInfo>Item.getStringValueCS()public CharSequence getStringValueCS()
getStringValueCS in interface Item<NodeInfo>getStringValueCS in interface ValueRepresentation<NodeInfo>Item.getStringValue()public int getNameCode()
getNameCode in interface NodeInfoallocatepublic int getFingerprint()
getFingerprint in interface NodeInfopublic String getLocalPart()
getLocalPart in interface NodeInfopublic String getURI()
getURI in interface NodeInfopublic String getPrefix()
getPrefix in interface NodeInfopublic String getDisplayName()
getDisplayName in interface NodeInfopublic NodeInfo getParent()
getParent in interface NodeInfopublic AxisIterator iterateAxis(byte axisNumber)
iterateAxis in interface NodeInfoaxisNumber - the axis to be searched, e.g. Axis.CHILD or Axis.ANCESTOR
Axis
public AxisIterator iterateAxis(byte axisNumber,
NodeTest nodeTest)
iterateAxis in interface NodeInfoaxisNumber - the axis to be searched, e.g. Axis.CHILD or Axis.ANCESTORnodeTest - A pattern to be matched by the returned nodes
Axispublic String getAttributeValue(int fingerprint)
getAttributeValue in interface NodeInfofingerprint - The fingerprint of the attribute name
public String getAttributeValue(String uri,
String local)
getAttributeValue in interface NodeInfouri - 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()
getRoot in interface NodeInfopublic DocumentInfo getDocumentRoot()
getDocumentRoot in interface NodeInfopublic boolean hasChildNodes()
hasChildNodes in interface NodeInfopublic void generateId(FastStringBuffer buffer)
generateId in interface NodeInfobuffer - 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 NodeInfoout - 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 CopyOptionslocationId - If non-zero, identifies the location of the instruction
that requested this copy. If zero, indicates that the location information
XPathException - if any downstream error occurspublic NamespaceBinding[] getDeclaredNamespaces(NamespaceBinding[] buffer)
getDeclaredNamespaces in interface NodeInfobuffer - 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 NodeInfopublic boolean isIdref()
isIdref in interface NodeInfopublic 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 MutableNodeInfosource - 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 undeclared
public 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 MutableNodeInfosource - 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 MutableNodeInfoattribute - the attribute node to be removed
public 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 MutableNodeInfonameCode - 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 MutableNodeInfopublic boolean isDeleted()
isDeleted in interface MutableNodeInfo
public void replace(NodeInfo[] replacement,
boolean inherit)
replace in interface MutableNodeInforeplacement - 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 MutableNodeInfostringValue - 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 MutableNodeInfonewNameCode - 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(NamespaceBinding nscode,
boolean inherit)
addNamespace in interface MutableNodeInfonscode - 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 MutableNodeInfopublic Builder newBuilder()
newBuilder in interface MutableNodeInfo
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||