Class StringReader

java.lang.Object
net.orbyfied.j8.util.StringReader

public class StringReader extends Object
A class to help with reading/parsing strings.
  • Field Details

  • Constructor Details

    • StringReader

      public StringReader(String str, int index)
      Constructor. Creates a new string reader for the provided string from the provided index.
      Parameters:
      str - The string.
      index - The index.
    • StringReader

      public StringReader(String str)
      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 returns DONE if 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 or DONE if in an invalid position.
      Returns:
      The character.
    • next

      public char next(int a)
      Advances the position by a and returns the character or DONE if 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 or DONE if in an invalid position.
      Returns:
      The character.
    • prev

      public char prev(int a)
      Decreases the position by a and returns the character or DONE if 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 or DONE if in an invalid position.
      Returns:
      The character.
    • collect

      public String collect()
      Collects until the end of the string.
      Returns:
      The string.
    • collect

      public String collect(Predicate<Character> pred, int offEnd)
    • collect

      public String collect(Predicate<Character> pred)
    • collect

      public String collect(Predicate<Character> pred, Predicate<Character> skip, int offEnd)
    • collect

      public String collect(Predicate<Character> pred, Predicate<Character> skip)
    • collect

      public String collect(Predicate<Character> pred, Predicate<Character> skip, Consumer<Character> charEval)
    • pcollect

      public String pcollect(Predicate<Character> pred)
    • pcollect

      public String pcollect(Predicate<Character> pred, Predicate<Character> skip)
    • split

      public List<String> split(char... chars)
    • index

      public int index()
    • index

      public StringReader index(int i)
    • getString

      public String getString()
    • subForward

      public StringReader subForward(int from, int len)
    • subFrom

      public StringReader subFrom(int from, int len)
    • branch

      public StringReader branch()
    • debugPrint

      public void debugPrint(String s, PrintStream stream)
    • debugPrint

      public void debugPrint(String s)
    • 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()