All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class mathbus.Node

java.lang.Object
   |
   +----mathbus.Node

public class Node
extends Object
The Mathbus term structure is represented by the mathbus.Node class.

See Also:
Registry, Base64InputStream, Base64OutputStream, MBConvert

Variable Index

 o label
 o subterms

Constructor Index

 o Node()
Creates a node with MBS.Null as its label.
 o Node(double)
Creates a node of with label MBS.IEEEFloat.
 o Node(int)
 o Node(int, int)
Creates a node with lab as its label and with the ability to store as many as cnt sub-terms.
 o Node(String)
Creates a node of with label MBS.String.
 o Node(String, int)
Creates a node with lab as its label and with room for as many as cnt sub-terms.

Method Index

 o extractSequenceValue()
Extracts the sequence value of the underlying node.
 o getAttribute(int)
Returns the Noad of the indicated StringID attribute.
 o getDouble()
Returns the double value of a MBS.IEEEFloat node.
 o Label()
Returns the numeric label of the node as an int.
 o LongInteger(String)
Creates a node of with label MBS.LongInteger.
 o nodeWithRegistryInfo()
Returns the node augmented with all necessary local registry information in RegistryStoreLocal terms.
 o nSubterms()
Returns the number of subterms of the node as an int.
 o ParsePrefix(InputStream)
Create a Node from the prefix form found in istream.
 o primToString()
Returns a string representing a String, LongInteger or IEEEFloat node without any surrounding brackets.
 o primToStringBuffer(StringBuffer)
Prints to buf the a String, LongInteger or IEEEFloat node without any surrounding brackets.
 o setAttribute(int, Node)
Add the indicate identifer, value pair to the attributes of this node.
 o setSubterm(int, int)
Sets the indicated subterm's value to be a 32-bit integer.
 o setSubterm(int, Integer)
Sets the indicated subterm's value to be a 32-bit integer.
 o setSubterm(int, Node)
Sets the indicated subterm's value to be a Node reference.
 o SubInteger(int)
Returns the indicated subtermnumber of the node.
 o Subnode(int)
Returns the indicated subtermnumber of the node.
 o Subterm(int)
Returns the indicated subtermnumber of the node.
 o toString()
Returns a string containing the parenthesized notation form for the term.
 o toStringBuffer(StringBuffer)
 o treeShape()
Returns an array of size 4 that describes the shape of the MathBus tree.

Variables

 o label
 protected int label
 o subterms
 protected Object subterms[]

Constructors

 o Node
 public Node()
Creates a node with MBS.Null as its label.

 o Node
 public Node(int lab,
             int cnt)
Creates a node with lab as its label and with the ability to store as many as cnt sub-terms.

 o Node
 public Node(String lab,
             int cnt)
Creates a node with lab as its label and with room for as many as cnt sub-terms. The symbolic label lab is converted to a numeric label before being inserted in the node.

 o Node
 public Node(String data)
Creates a node of with label MBS.String. The sub-terms of this node are all 32-bit integers that are used to store the characters of the string in accordance with the definition of String nodes.

For extra flexibility, the if the input string contains a sequence like "\\uXXXX" where XXXX is a four digit hexadecimal number, then the sequence is treated like a single Unicode character.

 o Node
 public Node(int data)
 o Node
 public Node(double data)
Creates a node of with label MBS.IEEEFloat. The two 32-bit integer sub-terms represent the IEEE double.accordance with the definition of IEEEFLoat nodes.

Methods

 o LongInteger
 public static Node LongInteger(String data)
Creates a node of with label MBS.LongInteger. The sub-terms of this node are all 32-bit integers that are used to store the characters of the string in accordance with the definition of LongInteger nodes.

Parameters:
data - A string consisting of a leading + or - and a sequence of decimal digits. The string is the decimal printed representation of the integer.
 o getDouble
 public double getDouble() throws NodeException
Returns the double value of a MBS.IEEEFloat node.

See Also:
Node
 o Label
 public final int Label()
