Top Description Fields Constructors Methods
org.wildfly.common.iteration

public abstract Class CodePointIterator

extends Object
implements BiDirIntIterator, IndexIterator
Class Inheritance
All Implemented Interfaces
org.wildfly.common.iteration.IndexIterator, org.wildfly.common.iteration.BiDirIntIterator, org.wildfly.common.iteration.IntIterator
Known Direct Subclasses
org.wildfly.common.iteration.Latin1DecodingIterator, org.wildfly.common.iteration.LimitedCodePointIterator, org.wildfly.common.iteration.SkippingCodePointIterator, org.wildfly.common.iteration.StringIterator, org.wildfly.common.iteration.Utf8DecodingIterator, org.wildfly.common.iteration.DelimitedCodePointIterator, org.wildfly.common.iteration.Base16EncodingCodePointIterator, org.wildfly.common.iteration.Base32EncodingCodePointIterator, org.wildfly.common.iteration.Base64EncodingIterator, org.wildfly.common.iteration.CharArrayIterator
Imports
java.util.NoSuchElementException, java.util.function.IntPredicate, org.wildfly.common.codec.Base32Alphabet, .Base64Alphabet

A code point by code point iterator.

Field Summary

Modifier and TypeField and Description
public static final CodePointIterator
EMPTY

The empty code point iterator.

private static final char[]

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public ByteIterator

Returns:

the byte iterator
asLatin1
()

Get a byte iterator over the latin-1 encoding of this code point iterator.

public ByteIterator

Returns:

the byte iterator
asUtf8
()

Get a byte iterator over the UTF-8 encoding of this code point iterator.

public ByteIterator

Returns:

the byte iterator
asUtf8
(final boolean
true to escape NUL (0) characters as two bytes, false to encode them as one byte
escapeNul
)

Get a byte iterator over the UTF-8 encoding of this code point iterator.

public ByteIterator

Returns:

an iterator over the decoded bytes
base32Decode
(final Base32Alphabet
the alphabet to use
alphabet
,
boolean
true to require padding, false if padding is optional
requirePadding
)

Base32-decode the current stream.

public ByteIterator

Returns:

an iterator over the decoded bytes
base32Decode
(final Base32Alphabet
the alphabet to use
alphabet
)

Base32-decode the current stream.

public ByteIterator

Returns:

an iterator over the decoded bytes
base32Decode
()

Base32-decode the current stream.

public ByteIterator

Returns:

an iterator over the decoded bytes
base64Decode
(final Base64Alphabet
the alphabet to use
alphabet
,
boolean
true to require padding, false if padding is optional
requirePadding
)

Base64-decode the current stream.

public ByteIterator

Returns:

an iterator over the decoded bytes
base64Decode
(final Base64Alphabet
the alphabet to use
alphabet
)

Base64-decode the current stream.

public ByteIterator

Returns:

an iterator over the decoded bytes
base64Decode
()

Base64-decode the current stream.

public final boolean

Returns:

true if the contents are equal, false otherwise
contentEquals
(CodePointIterator
the other byte iterator
other
)

Determine if the remaining contents of this iterator are identical to the remaining contents of the other iterator.

public boolean

Returns:

true if the contents are equal, false otherwise
contentEquals
(String
the other string
other
)

Determine if the remaining contents of this iterator are identical to the given string.

public final CodePointIterator

Returns:

the sub-iterator
delimitedBy
(final int...
the code point delimiters
delims
)

Get a sub-iterator that is delimited by the given code points.

public StringBuilder

Returns:

the same string builder
drainTo
(StringBuilder
the string builder
b
)

Drain all the remaining code points in this iterator to the given string builder.

public StringBuilder

Returns:

the same string builder
drainTo
(StringBuilder
the string builder
b
,
final String
the prefix
prefix
,
final int
the delimiter
delim
,
final int
the number of code points between each prefix and delimiter
n
)

Drain all the remaining code points in this iterator to the given string builder, inserting the given prefix and delimiter before and after every n code points, respectively.

