pds.util
Class PPITable

java.lang.Object
  |
  +--pds.util.PPITable

public class PPITable
extends java.lang.Object

PPITable is a class for reading and writing ASCII tables.

Since:
1.0

Field Summary
(package private)  java.lang.String[] mFieldName
          Array of field names
(package private)  java.lang.String[] mFieldValue
          Array of field Values
(package private)  java.io.FileInputStream mFile
          base file object
(package private)  java.io.BufferedReader mReader
          File object reader
(package private)  int mRecordAt
          Current record count
 
Constructor Summary
PPITable()
          Creates an instance.
 
Method Summary
 boolean close()
          Close a connection.
static boolean copy(java.lang.String source, java.lang.String destination)
          Copy a file from one location to another.
 java.lang.String getValue(int index)
          Return the value associated with a field given the index of the field.
 boolean open(java.lang.String pathName, boolean nameHeader)
          Open a table containing ASCII comma seperated values (CSV).
 java.lang.String[] parseLine(java.lang.String buffer)
          Parse a string, using a comma (",") as the delimiter.
 boolean readRecord()
          Read one record from a connection and parse the record into fields.
 int recordAt()
          Return the count of the number of records read from the table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mFile

java.io.FileInputStream mFile
base file object


mReader

java.io.BufferedReader mReader
File object reader


mFieldName

java.lang.String[] mFieldName
Array of field names


mFieldValue

java.lang.String[] mFieldValue
Array of field Values


mRecordAt

int mRecordAt
Current record count

Constructor Detail

PPITable

public PPITable()
Creates an instance.

Since:
1.0
Method Detail

open

public boolean open(java.lang.String pathName,
                    boolean nameHeader)
Open a table containing ASCII comma seperated values (CSV). Establishes a connection to a file that contains a table. The table may contain a header line which contains field names.

Parameters:
pathName - the path and name of the file containing the table of data.
nameHeader - if true the first line of the file is read, parsed and used to define the name of each field.. If false no header line is read and no names are defined for each field.
Returns:
true if the file was opened. false otherwise.
Since:
1.0

close

public boolean close()
Close a connection.

Returns:
true if the connection to the source was closed properly. false otherwise.
Since:
1.0

readRecord

public boolean readRecord()
Read one record from a connection and parse the record into fields.

Returns:
true if read was successful false otherwise.
Since:
1.0

recordAt

public int recordAt()
Return the count of the number of records read from the table.

Returns:
the count of the number of records read from the table.
Since:
1.0

parseLine

public java.lang.String[] parseLine(java.lang.String buffer)
Parse a string, using a comma (",") as the delimiter. After parsing the string removes any leading and trailing spaces around each constitute part.

Returns:
an array of String containing the constitute parts.
Since:
1.0

getValue

public java.lang.String getValue(int index)
Return the value associated with a field given the index of the field.

Parameters:
index - the index of the field for which to extract the value.
Returns:
a String containing the value in the field.
Since:
1.0

copy

public static boolean copy(java.lang.String source,
                           java.lang.String destination)
Copy a file from one location to another. The copy is failure safe in that if the copy fails to complete the destination is not over written.

Parameters:
source - the name of the source file.
destination - the name of the file to copy the source file to.
Returns:
true if the copy is successful. false otherwise.
Since:
1.0