Overview | Package | Class | Tree | Index | Help NetCharts Pro (Applets) 7.0
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

netcharts.util
Class NFToken

java.lang.Object
  |
  +--netcharts.util.NFToken

public class NFToken
This class is used to tokenize any input stream for parameter processing purposes.


Constructor Summary
NFToken()
          Create a new tokenizer, using the given input stream.
 
Method Summary
void close()
          Close any existing input stream
static java.lang.StringBuffer doEscapes(java.lang.String str, java.lang.StringBuffer buf)
          This method appends the given string to the given string buffer, with all special characters escaped.
static java.lang.StringBuffer doEscapes(java.lang.String str, java.lang.StringBuffer buf, boolean allowQuotes)
          This method appends the given string to the given string buffer, with all special characters escaped.
void getAllUntil(char symbol, java.lang.StringBuffer buf)
          Appends all characters up until the given symbol (or the EOF) to the given buffer.
boolean getParamSymbol(char symbol)
          Returns true if the next non-whitespace character matches the given symbol.
static boolean isQuoted(java.lang.String str)
          Returns true if the given string is a quoted value according to the default symbol table.
boolean isWhiteSpace(int c)
          Returns true if the character is whitespace.
static int loadTable(java.lang.Object table, java.lang.Object input)
          Returns a generic input stream which may contain comment lines and lines with two values, separated by white space.
NFKeyValue nextStatement()
          Retrieves the next parameter definition from the input stream and returns a key/value pair, in which the key is a String parameter name and the value is a vector of String or StringBuffer tokens.
java.lang.StringBuffer nextToken()
          Get the next token from the input.
java.lang.StringBuffer nextToken(java.lang.StringBuffer buf)
          Get the next token from the input.
void setCharRange(int type, int first, int last)
          Sets the given character type for the range of characters.
void setCharType(int type, int c, int quote)
          Set the given character type for the character <c>.
void setInput(java.io.InputStream stream)
          Use the given stream as input, ignoring any previous input.
void setInput(java.io.InputStream stream, boolean useBufferedStream)
          Use the given stream as input, ignoring any previous input.
void setInput(NFTokenInput is)
          Use the given token stream as input, ignoring any previous input.
void setInput(java.lang.Object obj)
          Use the given object as the input, which must be one of the specific types accepted by the other setInput() methods.
void setInput(java.lang.String str)
          Use the given string as input, ignoring any previous input.
void setInput(java.lang.StringBuffer buf)
          Use the given string buffer as input, ignoring any previous input.
boolean skipComment()
          Skip any comment in the current input stream until the next semi-colon, carriage-return or newline character.
void skipWhiteSpace()
          Skip any whitespace in the input stream
static java.lang.String stripQuotes(java.lang.String str)
          Strip any surrounding quotes from the given string, returning a new string based on the default symbol table definition of a quote.
 

Constructor Detail

NFToken

public NFToken()
Create a new tokenizer, using the given input stream.
Method Detail

setInput

public void setInput(java.lang.String str)
Use the given string as input, ignoring any previous input.
Parameters:
str - The string to use as input.

setInput

public void setInput(java.lang.StringBuffer buf)
Use the given string buffer as input, ignoring any previous input.
Parameters:
buf - The stringbuffer to use as input.

setInput

public void setInput(java.io.InputStream stream)
Use the given stream as input, ignoring any previous input.
Parameters:
stream - The stream to use as input.

setInput

public void setInput(java.io.InputStream stream,
                     boolean useBufferedStream)
Use the given stream as input, ignoring any previous input.
Parameters:
stream - The stream to use as input.
useBufferedStream - If true, create a buffered stream on top of the stream.

setInput

public void setInput(NFTokenInput is)
Use the given token stream as input, ignoring any previous input.
Parameters:
is - The stream to use as input.

setInput

public void setInput(java.lang.Object obj)
Use the given object as the input, which must be one of the specific types accepted by the other setInput() methods.
Parameters:
obj - The input.

close

public void close()
Close any existing input stream

setCharType

public void setCharType(int type,
                        int c,
                        int quote)
Set the given character type for the character <c>. If the type is QUOTE, then <quote> is assigned as the endquote.
Parameters:
type - The type.
c - The character.
quote - The quote.

setCharRange

public void setCharRange(int type,
                         int first,
                         int last)
Sets the given character type for the range of characters.
Parameters:
type - The type.
first - The first character.
last - The last character.

nextToken

