EDU.bmrb.starlibj
Class BlockNode

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

public class BlockNode
extends StarNode
implements java.lang.Cloneable

A single block in the file - this can be either a data block or a global block - they are both handled the same way.


Field Summary
protected  BlockListVector myDataList
           
protected  java.lang.String myHeading
           
 
Fields inherited from class EDU.bmrb.starlibj.StarNode
colNum, lineNum, parent, preComment
 
Method Summary
 void addElement(java.lang.Object obj)
          Just like the Vector method of the same name.
 java.lang.Object clone()
          Allocates a new copy of me and returns a reference to it.
 boolean contains(java.lang.Object obj)
          Just like the Vector method of the same name.
 StarNode elementAt(int index)
          Just like the Vector method of the same name.
 java.util.Enumeration elements()
          Just like the Vector method of the same name.
 StarNode firstElement()
          Just like the Vector method of the same name.
 java.lang.String getLabel()
          Return my name (global_ or data_..)
 int indexOf(java.lang.Object obj)
          Just like the Vector method of the same name.
 int indexOf(java.lang.Object obj, int index)
          Just like the Vector method of the same name.
 void insertElementAt(java.lang.Object obj, int index)
          Just like the Vector method of the same name.
 boolean isEmpty()
          Just like the Vector method of the same name.
 StarNode lastElement()
          Just like the Vector method of the same name.
 int lastIndexOf(java.lang.Object obj)
          Just like the Vector method of the same name.
 int lastIndexOf(java.lang.Object obj, int index)
          Just like the Vector method of the same name.
 boolean removeElement(java.lang.Object obj)
          Just like the Vector method of the same name.
 void removeElementAt(int index)
          Similar to the Vector method of the same name.
 VectorCheckType searchByName(java.lang.String searchFor)
          Given a tag name, find the AST object it resides in.
 VectorCheckType searchByTagValue(java.lang.String tag, java.lang.String value)
          Given a tag name and a value, find the AST object that that particular tag and value pair resides in.
 VectorCheckType searchForType(java.lang.Class type, short delim)
          This method returns a vector of all the nodes of the given type.
 void setElementAt(java.lang.Object obj, int index)
          Just like the Vector method of the same name.
 void setLabel(java.lang.String newName)
          Change my name (global_ or data_..) - generate an exception if the given name is not valid.
 void setSize(int newSize)
          Just like the Vector method of the same name.
 int size()
          Just like the Vector method of the same name.
 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, 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

myDataList

protected BlockListVector myDataList

myHeading

protected java.lang.String myHeading
Method Detail

clone

public java.lang.Object clone()
Allocates a new copy of me and returns a reference to it. This is a deep copy, meaning that all children are copied instead of linked.
Overrides:
clone in class StarNode
Following copied from class: EDU.bmrb.starlibj.StarNode
See Also:
StarFileNode

getLabel

public java.lang.String getLabel()
Return my name (global_ or data_..)

setLabel

public void setLabel(java.lang.String newName)
              throws NameViolatesStarSyntax
Change my name (global_ or data_..) - generate an exception if the given name is not valid.


setSize

public void setSize(int newSize)
Just like the Vector method of the same name. Makes enough room so that there can be newSize elements in the node, without having to insert them manually one at a time. The nodes start out will a null value that can be replaced with setElementAt.
See Also:
VectorCheckType.setSize

size

public int size()
Just like the Vector method of the same name. Returns the number of elements in this block.
See Also:
java.util.Vector.size

isEmpty

public boolean isEmpty()
Just like the Vector method of the same name. True if this block has no elements in it.
See Also:
java.util.Vector.isEmpty

elements

public java.util.Enumeration elements()
Just like the Vector method of the same name. Gives an enumeration over the loops, saveframes, and data items in this block.
See Also:
java.util.Vector.Enumeration

contains

public boolean contains(java.lang.Object obj)
Just like the Vector method of the same name. True if the node given is a loop, item, or saveframe immediately inside this block. This is not a deep recursive search - it only looks at the level immediately inside the block.
Parameters:
obj - The loop, item, or saveframe to look for
See Also:
java.util.Vector.contains

indexOf

public int indexOf(java.lang.Object obj)
Just like the Vector method of the same name. Returns the integer index of the given item, loop or saveframe inside this StarFileNode. This is not a deep recursive search.
Parameters:
obj - The loop, item, or saveframe to look for
See Also:
java.util.Vector.indexOf