public StringBuilder

Returns:

the same string builder
drainTo
(StringBuilder
the string builder
b
,
final int
the delimiter
delim
,
final int
the number of code points between each delimiter
n
)

Drain all the remaining code points in this iterator to the given string builder, inserting the given delimiter after every n code points.

public StringBuilder

Returns:

the same string builder
drainTo
(StringBuilder
the string builder
b
,
final String
the prefix
prefix
,
final int
the number of code points between each prefix
n
)

Drain all the remaining code points in this iterator to the given string builder, inserting the given prefix before every n code points.

public String

Returns:

the string
drainToString
()

Drain all the remaining code points in this iterator to a new string.

public String

Returns:

the string
drainToString
(final String
the prefix
prefix
,
final int
the delimiter
delim
,
final int
the number of code points between each prefix and delimiter
n
)

Drain all the remaining code points in this iterator to a new string, inserting the given prefix and delimiter before and after every n code points, respectively.

public String

Returns:

the string
drainToString
(final int
the delimiter
delim
,
final int
the number of code points between each delimiter
n
)

Drain all the remaining code points in this iterator to a new string, inserting the given delimiter after every n code points.

public String

Returns:

the string
drainToString
(final String
the prefix
prefix
,
final int
the number of code points between each prefix
n
)

Drain all the remaining code points in this iterator to a new string, inserting the given prefix before every n code points.

public abstract long

Returns:

the code point offset
getIndex
()

Redeclares org.wildfly.common.iteration.IndexIterator.getIndex.

Get the current offset, by code point.
public abstract boolean

Returns:

true if there are more code points, false otherwise
hasNext
()

Redeclares org.wildfly.common.iteration.BiDirIntIterator.hasNext.

Determine if there are more code points after the current code point.
public abstract boolean

Returns:

true if there are more code points, false otherwise
hasPrevious
()

Redeclares org.wildfly.common.iteration.BiDirIntIterator.hasPrevious.

Determine if there are more code points before the current code point.
public ByteIterator

Returns:

an iterator over the decoded bytes
hexDecode
()

Hex-decode the current stream.

public final CodePointIterator

Returns:

the limited code point iterator
limitedTo
(final long
the number of code points
size
)

Return a copy of this iterator which is limited to the given number of code points after the current one.

public abstract int

Returns:

the next code point
next
()

Redeclares org.wildfly.common.iteration.BiDirIntIterator.next.

Get the next code point.
public static CodePointIterator

Returns:

the code point iterator
ofChars
(final char[]
the array
chars
)

Get a code point iterator for a character array.

public static CodePointIterator

Returns:

the code point iterator
ofChars
(final char[]
the array
chars
,
final int
the array offset
offs
)

Get a code point iterator for a character array.

public static CodePointIterator

Returns:

the code point iterator
ofChars
(final char[]
the array
chars
,
final int
the array offset
offs
,
final int
the number of characters to include
len
)

Get a code point iterator for a character array.

public static CodePointIterator

Returns:

the code point iterator
ofLatin1Bytes
(final byte[]
the array
bytes
)

Get a code point iterator for a ISO-8859-1 (Latin-1) encoded array.

public static CodePointIterator

Returns:

the code point iterator
ofLatin1Bytes
(final byte[]
the array
bytes
,
final int
the array offset
offs
,
final int
the number of characters to include
len
)

Get a code point iterator for a ISO-8859-1 (Latin-1) encoded array.

public static CodePointIterator

Returns:

the code point iterator
ofString
(final String
the string
string
)

Get a code point iterator for a string.

public static CodePointIterator

Returns:

the code point iterator
ofString
(final String
the string
string
,
final int offs, final int len)

Get a code point iterator for a string.

public static CodePointIterator

Returns:

the code point iterator
ofUtf8Bytes
(final byte[]
the array
bytes
)

Get a code point iterator for a UTF-8 encoded byte array.

public static CodePointIterator

Returns:

