pds.label
Class PDSElement

java.lang.Object
  extended by 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.
 char[] 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_BLANK_LINE
          A blank line
static int TYPE_COMMENT
          A comment
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
PDSElement(int line)
          Creates an instance of a PDSElement
 
Method Summary
 void clear()
          Clears an element and set it to an initial state
 PDSElement copy()
          Create a copy of the element and return a new instance of a PDSElement.
 void deleteString(char[] cbuff, int start, int end)
           
 void dump(java.io.PrintStream out)
          Dump all information about an element.
 int indexOf(char[] cbuff, char c)
           
 boolean isObject()
          Determines if an element is an "OBJECT".
 boolean isSpace(int c)
          Determines if a character is a white space character.
 boolean parse(java.io.BufferedReader reader)
          Parses the next element from a file stream.
 boolean parseValue(char[] cbuff, int startAt)
          Parses a string as a value according to the PDS Object Defnition Language (ODL).
 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.
 char[] readLine(java.io.BufferedReader reader)
          Read the next element definition from an input file stream.
 boolean setValue(java.lang.String buffer)
          Sets the value of an element.
 boolean setValue(java.lang.String buffer, int type)
          Sets the value of an element and set the type of the value.
 int strlen(char[] cbuff)
           
 int strlen(char[] cbuff, int startAt)
           
 void trimSpace(char[] cbuff)
          Trims the leading and trailing white space from a character array.
 void trimSpace(char[] cbuff, int startAt)
          Trims the leading and trailing white space from a character array.
 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.
 java.lang.String valueString()
          Create a string representation of the value.
 java.lang.String valueString(boolean plain)
          Create a string representation of the value.
 java.lang.String valueString(boolean plain, boolean odl)
          Create a string representation of the value.
 
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

TYPE_BLANK_LINE

public static final int TYPE_BLANK_LINE
A blank line

See Also:
Constant Field Values

TYPE_COMMENT

public static final int TYPE_COMMENT
A comment

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 char[] 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


PDSElement

public PDSElement(int line)
Creates an instance of a PDSElement

Method Detail

clear

public void clear()
Clears an element and set it to an initial state


parse

public boolean parse(java.io.BufferedReader reader)
              throws PDSException
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:
reader - 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.
Throws:
PDSException
Since:
1.0
See Also:
FileInputStream

indexOf

public int indexOf(char[] cbuff,
                   char c)

deleteString

public void deleteString(char[] cbuff,
                         int start,
                         int end)

strlen

public int strlen(char[] cbuff)

strlen

public int strlen(char[] cbuff,
                  int startAt)

readLine

public char[] readLine(java.io.BufferedReader reader)
                throws PDSException
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:
reader - 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.
Throws:
PDSException
Since:
1.0
See Also:
FileInputStream

trimSpace

public void trimSpace(char[] cbuff)
Trims the leading and trailing white space from a character array. White space characters are tab, space, new line, return.

Parameters:
cbuff - the character array to trim.
Since:
1.0

trimSpace

public void trimSpace(char[] cbuff,
                      int startAt)
Trims the leading and trailing white space from a character array. White space characters are tab, space, new line, return.

Parameters:
cbuff - the character array to trim.
Since:
1.0

isSpace

public boolean isSpace(int c)
Determines if a character is a white space character. White space characters are tab, space, new line, return.

Parameters:
c - the character to check.
Returns:
true if the character is white space; false otherwise.
Since:
1.0

isObject

public boolean isObject()
Determines if an element is an "OBJECT".

Returns:
true if element is an OBJECT; false otherwise.
Since:
1.0

parseValue

public boolean parseValue(char[] cbuff,
                          int startAt)
                   throws PDSException
Parses a string as a value according to the PDS Object Defnition Language (ODL). In this context a value can be a string, 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.
Throws:
PDSException
Since:
1.0

setValue

public boolean setValue(java.lang.String buffer)
                 throws PDSException
Sets the value of an element. The type of the value is set to TYPE_NODE. Clears any currently set values.

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

setValue

public boolean setValue(java.lang.String buffer,
                        int type)
                 throws PDSException
Sets the value of an element and set the type of the value. Clears any currently set values.

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

parseValue

public boolean parseValue(java.lang.String buffer)
                   throws PDSException
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.
Throws:
PDSException
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 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

valueString

public java.lang.String valueString()
Create a string representation of the value.

Returns:
a String containing the formatted value.
Since:
1.0

valueString

public java.lang.String valueString(boolean plain)
Create a string representation of the value.

Parameters:
plain - flag indicating if the value is not to be adorned with appropriate quotation marks.
Returns:
a String containing the formatted value.
Since:
1.0

valueString

public java.lang.String valueString(boolean plain,
                                    boolean odl)
Create a string representation of the value.

Parameters:
plain - flag indicating if the value is not to be adorned with appropriate quotation marks.
odl - flag indicating if the value is to be formated with ODL syntax for lists.
Returns:
a String containing the formatted value.
Since:
1.0

dump

public void dump(java.io.PrintStream out)
Dump all information about an element.

Parameters:
out - the stream to print the element to.
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