Class ParseTable

java.lang.Object
  |
  +--ParseTable

public class ParseTable
extends java.lang.Object

This class parses string row input data into data for a spot element. It is similar to StringTokenizer class except the null is returned for each token field when there are multiple delimiters repeated. Also, for now, a single character is the delimiter.

This work was produced by Peter Lemkin of the National Cancer Institute, an agency of the United States Government. As a work of the United States Government there is no associated copyright. It is offered as open source software under the Mozilla Public License (version 1.1) subject to the limitations noted in the accompanying LEGAL file.

Version:
$Date: 2002/10/14 19:22:30 $ $Revision: 1.6 $
Author:
P. Lemkin (NCI), G. Thornwall (SAIC), NCI-Frederick, Frederick, MD
See Also:
MAExplorer Home

Field Summary
private static int delim
          delimiter character
private static boolean doneFlag
          Done parsing flag
(package private) static java.lang.String nullStr
          string to return if see a null input string
(package private) static java.lang.String str
          Input working string
private static char[] tokBuf
          token assembly buf - alloc once
 
Constructor Summary
ParseTable(int t)
          ParseTable() - constructor to create empty unnamed table
ParseTable(int t, java.lang.String ns)
          ParseTable() - constructor to create empty named table
 
Method Summary
 int countTokens(java.lang.String line)
          countTokens() - count tokens in the string
static int getAllDelimTokens(java.lang.String line, java.lang.String[] tokArray, boolean rmvTrailingWhiteSpaceFlag)
          getAllDelimTokens() - get array of all delimited tokens into tokArray[].
static int getDelimTokens(java.lang.String line, boolean[] useTokFlag, java.lang.String[] tokArray, boolean rmvTrailingWhiteSpaceFlag, java.lang.String missingDataStr)
          getDelimTokens() - get array of delimited tokens into tokArray[].
 java.lang.String getString()
          getString() - get current string str
 boolean hasMoreTokens()
          hasMoreTokens() - return true if more tokens in string
 java.lang.String nextToken()
          nextToken() - get and return next token.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

str

static java.lang.String str
Input working string

nullStr

static java.lang.String nullStr
string to return if see a null input string

delim

private static int delim
delimiter character

doneFlag

private static boolean doneFlag
Done parsing flag

tokBuf

private static char[] tokBuf
token assembly buf - alloc once
Constructor Detail

ParseTable

public ParseTable(int t)
ParseTable() - constructor to create empty unnamed table
Parameters:
t - is delimiter between fields and data in rows

ParseTable

public ParseTable(int t,
                  java.lang.String ns)
ParseTable() - constructor to create empty named table
Parameters:
t - is delimiter between fields and data in rows
ns - is value to use for "null string"
Method Detail

getAllDelimTokens

public static int getAllDelimTokens(java.lang.String line,
                                    java.lang.String[] tokArray,
                                    boolean rmvTrailingWhiteSpaceFlag)
getAllDelimTokens() - get array of all delimited tokens into tokArray[]. If there is no more data, it will leave those cells in tokArray[0:tokArray.length-1] set to "".
Parameters:
line - is the source string
tokArray - is the array to return the data
rmvTrailingWhiteSpaceFlag - if trailing white space is to be removed
Returns:
number of columns found else 0

getDelimTokens

public static int getDelimTokens(java.lang.String line,
                                 boolean[] useTokFlag,
                                 java.lang.String[] tokArray,
                                 boolean rmvTrailingWhiteSpaceFlag,
                                 java.lang.String missingDataStr)
getDelimTokens() - get array of delimited tokens into tokArray[]. The number of expected columns is specified and if there is no more data, it will leave those cells tokArray[0:useTokFlag.length-1] set to null. If useTokFlag[] is null, then return all tokens.
Parameters:
line - is the source string
useTokFlag - is a list of tokens to get. Set un-needed tokens false to speedup or all if this is null
tokArray - is the array of returned data
rmvTrailingWhiteSpaceFlag - to remove trailing white space
missingDataStr - to use if missing data
Returns:
number of columns found else 0

countTokens

public int countTokens(java.lang.String line)
countTokens() - count tokens in the string
Parameters:
line - is string to analyze
Returns:
number of tokens in the string

hasMoreTokens

public boolean hasMoreTokens()
hasMoreTokens() - return true if more tokens in string
Returns:
true if more tokens to read

nextToken

public java.lang.String nextToken()
nextToken() - get and return next token.
Returns:
"" if no more tokens and set done flag to true.

getString

public java.lang.String getString()
getString() - get current string str
Returns:
current string