Package org.exbin.auxiliary.paged_data
Class ByteArrayData
- java.lang.Object
-
- org.exbin.auxiliary.paged_data.ByteArrayData
-
- All Implemented Interfaces:
BinaryData,DataPage
- Direct Known Subclasses:
ByteArrayEditableData
@ParametersAreNonnullByDefault public class ByteArrayData extends java.lang.Object implements BinaryData, DataPage
Basic implementation of binary data interface using byte array.
-
-
Field Summary
Fields Modifier and Type Field Description protected byte[]data
-
Constructor Summary
Constructors Constructor Description ByteArrayData()ByteArrayData(byte[] data)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancompareTo(BinaryData other)BinaryDatacopy()Creates copy of all data.BinaryDatacopy(long startFrom, long length)Creates copy of given area.voidcopyToArray(long startFrom, byte[] target, int offset, int length)Creates copy of given area into array of bytes.voiddispose()Disposes all allocated data if possible.booleanequals(java.lang.Object obj)bytegetByte(long position)Returns particular byte from data.byte[]getData()Returns internal data.java.io.InputStreamgetDataInputStream()Provides handler for input stream generation.intgetDataLength()Returns internal data length.longgetDataSize()Returns size of data or -1 if size is not available.inthashCode()booleanisEmpty()Returns true if data are empty.voidsaveToStream(java.io.OutputStream outputStream)Saves/copies all data to given stream.voidsetData(byte[] data)Sets internal data.
-
-
-
Method Detail
-
getData
@Nonnull public byte[] getData()
Returns internal data.
-
setData
public void setData(byte[] data)
Sets internal data.
-
isEmpty
public boolean isEmpty()
Description copied from interface:BinaryDataReturns true if data are empty.- Specified by:
isEmptyin interfaceBinaryData- Returns:
- true if data empty
-
getDataSize
public long getDataSize()
Description copied from interface:BinaryDataReturns size of data or -1 if size is not available.- Specified by:
getDataSizein interfaceBinaryData- Returns:
- size of data in bytes
-
getDataLength
public int getDataLength()
Returns internal data length.- Specified by:
getDataLengthin interfaceDataPage- Returns:
- data length
-
getByte
public byte getByte(long position)
Description copied from interface:BinaryDataReturns particular byte from data.- Specified by:
getBytein interfaceBinaryData- Parameters:
position- position- Returns:
- byte on requested position
-
copy
@Nonnull public BinaryData copy()
Description copied from interface:BinaryDataCreates copy of all data.- Specified by:
copyin interfaceBinaryData- Returns:
- copy of data
-
copy
@Nonnull public BinaryData copy(long startFrom, long length)
Description copied from interface:BinaryDataCreates copy of given area.- Specified by:
copyin interfaceBinaryData- Parameters:
startFrom- position to start copy fromlength- length of area- Returns:
- copy of data
-
copyToArray
public void copyToArray(long startFrom, byte[] target, int offset, int length)Description copied from interface:BinaryDataCreates copy of given area into array of bytes.- Specified by:
copyToArrayin interfaceBinaryData- Parameters:
startFrom- position to start copy fromtarget- target byte arrayoffset- offset position in targetlength- length of area to copy
-
saveToStream
public void saveToStream(java.io.OutputStream outputStream) throws java.io.IOExceptionDescription copied from interface:BinaryDataSaves/copies all data to given stream.- Specified by:
saveToStreamin interfaceBinaryData- Parameters:
outputStream- output stream- Throws:
java.io.IOException- if input/output error
-
getDataInputStream
@Nonnull public java.io.InputStream getDataInputStream()
Description copied from interface:BinaryDataProvides handler for input stream generation.- Specified by:
getDataInputStreamin interfaceBinaryData- Returns:
- new instance of input stream
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(@Nullable java.lang.Object obj)- Overrides:
equalsin classjava.lang.Object
-
compareTo
public boolean compareTo(BinaryData other)
-
dispose
public void dispose()
Description copied from interface:BinaryDataDisposes all allocated data if possible.- Specified by:
disposein interfaceBinaryData
-
-