com.conradroche.matra.data
Class ParseableData

java.lang.Object
  |
  +--com.conradroche.matra.data.Data
        |
        +--com.conradroche.matra.data.ParseableData
Direct Known Subclasses:
DTDData

public class ParseableData
extends Data

Author:
Conrad Roche Class created by refactoring the Data class. It contains parsing related methods.

Fields inherited from class com.conradroche.matra.data.Data
CHAR_NOT_FOUND, END_OF_DATA_CHAR, FOUND_CHAR
 
Constructor Summary
ParseableData()
          ParseableData constructor.
ParseableData(java.lang.String strData)
          ParseableData constructor.
 
Method Summary
 java.lang.String getNextToken()
          Read the next token, delimited by a whitespace, from the data stream.
 java.lang.String getNextToken(char delim)
          Read the next token, delimited by the specified delimiter, from the data stream.
 java.lang.String getNextToken(char[] delims)
          Read the next token, delimited by one of the specified delimiters, from the data stream.
static boolean isWhiteSpace(char c)
          Check if the given char is a whitespace.
 boolean nextStringEquals(char[] str)
          Check if the current location starts with the string specified.
 boolean nextStringEquals(java.lang.String str)
          Check if the current location starts with the string specified.
 boolean nextTokenEquals(char[] str)
          Checks if the next token, delimited by whitespace, is equal to the specified string (char array).
 boolean nextTokenEquals(java.lang.String str)
          Checks if the next token, delimited by whitespace, is equal to the specified string.
 void skipChars(char[] delims)
          Read from the data stream while the char is among the one specified.
 void skipChars(int numChars)
          Skip the next few chars.
 void skipWhiteSpace()
          Read from the data stream while the char is a whitespace character.
 
Methods inherited from class com.conradroche.matra.data.Data
checkNextChar, endOfData, getColumn, getCurrentLocation, getCurrentPosition, getNextChar, getPrevChar, getRemaining, getRow, length, lookNextChar, peekAhead, reset, rewind, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ParseableData

public ParseableData()
ParseableData constructor.

ParseableData

public ParseableData(java.lang.String strData)
ParseableData constructor.
Parameters:
StrData - The data to be parsed.
Method Detail

getNextToken

public java.lang.String getNextToken()
Read the next token, delimited by a whitespace, from the data stream.
Returns:
The next token.

nextStringEquals

public boolean nextStringEquals(java.lang.String str)
Check if the current location starts with the string specified.
Parameters:
str - The string to check against.
Returns:
true if the current location starts with the string specified; false otherwise.

nextStringEquals

public boolean nextStringEquals(char[] str)
Check if the current location starts with the string specified.
Parameters:
str - The string to check against.
Returns:
true if the current location starts with the string specified; false otherwise.

nextTokenEquals

public boolean nextTokenEquals(java.lang.String str)
Checks if the next token, delimited by whitespace, is equal to the specified string.
Parameters:
str - String to check the next token against.
Returns:
true if the next token in the data stream is equal to the string specified; false otherwise.

nextTokenEquals

public boolean nextTokenEquals(char[] str)
Checks if the next token, delimited by whitespace, is equal to the specified string (char array).
Parameters:
str - String to check the next token against.
Returns:
true if the next token in the data stream is equal to the string specified; false otherwise.

getNextToken

public java.lang.String getNextToken(char[] delims)
Read the next token, delimited by one of the specified delimiters, from the data stream.
Parameters:
delims - The list of delimiters for the Token.
Returns:
The next Token.

getNextToken

public java.lang.String getNextToken(char delim)
Read the next token, delimited by the specified delimiter, from the data stream.
Parameters:
delim - The delimiter for the Token.
Returns:
The next Token.

skipChars

public void skipChars(char[] delims)
Read from the data stream while the char is among the one specified.
Parameters:
delims - The list of characters to be skipped.

skipChars

public void skipChars(int numChars)
Skip the next few chars.
Parameters:
numChars - Number of characters to skip. 0 will not skip any characters. 1 will read and discard one charater.

skipWhiteSpace

public void skipWhiteSpace()
Read from the data stream while the char is a whitespace character.

isWhiteSpace

public static boolean isWhiteSpace(char c)
Check if the given char is a whitespace. Whitespace is defined as the space, tab, linefeed and carriage return characters.
Parameters:
c - The character to be checked.
Returns:
true if the char is a whitespace char; if not returns false.