Class ArgumentTokenizer
java.lang.Object
com.blackrook.engine.struct.ArgumentTokenizer
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 -
Method Summary
Modifier and TypeMethodDescriptionbooleanReads the next token and parses it as a boolean value.booleannextBoolean(boolean blank) Reads the next token and parses it as a boolean value.bytenextByte()Reads the next token and parses it as a byte value.bytenextByte(byte blank) Reads the next token and parses it as a byte value.charnextChar()Reads the next token and parses it as a char value.charnextChar(char blank) Reads the next token and parses it as a char value.doubleReads the next token and parses it as a double value.doublenextDouble(double blank) Reads the next token and parses it as a double value.floatReads the next token and parses it as a float value.floatnextFloat(float blank) Reads the next token and parses it as a float value.intnextInt()Reads the next token and parses it as an integer value.intnextInt(int blank) Reads the next token and parses it as an integer value.longnextLong()Reads the next token and parses it as a long value.longnextLong(long blank) Reads the next token and parses it as a long value.shortReads the next token and parses it as a short value.shortnextShort(short blank) Reads the next token and parses it as a short value.
-
Constructor Details
-
ArgumentTokenizer
Creates an argument tokenizer.- Parameters:
sequence- the character sequence to parse.
-
-
Method Details
-
nextToken
- Returns:
- the next token, or
nullif 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
falseif the token is not parseable ornull.
-
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
falseif the token is not parseable orblankifnull.
-
nextByte
public byte nextByte()Reads the next token and parses it as a byte value.- Returns:
- the next byte value, or
0if the token is not parseable ornull.
-
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
0if the token is not parseable orblankifnull.
-
nextShort
public short nextShort()Reads the next token and parses it as a short value.- Returns:
- the next short value, or
0if the token is not parseable ornull.
-
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
0if the token is not parseable orblankifnull.
-
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 ornull.
-
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
0if the token is not parseable orblankifnull.
-
nextInt
public int nextInt()Reads the next token and parses it as an integer value.- Returns:
- the next integer value, or
0if the token is not parseable ornull.
-
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
0if the token is not parseable orblankifnull.
-
nextLong
public long nextLong()Reads the next token and parses it as a long value.- Returns:
- the next long value, or
0if the token is not parseable ornull.
-
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
blankif the token is not parseable orblankifnull.
-
nextFloat
public float nextFloat()Reads the next token and parses it as a float value.- Returns:
- the next float value, or
0fif the token is not parseable ornull.
-
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
0fif the token is not parseable orblankifnull.
-
nextDouble
public double nextDouble()Reads the next token and parses it as a double value.- Returns:
- the next double value, or
0.0if the token is not parseable ornull.
-
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.0if the token is not parseable orblankifnull.
-