public java.lang.StringBuffer nextToken()
                                throws java.lang.Exception
Get the next token from the input.
Returns:
The next token.
Throws:
java.lang.Exception - If a tokenizing error occurs.

nextToken

public java.lang.StringBuffer nextToken(java.lang.StringBuffer buf)
                                throws java.lang.Exception
Get the next token from the input.
Parameters:
buf - The buffer to append the next token to.
Returns:
The next token.
Throws:
java.lang.Exception - If a tokenizing error occurs.

nextStatement

public NFKeyValue nextStatement()
                                       throws java.lang.Exception
Retrieves the next parameter definition from the input stream and returns a key/value pair, in which the key is a String parameter name and the value is a vector of String or StringBuffer tokens. If the EOF is reached, null is returned.
Returns:
The next statement.
Throws:
java.lang.Exception - If a tokenizing error occurs.

isQuoted

public static boolean isQuoted(java.lang.String str)
Returns true if the given string is a quoted value according to the default symbol table.
Parameters:
str - The string to check.
Returns:
true if the string is quoted, false otherwise.

stripQuotes

public static java.lang.String stripQuotes(java.lang.String str)
Strip any surrounding quotes from the given string, returning a new string based on the default symbol table definition of a quote.
Parameters:
str - The string to strip quotes from.
Returns:
The string with quotes stripped.

doEscapes

public static java.lang.StringBuffer doEscapes(java.lang.String str,
                                     java.lang.StringBuffer buf)
This method appends the given string to the given string buffer, with all special characters escaped. This method assumes that the given string may be quoted, in which case, the quote characters are not escaped.
Parameters:
str - The string to escape.
buf - The buffer to append the escaped string to.
Returns:
The escaped string.

doEscapes

public static java.lang.StringBuffer doEscapes(java.lang.String str,
                                     java.lang.StringBuffer buf,
                                     boolean allowQuotes)
This method appends the given string to the given string buffer, with all special characters escaped. If allowQuotes is true, then any surrounding quotes will not be escaped.
Parameters:
str - The string to escape.
buf - The buffer to append the escaped string to.
allowQuotes - Whether to allow quotes or not.
Returns:
The escaped string.

skipComment

public boolean skipComment()
                   throws java.lang.Exception
Skip any comment in the current input stream until the next semi-colon, carriage-return or newline character.
Returns:
true if successful, false otherwise.
Throws:
java.lang.Exception - If a tokenizing error occurs.

isWhiteSpace

public boolean isWhiteSpace(int c)
Returns true if the character is whitespace.
Parameters:
c - The character.
Returns:
true if the character is classified as white space, false otherwise.

skipWhiteSpace

public void skipWhiteSpace()
                   throws java.lang.Exception
Skip any whitespace in the input stream
Throws:
java.lang.Exception - If a tokenizing error occurs.

getParamSymbol

public boolean getParamSymbol(char symbol)
                      throws java.lang.Exception
Returns true if the next non-whitespace character matches the given symbol. If a match is found, the character is read. Otherwise, it is pushed back into the input stream
Parameters:
symbol - The character to match.
Returns:
true if the character matches, false otherwise.
Throws:
java.lang.Exception - If a tokenizing error occurs.

getAllUntil

public void getAllUntil(char symbol,
                        java.lang.StringBuffer buf)
                throws java.lang.Exception
Appends all characters up until the given symbol (or the EOF) to the given buffer.
Parameters:
symbol - The character to append until.
buf - The buffer to append to.
Throws:
java.lang.Exception - If a tokenizing error occurs.

loadTable

public static int loadTable(java.lang.Object table,
                            java.lang.Object input)
                    throws java.lang.Exception
Returns a generic input stream which may contain comment lines and lines with two values, separated by white space. Each key/value pair found is appended to the given table, which may be a Hashtable or Vector. The INPUT object can be any input type accepted by NFToken.
Parameters:
table - The table to add to.
input - The input.
Returns:
The number of key/value pairs found.
Throws:
java.lang.Exception - If a tokenizing error occurs.

Overview | Package | Class | Tree | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD


Visual Mining, Inc.
2099 Gaither Grove Rd.
Suite 220
Rockville, MD 20850
800.308.0731
301.947.8293 FAX

Copyright © Visual Mining, Inc. 1996 - 2010
All Rights Reserved.

NetCharts ProTM is a registered trademark of Visual Mining, Inc. Other brands and their products are trademarks of their respective holders.

Last Modified: Jun 29, 2010