Class ArgumentTokenizer

java.lang.Object
com.blackrook.engine.struct.ArgumentTokenizer

public class ArgumentTokenizer extends Object
String splitting class that parses strings by whitespace and quote wrapping (single, double, or "backtick") and returns them as different formats. Not threadsafe.
Author:
Matthew Tropiano
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an argument tokenizer.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Reads the next token and parses it as a boolean value.
    boolean
    nextBoolean(boolean blank)
    Reads the next token and parses it as a boolean value.
    byte
    Reads the next token and parses it as a byte value.
    byte
    nextByte(byte blank)
    Reads the next token and parses it as a byte value.
    char
    Reads the next token and parses it as a char value.
    char
    nextChar(char blank)
    Reads the next token and parses it as a char value.
    double
    Reads the next token and parses it as a double value.
    double
    nextDouble(double blank)
    Reads the next token and parses it as a double value.
    float
    Reads the next token and parses it as a float value.
    float
    nextFloat(float blank)
    Reads the next token and parses it as a float value.
    int
    Reads the next token and parses it as an integer value.
    int
    nextInt(int blank)
    Reads the next token and parses it as an integer value.
    long
    Reads the next token and parses it as a long value.
    long
    nextLong(long blank)
    Reads the next token and parses it as a long value.
    short
    Reads the next token and parses it as a short value.
    short
    nextShort(short blank)
    Reads the next token and parses it as a short value.
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ArgumentTokenizer

      public ArgumentTokenizer(CharSequence sequence)
      Creates an argument tokenizer.
      Parameters:
      sequence - the character sequence to parse.
  • Method Details

    • nextToken

      public String nextToken()
      Returns:
      the next token, or null if no more tokens could be parsed.
    • nextBoolean

      public boolean nextBoolean()
      Reads the next token and parses it as a boolean value.
      Returns:
      the next boolean value, or false if the token is not parseable or null.
    • nextBoolean

      public boolean nextBoolean(boolean blank)
      Reads the next token and parses it as a boolean value.
      Parameters:
      blank - the value to return if the value is not parseable or if at the end of the tokenizer.
      Returns:
      the next boolean value, or false if the token is not parseable or blank if null.
    • nextByte

      public byte nextByte()
      Reads the next token and parses it as a byte value.
      Returns:
      the next byte value, or 0 if the token is not parseable or null.
    • nextByte

      public byte nextByte(byte blank)
      Reads the next token and parses it as a byte value.
      Parameters:
      blank - the value to return if the value is not parseable or if at the end of the tokenizer.
      Returns:
      the next byte value, or 0 if the token is not parseable or blank if null.
    • nextShort

      public short nextShort()
      Reads the next token and parses it as a short value.
      Returns:
      the next short value, or 0 if the token is not parseable or null.
    • nextShort

      public short nextShort(short blank)
      Reads the next token and parses it as a short value.
      Parameters:
      blank - the value to return if the value is not parseable or if at the end of the tokenizer.
      Returns:
      the next short value, or 0 if the token is not parseable or blank if null.
    • nextChar

      public char nextChar()
      Reads the next token and parses it as a char value.
      Returns:
      the next char value, or '\0' if the token is not parseable or null.
    • nextChar

      public char nextChar(char blank)
      Reads the next token and parses it as a char value.
      Parameters:
      blank - the value to return if the value is not parseable or if at the end of the tokenizer.
      Returns:
      the next char value, or 0 if the token is not parseable or blank if null.
    • nextInt

      public int nextInt()
      Reads the next token and parses it as an integer value.
      Returns:
      the next integer value, or 0 if the token is not parseable or null.
    • nextInt

      public int nextInt(int blank)
      Reads the next token and parses it as an integer value.
      Parameters:
      blank - the value to return if the value is not parseable or if at the end of the tokenizer.
      Returns:
      the next integer value, or 0 if the token is not parseable or blank if null.
    • nextLong

      public long nextLong()
      Reads the next token and parses it as a long value.
      Returns:
      the next long value, or 0 if the token is not parseable or null.
    • nextLong

      public long nextLong(long blank)
      Reads the next token and parses it as a long value.
      Parameters:
      blank - the value to return if the value is not parseable or if at the end of the tokenizer.
      Returns:
      the next long value, or blank if the token is not parseable or blank if null.
    • nextFloat

      public float nextFloat()
      Reads the next token and parses it as a float value.
      Returns:
      the next float value, or 0f if the token is not parseable or null.
    • nextFloat

      public float nextFloat(float blank)
      Reads the next token and parses it as a float value.
      Parameters:
      blank - the value to return if the value is not parseable or if at the end of the tokenizer.
      Returns:
      the next float value, or 0f if the token is not parseable or blank if null.
    • nextDouble

      public double nextDouble()
      Reads the next token and parses it as a double value.
      Returns:
      the next double value, or 0.0 if the token is not parseable or null.
    • nextDouble

      public double nextDouble(double blank)
      Reads the next token and parses it as a double value.
      Parameters:
      blank - the value to return if the value is not parseable or if at the end of the tokenizer.
      Returns:
      the next double value, or 0.0 if the token is not parseable or blank if null.