EDU.bmrb.starlibj
Class DataValueNode

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

public class DataValueNode
extends StarNode
implements java.lang.Cloneable

DataValueNode is the class that stores a single value from the STAR tree. It is used for both loop values and the values associated with tags outside of loops. Making this a class instead of just a string allows for the handling of the delimiter type.


Field Summary
protected  short delimType
           
static short DONT_CARE
          delimiter type that indicates that you don't care about the delimiter type - only used for searches such as searchForType()
static short DOUBLE
          delimiter type that indicates that this is a doublequoted value (")
static short FRAMECODE
          delimiter type that indicates that this is a framecode value
protected  java.lang.String myStrVal
           
static short NON
          delimiter type that indicates that this is a nonquoted value.
static short SEMICOLON
          delimiter type that indicates that this is semicolon demilited (;)
static short SINGLE
          delimiter type that indicates that this is a singlequoted value (')
 
Fields inherited from class EDU.bmrb.starlibj.StarNode
colNum, lineNum, parent, preComment
 
Constructor Summary
DataValueNode(DataValueNode copyMe)
          Constructor - copy another DataValueNode.
DataValueNode(java.lang.String str)
          Constructor - all DataValueNodes must have a string value, so no provisions are made for a 'default' no-args constructor.
DataValueNode(java.lang.String str, short delim)
          Constructor - all DataValueNodes must have a string value, so no provisions are made for a 'default' no-args constructor.
 
Method Summary
 java.lang.Object clone()
          Allocates a new copy of me and returns a reference to it.
 short getDelimType()
          Returns the delimiter type of this value.
 java.lang.String getLabel()
          Alias for getValue
 java.lang.String getValue()
          Returns the string containing the value of this node.
 int myLongestStr()
          Useful for printing.
 void setDelimType(short setTo)
          Sets the delimiter type of this value.
 void setValue(java.lang.String newVal)
          Sets the string value for this node.
 void setValue(java.lang.String newVal, short newDelim)
          Sets the string for this value, and the delimiter.
 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, searchByName, searchByTagValue, searchForType, 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

DONT_CARE

public static short DONT_CARE
delimiter type that indicates that you don't care about the delimiter type - only used for searches such as searchForType()
See Also:
getDelimType

NON

public static short NON
delimiter type that indicates that this is a nonquoted value.
See Also:
getDelimType

DOUBLE

public static short DOUBLE
delimiter type that indicates that this is a doublequoted value (")
See Also:
getDelimType

SINGLE

public static short SINGLE
delimiter type that indicates that this is a singlequoted value (')
See Also:
getDelimType

SEMICOLON

public static short SEMICOLON
delimiter type that indicates that this is semicolon demilited (;)
See Also:
getDelimType

FRAMECODE

public static short FRAMECODE
delimiter type that indicates that this is a framecode value
See Also:
getDelimType

myStrVal

protected java.lang.String myStrVal

delimType

protected short delimType
Constructor Detail

DataValueNode

public DataValueNode(java.lang.String str)
              throws BadValueForDelimiter
Constructor - all DataValueNodes must have a string value, so no provisions are made for a 'default' no-args constructor. The delimiter type will be chosen as the first delimiter type that is valid for the string value. It will try all the types of delimiter until a valid type is found, using the following order to try them in:
  1. NON
  2. DOUBLE
  3. SINGLE
  4. SEMICOLON
Throws:
BadValueForDelimiter - (Should theoretically never be thrown, since a Semicolon string should accept any data and it should at least be able to use a semicolon delimiter for everything. If you ever see this exception, it indicates a programming error within the starlibj itself.)

DataValueNode

public DataValueNode(java.lang.String str,
                     short delim)
              throws BadValueForDelimiter
Constructor - all DataValueNodes must have a string value, so no provisions are made for a 'default' no-args constructor.
Parameters:
str - The string to set the value to.
delim - The delimiter type to set the value to.

DataValueNode

public DataValueNode(DataValueNode copyMe)
Constructor - copy another DataValueNode.
Method Detail

getDelimType

public short getDelimType()
Returns the delimiter type of this value. Note that the delimiter type of this value determines what kind of delimiter is used by this value. The delimiter itself is not inlcuded as part of the value string. So a value that appears as "sample value" in the STAR file will contain sample value in the string, and will be of delimiter type DOUBLE. This is true for all the value types, including framecodes (the dollarsign is not part of the string value itself).
Returns:
NON, DOUBLE, SINGLE, SEMICOLON, or FRAMECODE

setDelimType

public void setDelimType(short setTo)
                  throws BadValueForDelimiter
Sets the delimiter type of this value. Lets the programmer choose a delimiter type for this value.
Throws:
BadValueForDelimiter - Throws this exception if the delimiter type is incorrect for the given type of string (for example, if a string with whitespace is given a delimiter type of "NON", that's an error.)

getValue

public java.lang.String getValue()
Returns the string containing the value of this node. All values are stored as strings, even numbers. If you desire to look at the value as a number, there are many Java methods that will let you convert strings to numbers on-the-fly.

setValue

public void setValue(java.lang.String newVal)
              throws BadValueForDelimiter
Sets the string value for this node.
Throws:
BadValueForDelimiter - The string value is not acceptable for the delimiter the value has. If you are intending to change the delimiter too in the next statement, try changing the delimiter *first*, or use the method to change both at once setValAndDelim
See Also:
setValAndDelim()

setValue

public void setValue(java.lang.String newVal,
                     short newDelim)
              throws BadValueForDelimiter
Sets the string for this value, and the delimiter.
Throws:
BadValueForDelimiter - The string value is not acceptable for the delimiter given..

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()
Alias for getValue

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

myLongestStr

public int myLongestStr()
Useful for printing.