the code point iterator
ofUtf8Bytes
(final byte[]
the array
bytes
,
final int
the array offset
offs
,
final int
the number of characters to include
len
)

Get a code point iterator for a UTF-8 encoded array.

public abstract int

Returns:

the next code point
peekNext
()

Redeclares org.wildfly.common.iteration.BiDirIntIterator.peekNext.

Peek at the next code point without advancing.
public abstract int

Returns:

the previous code point
peekPrevious
()

Redeclares org.wildfly.common.iteration.BiDirIntIterator.peekPrevious.

Peek at the previous code point without moving backwards.
public abstract int

Returns:

the previous code point
previous
()

Redeclares org.wildfly.common.iteration.BiDirIntIterator.previous.

Get the previous code point.
public CodePointIterator

Returns:

the code point iterator
skip
(IntPredicate
a IntPredicate that evaluates the code points that should be skipper. Returning true from the predicate indicates that the code point must be skipped.
predicate
)

Get a sub-iterator that removes code points based on a predicate.

public CodePointIterator

Returns:

the same code point iterator
skipAll
()

Skip all the remaining code points in this iterator.

public CodePointIterator

Returns:

the code point iterator
skipCrLf
()

Get a sub-iterator that removes the following code points: 10(\n) and 13(\r).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

EMPTYback to summary
public static final CodePointIterator EMPTY

The empty code point iterator.

NO_CHARSback to summary
private static final char[] NO_CHARS

Constructor Detail

CodePointIteratorback to summary
pack-priv CodePointIterator()

Method Detail

asLatin1back to summary
public ByteIterator asLatin1()

Get a byte iterator over the latin-1 encoding of this code point iterator.

Returns:ByteIterator

the byte iterator

asUtf8back to summary
public ByteIterator asUtf8()

Get a byte iterator over the UTF-8 encoding of this code point iterator.

Returns:ByteIterator

the byte iterator

asUtf8back to summary
public ByteIterator asUtf8(final boolean escapeNul)

Get a byte iterator over the UTF-8 encoding of this code point iterator.

Parameters
escapeNul:boolean

true to escape NUL (0) characters as two bytes, false to encode them as one byte

Returns:ByteIterator

the byte iterator

base32Decodeback to summary
public ByteIterator base32Decode(final Base32Alphabet alphabet, boolean requirePadding)

Base32-decode the current stream.

Parameters
alphabet:Base32Alphabet

the alphabet to use

requirePadding:boolean

true to require padding, false if padding is optional

Returns:ByteIterator

an iterator over the decoded bytes

base32Decodeback to summary
public ByteIterator base32Decode(final Base32Alphabet alphabet)

Base32-decode the current stream.

Parameters
alphabet:Base32Alphabet

the alphabet to use

Returns:ByteIterator

an iterator over the decoded bytes

base32Decodeback to summary
public ByteIterator base32Decode()

Base32-decode the current stream.

Returns:ByteIterator

an iterator over the decoded bytes

base64Decodeback to summary
public ByteIterator base64Decode(final Base64Alphabet alphabet, boolean requirePadding)

Base64-decode the current stream.

Parameters
alphabet:Base64Alphabet

the alphabet to use

requirePadding:boolean

true to require padding, false if padding is optional

Returns:ByteIterator

an iterator over the decoded bytes

base64Decodeback to summary
public ByteIterator base64Decode(final Base64Alphabet alphabet)

Base64-decode the current stream.

Parameters
alphabet:Base64Alphabet

the alphabet to use

Returns:ByteIterator

an iterator over the decoded bytes

base64Decodeback to summary
public ByteIterator base64Decode()

Base64-decode the current stream.

Returns:ByteIterator

an iterator over the decoded bytes

contentEqualsback to summary
public final boolean contentEquals(CodePointIterator other)

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 by next() 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:CodePointIterator

the other byte iterator

Returns:boolean

true if the contents are equal, false otherwise