indexOf

public int indexOf(java.lang.Object obj,
                   int index)
Just like the Vector method of the same name. Returns the integer index of the next item, loop or saveframe inside this StarFileNode, starting at the index given. This is not a deep recursive search.
Parameters:
obj - The item, loop, or saveframe to look for.
index - Start searching at this point in the vector.
See Also:
java.util.Vector.indexOf

lastIndexOf

public int lastIndexOf(java.lang.Object obj)
Just like the Vector method of the same name. Returns the lastmost integer index of the given item, loop, or saveframe
Parameters:
obj - The item, loop, or saveframe to look for.
See Also:
java.util.Vector.lastIndexOf

lastIndexOf

public int lastIndexOf(java.lang.Object obj,
                       int index)
Just like the Vector method of the same name. Returns the lastmost integer index of the given item, loop, or saveframe, but going no higher than the given index.
Parameters:
obj - The item, loop, or saveframe to look for.
index - Start searching back from this point in the vector.
See Also:
java.util.Vector.lastIndexOf

elementAt

public StarNode elementAt(int index)
Just like the Vector method of the same name. Returns the item, loop, or saveframe object at the given index.
Parameters:
index - The index to return the item, loop, or saveframe at.
Returns:
The returned object is either an item, loop, or saveframe.
See Also:
java.util.Vector.elementAt

firstElement

public StarNode firstElement()
Just like the Vector method of the same name. Returns the first item. loop. or saveframe object in the file.
Returns:
The returned object is a item, loop, or saveframe.
See Also:
java.util.Vector.firstElement

lastElement

public StarNode lastElement()
Just like the Vector method of the same name. Returns the last item, loop, or saveframe object in the file.
Returns:
The returned object is a item, loop, or saveframe
See Also:
java.util.Vector.lastElement

setElementAt

public void setElementAt(java.lang.Object obj,
                         int index)
                  throws WrongElementType
Just like the Vector method of the same name. Clobbers the item, loop, or saveframe at the given index with the object given.
Parameters:
obj - The item, loop, or saveframe to set it to.
index - the position to replace.
See Also:
java.util.Vector.setElementAt

removeElementAt

public void removeElementAt(int index)
Similar to the Vector method of the same name. Deletes the item, loop, or saveframe at the given index from the block node
Parameters:
index - the position to remove.
See Also:
java.util.Vector.removeElementAt

insertElementAt

public void insertElementAt(java.lang.Object obj,
                            int index)
                     throws WrongElementType
Just like the Vector method of the same name. Inserts an item, loop, or saveframe at the position given.
Parameters:
obj - The item, loop, or saveframe to insert.
index - the position to insert it in from of.
See Also:
java.util.Vector.insertElementAt

addElement

public void addElement(java.lang.Object obj)
                throws WrongElementType
Just like the Vector method of the same name. Adds an item, loop or saveframe to the end of the list.
Parameters:
obj - The item, loop, or saveframe to add.
See Also:
java.util.Vector.addElement

removeElement

public boolean removeElement(java.lang.Object obj)
Just like the Vector method of the same name. Removes the item, loop, or saveframe matching the one given.
Parameters:
obj - The item, loop, or saveframe to remove.
See Also:
java.util.Vector.removeElement

searchByName

public VectorCheckType searchByName(java.lang.String searchFor)
Given a tag name, find the AST object it resides in. It returns a reference to the lowest level AST object that the tag resides in. The caller needs to use the type-aware features of Java to discover what the object's type really is. The search for names is case-insensitive
Overrides:
searchByName in class StarNode
Parameters:
searchFor - - Look for this String as the tag name.

searchByTagValue

public VectorCheckType searchByTagValue(java.lang.String tag,
                                        java.lang.String value)
Given a tag name and a value, find the AST object that that particular tag and value pair resides in. This is like performing an SQL search: WHERE tag = value.

Only searches starting at the node it was called from, and its children. Recurses downward, but does not recurse upward. This function is only capable of returning one answer, so it cannot be called at the same levels where searchByTag() can be called (see above).

The search for 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. Set to DataValueNode.DONT_CARE if it doesn't matter.
Returns:
A java.util.vector containing the matching StarNodes. This vector will have a size of zero if there are no matches.

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