All Packages Class Hierarchy This Package Previous Next Index
Interface fr.inria.openmath.omapi.Node
- public interface Node
Defines tree like access/construction API for OpenMath objects
(similar to the level 1 core DOM API)
The Node
interface represents a single node in the tree.
While all objects implementing the Node
interface expose
methods for dealing with children, not all objects implementing the
Node
interface may have children. For example,
Float
nodes have no children, and adding children to such
nodes results in a OMException
being raised.
-
OM_APP
-
-
OM_ATP
-
-
OM_ATTR
-
-
OM_BE_BIG_LEN_MASK
- In binary encoding when len of token is > 255
this bit mask is ored to token type
following len field is encoded on 4 bytes rather
than on only one
-
OM_BE_NEG_BASE_10
-
-
OM_BE_NEG_BASE_16
-
-
OM_BE_POS_BASE_10
-
-
OM_BE_POS_BASE_16
-
-
OM_BE_SHARED_MASK
- In binary encoding if an object is in fact a reference
to a previously seen one, this bit mask is ored to
token type
-
OM_BIGINT
-
-
OM_BIND
-
-
OM_BVAR
-
-
OM_BYTEARRAY
-
-
OM_COMMENT
-
-
OM_END_APP
- These are not real nodes (rather tags)
they are used mainly in binary encoding
-
OM_END_ATP
-
-
OM_END_ATTR
-
-
OM_END_BIND
-
-
OM_END_BVAR
-
-
OM_END_ERROR
-
-
OM_END_OBJECT
-
-
OM_ERROR
-
-
OM_FLOAT64
-
-
OM_INT32
-
-
OM_OBJECT
-
-
OM_PINSTRUCTION
-
-
OM_STRING
-
-
OM_SYMBOL
-
-
OM_UKNOWN
- NodeType
These values are those of the C library and they have been carefully
chosen to make encoding autodetection easy.
-
OM_VAR
-
-
OM_WCSTRING
- constants used for binary encoding
-
appendChild(Node)
- Adds the node
newChild
to the end of the list of
children of this node.
-
cloneNode(boolean)
- Returns a duplicate of this node, ie: serves as a generic copy
constructor for nodes.
-
getAttribute(Symbol)
- Retrieves an attribute's value (a node) given its name (a Symbol)
-
getAttributeNumber()
- The number of attributes set on this node.
-
getChildNodes()
- A
NodeList
that contains all children of this node.
-
getComments()
- Get the comments that have been set on this node.
-
getFirstChild()
- The first child of this node.
-
getLastChild()
- The last child of this node.
-
getNextSibling()
- The node immediately following this node.
-
getNodeName()
- The name of this node, depending on its type; see the table above.
-
getNodeType()
- A code representing the type of the underlying object, as defined above.
-
getNthAttributeName(int)
- Returns the
index
th attribute name.
-
getNthAttributeValue(int)
- Returns the
index
th attribute value.
-
getParent()
- The parent of this node.
-
getPInstructions()
- Get the vector of strings that represents all the
processing instructions that have been set on this node.
-
getPreviousSibling()
- The node immediately preceding this node.
-
hasChildNodes()
- This is a convenience method to allow easy determination of whether a
node has any children.
-
insertBefore(Node, Node)
- Inserts the node
newChild
before the existing child node
refChild
.
-
removeAttribute(Symbol)
- Removes am attribute specified by name.
-
removeChild(Node)
- Removes the child node indicated by
oldChild
from the list
of children, and returns it.
-
replaceChild(Node, Node)
- Replaces the child node
oldChild
with newChild
in the list of children, and returns the oldChild
node.
-
setAttribute(Symbol, Node)
- Adds an attribute value using its name.
-
setComments(String)
- Set the comments on this node.
-
setPInstructions(Vector)
- Set the vector of strings that represents all the
processing instructions of this node.
OM_UKNOWN
public static final byte OM_UKNOWN
- NodeType
These values are those of the C library and they have been carefully
chosen to make encoding autodetection easy.
OM_INT32
public static final byte OM_INT32
OM_BIGINT
public static final byte OM_BIGINT
OM_FLOAT64
public static final byte OM_FLOAT64
OM_BYTEARRAY
public static final byte OM_BYTEARRAY
OM_VAR
public static final byte OM_VAR
OM_STRING
public static final byte OM_STRING
OM_SYMBOL
public static final byte OM_SYMBOL
OM_PINSTRUCTION
public static final byte OM_PINSTRUCTION
OM_COMMENT
public static final byte OM_COMMENT
OM_APP
public static final byte OM_APP
OM_ERROR
public static final byte OM_ERROR
OM_OBJECT
public static final byte OM_OBJECT
OM_BIND
public static final byte OM_BIND
OM_END_APP
public static final byte OM_END_APP
- These are not real nodes (rather tags)
they are used mainly in binary encoding
OM_ATTR
public static final byte OM_ATTR
OM_END_ATTR
public static final byte OM_END_ATTR
OM_ATP
public static final byte OM_ATP
OM_END_ATP
public static final byte OM_END_ATP
OM_END_ERROR
public static final byte OM_END_ERROR
OM_END_OBJECT
public static final byte OM_END_OBJECT
OM_END_BIND
public static final byte OM_END_BIND
OM_BVAR
public static final byte OM_BVAR
OM_END_BVAR
public static final byte OM_END_BVAR
OM_WCSTRING
public static final byte OM_WCSTRING
- constants used for binary encoding
OM_BE_POS_BASE_10
public static final byte OM_BE_POS_BASE_10
OM_BE_NEG_BASE_10
public static final byte OM_BE_NEG_BASE_10
OM_BE_POS_BASE_16
public static final byte OM_BE_POS_BASE_16
OM_BE_NEG_BASE_16
public static final byte OM_BE_NEG_BASE_16
OM_BE_BIG_LEN_MASK
public static final byte OM_BE_BIG_LEN_MASK
- In binary encoding when len of token is > 255
this bit mask is ored to token type
following len field is encoded on 4 bytes rather
than on only one
OM_BE_SHARED_MASK
public static final byte OM_BE_SHARED_MASK
- In binary encoding if an object is in fact a reference
to a previously seen one, this bit mask is ored to
token type
getNodeName
public abstract String getNodeName()
- The name of this node, depending on its type; see the table above.
getNodeType
public abstract short getNodeType()
- A code representing the type of the underlying object, as defined above.
getParent
public abstract Node getParent()
- The parent of this node.
All nodes, except the root
have a parent.
However, if a node has just been created and not yet added to the tree,
or if it has been removed from the tree, this is null
.
hasChildNodes
public abstract boolean hasChildNodes()
- This is a convenience method to allow easy determination of whether a
node has any children.
- Returns:
-
true
if the node has any children,
false
if the node has no children.
getChildNodes
public abstract NodeList getChildNodes()
- A
NodeList
that contains all children of this node.
If there are no children, this is a NodeList
containing
no nodes.
The content of the returned NodeList
is "live" in the sense
that, for instance, changes to the children of the node object that
it was created from are immediately reflected in the nodes returned by
the NodeList
accessors; it is not a static snapshot of the
content of the node.
- See Also:
- hasChildNodes
getFirstChild
public abstract Node getFirstChild()
- The first child of this node. If there is no such node, this returns
null
.
getLastChild
public abstract Node getLastChild()
- The last child of this node. If there is no such node, this returns
null
.
getPreviousSibling
public abstract Node getPreviousSibling()
- The node immediately preceding this node. If there is no such node, this
returns
null
.
getNextSibling
public abstract Node getNextSibling()
- The node immediately following this node. If there is no such node, this
returns
null
.
insertBefore
public abstract Node insertBefore(Node newChild,
Node refChild) throws OMException
- Inserts the node
newChild
before the existing child node
refChild
. If refChild
is null
,
insert newChild
at the end of the list of children.
If the newChild
is already in the tree, it is first
removed.
- Parameters:
- newChild - The node to insert.
- refChild - The reference node, ie: the node before which the new
node must be inserted.
- Returns:
- The node being inserted.
- Throws: OMException
- OME_HIERARCHY_REQUEST: Raised if this node is of a type that
does not allow children, or if the node to insert is one of this
node's ancestors.
OME_NODE_NOT_FOUND: Raised if refChild
is not
a child of this node.
replaceChild
public abstract Node replaceChild(Node newChild,
Node oldChild) throws OMException
- Replaces the child node
oldChild
with newChild
in the list of children, and returns the oldChild
node. If
the newChild
is already in the tree, it is first removed.
- Parameters:
- newChild - The new node to put in the child list.
- oldChild - The node being replaced in the list.
- Returns:
- The node replaced.
- Throws: OMException
- OME_HIERARCHY_REQUEST: Raised if this node is of a type that does not
allow children, or if the node to put in is one of this node's
ancestors.
OME_NOT_FOUND: Raised if oldChild
is not a child of
this node.
removeChild
public abstract Node removeChild(Node oldChild) throws OMException
- Removes the child node indicated by
oldChild
from the list
of children, and returns it.
- Parameters:
- oldChild - The node being removed.
- Returns:
- The node removed.
- Throws: OMException
- OME_NOT_FOUND: Raised if
oldChild
is not a child of
this node.
appendChild
public abstract Node appendChild(Node newChild) throws OMException
- Adds the node
newChild
to the end of the list of
children of this node. If the newChild
is already in
the tree, it is first removed.
- Parameters:
- newChild - The node to add.
- Returns:
- The node added.
- Throws: OMException
- OME_HIERARCHY_REQUEST: Raised if this node is of a type that does not
allow children, or if the node to append is one of this node's
ancestors.
cloneNode
public abstract Node cloneNode(boolean deep)
- Returns a duplicate of this node, ie: serves as a generic copy
constructor for nodes. The duplicate node has no parent
(
parentNode
returns null
.).
All attributes or comments are also copied.
- Parameters:
- deep - If
true
, recursively clone the subtree under
the specified node;
if false
, clone only the node itself (and its attributes
and comments).
- Returns:
- The duplicate node.
getAttribute
public abstract Node getAttribute(Symbol name)
- Retrieves an attribute's value (a node) given its name (a Symbol)
- Parameters:
- name - Name of attribute to retrieve.
- Returns:
- A
Node
linked with the specified attribute's name, or
null
if the specified attribute has not been set on this Node
.
setAttribute
public abstract void setAttribute(Symbol name,
Node value)
- Adds an attribute value using its name.
If an attribute with that name has already been set
on this node, nothing is specified. (implementation
specific behavior)
(DOM is slightly different at this point)
removeAttribute
public abstract Node removeAttribute(Symbol name)
- Removes am attribute specified by name.
- Parameters:
- name - The name of attribute to remove.
- Returns:
- The node removed from the map or
null
.
getAttributeNumber
public abstract int getAttributeNumber()
- The number of attributes set on this node. The range of valid
attribute indices is 0 to
length-1
inclusive.
- See Also:
- getNthAttributeValue, getNthAttributeName
getNthAttributeValue
public abstract Node getNthAttributeValue(int index)
- Returns the
index
th attribute value. If index
is greater than or equal to the number of attributes set on this node,
this returns null
.
- Parameters:
- index - Index of attribute.
- Returns:
- The attribute's value (node) at the
index
th
position, or null
if that is not a valid index.
getNthAttributeName
public abstract Symbol getNthAttributeName(int index)
- Returns the
index
th attribute name. If index
is greater than or equal to the number of attributes set on this node,
this returns null
.
- Parameters:
- index - Index of attribute.
- Returns:
- The attribute's name (symbol) at the
index
th
position, or null
if that is not a valid index.
getComments
public abstract String getComments()
- Get the comments that have been set on this node.
- Returns:
- the comment string of this node or
null
.
setComments
public abstract String setComments(String comment)
- Set the comments on this node.
- Returns:
- the old comment string of this node or
null
.
getPInstructions
public abstract Vector getPInstructions()
- Get the vector of strings that represents all the
processing instructions that have been set on this node.
- Returns:
- the vector of processing instructions strings for this node or
null
.
setPInstructions
public abstract Vector setPInstructions(Vector pis)
- Set the vector of strings that represents all the
processing instructions of this node.
- Returns:
- the old vector of this node or
null
.
All Packages Class Hierarchy This Package Previous Next Index