Top Fields Constructors Methods
org.wildfly.common.iteration

pack-priv final Class ByteArrayIterator

extends ByteIterator
Class Inheritance
Imports
java.io.ByteArrayOutputStream, java.nio.charset.StandardCharsets, java.security.MessageDigest, .Signature, .SignatureException, java.util.Arrays, .NoSuchElementException, javax.crypto.Mac, org.wildfly.common.bytes.ByteStringBuilder

Field Summary

Modifier and TypeField and Description
private final byte[]
private int
private final int
private final int
Inherited from org.wildfly.common.iteration.ByteIterator:
EMPTY

Constructor Summary

AccessConstructor and Description
pack-priv
ByteArrayIterator(final int len, final byte[] bytes, final int offs)

Method Summary

Modifier and TypeMethod and Description
public ByteStringBuilder
public ByteIterator
public ByteIterator
public byte[]
drain()

Overrides org.wildfly.common.iteration.ByteIterator.drain.

Drain all the remaining bytes in this iterator.
public int
drain(final byte[]
the buffer into which the data is drained
dst
,
final int
the start offset in array dst at which the data is written.
offs
,
final int
the maximum number of bytes to drain
dlen
)

Overrides org.wildfly.common.iteration.ByteIterator.drain.

Drains up to len bytes from this iterator into the given dst array.
public ByteArrayOutputStream
drainTo(final ByteArrayOutputStream
the stream
stream
)

Overrides org.wildfly.common.iteration.ByteIterator.drainTo.

Drain all the remaining bytes in this iterator to the given stream.
public String
drainToLatin1(final int
the maximum number of bytes to consume
count
)

Overrides org.wildfly.common.iteration.ByteIterator.drainToLatin1.

Convenience method to directly drain a certain number of bytes to a Latin-1 string.
public String
drainToUtf8(final int
the maximum number of bytes to consume
count
)

Overrides org.wildfly.common.iteration.ByteIterator.drainToUtf8.

Convenience method to directly drain a certain number of bytes to a UTF-8 string.
public long
public boolean
hasNext()

Implements abstract org.wildfly.common.iteration.ByteIterator.hasNext.

Implements org.wildfly.common.iteration.BiDirIntIterator.hasNext.

Determine if there are more bytes after the current byte.
public boolean
hasPrevious()

Implements abstract org.wildfly.common.iteration.ByteIterator.hasPrevious.

Implements org.wildfly.common.iteration.BiDirIntIterator.hasPrevious.

Determine if there are more bytes before the current byte.
public int
public int
peekNext()

Implements abstract org.wildfly.common.iteration.ByteIterator.peekNext.

Implements org.wildfly.common.iteration.BiDirIntIterator.peekNext.

Peek at the next byte without advancing.
public int
peekPrevious()

Implements abstract org.wildfly.common.iteration.ByteIterator.peekPrevious.

Implements org.wildfly.common.iteration.BiDirIntIterator.peekPrevious.

Peek at the previous byte without moving backwards.
public int
public void
public void
public void
public boolean
Inherited from org.wildfly.common.iteration.ByteIterator:
asInputStreamasLatin1StringasUtf8Stringbase32Encodebase32Encodebase32Encodebase64Encodebase64Encodebase64EncodecontentEqualsdelimitedBydraindraindrainAllgetBE16getBE32getBE64getLE16getLE32getLE64getPackedBE32getPackedBE64hexEncodehexEncodeinterleavedWithinterleavedWithlimitedToofByteBufferofBytesofBytesofBytesofBytesofIteratorssign

Field Detail

bytesback to summary
private final byte[] bytes
idxback to summary
private int idx
lenback to summary
private final int len
offsback to summary
private final int offs

Constructor Detail

ByteArrayIteratorback to summary
pack-priv ByteArrayIterator(final int len, final byte[] bytes, final int offs)

Method Detail

appendToback to summary
public ByteStringBuilder appendTo(final ByteStringBuilder builder)

Overrides org.wildfly.common.iteration.ByteIterator.appendTo.

doFinalback to summary
public ByteIterator doFinal(final MessageDigest digest) throws IllegalStateException

Overrides org.wildfly.common.iteration.ByteIterator.doFinal.

doFinalback to summary
public ByteIterator doFinal(final Mac mac) throws IllegalStateException

Overrides org.wildfly.common.iteration.ByteIterator.doFinal.

drainback to summary
public byte[] drain()

Overrides org.wildfly.common.iteration.ByteIterator.drain.

Doc from org.wildfly.common.iteration.ByteIterator.drain.

Drain all the remaining bytes in this iterator.

Returns:byte[]

the remaining bytes as a single array

drainback to summary
public int drain(final byte[] dst, final int offs, final int dlen)

Overrides org.wildfly.common.iteration.ByteIterator.drain.

Doc from org.wildfly.common.iteration.ByteIterator.drain.

