Package org.wildfly.common.iteration
Class CodePointIterator
java.lang.Object
org.wildfly.common.iteration.CodePointIterator
- All Implemented Interfaces:
BiDirIntIterator,IndexIterator,IntIterator
A code point by code point iterator.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionasLatin1()Get a byte iterator over the latin-1 encoding of this code point iterator.asUtf8()Get a byte iterator over the UTF-8 encoding of this code point iterator.asUtf8(boolean escapeNul) Get a byte iterator over the UTF-8 encoding of this code point iterator.Base32-decode the current stream.base32Decode(Base32Alphabet alphabet) Base32-decode the current stream.base32Decode(Base32Alphabet alphabet, boolean requirePadding) Base32-decode the current stream.Base64-decode the current stream.base64Decode(Base64Alphabet alphabet) Base64-decode the current stream.base64Decode(Base64Alphabet alphabet, boolean requirePadding) Base64-decode the current stream.booleancontentEquals(String other) Determine if the remaining contents of this iterator are identical to the given string.final booleancontentEquals(CodePointIterator other) Determine if the remaining contents of this iterator are identical to the remaining contents of the other iterator.final CodePointIteratordelimitedBy(int... delims) Get a sub-iterator that is delimited by the given code points.Drain all the remaining code points in this iterator to the given string builder.drainTo(StringBuilder b, int delim, int n) Drain all the remaining code points in this iterator to the given string builder, inserting the given delimiter after everyncode points.drainTo(StringBuilder b, String prefix, int n) Drain all the remaining code points in this iterator to the given string builder, inserting the given prefix before everyncode points.drainTo(StringBuilder b, String prefix, int delim, int n) Drain all the remaining code points in this iterator to the given string builder, inserting the given prefix and delimiter before and after everyncode points, respectively.Drain all the remaining code points in this iterator to a new string.drainToString(int delim, int n) Drain all the remaining code points in this iterator to a new string, inserting the given delimiter after everyncode points.drainToString(String prefix, int n) Drain all the remaining code points in this iterator to a new string, inserting the given prefix before everyncode points.drainToString(String prefix, int delim, int n) Drain all the remaining code points in this iterator to a new string, inserting the given prefix and delimiter before and after everyncode points, respectively.abstract longgetIndex()Get the current offset, by code point.abstract booleanhasNext()Determine if there are more code points after the current code point.abstract booleanDetermine if there are more code points before the current code point.Hex-decode the current stream.final CodePointIteratorlimitedTo(long size) Return a copy of this iterator which is limited to the given number of code points after the current one.abstract intnext()Get the next code point.static CodePointIteratorofChars(char[] chars) Get a code point iterator for a character array.static CodePointIteratorofChars(char[] chars, int offs) Get a code point iterator for a character array.static CodePointIteratorofChars(char[] chars, int offs, int len) Get a code point iterator for a character array.static CodePointIteratorofLatin1Bytes(byte[] bytes) Get a code point iterator for a ISO-8859-1 (Latin-1) encoded array.static CodePointIteratorofLatin1Bytes(byte[] bytes, int offs, int len) Get a code point iterator for a ISO-8859-1 (Latin-1) encoded array.static CodePointIteratorGet a code point iterator for a string.static CodePointIteratorGet a code point iterator for a string.static CodePointIteratorofUtf8Bytes(byte[] bytes) Get a code point iterator for a UTF-8 encoded byte array.static CodePointIteratorofUtf8Bytes(byte[] bytes, int offs, int len) Get a code point iterator for a UTF-8 encoded array.abstract intpeekNext()Peek at the next code point without advancing.abstract intPeek at the previous code point without moving backwards.abstract intprevious()Get the previous code point.skip(IntPredicate predicate) Get a sub-iterator that removes code points based on apredicate.skipAll()Skip all the remaining code points in this iterator.skipCrLf()Get a sub-iterator that removes the following code points:10(\n) and13(\r).
-
Field Details
-
EMPTY
The empty code point iterator.
-
-
Method Details
-
hasNext
public abstract boolean hasNext()Determine if there are more code points after the current code point.- Specified by:
hasNextin interfaceBiDirIntIterator- Specified by:
hasNextin interfaceIntIterator- Returns:
trueif there are more code points,falseotherwise
-
hasPrevious
public abstract boolean hasPrevious()Determine if there are more code points before the current code point.- Specified by:
hasPreviousin interfaceBiDirIntIterator- Returns:
trueif there are more code points,falseotherwise
-
next
Get the next code point.- Specified by:
nextin interfaceBiDirIntIterator- Specified by:
nextin interfaceIntIterator- Returns:
- the next code point
- Throws:
NoSuchElementException- ifhasNext()returnsfalse
-
peekNext
Peek at the next code point without advancing.- Specified by:
peekNextin interfaceBiDirIntIterator- Specified by:
peekNextin interfaceIntIterator- Returns:
- the next code point
- Throws:
NoSuchElementException- ifhasNext()returnsfalse
-
previous
Get the previous code point.- Specified by:
previousin interfaceBiDirIntIterator- Returns:
- the previous code point
- Throws:
NoSuchElementException- ifhasPrevious()returnsfalse
-
peekPrevious
Peek at the previous code point without moving backwards.- Specified by:
peekPreviousin interfaceBiDirIntIterator- Returns:
- the previous code point
- Throws:
NoSuchElementException- ifhasPrevious()returnsfalse
-
getIndex
public abstract long getIndex()Get the current offset, by code point.- Specified by:
getIndexin interfaceIndexIterator- Returns:
- the code point offset
-
contentEquals
Determine if the remaining contents of this iterator are identical to the remaining contents of the other iterator. If the contents are not equal, the iterators will be positioned at the location of the first difference (i.e. the code point returned bynext()will be the differing code point. If the contents are equal, the iterators will both be positioned at the end of their contents.- Parameters:
other- the other byte iterator- Returns:
trueif the contents are equal,falseotherwise
-
contentEquals
Determine if the remaining contents of this iterator are identical to the given string. If the contents are not equal, the iterator will be positioned at the location of the first difference (i.e. the code point returned bynext()will be the differing code point. If the contents are equal, the iterator will be positioned at the end of its contents.- Parameters:
other- the other string- Returns:
trueif the contents are equal,falseotherwise
-
limitedTo
Return a copy of this iterator which is limited to the given number of code points after the current one. Advancing the returned iterator will also advance this one.- Parameters:
size- the number of code points- Returns:
- the limited code point iterator
-
delimitedBy
Get a sub-iterator that is delimited by the given code points. The returned iterator offset starts at 0 and cannot be backed up before that point. The returned iterator will returnfalseforhasNext()if the next character in the encapsulated iterator is a delimiter or if the underlying iterator returnsfalseforhasNext().- Parameters:
delims- the code point delimiters- Returns:
- the sub-iterator
-
drainTo
Drain all the remaining code points in this iterator to the given string builder.- Parameters:
b- the string builder- Returns:
- the same string builder
-
skipAll
Skip all the remaining code points in this iterator. (Useful in combination withdelimitedBy(int...))- Returns:
- the same code point iterator
-
drainTo
Drain all the remaining code points in this iterator to the given string builder, inserting the given prefix and delimiter before and after everyncode points, respectively.- Parameters:
b- the string builderprefix- the prefixdelim- the delimitern- the number of code points between each prefix and delimiter- Returns:
- the same string builder
-
drainTo
Drain all the remaining code points in this iterator to the given string builder, inserting the given delimiter after everyncode points.- Parameters:
b- the string builderdelim- the delimitern- the number of code points between each delimiter- Returns:
- the same string builder
-
drainTo
Drain all the remaining code points in this iterator to the given string builder, inserting the given prefix before everyncode points.- Parameters:
b- the string builderprefix- the prefixn- the number of code points between each prefix- Returns:
- the same string builder
-
drainToString
Drain all the remaining code points in this iterator to a new string.- Returns:
- the string
-
drainToString
Drain all the remaining code points in this iterator to a new string, inserting the given prefix and delimiter before and after everyncode points, respectively.- Parameters:
prefix- the prefixdelim- the delimitern- the number of code points between each prefix and delimiter- Returns:
- the string
-
drainToString
Drain all the remaining code points in this iterator to a new string, inserting the given delimiter after everyncode points.- Parameters:
delim- the delimitern- the number of code points between each delimiter- Returns:
- the string
-
drainToString
Drain all the remaining code points in this iterator to a new string, inserting the given prefix before everyncode points.- Parameters:
prefix- the prefixn- the number of code points between each prefix- Returns:
- the string
-
base64Decode
Base64-decode the current stream.- Parameters:
alphabet- the alphabet to userequirePadding-trueto require padding,falseif padding is optional- Returns:
- an iterator over the decoded bytes
-
base32Decode
Base32-decode the current stream.- Parameters:
alphabet- the alphabet to userequirePadding-trueto require padding,falseif padding is optional- Returns:
- an iterator over the decoded bytes
-
hexDecode
Hex-decode the current stream.- Returns:
- an iterator over the decoded bytes
-
base64Decode
Base64-decode the current stream.- Parameters:
alphabet- the alphabet to use- Returns:
- an iterator over the decoded bytes
-
base64Decode
Base64-decode the current stream.- Returns:
- an iterator over the decoded bytes
-
base32Decode
Base32-decode the current stream.- Parameters:
alphabet- the alphabet to use- Returns:
- an iterator over the decoded bytes
-
base32Decode
Base32-decode the current stream.- Returns:
- an iterator over the decoded bytes
-
asLatin1
Get a byte iterator over the latin-1 encoding of this code point iterator.- Returns:
- the byte iterator
-
asUtf8
Get a byte iterator over the UTF-8 encoding of this code point iterator.- Returns:
- the byte iterator
-
asUtf8
Get a byte iterator over the UTF-8 encoding of this code point iterator.- Parameters:
escapeNul-trueto escape NUL (0) characters as two bytes,falseto encode them as one byte- Returns:
- the byte iterator
-
ofString
Get a code point iterator for a string.- Parameters:
string- the string- Returns:
- the code point iterator
-
ofString
Get a code point iterator for a string.- Parameters:
string- the string- Returns:
- the code point iterator
-
ofChars
Get a code point iterator for a character array.- Parameters:
chars- the array- Returns:
- the code point iterator
-
ofChars
Get a code point iterator for a character array.- Parameters:
chars- the arrayoffs- the array offset- Returns:
- the code point iterator
-
ofChars
Get a code point iterator for a character array.- Parameters:
chars- the arrayoffs- the array offsetlen- the number of characters to include- Returns:
- the code point iterator
-
ofUtf8Bytes
Get a code point iterator for a UTF-8 encoded byte array.- Parameters:
bytes- the array- Returns:
- the code point iterator
-
ofUtf8Bytes
Get a code point iterator for a UTF-8 encoded array.- Parameters:
bytes- the arrayoffs- the array offsetlen- the number of characters to include- Returns:
- the code point iterator
-
ofLatin1Bytes
Get a code point iterator for a ISO-8859-1 (Latin-1) encoded array.- Parameters:
bytes- the array- Returns:
- the code point iterator
-
ofLatin1Bytes
Get a code point iterator for a ISO-8859-1 (Latin-1) encoded array.- Parameters:
bytes- the arrayoffs- the array offsetlen- the number of characters to include- Returns:
- the code point iterator
-
skipCrLf
Get a sub-iterator that removes the following code points:10(\n) and13(\r).- Returns:
- the code point iterator
-
skip
Get a sub-iterator that removes code points based on apredicate.- Parameters:
predicate- aIntPredicatethat evaluates the code points that should be skipper. Returning true from the predicate indicates that the code point must be skipped.- Returns:
- the code point iterator
-