EDU.bmrb.starlibj
Class LoopTableNode

java.lang.Object
  |
  +--EDU.bmrb.starlibj.StarNode
        |
        +--EDU.bmrb.starlibj.LoopTableNode

public class LoopTableNode
extends StarNode
implements java.lang.Cloneable

A LoopTableNode is a 'table' of values in a loop. It is a vector of LoopRowNodes. Every DataLoopNode has at least one LoopTableNode for the outermost loop. Each nested subtable is represented by another LoopTableNode.

It is possible for a LoopRowNode to contain a LoopTableNode under it. This is how nested loops are linked together. At the outermost level, there is a LoopTableNode containing LoopRowNodes. Each of these LoopRowNodes could have a LoopTableNode under it, which in turn is a collection of LoopRowNodes which could have LoopTableNodes under them, and so on.


Field Summary
protected  boolean myIndentFlag
           
protected  LoopRowsVector myRows
           
protected  int myRowsPerLine
           
protected  boolean myTabFlag
           
 
Fields inherited from class EDU.bmrb.starlibj.StarNode
colNum, lineNum, parent, preComment
 
Constructor Summary
LoopTableNode()
          default constructor - makes a loop with indent, linear.
LoopTableNode(boolean tabFlag)
           
LoopTableNode(boolean tabFlag, boolean indentFl, int rowsPerLn)
           
LoopTableNode(LoopTableNode copyMe)
          copy constructor - deep copy.
 
Method Summary
 void addElement(LoopRowNode row)
          Just like the Vector method of the same name, but it will throw an exception when invalid insertions are attempted.
protected  void calcPrintSizes(java.util.Vector preSizes, java.util.Vector postSizes)
          Calcualte the sizes to print this table in.
 int capacity()
          Just like the Vector method of the same name.
 java.lang.Object clone()
          clone - make a deep copy of me and return a reference to it.
 boolean contains(LoopRowNode row)
          Just like the Vector method of the same name.
 LoopRowNode elementAt(int index)
          Just like the Vector method of the same name.
 DataValueNode elementAt(int row, int col)
          Gets the value at a specific row and column in the table.
 java.util.Enumeration elements()
          Just like the Vector method of the same name.
 LoopRowNode firstElement()
          Just like the Vector method of the same name.
 boolean getIndentFlag()
          Gets the indentation Unparse flag for this table.
protected  int getMaxDepth()
           
protected  int getMyDepth()
           
 int getRowsPerLine()
          Gets the number of rows to be Unparsed on one line when in tabular mode.
 boolean getTabFlag()
          Gets the tabulation Unparse flag for this table.
 int indexOf(LoopRowNode val)
          Just like the Vector method of the same name.
 int indexOf(LoopRowNode row, int index)
          Just like the Vector method of the same name.
 void insertElementAt(LoopRowNode row, int index)
          Just like the Vector method of the same name, but it will throw an exception when invalid insertions are attempted.
 boolean isEmpty()
          Just like the Vector method of the same name.
 int isInLoop()
          isInLoop: Returns true if this LoopTableNode is inside a DataLoopNode, or false if it is not.
 LoopRowNode lastElement()
          Just like the Vector method of the same name.
 int lastIndexOf(LoopRowNode row)
          Just like the Vector method of the same name.
 int lastIndexOf(LoopRowNode row, int index)
          Just like the Vector method of the same name.
 boolean removeElement(LoopRowNode row)
          Just like the Vector method of the same name, but it makes this table go away if the row removed was the last one.
 void removeElementAt(int index)
          Similar to the Vector method of the same name.
 VectorCheckType searchForType(java.lang.Class type)
          Find all values of the type given in this table - this is fairly nonsensical because all values in the table are of type DataValueNode, but this function is here for orthogonality with the base class StarNode.
 VectorCheckType searchForType(java.lang.Class type, short delim)
          Find the type given in this row - Return all the matching values that meet the criteria given in the parameters.
protected  VectorCheckType searchForValsInColumn(int searchNest, int searchCol, java.lang.String value)
          Look for the value in the nest level/column given.
 void setElementAt(LoopRowNode row, int index)
          Just like the Vector method of the same name, except that it throws an exception if the number of values in the row is incorrect for the number of names in the list of names in this DataLoopNode.
 void setIndentFlag(boolean tabFlag)
          Sets the indentation Unparse flag for this table.
 void setRowsPerLine(int setTo)
          Sets the number of rows Unparsed per line when in tabular mode.
 void setSize(int newSize)
          Just like the Vector method of the same name.
 void setTabFlag(boolean tabFlag)
          Sets the tabulation Unparse flag for this table.
 int size()
          Just like the Vector method of the same name.
 java.lang.String stringAt(int row, int col)
          This routine obtains the value at the specified row and column as a string rather than as a DataValueNode A null is returned if no such row or column exists.
