Package net.orbyfied.j8.util
Class StringReader
java.lang.Object
net.orbyfied.j8.util.StringReader
A class to help with reading/parsing
strings.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbranch()intclamp(int index) Clamps an index in to the minimum (0) and maximum (string length) index.collect()Collects until the end of the string.doublefloatintintcollectInt(int radix) longlongcollectLong(int radix) charcurrent()Returns the character at the current position orDONEif in an invalid position.voiddebugPrint(String s) voiddebugPrint(String s, PrintStream stream) static intgetDigit(char c, int radix) intindex()index(int i) static booleanisDigit(char c, int radix) charnext()Advances the position by 1 and returns the character orDONEif in an invalid position.charnext(int a) Advances the position byaand returns the character orDONEif in an invalid position.charpeek(int i) Get a character from the string relative to the current index.charpeekAt(int i) Get a character from the string by index.charprev()Decreases the position by 1 and returns the character orDONEif in an invalid position.charprev(int a) Decreases the position byaand returns the character orDONEif in an invalid position.split(char... chars) subForward(int from, int len) subFrom(int from, int len)
-
Field Details
-
DONE
public static final char DONECharacter to indicate EOF.- See Also:
-
-
Constructor Details
-
StringReader
Constructor. Creates a new string reader for the provided string from the provided index.- Parameters:
str- The string.index- The index.
-
StringReader
- See Also:
-
-
Method Details
-
clamp
public int clamp(int index) Clamps an index in to the minimum (0) and maximum (string length) index.- Parameters:
index- The index.- Returns:
- The clamped index.
-
peekAt
public char peekAt(int i) Get a character from the string by index. Clamped.- Parameters:
i- The index.- Returns:
- The character.
-
peek
public char peek(int i) Get a character from the string relative to the current index. Not clamped, rather returnsDONEif the index is in an invalid position.- Parameters:
i- The index.- Returns:
- The character or
DONE
-
next
public char next()Advances the position by 1 and returns the character orDONEif in an invalid position.- Returns:
- The character.
-
next
public char next(int a) Advances the position byaand returns the character orDONEif in an invalid position.- Parameters:
a- The amount to advance by.- Returns:
- The character.
-
prev
public char prev()Decreases the position by 1 and returns the character orDONEif in an invalid position.- Returns:
- The character.
-
prev
public char prev(int a) Decreases the position byaand returns the character orDONEif in an invalid position.- Parameters:
a- The amount to decrease by.- Returns:
- The character.
-
current
public char current()Returns the character at the current position orDONEif in an invalid position.- Returns:
- The character.
-
collect
Collects until the end of the string.- Returns:
- The string.
-
collect
-
collect
-
collect
-
collect
-
collect
-
pcollect
-
pcollect
-
split
-
index
public int index() -
index
-
getString
-
subForward
-
subFrom
-
branch
-
debugPrint
-
debugPrint
-
isDigit
public static boolean isDigit(char c, int radix) -
getDigit
public static int getDigit(char c, int radix) -
collectInt
public int collectInt(int radix) -
collectInt
public int collectInt() -
collectLong
public long collectLong(int radix) -
collectLong
public long collectLong() -
collectFloat
public float collectFloat() -
collectDouble
public double collectDouble()
-