Drains up to len bytes from this iterator into the given dst array. An attempt is made to drain as many as len bytes, but a smaller number may be drained.

The number of bytes actually drained is returned as an integer. Unlike InputStream#read(byte[], int, int), this method never returns a negative result.

Parameters
dst:byte[]

the buffer into which the data is drained

offs:int

the start offset in array dst at which the data is written.

dlen:int

the maximum number of bytes to drain

Returns:int

the total number of bytes drained into dst, always greater or equal to 0

drainToback to summary
public ByteArrayOutputStream drainTo(final ByteArrayOutputStream stream)

Overrides org.wildfly.common.iteration.ByteIterator.drainTo.

Doc from org.wildfly.common.iteration.ByteIterator.drainTo.

Drain all the remaining bytes in this iterator to the given stream.

Parameters
stream:ByteArrayOutputStream

the stream

Returns:ByteArrayOutputStream

the same stream

drainToLatin1back to summary
public String drainToLatin1(final int count)

Overrides org.wildfly.common.iteration.ByteIterator.drainToLatin1.

Doc from org.wildfly.common.iteration.ByteIterator.drainToLatin1.

Convenience method to directly drain a certain number of bytes to a Latin-1 string. If fewer than count bytes are available, only the available bytes will be used to construct the string.

Parameters
count:int

the maximum number of bytes to consume

Returns:String

the Latin-1 string

drainToUtf8back to summary
public String drainToUtf8(final int count)

Overrides org.wildfly.common.iteration.ByteIterator.drainToUtf8.

Doc from org.wildfly.common.iteration.ByteIterator.drainToUtf8.

Convenience method to directly drain a certain number of bytes to a UTF-8 string. If fewer than count bytes are available, only the available bytes will be used to construct the string.

Parameters
count:int

the maximum number of bytes to consume

Returns:String

the UTF-8 string

getIndexback to summary
public long getIndex()

Implements abstract org.wildfly.common.iteration.ByteIterator.getIndex.

Implements org.wildfly.common.iteration.IndexIterator.getIndex.

Doc from org.wildfly.common.iteration.ByteIterator.getIndex.

Get the current offset, in bytes.

Returns:long

the byte offset

hasNextback to summary
public boolean hasNext()

Implements abstract org.wildfly.common.iteration.ByteIterator.hasNext.

Implements org.wildfly.common.iteration.BiDirIntIterator.hasNext.

Doc from org.wildfly.common.iteration.ByteIterator.hasNext.

Determine if there are more bytes after the current byte.

Returns:boolean

true if there are more bytes, false otherwise

hasPreviousback to summary
public boolean hasPrevious()

Implements abstract org.wildfly.common.iteration.ByteIterator.hasPrevious.

Implements org.wildfly.common.iteration.BiDirIntIterator.hasPrevious.

Doc from org.wildfly.common.iteration.ByteIterator.hasPrevious.

Determine if there are more bytes before the current byte.

Returns:boolean

true if there are more bytes, false otherwise

nextback to summary
public int next()

Implements abstract org.wildfly.common.iteration.ByteIterator.next.

Implements org.wildfly.common.iteration.BiDirIntIterator.next.

Doc from org.wildfly.common.iteration.ByteIterator.next.

Get the next byte.

Returns:int

the next byte

peekNextback to summary
public int peekNext() throws NoSuchElementException

Implements abstract org.wildfly.common.iteration.ByteIterator.peekNext.

Implements org.wildfly.common.iteration.BiDirIntIterator.peekNext.

Doc from org.wildfly.common.iteration.ByteIterator.peekNext.

Peek at the next byte without advancing.

Returns:int

the next byte

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

Implements abstract org.wildfly.common.iteration.ByteIterator.peekPrevious.

Implements org.wildfly.common.iteration.BiDirIntIterator.peekPrevious.

Doc from org.wildfly.common.iteration.ByteIterator.peekPrevious.

Peek at the previous byte without moving backwards.

Returns:int

the previous byte

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

Implements abstract org.wildfly.common.iteration.ByteIterator.previous.

Implements org.wildfly.common.iteration.BiDirIntIterator.previous.

Doc from org.wildfly.common.iteration.ByteIterator.previous.

Get the previous byte.

Returns:int

the previous byte

updateback to summary
public void update(final MessageDigest digest) throws IllegalStateException

Overrides org.wildfly.common.iteration.ByteIterator.update.

updateback to summary
public void update(final Mac mac) throws IllegalStateException

Overrides org.wildfly.common.iteration.ByteIterator.update.

updateback to summary
public void update(final Signature signature) throws SignatureException

Overrides org.wildfly.common.iteration.ByteIterator.update.

verifyback to summary
public boolean verify(final Signature signature) throws SignatureException

Overrides org.wildfly.common.iteration.ByteIterator.verify.