protected  void truncateNestLevel(int depth)
           
 void Unparse(int indent)
          Unparse prints the contents of the StarNode object out to the given stream.
 
Methods inherited from class EDU.bmrb.starlibj.StarNode
getColNum, getLineNum, getParallelCopy, getParent, getPreComment, mySkips, searchByName, searchByTagValue, searchForTypeByName, searchForTypeByTagValue, setColNum, setLineNum, setParent, setPeer, setPreComment
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myTabFlag

protected boolean myTabFlag

myRows

protected LoopRowsVector myRows

myIndentFlag

protected boolean myIndentFlag

myRowsPerLine

protected int myRowsPerLine
Constructor Detail

LoopTableNode

public LoopTableNode()
default constructor - makes a loop with indent, linear.

LoopTableNode

public LoopTableNode(boolean tabFlag)
Parameters:
tabFlag - set to true for a tabularly printed loop, or false for a linearly printed loop. This only affects output with Unparse() and nothing else.

LoopTableNode

public LoopTableNode(boolean tabFlag,
                     boolean indentFl,
                     int rowsPerLn)
Parameters:
tabFlag - set to true for a tabularly printed loop, or false for a linearly printed loop. This only affects output with Unparse() and nothing else.
indentFl - set to true if this loop should be output indented.
rowsPerLn - set to the number of rows to include on one line of text. Only has meaning if tabFlag is true.

LoopTableNode

public LoopTableNode(LoopTableNode copyMe)
copy constructor - deep copy.
Method Detail

clone

public java.lang.Object clone()
clone - make a deep copy of me and return a reference to it.
Overrides:
clone in class StarNode

setSize

public void setSize(int newSize)
Just like the Vector method of the same name.
See Also:
VectorCheckType.setSize

capacity

public int capacity()
Just like the Vector method of the same name.
See Also:
VectorCheckType.capacity

size

public int size()
Just like the Vector method of the same name.
See Also:
VectorCheckType.size

isEmpty

public boolean isEmpty()
Just like the Vector method of the same name.
See Also:
VectorCheckType.isEmpty

elements

public java.util.Enumeration elements()
Just like the Vector method of the same name.
See Also:
VectorCheckType.Enumeration

contains

public boolean contains(LoopRowNode row)
Just like the Vector method of the same name.
See Also:
VectorCheckType.contains

indexOf

public int indexOf(LoopRowNode val)
Just like the Vector method of the same name.
See Also:
VectorCheckType.indexOf

indexOf

public int indexOf(LoopRowNode row,
                   int index)
Just like the Vector method of the same name.
See Also:
VectorCheckType.indexOf

lastIndexOf

public int lastIndexOf(LoopRowNode row)
Just like the Vector method of the same name.
See Also:
VectorCheckType.lastIndexOf

lastIndexOf

public int lastIndexOf(LoopRowNode row,
                       int index)
Just like the Vector method of the same name.
See Also:
VectorCheckType.lastIndexOf

elementAt

public LoopRowNode elementAt(int index)
Just like the Vector method of the same name.
See Also:
VectorCheckType.elementAt

elementAt

public DataValueNode elementAt(int row,
                               int col)
Gets the value at a specific row and column in the table. This routine counts starting at zero, in row-major order. If the specific row or column don't exist, then a null is returned.

stringAt

public java.lang.String stringAt(int row,
                                 int col)
This routine obtains the value at the specified row and column as a string rather than as a DataValueNode A null is returned if no such row or column exists.

firstElement

public LoopRowNode firstElement()
Just like the Vector method of the same name.
See Also:
VectorCheckType.firstElement

lastElement

public LoopRowNode lastElement()
Just like the Vector method of the same name.
See Also:
VectorCheckType.lastElement

setElementAt

public void setElementAt(LoopRowNode row,
                         int index)
                  throws OperationCausesMismatchedLoopData