Returns the numeric label of the node as an int. If the node is an Attributes node then the label of the attributed node is returned, not that of this node itself.

 o nSubterms
 public final int nSubterms()
Returns the number of subterms of the node as an int. If the node is an Attributes node then the number of subterms of the attributed node is returned, not that of this node itself.

 o Subterm
 public final Object Subterm(int index)
Returns the indicated subtermnumber of the node. If the node is an Attributes node then the subterm of the attributed node is returned, not that of this node itself. The type of the return value of this method is Object.

See Also:
Subnode, SubInteger
 o Subnode
 public final Node Subnode(int index)
Returns the indicated subtermnumber of the node. If the node is an Attributes node then the subterm of the attributed node is returned, not that of this node itself. The type of the return value of this method is Node. This member function should not be used unless the type of the subterm is known to be a Node.

See Also:
Subterm, SubInteger
 o SubInteger
 public final Integer SubInteger(int index)
Returns the indicated subtermnumber of the node. If the node is an Attributes node then the subterm of the attributed node is returned, not that of this node itself. The type of the return value of this method is Integer. This member function should not be used unless the type of the subterm is known to be a 32-bit integer.

See Also:
Subterm, Subnode
 o setSubterm
 public int setSubterm(int index,
                       int value)
Sets the indicated subterm's value to be a 32-bit integer. If this node is an Attributes node then the attributed node is modified instead.

Parameters:
index - The index of the subterm to be modified.
value - The new 32-bit integer value of the subterm.
 o setSubterm
 public int setSubterm(int index,
                       Integer value)
Sets the indicated subterm's value to be a 32-bit integer. If this node is an Attributes node then the attributed node is modified instead.

Parameters:
index - The index of the subterm to be modified.
value - The new 32-bit integer value of the subterm, as a 32-bit integer.
 o setSubterm
 public Node setSubterm(int index,
                        Node value)
Sets the indicated subterm's value to be a Node reference. If this node is an Attributes node then the attributed node is modified instead.

Parameters:
index - The index of the subterm to be modified.
value - The Node to which this subterm should refer.
 o getAttribute
 public Node getAttribute(int ident)
Returns the Noad of the indicated StringID attribute. If there is no such attribute then null is returned

 o setAttribute
 public Node setAttribute(int ident,
                          Node value)
Add the indicate identifer, value pair to the attributes of this node. This returns the newly modified node. If the Node did not previously have attributes then it will need to be replaced by the node returned by this method.

 o primToString
 public String primToString()
Returns a string representing a String, LongInteger or IEEEFloat node without any surrounding brackets.

 o primToStringBuffer
 public void primToStringBuffer(StringBuffer buf)
Prints to buf the a String, LongInteger or IEEEFloat node without any surrounding brackets.

 o toString
 public String toString()
Returns a string containing the parenthesized notation form for the term.

Overrides:
toString in class Object
 o toStringBuffer
 public void toStringBuffer(StringBuffer buf)
 o ParsePrefix
 public static Node ParsePrefix(InputStream istream)
Create a Node from the prefix form found in istream. Istream should produce a string that is the parenthesized, prefix form of a MathBus node.

 o treeShape
 public int[] treeShape()
Returns an array of size 4 that describes the shape of the MathBus tree. The maximum depth of the tree is the 0-element of the array and the maximum width of the tree as ts 1-element. The number of inner nodes and the number of leaves are given as the 2-element and 3-element of the returned array.

Returns:
maximum depth, maximum width, number of inner nodes, and number of leaves
 o extractSequenceValue
 public Node extractSequenceValue()
Extracts the sequence value of the underlying node. Thus, if the top level node is not a MBS.Sequence, then just the node itself will be returned. The function works recursively through nested sequences.

Returns:
the sequence value of the node
See Also:
Sequence
 o nodeWithRegistryInfo
 public Node nodeWithRegistryInfo()
Returns the node augmented with all necessary local registry information in RegistryStoreLocal terms.

See Also:
Sequence, RegistryStoreLocal

All Packages  Class Hierarchy  This Package  Previous  Next  Index