contentEqualsback to summary
public boolean contentEquals(String other)

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 by next() will be the differing code point. If the contents are equal, the iterator will be positioned at the end of its contents.

Parameters
other:String

the other string

Returns:boolean

true if the contents are equal, false otherwise

delimitedByback to summary
public final CodePointIterator delimitedBy(final int... delims)

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 return false for hasNext() if the next character in the encapsulated iterator is a delimiter or if the underlying iterator returns false for hasNext().

Parameters
delims:int[]

the code point delimiters

Returns:CodePointIterator

the sub-iterator

drainToback to summary
public StringBuilder drainTo(StringBuilder b)

Drain all the remaining code points in this iterator to the given string builder.

Parameters
b:StringBuilder

the string builder

Returns:StringBuilder

the same string builder

drainToback to summary
public StringBuilder drainTo(StringBuilder b, final String prefix, final int delim, final 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 every n code points, respectively.

Parameters
b:StringBuilder

the string builder

prefix:String

the prefix

delim:int

the delimiter

n:int

the number of code points between each prefix and delimiter

Returns:StringBuilder

the same string builder

drainToback to summary
public StringBuilder drainTo(StringBuilder b, final int delim, final int n)

Drain all the remaining code points in this iterator to the given string builder, inserting the given delimiter after every n code points.

Parameters
b:StringBuilder

the string builder

delim:int

the delimiter

n:int

the number of code points between each delimiter

Returns:StringBuilder

the same string builder

drainToback to summary
public StringBuilder drainTo(StringBuilder b, final String prefix, final int n)

Drain all the remaining code points in this iterator to the given string builder, inserting the given prefix before every n code points.

Parameters
b:StringBuilder

the string builder

prefix:String

the prefix

n:int

the number of code points between each prefix

Returns:StringBuilder

the same string builder

drainToStringback to summary
public String drainToString()

Drain all the remaining code points in this iterator to a new string.

Returns:String

the string

drainToStringback to summary
public String drainToString(final String prefix, final int delim, final int n)

Drain all the remaining code points in this iterator to a new string, inserting the given prefix and delimiter before and after every n code points, respectively.

Parameters
prefix:String

the prefix

delim:int

the delimiter

n:int

the number of code points between each prefix and delimiter

Returns:String

the string

drainToStringback to summary
public String drainToString(final int delim, final int n)

Drain all the remaining code points in this iterator to a new string, inserting the given delimiter after every n code points.

Parameters
delim:int

the delimiter

n:int

the number of code points between each delimiter

Returns:String

the string

drainToStringback to summary
public String drainToString(final String prefix, final int n)

Drain all the remaining code points in this iterator to a new string, inserting the given prefix before every n code points.

Parameters
prefix:String

the prefix

n:int

the number of code points between each prefix

Returns:String

the string

getIndexback to summary
public abstract long getIndex()

Redeclares org.wildfly.common.iteration.IndexIterator.getIndex.

Get the current offset, by code point.

Returns:long

the code point offset

hasNextback to summary
public abstract boolean hasNext()

Redeclares org.wildfly.common.iteration.BiDirIntIterator.hasNext.

Determine if there are more code points after the current code point.

Returns:boolean

true if there are more code points, false otherwise

hasPreviousback to summary
public abstract boolean hasPrevious()

Redeclares org.wildfly.common.iteration.BiDirIntIterator.hasPrevious.

Determine if there are more code points before the current code point.

Returns:boolean

true if there are more code points, false otherwise

hexDecodeback to summary
public ByteIterator hexDecode()

Hex-decode the current stream.

Returns:ByteIterator

an iterator over the decoded bytes

limitedToback to summary
public final CodePointIterator limitedTo(final long size)

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:long

the number of code points

Returns:CodePointIterator

the limited code point iterator

nextback to summary
public abstract int next() throws NoSuchElementException

Redeclares org.wildfly.common.iteration.BiDirIntIterator.next.

Get the next code point.

Returns:int

the next code point

Exceptions
NoSuchElementException:
if hasNext() returns false
ofCharsback to summary
public static CodePointIterator ofChars(final char[] chars)

Get a code point iterator for a character array.

Parameters
chars:char[]

the array

Returns:CodePointIterator

the code point iterator

ofCharsback to summary
public static CodePointIterator ofChars(final char[] chars, final int offs)

Get a code point iterator for a character array.

Parameters
chars:char[]

the array

offs:int

the array offset

Returns:CodePointIterator

the code point iterator

ofCharsback to summary
public static CodePointIterator ofChars(final char[] chars, final int offs, final int len)

Get a code point iterator for a character array.

Parameters
chars:char[]

the array

offs:int

the array offset

len:int

the number of characters to include

Returns:CodePointIterator

the code point iterator

ofLatin1Bytesback to summary
public static CodePointIterator ofLatin1Bytes(final byte[] bytes)

Get a code point iterator for a ISO-8859-1 (Latin-1) encoded array.

Parameters
bytes:byte[]

the array

Returns:CodePointIterator

the code point iterator

ofLatin1Bytesback to summary
public static CodePointIterator ofLatin1Bytes(final byte[] bytes, final int offs, final int len)

Get a code point iterator for a ISO-8859-1 (Latin-1) encoded array.

Parameters
bytes:byte[]

the array

offs:int

the array offset

len:int

the number of characters to include

Returns:CodePointIterator

the code point iterator

ofStringback to summary
public static CodePointIterator ofString(final String string)

Get a code point iterator for a string.

Parameters
string:String

the string

Returns:CodePointIterator

the code point iterator

ofStringback to summary
public static CodePointIterator ofString(final String string, final int offs, final int len)

Get a code point iterator for a string.

Parameters
string:String

the string

Returns:CodePointIterator

the code point iterator

ofUtf8Bytesback to summary
public static CodePointIterator ofUtf8Bytes(final byte[] bytes)

Get a code point iterator for a UTF-8 encoded byte array.

Parameters
bytes:byte[]

the array

Returns:CodePointIterator

the code point iterator

ofUtf8Bytesback to summary
public static CodePointIterator ofUtf8Bytes(final byte[] bytes, final int offs, final int len)

Get a code point iterator for a UTF-8 encoded array.

Parameters
bytes:byte[]

the array

offs:int

the array offset

len:int

the number of characters to include

Returns:CodePointIterator

the code point iterator

peekNextback to summary
public abstract int peekNext() throws NoSuchElementException

Redeclares org.wildfly.common.iteration.BiDirIntIterator.peekNext.

Peek at the next code point without advancing.

Returns:int

the next code point

Exceptions
NoSuchElementException:
if hasNext() returns false
peekPreviousback to summary
public abstract int peekPrevious() throws NoSuchElementException

Redeclares org.wildfly.common.iteration.BiDirIntIterator.peekPrevious.

Peek at the previous code point without moving backwards.

Returns:int

the previous code point

Exceptions
NoSuchElementException:
if hasPrevious() returns false
previousback to summary
public abstract int previous() throws NoSuchElementException

Redeclares org.wildfly.common.iteration.BiDirIntIterator.previous.

Get the previous code point.

Returns:int

the previous code point

Exceptions
NoSuchElementException:
if hasPrevious() returns false
skipback to summary
public CodePointIterator skip(IntPredicate predicate)

Get a sub-iterator that removes code points based on a predicate.

Parameters
predicate:IntPredicate

a IntPredicate that evaluates the code points that should be skipper. Returning true from the predicate indicates that the code point must be skipped.

Returns:CodePointIterator

the code point iterator

skipAllback to summary
public CodePointIterator skipAll()

Skip all the remaining code points in this iterator. (Useful in combination with delimitedBy(int...))

Returns:CodePointIterator

the same code point iterator

skipCrLfback to summary
public CodePointIterator skipCrLf()

Get a sub-iterator that removes the following code points: 10(\n) and 13(\r).

Returns:CodePointIterator

the code point iterator