Just like the Vector method of the same name, except that it throws an exception if the number of values in the row is incorrect for the number of names in the list of names in this DataLoopNode. (If this table is not inside a DataLoopNode, then this exception is never thrown.
See Also:
VectorCheckType.setElementAt

removeElementAt

public void removeElementAt(int index)
Similar to the Vector method of the same name. If this is the last row in te table, and if this table is nested inside a LoopRowNode, then it will unlink itself from the parent LoopRowNode (which should make this table go away at garbage collection time.)
See Also:
VectorCheckType.removeElementAt

insertElementAt

public void insertElementAt(LoopRowNode row,
                            int index)
Just like the Vector method of the same name, but it will throw an exception when invalid insertions are attempted.

An invalid insertion is one with the following conditions: 1 - This table is already inside a DataLoopNode (and not 'free floating'.), and
2 - The row being inserted has the wrong number of values. (The number of values in the row must match the number of names in the loop header.)

See Also:
VectorCheckType.insertElementAt

addElement

public void addElement(LoopRowNode row)
Just like the Vector method of the same name, but it will throw an exception when invalid insertions are attempted.

An invalid insertion is one with the following conditions: 1 - This table is already inside a DataLoopNode (and not 'free floating'.), and
2 - The row being inserted has the wrong number of values. (The number of values in the row must match the number of names in the loop header.)

See Also:
VectorCheckType.addElement

removeElement

public boolean removeElement(LoopRowNode row)
Just like the Vector method of the same name, but it makes this table go away if the row removed was the last one.

If this is the last row in the table, and if this table is nested inside a LoopRowNode, then it will unlink itself from the parent LoopRowNode (which should make this table go away at garbage collection time.)

See Also:
VectorCheckType.removeElement

isInLoop

public int isInLoop()
isInLoop: Returns true if this LoopTableNode is inside a DataLoopNode, or false if it is not. (In a complete STAR tree it is always true, but when building up a loop piece by piece an LoopTableNode might not have been attached to a loop yet.)

The value returned is an integer. It is a count of how many nesting levels deep this is in the loop that it was found it. Thus if it is zero (false) it was not found in a loop, and if it is 1 then it was found in nesting level 1 of a loop, 2 = nesting level 2, etc.

Note that this is off-by-one with the index used in the [] operator, which starts counting at zero. This was done so that this method could be used like a boolean. (zero means not found, nonzero means found).


Unparse

public void Unparse(int indent)
Unparse prints the contents of the StarNode object out to the given stream. This is essentially the inverse of the CS term to "parse", hence the name "Unparse". The parameter given is the indentation level to print things.
Overrides:
Unparse in class StarNode

setTabFlag

public void setTabFlag(boolean tabFlag)
Sets the tabulation Unparse flag for this table.
Parameters:
tabFlag - true for tabular, false for linear.

getTabFlag

public boolean getTabFlag()
Gets the tabulation Unparse flag for this table.
Returns:
true = tabular, false = linear

setIndentFlag

public void setIndentFlag(boolean tabFlag)
Sets the indentation Unparse flag for this table.
Parameters:
tabFlag - true for indented from margin (norma), false for up-against-margin.

getIndentFlag

public boolean getIndentFlag()
Gets the indentation Unparse flag for this table.
Returns:
true for indented from margin (norma), false for up-against-margin.

setRowsPerLine

public void setRowsPerLine(int setTo)
Sets the number of rows Unparsed per line when in tabular mode. if getIndentFlag() is false, then this is meaningless.
Parameters:
setTo - the number of rows per line.

getRowsPerLine

public int getRowsPerLine()
Gets the number of rows to be Unparsed on one line when in tabular mode.
Returns:
the number of rows per line.

searchForType

public VectorCheckType searchForType(java.lang.Class type)
Find all values of the type given in this table - this is fairly nonsensical because all values in the table are of type DataValueNode, but this function is here for orthogonality with the base class StarNode.
Parameters:
type - look for this type.

searchForType

public VectorCheckType searchForType(java.lang.Class type,
                                     short delim)
Find the type given in this row - Return all the matching values that meet the criteria given in the parameters.
Parameters:
type - look for this type
delim - Look for this delimiter type.
Overrides:
searchForType in class StarNode
See Also:

getMyDepth

protected int getMyDepth()

getMaxDepth

protected int getMaxDepth()

truncateNestLevel

protected void truncateNestLevel(int depth)

searchForValsInColumn

protected VectorCheckType searchForValsInColumn(int searchNest,
                                                int searchCol,
                                                java.lang.String value)
Look for the value in the nest level/column given. nest level and column both start counting at zero.

calcPrintSizes

protected void calcPrintSizes(java.util.Vector preSizes,
                              java.util.Vector postSizes)
Calcualte the sizes to print this table in.