pds.label
Class PDSElement

java.lang.Object
  |
  +--pds.label.PDSElement

public class PDSElement
extends java.lang.Object

PDSElement is a class that contains a single definition or line as specified in the PDS Object Defnition Language (ODL). In this context a line may be an simple line of text, a block of commented text, or a keyword/value pair. A value may extend over more than one physical line if it is quoted or part of a value set.

Since:
1.0

Field Summary
 java.lang.String mComment
          The comment text found within the element.
 java.lang.String mKeyword
          The text found before the equal sign of an element.
 int mLineCount
          The count of the number of physical lines parsed into this element
 int mMaxLength
          Maximum line length when printing.
 java.lang.String mRaw
          The raw line as read from the file.
 boolean mSyntaxError
          Indicates whether a symtax error occurred will parsing or reading a line.
 int mType
          The basic type of the value.
 java.util.ArrayList mValue
          An array containing a PDSValue object for each value following the equal sign in the element.
static int TYPE_NONE
          Unspecified grouping type.
static int TYPE_ORDERED
          Ordered list of values.
static int TYPE_UNORDERED
          An unordered list of values.
 
Constructor Summary
PDSElement()
          Creates an instance of a PDSElement
 
Method Summary
 pds.label.PDSElement copy()
          Create a copy of the element and return a new instance of a PDSElement.
 boolean parse(java.io.FileInputStream file)
          Parses the next element from a file stream.
 boolean parseValue(java.lang.String buffer)
          Parses a string as a value according to the PDS Object Defnition Language (ODL).
 void print(int indent, int equal, int level)
          Print the element according to PDS specifications for label files to Syste.out.
 void print(java.io.PrintStream out, int indent, int equal, int level)
          Print the element according to PDS specifications for label files.
 void printSpaces(java.io.PrintStream out, int count)
          Print a string of spaces to an output stream.
 java.lang.String readLine(java.io.FileInputStream file)
          Read the next element definition from an input file stream.
 java.lang.String units(int index)
          Returns the units associated with the value item in the value array that is assocaited with the given index.
 java.lang.String value(int index)
          Returns the value associated with the value item in the value array that is assocaited with the given index.
 int valueSize()
          Returns the number of values in the value list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_NONE

public static final int TYPE_NONE
Unspecified grouping type.

See Also:
Constant Field Values

TYPE_ORDERED

public static final int TYPE_ORDERED
Ordered list of values.

See Also:
Constant Field Values

TYPE_UNORDERED

public static final int TYPE_UNORDERED
An unordered list of values.

See Also:
Constant Field Values

mKeyword

public java.lang.String mKeyword
The text found before the equal sign of an element. If the element does not contain and equal sign the value is blank.


mValue

public java.util.ArrayList mValue
An array containing a PDSValue object for each value following the equal sign in the element. There may be any number of values.


mType

public int mType
The basic type of the value. Possible values include:
TYPE_NONE
Unspecified grouping type
TYPE_ORDERED
An ordered list of values
TYPE_UNORDERED
A unordered list of values


mComment

public java.lang.String mComment
The comment text found within the element. If the element does not contain a comment the vlaue is blank.


mRaw

public java.lang.String mRaw
The raw line as read from the file.


mMaxLength

public int mMaxLength
Maximum line length when printing. Really its 80 including the DOS style new line (2 bytes). All lines are wrapped if they exceed this length


mLineCount

public int mLineCount
The count of the number of physical lines parsed into this element


mSyntaxError

public boolean mSyntaxError
Indicates whether a symtax error occurred will parsing or reading a line.

Constructor Detail

PDSElement

public PDSElement()
Creates an instance of a PDSElement

Method Detail

parse

public boolean parse(java.io.FileInputStream file)
Parses the next element from a file stream. An element is a single definition or line as specified in the PDS Object Defnition Language (ODL). In this context a line may be an simple line of text, a block of commented text, or a keyword/value pair. A value may extend over more than one physical line if it is quoted or part of a value set.

Parameters:
file - the input file stream
Returns:
true if an element was parsed from the stream; false if the end of file or an error was encountered.
Since:
1.0
See Also:
FileInputStream

readLine

public java.lang.String readLine(java.io.FileInputStream file)
Read the next element definition from an input file stream. An element may extend over more than one physical line if it is quoted or part of a value set.

Parameters:
file - the input file stream
Returns:
true if an element was parsed from the stream; false if the end of file or an error was encountered.
Since:
1.0
See Also:
FileInputStream

parseValue

public boolean parseValue(java.lang.String buffer)
Parses a string as a value according to the PDS Object Defnition Language (ODL). In this context a value can be a stirng, literal or list of values. Lists may be ordered (enclosed in parenthesis () ) or unordered (enclosed in curly braces {} ). A value may extend over more than one physical line if it is quoted or part of a value set.

Parameters:
buffer - the string to parse as a value.
Returns:
true if an value was parsed from properly; false if the an error was encountered.
Since:
1.0

valueSize

public int valueSize()
Returns the number of values in the value list. An element may contain any number of values, including 0. For example, an element that is just comment text will have a value size of 0.

Returns:
the number of values in the value list.
Since:
1.0

value

public java.lang.String value(int index)
Returns the value associated with the value item in the value array that is assocaited with the given index. If the index is out of range a blank value is returned.

Parameters:
index - the index of the value to return.
Returns:
a string containing the value associated with the given index.
Since:
1.0

units

public java.lang.String units(int index)
Returns the units associated with the value item in the value array that is assocaited with the given index. If the index is out of range a blank value is returned.

Parameters:
index - the index of the value to return.
Returns:
a string containing the units associated with the given index.
Since:
1.0

copy

public pds.label.PDSElement copy()
Create a copy of the element and return a new instance of a PDSElement.

Returns:
a new instance of a PDSElement with the same content as this element.
Since:
1.0

print

public void print(int indent,
                  int equal,
                  int level)
Print the element according to PDS specifications for label files to Syste.out. The line that is output can be indented with the equal sign (when present) placed at a fixed position. The line is printed to System.out.

Parameters:
indent - the number of spaces to indent for each level.
equal - the number of spaces from the end of the indent to align the equal sign for elements which have a keyword and value.
level - the current level of indenting. The number of spaces the element will be indented is level*indent
Since:
1.0

print

public void print(java.io.PrintStream out,
                  int indent,
                  int equal,
                  int level)
Print the element according to PDS specifications for label files. The line that is output can be indented with the equal sign (when present) placed at a fixed position. The line is printed to System.out.

Parameters:
out - the stream to print the element to.
indent - the number of spaces to indent for each level.
equal - the number of spaces from the end of the indent to align the equal sign for elements which have a keyword and value.
level - the current level of indenting. The number of spaces the element will be indented is level*indent
Since:
1.0

printSpaces

public void printSpaces(java.io.PrintStream out,
                        int count)
Print a string of spaces to an output stream.

Parameters:
out - the stream to print the element to.
count - the number of spaces to print.
Since:
1.0