public abstract class ByteIterator extends Object
Modifier and Type | Field and Description |
---|---|
static ByteIterator |
EMPTY
The empty byte iterator.
|
Constructor and Description |
---|
ByteIterator() |
Modifier and Type | Method and Description |
---|---|
ByteStringBuilder |
appendTo(ByteStringBuilder builder) |
InputStream |
asInputStream() |
CodePointIterator |
asLatin1String()
Get this byte iterator as a Latin-1 string.
|
CodePointIterator |
asUtf8String()
Get this byte iterator as a UTF-8 string.
|
ByteIterator |
base32Decode()
Base32-decode the current stream, assuming that the byte data is encoded in an ASCII-derived encoding.
|
ByteIterator |
base32Decode(Alphabet.Base32Alphabet alphabet)
Base32-decode the current stream, assuming that the byte data is encoded in an ASCII-derived encoding.
|
ByteIterator |
base32Decode(Alphabet.Base32Alphabet alphabet,
boolean requirePadding)
Base32-decode the current stream, assuming that the byte data is encoded in an ASCII-derived encoding.
|
CodePointIterator |
base32Encode()
Base32-encode the current stream.
|
CodePointIterator |
base32Encode(Alphabet.Base32Alphabet alphabet)
Base32-encode the current stream.
|
CodePointIterator |
base32Encode(Alphabet.Base32Alphabet alphabet,
boolean addPadding)
Base32-encode the current stream.
|
ByteIterator |
base64Decode()
Base64-decode the current stream, assuming that the byte data is encoded in an ASCII-derived encoding.
|
ByteIterator |
base64Decode(Alphabet.Base64Alphabet alphabet)
Base64-decode the current stream, assuming that the byte data is encoded in an ASCII-derived encoding.
|
ByteIterator |
base64Decode(Alphabet.Base64Alphabet alphabet,
boolean requirePadding)
Base64-decode the current stream, assuming that the byte data is encoded in an ASCII-derived encoding.
|
CodePointIterator |
base64Encode()
Base64-encode the current stream.
|
CodePointIterator |
base64Encode(Alphabet.Base64Alphabet alphabet)
Base64-encode the current stream.
|
CodePointIterator |
base64Encode(Alphabet.Base64Alphabet alphabet,
boolean addPadding)
Base64-encode the current stream.
|
boolean |
contentEquals(ByteIterator other)
Determine if the remaining contents of this iterator are identical to the remaining contents of the other iterator.
|
ByteIterator |
delimitedBy(int... delims)
Get a sub-iterator that is delimited by the given bytes.
|
ByteIterator |
doFinal(Mac mac) |
ByteIterator |
doFinal(MessageDigest digest) |
byte[] |
drain()
Drain all the remaining bytes in this iterator.
|
int |
drain(byte[] dst) |
int |
drain(byte[] dst,
int offs,
int len) |
byte[] |
drain(int count)
Drain up to
count bytes from this iterator, returning the result. |
byte[] |
drainAll(int count)
Drain exactly
count bytes from this iterator, returning the result. |
ByteArrayOutputStream |
drainTo(ByteArrayOutputStream stream)
Drain all the remaining bytes in this iterator to the given stream.
|
String |
drainToLatin1(int count)
Convenience method to directly drain a certain number of bytes to a Latin-1 string.
|
String |
drainToUtf8(int count)
Convenience method to directly drain a certain number of bytes to a UTF-8 string.
|
int |
getBE16() |
int |
getBE32() |
long |
getBE64() |
int |
getPackedBE32() |
long |
getPackedBE64() |
abstract boolean |
hasNext()
Determine if there are more bytes after the current byte.
|
abstract boolean |
hasPrev()
Determine if there are more bytes before the current byte.
|
ByteIterator |
hexDecode()
Hex-decode the current stream, assuming that the byte data is encoded in an ASCII-derived encoding.
|
CodePointIterator |
hexEncode()
Hex-encode the current stream.
|
CodePointIterator |
hexEncode(boolean toUpperCase)
Hex-encode the current stream.
|
ByteIterator |
interleavedWith(byte[] table)
Get a byte iterator which translates this byte iterator through an interleaving table.
|
ByteIterator |
interleavedWith(int[] table)
Get a byte iterator which translates this byte iterator through an interleaving table.
|
ByteIterator |
limitedTo(int size)
Return a copy of this iterator which is limited to the given number of bytes after the current one.
|
abstract int |
next()
Get the next byte.
|
static ByteIterator |
ofBytes(byte... bytes)
Get a byte iterator for a byte array.
|
static ByteIterator |
ofBytes(byte[] bytes,
int[] interleave)
Get a byte iterator for a byte array with interleave.
|
static ByteIterator |
ofBytes(byte[] bytes,
int offs,
int len)
Get a byte iterator for a byte array.
|
static ByteIterator |
ofBytes(byte[] bytes,
int offs,
int len,
int[] interleave)
Get a byte iterator for a byte array with interleave.
|
abstract int |
offset()
Get the current offset, in bytes.
|
abstract int |
peekNext()
Peek at the next byte without advancing.
|
abstract int |
peekPrev()
Peek at the previous byte without moving backwards.
|
abstract int |
prev()
Get the previous byte.
|
ByteIterator |
sign(Signature signature) |
void |
update(Mac mac) |
void |
update(MessageDigest digest) |
void |
update(Signature signature) |
boolean |
verify(Signature signature) |
public static final ByteIterator EMPTY
public abstract boolean hasNext()
true
if there are more bytes, false
otherwisepublic abstract boolean hasPrev()
true
if there are more bytes, false
otherwisepublic abstract int next() throws NoSuchElementException
NoSuchElementException
- if hasNext()
returns false
public abstract int peekNext() throws NoSuchElementException
NoSuchElementException
- if hasNext()
returns false
public abstract int prev() throws NoSuchElementException
NoSuchElementException
- if hasPrev()
returns false
public abstract int peekPrev() throws NoSuchElementException
NoSuchElementException
- if hasPrev()
returns false
public abstract int offset()
public int getBE16() throws NoSuchElementException
NoSuchElementException
public int getBE32() throws NoSuchElementException
NoSuchElementException
public long getBE64() throws NoSuchElementException
NoSuchElementException
public int getPackedBE32() throws NoSuchElementException
NoSuchElementException
public long getPackedBE64() throws NoSuchElementException
NoSuchElementException
public ByteStringBuilder appendTo(ByteStringBuilder builder)
public void update(MessageDigest digest) throws IllegalStateException
IllegalStateException
public ByteIterator doFinal(MessageDigest digest) throws IllegalStateException
IllegalStateException
public void update(Mac mac) throws IllegalStateException
IllegalStateException
public ByteIterator doFinal(Mac mac) throws IllegalStateException
IllegalStateException
public void update(Signature signature) throws IllegalStateException
IllegalStateException
public ByteIterator sign(Signature signature) throws IllegalStateException
IllegalStateException
public boolean verify(Signature signature) throws IllegalStateException
IllegalStateException
public ByteIterator base64Decode(Alphabet.Base64Alphabet alphabet, boolean requirePadding)
alphabet
- the alphabet to userequirePadding
- true
to require padding, false
if padding is optionalpublic ByteIterator base64Decode(Alphabet.Base64Alphabet alphabet)
alphabet
- the alphabet to usepublic ByteIterator base64Decode()
public CodePointIterator base64Encode(Alphabet.Base64Alphabet alphabet, boolean addPadding)
alphabet
- the alphabet to useaddPadding
- true
to add trailing padding, false
to leave it offpublic CodePointIterator base64Encode(Alphabet.Base64Alphabet alphabet)
alphabet
- the alphabet to usepublic CodePointIterator base64Encode()
public ByteIterator base32Decode(Alphabet.Base32Alphabet alphabet, boolean requirePadding)
alphabet
- the alphabet to userequirePadding
- true
to require padding, false
if padding is optionalpublic ByteIterator base32Decode(Alphabet.Base32Alphabet alphabet)
alphabet
- the alphabet to usepublic ByteIterator base32Decode()
public CodePointIterator base32Encode(Alphabet.Base32Alphabet alphabet, boolean addPadding)
alphabet
- the alphabet to useaddPadding
- true
to add trailing padding, false
to leave it offpublic CodePointIterator base32Encode(Alphabet.Base32Alphabet alphabet)
alphabet
- the alphabet to usepublic CodePointIterator base32Encode()
public ByteIterator hexDecode()
public CodePointIterator hexEncode(boolean toUpperCase)
toUpperCase
- true
to use upper case characters when encoding,
false
to use lower case characterspublic CodePointIterator hexEncode()
public CodePointIterator asUtf8String()
public CodePointIterator asLatin1String()
public final boolean contentEquals(ByteIterator other)
other
- the other byte iteratortrue
if the contents are equal, false
otherwisepublic final ByteIterator limitedTo(int size)
size
- the number of bytespublic final ByteIterator delimitedBy(int... delims)
false
for hasNext()
if the next
character in the encapsulated iterator is a delimiter or if the underlying iterator returns false
for
hasNext()
.delims
- the byte delimiterspublic ByteIterator interleavedWith(byte[] table)
table
- the interleaving tablepublic ByteIterator interleavedWith(int[] table)
table
- the interleaving tablepublic ByteArrayOutputStream drainTo(ByteArrayOutputStream stream)
stream
- the streampublic byte[] drain()
public byte[] drain(int count)
count
bytes from this iterator, returning the result.count
- the number of bytes to readcount
)public byte[] drainAll(int count) throws NoSuchElementException
count
bytes from this iterator, returning the result.count
- the number of bytes to readNoSuchElementException
- if there are not enough bytes to fill the arraypublic int drain(byte[] dst)
public int drain(byte[] dst, int offs, int len)
public String drainToUtf8(int count)
count
bytes are available, only the available bytes will be used to construct the string.count
- the maximum number of bytes to consumepublic String drainToLatin1(int count)
count
bytes are available, only the available bytes will be used to construct the string.count
- the maximum number of bytes to consumepublic static ByteIterator ofBytes(byte... bytes)
bytes
- the arraypublic static ByteIterator ofBytes(byte[] bytes, int offs, int len)
bytes
- the arrayoffs
- the array offsetlen
- the number of bytes to includepublic static ByteIterator ofBytes(byte[] bytes, int offs, int len, int[] interleave)
bytes
- the arrayoffs
- the array offsetlen
- the number of bytes to includeinterleave
- the interleave table to usepublic static ByteIterator ofBytes(byte[] bytes, int[] interleave)
bytes
- the arrayinterleave
- the interleave table to usepublic final InputStream asInputStream()
Copyright © 2016 JBoss by Red Hat. All rights reserved.