jimmc.roots
Class StringParser

java.lang.Object
  |
  +--jimmc.roots.StringParser

public class StringParser
extends java.lang.Object

String parser parses a string into a series of smaller strings using shell-style rules: unquoted strings are broken at spaces, or strings can be quoted using double or single quotes. Backslash can be used to quote a single character, either within or outside of a string.


Constructor Summary
StringParser(java.lang.String input)
          Create a string parser.
 
Method Summary
protected  void addQuotedString(java.lang.StringBuffer sb, int quoteChar)
          Add characters within quotes to the buffer.
 java.lang.String getNextString()
          Get the next string from the input.
protected  boolean isEos()
          Return true if we are at the end of the string.
static void main(java.lang.String[] args)
          A main routine for testing.
protected  int nextChar()
          Get the next character from the string.
protected  int nextCharAfterWhiteSpace()
          Skip over white space, return next char.
 java.lang.String[] parse()
          Parse our string into an array of strings.
static java.lang.String[] parse(java.lang.String input)
          Convenience routine to parse a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringParser

public StringParser(java.lang.String input)
Create a string parser.
Method Detail

parse

public static java.lang.String[] parse(java.lang.String input)
Convenience routine to parse a string.

parse

public java.lang.String[] parse()
Parse our string into an array of strings.

getNextString

public java.lang.String getNextString()
Get the next string from the input.

addQuotedString

protected void addQuotedString(java.lang.StringBuffer sb,
                               int quoteChar)
Add characters within quotes to the buffer.

nextCharAfterWhiteSpace

protected int nextCharAfterWhiteSpace()
Skip over white space, return next char.
Returns:
first character after whitespace, or -1 on EOS.

nextChar

protected int nextChar()
Get the next character from the string.

isEos

protected boolean isEos()
Return true if we are at the end of the string.

main

public static void main(java.lang.String[] args)
A main routine for testing.