Class Reader<T>

java.lang.Object
net.orbyfied.j8.util.Reader<T>
Type Parameters:
T - The type the sequence serves.

public class Reader<T> extends Object
A class which sequentially reads. data from a sequence.
  • Constructor Details

    • Reader

      public Reader(Sequence<T> str, int index)
      Constructor. Creates a new string reader for the provided string from the provided index.
      Parameters:
      str - The string.
      index - The index.
    • Reader

      public Reader(Sequence<T> 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 T peekAt(int i)
      Get a data from the string by index. Clamped.
      Parameters:
      i - The index.
      Returns:
      The data.
    • peek

      public T peek(int i)
      Get a data from the string relative to the current index. Not clamped, rather returns null if the index is in an invalid position.
      Parameters:
      i - The index.
      Returns:
      The data or null
    • next

      public T next()
      Advances the position by 1 and returns the data or null if in an invalid position.
      Returns:
      The data.
    • next

      public T next(int a)
      Advances the position by a and returns the data or null if in an invalid position.
      Parameters:
      a - The amount to advance by.
      Returns:
      The data.
    • prev

      public T prev()
      Decreases the position by 1 and returns the data or null if in an invalid position.
      Returns:
      The data.
    • prev

      public T prev(int a)
      Decreases the position by a and returns the data or null if in an invalid position.
      Parameters:
      a - The amount to decrease by.
      Returns:
      The data.
    • current

      public T current()
      Returns the data at the current position or null if in an invalid position.
      Returns:
      The data.
    • collect

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

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

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

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

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

      public String collect(Predicate<T> pred, Predicate<T> skip, Consumer<T> TEval)
    • pcollect

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

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

      public List<String> split(T... Ts)
    • index

      public int index()
    • index

      public Reader index(int i)
    • getSequence

      public Sequence<T> getSequence()
    • subForward

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

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

      public Reader branch()