Package com.helger.io.resource.inmemory
Class ReadableResourceByteArray
java.lang.Object
com.helger.io.resource.inmemory.AbstractMemoryReadableResource
com.helger.io.resource.inmemory.ReadableResourceByteArray
- All Implemented Interfaces:
com.helger.base.iface.IHasSize,com.helger.base.io.iface.IHasByteArray,com.helger.base.io.iface.IHasInputStream,com.helger.base.io.iface.IHasInputStreamAndReader,com.helger.base.io.iface.IWriteToStream,IMemoryReadableResource,IReadableResource,IResourceBase
- Direct Known Subclasses:
ReadableResourceString
public class ReadableResourceByteArray
extends AbstractMemoryReadableResource
implements com.helger.base.io.iface.IHasByteArray
An in-memory
IReadableResource based on a byte array.- Author:
- Philip Helger
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionReadableResourceByteArray(byte @NonNull [] aBytes) Constructor using the full byte array with default copy behavior.ReadableResourceByteArray(byte @NonNull [] aBytes, boolean bCopyNeeded) Constructor using the full byte array with explicit copy behavior.ReadableResourceByteArray(byte @NonNull [] aBytes, int nOfs, int nLen) Constructor using a sub-range of the byte array with default copy behavior.ReadableResourceByteArray(byte @NonNull [] aBytes, int nOfs, int nLen, boolean bCopyNeeded) Constructor using a sub-range of the byte array with explicit copy behavior.ReadableResourceByteArray(@Nullable String sResourceID, byte @NonNull [] aBytes) Constructor with resource ID using the full byte array with default copy behavior.ReadableResourceByteArray(@Nullable String sResourceID, byte @NonNull [] aBytes, boolean bCopyNeeded) Constructor with resource ID using the full byte array with explicit copy behavior.ReadableResourceByteArray(@Nullable String sResourceID, byte @NonNull [] aBytes, int nOfs, int nLen) Constructor with resource ID using a sub-range with default copy behavior.ReadableResourceByteArray(@Nullable String sResourceID, byte @NonNull [] aBytes, int nOfs, int nLen, boolean bCopyNeeded) Full constructor with resource ID, sub-range and explicit copy behavior. -
Method Summary
Methods inherited from class com.helger.io.resource.inmemory.AbstractMemoryReadableResource
exists, getAsFile, getAsURL, getPath, getReadableCloneForPath, getResourceID, setPathMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.helger.base.io.iface.IHasByteArray
getAllBytes, getBytesAsString, getHexEncoded, hasOffset, isNotEmpty, isPartialArray, startsWith, writeToMethods inherited from interface com.helger.base.io.iface.IHasInputStream
getBufferedInputStream, withBufferedInputStreamDo, withInputStreamDoMethods inherited from interface com.helger.base.io.iface.IHasInputStreamAndReader
getBufferedReader, getReaderMethods inherited from interface com.helger.base.io.iface.IWriteToStream
writeToAndClose
-
Field Details
-
DEFAULT_COPY_NEEDED
public static final boolean DEFAULT_COPY_NEEDED- See Also:
-
-
Constructor Details
-
ReadableResourceByteArray
public ReadableResourceByteArray(byte @NonNull [] aBytes) Constructor using the full byte array with default copy behavior.- Parameters:
aBytes- The byte array to use. May not benull.
-
ReadableResourceByteArray
public ReadableResourceByteArray(byte @NonNull [] aBytes, @Nonnegative int nOfs, @Nonnegative int nLen) Constructor using a sub-range of the byte array with default copy behavior.- Parameters:
aBytes- The byte array to use. May not benull.nOfs- The offset into the byte array. Must be ≥ 0.nLen- The number of bytes to use. Must be ≥ 0.
-
ReadableResourceByteArray
public ReadableResourceByteArray(byte @NonNull [] aBytes, boolean bCopyNeeded) Constructor using the full byte array with explicit copy behavior.- Parameters:
aBytes- The byte array to use. May not benull.bCopyNeeded-trueif a copy of the byte array should be made,falseto use it directly.
-
ReadableResourceByteArray
public ReadableResourceByteArray(byte @NonNull [] aBytes, @Nonnegative int nOfs, @Nonnegative int nLen, boolean bCopyNeeded) Constructor using a sub-range of the byte array with explicit copy behavior.- Parameters:
aBytes- The byte array to use. May not benull.nOfs- The offset into the byte array. Must be ≥ 0.nLen- The number of bytes to use. Must be ≥ 0.bCopyNeeded-trueif a copy of the byte array should be made,falseto use it directly.
-
ReadableResourceByteArray
Constructor with resource ID using the full byte array with default copy behavior.- Parameters:
sResourceID- The resource ID. May benull.aBytes- The byte array to use. May not benull.
-
ReadableResourceByteArray
public ReadableResourceByteArray(@Nullable String sResourceID, byte @NonNull [] aBytes, @Nonnegative int nOfs, @Nonnegative int nLen) Constructor with resource ID using a sub-range with default copy behavior.- Parameters:
sResourceID- The resource ID. May benull.aBytes- The byte array to use. May not benull.nOfs- The offset into the byte array. Must be ≥ 0.nLen- The number of bytes to use. Must be ≥ 0.
-
ReadableResourceByteArray
public ReadableResourceByteArray(@Nullable String sResourceID, byte @NonNull [] aBytes, boolean bCopyNeeded) Constructor with resource ID using the full byte array with explicit copy behavior.- Parameters:
sResourceID- The resource ID. May benull.aBytes- The byte array to use. May not benull.bCopyNeeded-trueif a copy of the byte array should be made,falseto use it directly.
-
ReadableResourceByteArray
public ReadableResourceByteArray(@Nullable String sResourceID, byte @NonNull [] aBytes, @Nonnegative int nOfs, @Nonnegative int nLen, boolean bCopyNeeded) Full constructor with resource ID, sub-range and explicit copy behavior.- Parameters:
sResourceID- The resource ID. May benull.aBytes- The byte array to use. May not benull.nOfs- The offset into the byte array. Must be ≥ 0.nLen- The number of bytes to use. Must be ≥ 0.bCopyNeeded-trueif a copy of the byte array should be made,falseto use it directly.
-
-
Method Details
-
isCopy
public final boolean isCopy()- Specified by:
isCopyin interfacecom.helger.base.io.iface.IHasByteArray- Returns:
trueif the internal byte array is a copy,falseif the original reference is used.
-
bytes
@ReturnsMutableObject public final byte @NonNull [] bytes()- Specified by:
bytesin interfacecom.helger.base.io.iface.IHasByteArray
-
getOffset
@Nonnegative public int getOffset()- Specified by:
getOffsetin interfacecom.helger.base.io.iface.IHasByteArray
-
size
@Nonnegative public final int size()- Specified by:
sizein interfacecom.helger.base.iface.IHasSize
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfacecom.helger.base.io.iface.IHasByteArray- Specified by:
isEmptyin interfacecom.helger.base.iface.IHasSize
-
getInputStream
- Specified by:
getInputStreamin interfacecom.helger.base.io.iface.IHasByteArray- Specified by:
getInputStreamin interfacecom.helger.base.io.iface.IHasInputStream
-
isReadMultiple
public boolean isReadMultiple()- Specified by:
isReadMultiplein interfacecom.helger.base.io.iface.IHasByteArray- Specified by:
isReadMultiplein interfacecom.helger.base.io.iface.IHasInputStream
-
toString
- Overrides:
toStringin classAbstractMemoryReadableResource
-