Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.voytechs.jnetstream.npl
Class ArrayDimensionNode  view ArrayDimensionNode download ArrayDimensionNode.java

java.lang.Object
  extended bycom.voytechs.jnetstream.npl.Node
      extended bycom.voytechs.jnetstream.npl.NodeList
          extended bycom.voytechs.jnetstream.npl.ArrayDimensionNode
All Implemented Interfaces:
Visitable

public class ArrayDimensionNode
extends NodeList

Support class that allows muti-dimensional array manipulation. Since array references can have dynamic code associated with array lookup, a number of convenience functions are performed by the class. 1) Bounds checking for MAX and MIN bounds for all dimensions. 2) Node traversal for each dimension 3) Scalar array size computation which also needs to be done at run time because of dynamic code.


Field Summary
private  boolean constantDimension
           
private static boolean debug
           
private  int scalarSize
           
 
Fields inherited from class com.voytechs.jnetstream.npl.NodeList
 
Fields inherited from class com.voytechs.jnetstream.npl.Node
token
 
Constructor Summary
ArrayDimensionNode()
           
 
Method Summary
 int calculateArraySize()
           
protected static int calculateArraySize(ArrayDimensionNode max, int level)
           
 int calculateScalarSize(ArrayDimensionNode dim)
          Calculates the scalar dimension of the entire array.
protected static int calculateScalarSize(ArrayDimensionNode max, ArrayDimensionNode dim)
           
 boolean checkBoundary(ArrayDimensionNode dim)
          Checks that "dim" is within allocated limits of the array dimension.
 java.lang.String createLabel(int scalar)
           
 ArrayDimensionNode evaluateToStatic()
          This method evaluates the code to its NodeInt equivelent and creates a new Dimension object with static values.
static void main(java.lang.String[] args)
          Test function for ArrayDimensionNode
 int toScalar()
           
 int toScalar(ArrayDimensionNode dim)
          Returns the scalar equivelent value of the entire array.
 
Methods inherited from class com.voytechs.jnetstream.npl.NodeList
add, add, addFirst, addLast, canOptimize, clear, contains, empty, get, getBoolean, getFirst, getInt, getLast, getString, indexOf, merge, optimize, remove, remove, size, toString, visit
 
Methods inherited from class com.voytechs.jnetstream.npl.Node
getToken, setToken
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

debug

private static final boolean debug
See Also:
Constant Field Values

constantDimension

private boolean constantDimension

scalarSize

private int scalarSize
Constructor Detail

ArrayDimensionNode

public ArrayDimensionNode()
Method Detail

toScalar

public int toScalar(ArrayDimensionNode dim)
             throws NodeException
Returns the scalar equivelent value of the entire array. Since the value has to be evaluated dynamically, there some caching of the value is done to improve performance.


toScalar

public int toScalar()
             throws NodeException

calculateScalarSize

public int calculateScalarSize(ArrayDimensionNode dim)
                        throws NodeException
Calculates the scalar dimension of the entire array. This is how many elements the array takes overall.


calculateScalarSize

protected static int calculateScalarSize(ArrayDimensionNode max,
                                         ArrayDimensionNode dim)
                                  throws NodeException

calculateArraySize

public int calculateArraySize()
                       throws NodeException

calculateArraySize

protected static int calculateArraySize(ArrayDimensionNode max,
                                        int level)
                                 throws NodeException

createLabel

public java.lang.String createLabel(int scalar)
                             throws NodeException

checkBoundary

public boolean checkBoundary(ArrayDimensionNode dim)
                      throws NodeException
Checks that "dim" is within allocated limits of the array dimension.


evaluateToStatic

public ArrayDimensionNode evaluateToStatic()
                                    throws NodeException
This method evaluates the code to its NodeInt equivelent and creates a new Dimension object with static values. This is needed for when arrays are first instantiated, the dynamic code can only be run once, otherwise array dimensions could suddenly change on us. Make sure this method is called only when all the reference have been resolved and context loaded with primitives. Otherwise an NodeException will be thrown if references can not be properly dereferenced.


main

public static void main(java.lang.String[] args)
Test function for ArrayDimensionNode