org.vmdb.hl7
Class StringList

java.lang.Object
  |
  +--org.vmdb.hl7.StringList
All Implemented Interfaces:
java.io.Serializable

public class StringList
extends java.lang.Object
implements java.io.Serializable

String List Modified String Tokenizer.

Description: HL7 Network Connectivity For VMDB.

Copyright: Copyright (c) 2002-2003.

Company: Veterinary Medical Database (VMDB).

More or less take over from the StringTokenizer class but with two modifications. First, two sequential tokens result in an empty string rather than no token. Second getIndex and setIndex allow saving and restoring state to allow roll-back of reading from the list.

See Also:
Serialized Form

Field Summary
static char NONE
          NULL character used to specify no escape character.
 
Constructor Summary
StringList(java.io.Reader rData, char cDelimiter)
          Construct a string list, splitting the data string with the delimiter character.
StringList(java.lang.String sData, char cDelimiter)
          Construct a string list, splitting the data string with the delimiter character.
 
Method Summary
 int getIndex()
          Get the current location of the string retrieval pointer as an integer.
 boolean hasMoreStrings()
          Test list for existence of one or more remaining tokens.
 void init(java.io.Reader rData, char cDelimiter)
          Populate this string list, splitting the data string with the delimiter character.
 void init(java.lang.String sData, char cDelimiter)
          Populate this string list, splitting the data string with the delimiter character.
 java.lang.String nextString()
          Get the next string from the list of tokenized strings.
 void setIndex(int iCurIndex)
          Return the current location pointer to a saved location.
 int size()
          Return the number of strings in the tokenized list.
 java.lang.String toString()
          This is mostly a debugging method.
 boolean undoNext()
          Move the pointer back one, having the effect of putting the last string retrieved back onto the list.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NONE

public static final char NONE
NULL character used to specify no escape character.

See Also:
Constant Field Values
Constructor Detail

StringList

public StringList(java.lang.String sData,
                  char cDelimiter)
Construct a string list, splitting the data string with the delimiter character.

Parameters:
sData - String to be tokenized
cDelimiter - char Character dividing the data into tokens.

StringList

public StringList(java.io.Reader rData,
                  char cDelimiter)
Construct a string list, splitting the data string with the delimiter character.

Parameters:
rData - Reader to be tokenized
cDelimiter - char Character dividing the data into tokens.
Method Detail

init

public void init(java.lang.String sData,
                 char cDelimiter)
Populate this string list, splitting the data string with the delimiter character.

Parameters:
sData - String to be tokenized
cDelimiter - char Character dividing the data into tokens.

init

public void init(java.io.Reader rData,
                 char cDelimiter)
Populate this string list, splitting the data string with the delimiter character.

Parameters:
cDelimiter - char Character dividing the data into tokens.

toString

public java.lang.String toString()
This is mostly a debugging method. It converts the string list to one line per token format.

Overrides:
toString in class java.lang.Object
Returns:
String in one line per token format.

hasMoreStrings

public boolean hasMoreStrings()
Test list for existence of one or more remaining tokens.

Returns:
true if any more strings remain to be returned.

nextString

public java.lang.String nextString()
Get the next string from the list of tokenized strings.

Returns:
next string.

undoNext

public boolean undoNext()
Move the pointer back one, having the effect of putting the last string retrieved back onto the list.

Returns:
true if the pointer could be moved back or false if it was already at the beginning of the list.

size

public int size()
Return the number of strings in the tokenized list.

Returns:
integer number of strings.

getIndex

public int getIndex()
Get the current location of the string retrieval pointer as an integer.

This can be saved and used later to undo a number of nextString() calls. The effect is of bookmarking a location.

Returns:
integer position in list.

setIndex

public void setIndex(int iCurIndex)
Return the current location pointer to a saved location.

Parameters:
iCurIndex - int saved from a call to getIndex()

SourceForge.net Logo