Package com.avast.bytes
Class ConcatBytes
- java.lang.Object
-
- com.avast.bytes.AbstractBytes
-
- com.avast.bytes.ConcatBytes
-
- All Implemented Interfaces:
Bytes
public final class ConcatBytes extends AbstractBytes
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.avast.bytes.Bytes
Bytes.BuilderStream
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description byte
byteAt(int index)
Returns byte at the specified index.java.io.InputStream
newInputStream()
Returns newInputStream
that reads data contained in thisBytes
.int
size()
Returns number of bytes in thisBytes
.byte[]
toByteArray()
Converts thisBytes
to array of bytes.java.nio.ByteBuffer
toReadOnlyByteBuffer()
Converts thisBytes
to read-only.java.lang.String
toString(java.nio.charset.Charset charset)
Converts thisBytes
toString
in the specified charset.Bytes
view(int beginIndex, int endIndex)
ReturnsBytes
that is a view into this one.static ConcatBytes
wrap(Bytes bytes1, Bytes bytes2, Bytes... bytesN)
Wraps existing instances ofBytes
and concatenates them.static ConcatBytes
wrap(java.util.List<Bytes> bytesN)
Wraps existing instances ofBytes
and concatenates them.-
Methods inherited from class com.avast.bytes.AbstractBytes
equals, hashCode, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.avast.bytes.Bytes
concat, isEmpty, toHexString, toStringUtf8
-
-
-
-
Method Detail
-
size
public int size()
Description copied from interface:Bytes
Returns number of bytes in thisBytes
.- Returns:
- number of bytes in this
Bytes
-
byteAt
public byte byteAt(int index)
Description copied from interface:Bytes
Returns byte at the specified index.- Parameters:
index
- (zero-based) index- Returns:
- byte at the specified index
-
toByteArray
public byte[] toByteArray()
Description copied from interface:Bytes
Converts thisBytes
to array of bytes. This operation always copying and allocation of a new byte array.- Returns:
- new array containing data of this
Bytes
.
-
toReadOnlyByteBuffer
public java.nio.ByteBuffer toReadOnlyByteBuffer()
Description copied from interface:Bytes
Converts thisBytes
to read-only.ByteBuffer
. This operation will involve allocation and copying unless the implementation is backed byByteBuffer
.- Returns:
- read-only
ByteBuffer
containing data of thisBytes
-
toString
public java.lang.String toString(java.nio.charset.Charset charset)
Description copied from interface:Bytes
Converts thisBytes
toString
in the specified charset. This operation has the same characteristics in terms of allocation and copying asBytes.toByteArray()
- Parameters:
charset
- charset to be used when decoding the bytes- Returns:
String
decoded from the bytes
-
newInputStream
public java.io.InputStream newInputStream()
Description copied from interface:Bytes
Returns newInputStream
that reads data contained in thisBytes
.- Returns:
- new
InputStream
that reads data contained in thisBytes
-
view
public Bytes view(int beginIndex, int endIndex)
Description copied from interface:Bytes
ReturnsBytes
that is a view into this one. The view begins at the specifiedbeginIndex
and extends to the byte at indexendIndex - 1
. Thus the length of the view isendIndex-beginIndex
.- Parameters:
beginIndex
- the beginning index, inclusiveendIndex
- the ending index, exclusive- Returns:
- the specified view
-
wrap
public static ConcatBytes wrap(Bytes bytes1, Bytes bytes2, Bytes... bytesN)
Wraps existing instances ofBytes
and concatenates them.- Returns:
- new
ConcatBytes
wrapping the specifiedBytes
instances
-
wrap
public static ConcatBytes wrap(java.util.List<Bytes> bytesN)
Wraps existing instances ofBytes
and concatenates them.- Returns:
- new
ConcatBytes
wrapping the specifiedBytes
instances
-
-