Package net.orbyfied.j8.util
Class Reader<T>
java.lang.Object
net.orbyfied.j8.util.Reader<T>
- Type Parameters:
T- The type the sequence serves.
A class which sequentially reads.
data from a sequence.
-
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.current()Returns the data at the current position ornullif in an invalid position.intindex()index(int i) next()Advances the position by 1 and returns the data ornullif in an invalid position.next(int a) Advances the position byaand returns the data ornullif in an invalid position.peek(int i) Get a data from the string relative to the current index.peekAt(int i) Get a data from the string by index.prev()Decreases the position by 1 and returns the data ornullif in an invalid position.prev(int a) Decreases the position byaand returns the data ornullif in an invalid position.subForward(int from, int len) subFrom(int from, int len)
-
Constructor Details
-
Reader
Constructor. Creates a new string reader for the provided string from the provided index.- Parameters:
str- The string.index- The index.
-
Reader
- 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
Get a data from the string by index. Clamped.- Parameters:
i- The index.- Returns:
- The data.
-
peek
Get a data from the string relative to the current index. Not clamped, rather returnsnullif the index is in an invalid position.- Parameters:
i- The index.- Returns:
- The data or
null
-
next
Advances the position by 1 and returns the data ornullif in an invalid position.- Returns:
- The data.
-
next
Advances the position byaand returns the data ornullif in an invalid position.- Parameters:
a- The amount to advance by.- Returns:
- The data.
-
prev
Decreases the position by 1 and returns the data ornullif in an invalid position.- Returns:
- The data.
-
prev
Decreases the position byaand returns the data ornullif in an invalid position.- Parameters:
a- The amount to decrease by.- Returns:
- The data.
-
current
Returns the data at the current position ornullif in an invalid position.- Returns:
- The data.
-
collect
Collects until the end of the string.- Returns:
- The string.
-
collect
-
collect
-
collect
-
collect
-
collect
-
pcollect
-
pcollect
-
split
-
index
public int index() -
index
-
getSequence
-
subForward
-
subFrom
-
branch
-