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.


Variable Index

 o OM_APP
 o OM_ATP
 o OM_ATTR
 o 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
 o OM_BE_NEG_BASE_10
 o OM_BE_NEG_BASE_16
 o OM_BE_POS_BASE_10
 o OM_BE_POS_BASE_16
 o 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
 o OM_BIGINT
 o OM_BIND
 o OM_BVAR
 o OM_BYTEARRAY
 o OM_COMMENT
 o OM_END_APP
These are not real nodes (rather tags) they are used mainly in binary encoding
 o OM_END_ATP
 o OM_END_ATTR
 o OM_END_BIND
 o OM_END_BVAR
 o OM_END_ERROR
 o OM_END_OBJECT
 o OM_ERROR
 o OM_FLOAT64
 o OM_INT32
 o OM_OBJECT
 o OM_PINSTRUCTION
 o OM_STRING
 o OM_SYMBOL
 o OM_UKNOWN
NodeType These values are those of the C library and they have been carefully chosen to make encoding autodetection easy.
 o OM_VAR
 o OM_WCSTRING
constants used for binary encoding

Method Index

 o appendChild(Node)
Adds the node newChild to the end of the list of children of this node.
 o cloneNode(boolean)
Returns a duplicate of this node, ie: serves as a generic copy constructor for nodes.
 o getAttribute(Symbol)
Retrieves an attribute's value (a node) given its name (a Symbol)
 o getAttributeNumber()
The number of attributes set on this node.
 o getChildNodes()
A NodeList that contains all children of this node.
 o getComments()
Get the comments that have been set on this node.
 o getFirstChild()
The first child of this node.
 o getLastChild()
The last child of this node.
 o getNextSibling()
The node immediately following this node.
 o getNodeName()
The name of this node, depending on its type; see the table above.
 o getNodeType()
A code representing the type of the underlying object, as defined above.
 o getNthAttributeName(int)
Returns the indexth attribute name.
 o getNthAttributeValue(int)
Returns the indexth attribute value.
 o getParent()
The parent of this node.
 o getPInstructions()
Get the vector of strings that represents all the processing instructions that have been set on this node.
 o getPreviousSibling()
The node immediately preceding this node.
 o hasChildNodes()
This is a convenience method to allow easy determination of whether a node has any children.
 o insertBefore(Node, Node)
Inserts the node newChild before the existing child node refChild.
 o removeAttribute(Symbol)
Removes am attribute specified by name.
 o removeChild(Node)
Removes the child node indicated by oldChild from the list of children, and returns it.
 o replaceChild(Node, Node)
Replaces the child node oldChild with newChild in the list of children, and returns the oldChild node.
 o setAttribute(Symbol, Node)
Adds an attribute value using its name.
 o setComments(String)
Set the comments on this node.
 o setPInstructions(Vector)
Set the vector of strings that represents all the processing instructions of this node.

Variables

 o 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.

 o OM_INT32
 public static final byte OM_INT32
 o OM_BIGINT
 public static final byte OM_BIGINT
 o OM_FLOAT64
 public static final byte OM_FLOAT64
 o OM_BYTEARRAY
 public static final byte OM_BYTEARRAY
 o OM_VAR
 public static final byte OM_VAR
 o OM_STRING
 public static final byte OM_STRING
 o OM_SYMBOL
 public static final byte OM_SYMBOL
 o OM_PINSTRUCTION
 public static final byte OM_PINSTRUCTION
 o OM_COMMENT
 public static final byte OM_COMMENT
 o OM_APP
 public static final byte OM_APP
 o OM_ERROR
 public static final byte OM_ERROR
 o OM_OBJECT
 public static final byte OM_OBJECT
 o OM_BIND
 public static final byte OM_BIND
 o OM_END_APP
 public static final byte OM_END_APP
These are not real nodes (rather tags) they are used mainly in binary encoding

 o OM_ATTR
 public static final byte OM_ATTR
 o OM_END_ATTR
 public static final byte OM_END_ATTR
 o OM_ATP
 public static final byte OM_ATP
 o OM_END_ATP
 public static final byte OM_END_ATP
 o OM_END_ERROR
 public static final byte OM_END_ERROR
 o OM_END_OBJECT
 public static final byte OM_END_OBJECT
 o OM_END_BIND
 public static final byte OM_END_BIND
 o OM_BVAR
 public static final byte OM_BVAR
 o OM_END_BVAR
 public static final byte OM_END_BVAR
 o OM_WCSTRING
 public static final byte OM_WCSTRING
constants used for binary encoding

 o OM_BE_POS_BASE_10
 public static final byte OM_BE_POS_BASE_10
 o OM_BE_NEG_BASE_10
 public static final byte OM_BE_NEG_BASE_10
 o OM_BE_POS_BASE_16
 public static final byte OM_BE_POS_BASE_16
 o OM_BE_NEG_BASE_16
 public static final byte OM_BE_NEG_BASE_16
 o 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

 o 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

Methods

 o getNodeName
 public abstract String getNodeName()
The name of this node, depending on its type; see the table above.

 o getNodeType
 public abstract short getNodeType()
A code representing the type of the underlying object, as defined above.

 o 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.

 o 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.
 o 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
 o getFirstChild
 public abstract Node getFirstChild()
The first child of this node. If there is no such node, this returns null.

 o getLastChild
 public abstract Node getLastChild()
The last child of this node. If there is no such node, this returns null.

 o getPreviousSibling
 public abstract Node getPreviousSibling()
The node immediately preceding this node. If there is no such node, this returns null.

 o getNextSibling
 public abstract Node getNextSibling()
The node immediately following this node. If there is no such node, this returns null.

 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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)

 o 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.
 o 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
 o getNthAttributeValue
 public abstract Node getNthAttributeValue(int index)
Returns the indexth 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 indexth position, or null if that is not a valid index.
 o getNthAttributeName
 public abstract Symbol getNthAttributeName(int index)
Returns the indexth 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 indexth position, or null if that is not a valid index.
 o getComments
 public abstract String getComments()
Get the comments that have been set on this node.

Returns:
the comment string of this node or null.
 o setComments
 public abstract String setComments(String comment)
Set the comments on this node.

Returns:
the old comment string of this node or null.
 o 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.
 o 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