EDU.bmrb.starlibj
Class DataLoopNode

java.lang.Object
  |
  +--EDU.bmrb.starlibj.StarNode
        |
        +--EDU.bmrb.starlibj.DataLoopNode
All Implemented Interfaces:
java.lang.Cloneable

public class DataLoopNode
extends StarNode
implements java.lang.Cloneable

A DataLoopNode holds one loop from the Star file tree. The loop can be nested. A DataLoopNode is mostly just a pairing of a LoopTableNode with its associated DataLoopNameListNode. Most of the interesting methods are contained in one of those two types.


Field Summary
protected  DataLoopNameListNode myNames
           
protected  LoopTableNode myVals
           
protected  boolean parseMismatchFlag
           
 
Fields inherited from class EDU.bmrb.starlibj.StarNode
colNum, lineNum, parent, preComment
 
Constructor Summary
DataLoopNode()
          constructor - makes empty DataLoopNode.
DataLoopNode(boolean tab)
          constructor - makes a loop with the given tabulation setting.
DataLoopNode(boolean tab, boolean indent, int rowsPerLine)
          constructor - makes a loop with the given settings.
DataLoopNode(DataLoopNameListNode names, LoopTableNode table)
          Constructor, given the name list and table.
DataLoopNode(DataLoopNode copyMe)
          copy constructor - deep copy.
 
Method Summary
 java.lang.Object clone()
          clone - allocate a copy of me and return it
 DataLoopNameListNode getNames()
          return a reference to the DataLoopNameList of names in me.
 boolean getTabFlag()
          Get the tabulation flag for this loop:
 LoopTableNode getVals()
          return a reference to the LoopTableNode of values in me.
 VectorCheckType searchByName(java.lang.String searchFor)
          searchByName() will generate a list of all the places a particular name exists in this Star object.
 VectorCheckType searchByTagValue(java.lang.String tag, java.lang.String value)
          Given a tag name and a value, find the DataValueNodes from inside this loop that match the criteria.
 VectorCheckType searchForType(java.lang.Class type, short delim)
          This method returns a vector of all the nodes of the given type.
 void setTabFlag(boolean fl)
          Set the tabulation flag for this loop:
 
Methods inherited from class EDU.bmrb.starlibj.StarNode
getColNum, getLineNum, getParallelCopy, getParent, getPreComment, searchForTypeByName, searchForTypeByTagValue, setColNum, setLineNum, setParent, setPeer, setPreComment, Unparse
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myNames

protected DataLoopNameListNode myNames

myVals

protected LoopTableNode myVals

parseMismatchFlag

protected boolean parseMismatchFlag
Constructor Detail

DataLoopNode

public DataLoopNode()
constructor - makes empty DataLoopNode. Defaults its loop format to 'linear'.

DataLoopNode

public DataLoopNode(boolean tab)
constructor - makes a loop with the given tabulation setting.
Parameters:
tab - true = loop will print tabularly, false = linearly

DataLoopNode

public DataLoopNode(boolean tab,
                    boolean indent,
                    int rowsPerLine)
constructor - makes a loop with the given settings.
Parameters:
tab - true = loop will print tabularly, false = linearly
indent - true = loop body will be indented (normal), false = not indented.
rowsPerLine - integer number of rows printed in a line of text. Normally you set it to 1.

DataLoopNode

public DataLoopNode(DataLoopNameListNode names,
                    LoopTableNode table)
Constructor, given the name list and table. Typically only used by the parser.

DataLoopNode

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

clone

public java.lang.Object clone()
clone - allocate a copy of me and return it
Overrides:
clone in class StarNode
Following copied from class: EDU.bmrb.starlibj.StarNode
See Also:
StarFileNode

getVals

public LoopTableNode getVals()
return a reference to the LoopTableNode of values in me.

getNames

public DataLoopNameListNode getNames()
return a reference to the DataLoopNameList of names in me.

getTabFlag

public boolean getTabFlag()
Get the tabulation flag for this loop:
Returns:
the tab flag

setTabFlag

public void setTabFlag(boolean fl)
Set the tabulation flag for this loop:
Parameters:
fl - the tab flag to set it to.

searchByName

public VectorCheckType searchByName(java.lang.String searchFor)
searchByName() will generate a list of all the places a particular name exists in this Star object. This name will match tag names in this DataLoopNode. The full tag name must be passed, so to look for a tag called foo, you need to use the underscore in the name: "_foo". Also, to look for a saveframe called foo, you need the save_ prefix, like this: "save_foo". This search is an exact string match, and it is case-sensitive.

The returned results are DataNameNodes when looking in a DataLoopNode like this.

It should be noted that this algorithm, and the other search algorithms that follow, are simple linear searches with no indexing. So they are computationally slow. So far the need has not yet surfaced for a faster indexed search technique, although one could be added behind the scenes without changing the interface.

The search for names is case-insensitive.

Overrides:
searchByName in class StarNode
Parameters:
searchFor - the string name to look for.
Returns:
A VectorCheckType containing the StarNodes that matched. This vector will have a size of zero if there are no matches.

searchByTagValue

public VectorCheckType searchByTagValue(java.lang.String tag,
                                        java.lang.String value)
Given a tag name and a value, find the DataValueNodes from inside this loop that match the criteria. More than one DataValueNode could be returned from the same DataLoopNode if the value being looked-for appears more than once in the column for a tag name.

The search for tag names is case-insensitive.

The search for values, however is case-sensitive.

Overrides:
searchByTagValue in class StarNode
Parameters:
tag - - Look for this tag...
value - - Where it has this value.
Returns:
A java.util.vector containing the matching StarNodes. This vector will have a size of zero if there are no matches.

searchForType

public VectorCheckType searchForType(java.lang.Class type,
                                     short delim)
This method returns a vector of all the nodes of the given type. It is much like searchByName() in that it heirarchically walks the STAR tree and calls the searchForType() functions of the subtrees within the tree. In this way it is possible to call this function at any level of the STAR file.

The second parameter is optional and is only useful when you are searching for DataValueNodes. It determines the kind of DataValueNode you are searching for, by delimiter type. For example, you could search for only those DataValueNodes that are semicolon-delimited by passing DataValueNode::SEMICOLON as the second argument. Or you could look for just framecodes by passing DataValueNode::FRAMECODE as the second parameter. Passing a negative number says you want all the DataValueNodes, regardless of their delimiter type.

If the search is for some ASTtype other than DataValueNode, then it is irrelevant what the second parameter of this function is, as it will never be used - You can just leave it off and accept the default.

Overrides:
searchForType in class StarNode
Parameters:
type - - type to search for
delim - - DataValueNode::ValType to look for. Default = "dont-care".
Returns:
A java.util.vector containing the matching StarNodes. This vector will have a size of zero if there are no matches.