@MustImplementEqualsAndHashcode public final class ByteArrayWrapper extends Object implements IHasByteArray, Serializable
IHasByteArray| Constructor and Description |
|---|
ByteArrayWrapper(byte[] aBytes,
boolean bCopyNeeded)
Wrap the whole byte array.
|
ByteArrayWrapper(byte[] aBytes,
int nOfs,
int nLength,
boolean bCopyNeeded)
Wrap the passed byte array or just parts of it.
|
| Modifier and Type | Method and Description |
|---|---|
byte[] |
bytes() |
static ByteArrayWrapper |
create(NonBlockingByteArrayOutputStream aBAOS,
boolean bCopyNeeded)
Wrap the content of a
NonBlockingByteArrayOutputStream. |
static ByteArrayWrapper |
create(String sText,
Charset aCharset)
Wrap the content of a String in a certain charset.
|
boolean |
equals(Object o) |
int |
getOffset() |
int |
hashCode() |
boolean |
isCopy() |
boolean |
isEmpty() |
boolean |
isNotEmpty() |
int |
size() |
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitgetAllBytes, getHexEncoded, getInputStream, hasOffset, isReadMultiple, startsWith, writeTogetBufferedReader, getReadergetBufferedInputStreampublic ByteArrayWrapper(@Nonnull byte[] aBytes, boolean bCopyNeeded)
aBytes - The byte array to be wrapped. May not be null.bCopyNeeded - true to copy it, false to reuse the
instance.public ByteArrayWrapper(@Nonnull byte[] aBytes, @Nonnegative int nOfs, @Nonnegative int nLength, boolean bCopyNeeded)
aBytes - The byte array to be wrapped. May not be null.nOfs - Offset. Must be ≥ 0.nLength - Length. Must be ≥ 0.bCopyNeeded - true to copy it, false to reuse the
instance.public boolean isCopy()
isCopy in interface IHasByteArraytrue if the contained byte array was copied in the
constructor or not.@Nonnull @ReturnsMutableObject public byte[] bytes()
bytes in interface IHasByteArraynull.@Nonnegative public int getOffset()
getOffset in interface IHasByteArrayIHasByteArray.bytes(),
IHasSize.size()@Nonnegative public int size()
public boolean isEmpty()
isEmpty in interface IHasByteArrayisEmpty in interface IHasSizetrue if no items are present, false if at
least a single item is present.IHasSize.size(),
IHasSize.isNotEmpty()public boolean isNotEmpty()
isNotEmpty in interface IHasByteArrayisNotEmpty in interface IHasSizetrue if at least one item is present,
false if no item is present.IHasSize.size(),
IHasSize.isEmpty()@Nonnull @ReturnsMutableCopy public static ByteArrayWrapper create(@Nonnull NonBlockingByteArrayOutputStream aBAOS, boolean bCopyNeeded)
NonBlockingByteArrayOutputStream.aBAOS - The output stream to be wrapped. May not be null.bCopyNeeded - true to copy it (needed if the output stream will be
modified afterwards), false to reuse the data (if the
output stream will not be modified afterwards).null.@Nonnull @ReturnsMutableCopy public static ByteArrayWrapper create(@Nonnull String sText, @Nonnull Charset aCharset)
sText - The String to be wrapped. May not be null.aCharset - The character set to be used for retrieving the bytes from the
string. May not be null.null.Copyright © 2014–2019 Philip Helger. All rights reserved.