bsh
Class BSHType

java.lang.Object
  |
  +--bsh.SimpleNode
        |
        +--bsh.BSHType
All Implemented Interfaces:
BshClassManager.Listener, Node, java.io.Serializable

class BSHType
extends SimpleNode
implements BshClassManager.Listener


Field Summary
private  int arrayDims
          If we are an array type this will be non zero and indicate the dimensionality of the array.
private  java.lang.Class baseType
          baseType is used during evaluation of full type and retained for the case where we are an array type.
protected  Node[] children
           
(package private)  Token firstToken
           
protected  int id
           
(package private)  Token lastToken
           
protected  Node parent
           
(package private)  java.lang.String sourceFile
          the source of the text from which this was parsed
private  java.lang.Class type
          Internal cache of the fully expressed type.
 
Constructor Summary
(package private) BSHType(int id)
           
 
Method Summary
 void addArrayDimension()
          Used by the grammar to indicate dimensions of array types during parsing.
 void classLoaderChanged()
           
 void dump(java.lang.String prefix)
           
 java.lang.Object eval(CallStack callstack, Interpreter interpreter)
          This is the general signature for evaluation of a node.
 java.lang.Object eval(NameSpace namespace)
          Some nodes require only a namespace for evaluation.
 int getArrayDims()
          If we are an array type this will be non zero and indicate the dimensionality of the array.
 java.lang.Class getBaseType()
          baseType is used during evaluation of full type and retained for the case where we are an array type.
 SimpleNode getChild(int i)
           
 int getLineNumber()
          Get the line number of the starting token
 java.lang.String getSourceFile()
          Get the name of the source file (or more generally source) of the text from which this node was parsed.
 java.lang.String getText()
          Get the text of the tokens comprising this node.
 java.lang.Class getType(NameSpace namespace)
          Returns a class for the type
 void jjtAddChild(Node n, int i)
          This method tells the node to add its argument to the node's list of children.
 void jjtClose()
          This method is called after all the child nodes have been added.
 Node jjtGetChild(int i)
          This method returns a child node.
 int jjtGetNumChildren()
          Return the number of children the node has.
 Node jjtGetParent()
           
 void jjtOpen()
          This method is called after the node has been made the current node.
 void jjtSetParent(Node n)
          This pair of methods are used to inform the node of its parent.
 void prune()
          Detach this node from its parent.
 void setSourceFile(java.lang.String sourceFile)
          Set the name of the source file (or more generally source) of the text from which this node was parsed.
 java.lang.String toString()
           
 java.lang.String toString(java.lang.String prefix)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

baseType

private java.lang.Class baseType
baseType is used during evaluation of full type and retained for the case where we are an array type. In the case where we are not an array this will be the same as type.


arrayDims

private int arrayDims
If we are an array type this will be non zero and indicate the dimensionality of the array. e.g. 2 for String[][];


type

private java.lang.Class type
Internal cache of the fully expressed type. i.e. primtive, class, or array. Cleared on classloader change.


parent

protected Node parent

children

protected Node[] children

id

protected int id

firstToken

Token firstToken

lastToken

Token lastToken

sourceFile

java.lang.String sourceFile
the source of the text from which this was parsed

Constructor Detail

BSHType

BSHType(int id)
Method Detail

addArrayDimension

public void addArrayDimension()
Used by the grammar to indicate dimensions of array types during parsing.


getType

public java.lang.Class getType(NameSpace namespace)
                        throws EvalError
Returns a class for the type

EvalError

getBaseType

public java.lang.Class getBaseType()
baseType is used during evaluation of full type and retained for the case where we are an array type. In the case where we are not an array this will be the same as type.


getArrayDims

public int getArrayDims()
If we are an array type this will be non zero and indicate the dimensionality of the array. e.g. 2 for String[][];


classLoaderChanged

public void classLoaderChanged()
Specified by:
classLoaderChanged in interface BshClassManager.Listener

jjtOpen

public void jjtOpen()
Description copied from interface: Node
This method is called after the node has been made the current node. It indicates that child nodes can now be added to it.

Specified by:
jjtOpen in interface Node

jjtClose

public void jjtClose()
Description copied from interface: Node
This method is called after all the child nodes have been added.

Specified by:
jjtClose in interface Node

jjtSetParent

public void jjtSetParent(Node n)
Description copied from interface: Node
This pair of methods are used to inform the node of its parent.

Specified by:
jjtSetParent in interface Node

jjtGetParent

public Node jjtGetParent()
Specified by:
jjtGetParent in interface Node

jjtAddChild

public void jjtAddChild(Node n,
                        int i)
Description copied from interface: Node
This method tells the node to add its argument to the node's list of children.

Specified by:
jjtAddChild in interface Node

jjtGetChild

public Node jjtGetChild(int i)
Description copied from interface: Node
This method returns a child node. The children are numbered from zero, left to right.

Specified by:
jjtGetChild in interface Node

getChild

public SimpleNode getChild(int i)

jjtGetNumChildren

public int jjtGetNumChildren()
Description copied from interface: Node
Return the number of children the node has.

Specified by:
jjtGetNumChildren in interface Node

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(java.lang.String prefix)

dump

public void dump(java.lang.String prefix)

prune

public void prune()
Detach this node from its parent. This is primarily useful in node serialization. (see BSHMethodDeclaration)


eval

public java.lang.Object eval(NameSpace namespace)
                      throws EvalError
Some nodes require only a namespace for evaluation.

EvalError

eval

public java.lang.Object eval(CallStack callstack,
                             Interpreter interpreter)
                      throws EvalError
This is the general signature for evaluation of a node.

EvalError

setSourceFile

public void setSourceFile(java.lang.String sourceFile)
Set the name of the source file (or more generally source) of the text from which this node was parsed.


getSourceFile

public java.lang.String getSourceFile()
Get the name of the source file (or more generally source) of the text from which this node was parsed. This will recursively search up the chain of parent nodes until a source is found or return a string indicating that the source is unknown.


getLineNumber

public int getLineNumber()
Get the line number of the starting token


getText

public java.lang.String getText()
Get the text of the tokens comprising this node.