|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--EDU.bmrb.starlibj.StarNode
StarNode is the generic class on which every other node in the STAR file tree is based. All nodes in the STAR tree are derived from StarNode. Some of the functionality is described in StarNode so that it can be guaranteed to always be there even when the type of StarNode is unknown. (You can searchByTag on any StarNode, whether you cast it to a specific type or not.)
Field Summary | |
protected int |
colNum
|
protected int |
lineNum
|
protected StarNode |
parent
|
protected java.lang.String |
preComment
|
Constructor Summary | |
StarNode()
Default Constructor. |
|
StarNode(StarNode copyMe)
Copy Constructor - deep copy. |
Method Summary | |
java.lang.Object |
clone()
Allocates a new copy (clone) of this StarNode and returns a reference to it. |
int |
getColNum()
Get the column number that this node was on in the original file. |
int |
getLineNum()
Get the line number that this node was on in the original file. |
StarNode |
getParallelCopy()
get parallelCopy is not really implemented yet. |
StarNode |
getParent()
Return the parent of this StarNode. |
java.lang.String |
getPreComment()
This functions are used to give each node in the AST tree the ability to remember a comment to be pasted into the file in front of that node. |
SkipTextHandler |
mySkips()
|
VectorCheckType |
searchByName(java.lang.String searchFor)
searchByName() will generate a list of all the places a particular name exists in this AST object. |
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. |
VectorCheckType |
searchForTypeByName(java.lang.Class type,
java.lang.String name)
Find all the occurrances where there is a node of the given type containing something with the given name. |
VectorCheckType |
searchForTypeByTagValue(java.lang.Class type,
java.lang.String tag,
java.lang.String value)
This is much like searchForTypeByTagValue() above, except that it looks for places where the given tag/value matches, and it contains the given value, then it looks to find a node of the given type that the match is inside of. |
void |
setColNum(int num)
setColNum sets the column number from the text file for this node. |
void |
setLineNum(int num)
setLineNum sets the line number from the text file for this node. |
protected void |
setParent(StarNode p)
|
void |
setPeer(StarNode peer)
setPeer is not really implemented yet. |
void |
setPreComment(java.lang.String cmt)
|
void |
Unparse(int indent)
Unparse prints the contents of the StarNode object out to the given stream. |
Methods inherited from class java.lang.Object |
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
protected StarNode parent
protected int lineNum
protected int colNum
protected java.lang.String preComment
Constructor Detail |
public StarNode()
public StarNode(StarNode copyMe)
Method Detail |
public void Unparse(int indent)
public StarNode getParent()
public VectorCheckType searchByName(java.lang.String searchFor)
This search is fully recursive. All the parts of the star tree that exist below this point will also be searched. Therefore if you call a StarFileNode's searchByName(), you search the whole star file, while if you call a SaveFrameNode's searchByName() you search just that saveframe.
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.
searchFor
- the string name to look for.public VectorCheckType searchByTagValue(java.lang.String tag, java.lang.String 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 tag names is case-insensitive.
The search for values, however is case-sensitive.
tag
- - Look for this tag...value
- - Where it has this value.public VectorCheckType searchForType(java.lang.Class type, short delim)
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.
type
- - type to search fordelim
- - DataValueNode::ValType to look for. Default = "dont-care".public VectorCheckType searchForTypeByName(java.lang.Class type, java.lang.String name)
First, this method searches for the given string name, just like searchForName() does. Then looks to see if that node is of the type requested. If not, it looks at the parent node to see if it is of the type given. If not that, then it looks at the grandparent node, and so on up until it hits the root of the tree.
In general, this method can be thought of as meaning, "Search for the nodes of such-and-such a type that contain this name."
If a name is matched, but it is not contained in a node of the specified type, then that is not considered a match, and it is not returned.
The search for names is case-insensitive.
type
- - the type to search for.name
- - the name to search for.public VectorCheckType searchForTypeByTagValue(java.lang.Class type, java.lang.String tag, java.lang.String value)
The search for tag names is case-insensitive.
The search for values, however is case-sensitive.
type
- - the type to search for.tag
- - the tag name to search for.value
- - the value to search for.public StarNode getParallelCopy()
public void setPeer(StarNode peer)
public int getLineNum()
public void setLineNum(int num)
public int getColNum()
public void setColNum(int num)
public java.lang.String getPreComment()
The string must contain the comment characters embedded inside, like so: "# this is a\n# multiline comment.", not like this: "this is a\nmultiline comment." This is so that the caller is allowed to have the comment contain blank lines like this:
# This is an example comment. # The comment has some blank # lines in it.If the Unparse() function were designed to insert the comment characters (#) itself, then such a comment block would be impossible to create.
Note that the comment lines are not syntax-checked in any way, so using these functions it is entirely possible to create invalid STAR files, since these "comments" can really be strings with anything at all in them - so be careful.
To get rid of the preComment if you change your mind, set it to a zero-length string with setPreComment().
public void setPreComment(java.lang.String cmt)
public SkipTextHandler mySkips()
public java.lang.Object clone()
StarFileNode
protected void setParent(StarNode p)
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |