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 boolean
compareTo(BinaryData other)
BinaryData
copy()
Creates copy of all data.BinaryData
copy(long startFrom, long length)
Creates copy of given area.void
copyToArray(long startFrom, byte[] target, int offset, int length)
Creates copy of given area into array of bytes.void
dispose()
Disposes all allocated data if possible.boolean
equals(java.lang.Object obj)
byte
getByte(long position)
Returns particular byte from data.byte[]
getData()
Returns internal data.java.io.InputStream
getDataInputStream()
Provides handler for input stream generation.int
getDataLength()
Returns internal data length.long
getDataSize()
Returns size of data or -1 if size is not available.int
hashCode()
boolean
isEmpty()
Returns true if data are empty.void
saveToStream(java.io.OutputStream outputStream)
Saves/copies all data to given stream.void
setData(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:BinaryData
Returns true if data are empty.- Specified by:
isEmpty
in interfaceBinaryData
- Returns:
- true if data empty
-
getDataSize
public long getDataSize()
Description copied from interface:BinaryData
Returns size of data or -1 if size is not available.- Specified by:
getDataSize
in interfaceBinaryData
- Returns:
- size of data in bytes
-
getDataLength
public int getDataLength()
Returns internal data length.- Specified by:
getDataLength
in interfaceDataPage
- Returns:
- data length
-
getByte
public byte getByte(long position)
Description copied from interface:BinaryData
Returns particular byte from data.- Specified by:
getByte
in interfaceBinaryData
- Parameters:
position
- position- Returns:
- byte on requested position
-
copy
@Nonnull public BinaryData copy()
Description copied from interface:BinaryData
Creates copy of all data.- Specified by:
copy
in interfaceBinaryData
- Returns:
- copy of data
-
copy
@Nonnull public BinaryData copy(long startFrom, long length)
Description copied from interface:BinaryData
Creates copy of given area.- Specified by:
copy
in 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:BinaryData
Creates copy of given area into array of bytes.- Specified by:
copyToArray
in 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.IOException
Description copied from interface:BinaryData
Saves/copies all data to given stream.- Specified by:
saveToStream
in interfaceBinaryData
- Parameters:
outputStream
- output stream- Throws:
java.io.IOException
- if input/output error
-
getDataInputStream
@Nonnull public java.io.InputStream getDataInputStream()
Description copied from interface:BinaryData
Provides handler for input stream generation.- Specified by:
getDataInputStream
in interfaceBinaryData
- Returns:
- new instance of input stream
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(@Nullable java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
compareTo
public boolean compareTo(BinaryData other)
-
dispose
public void dispose()
Description copied from interface:BinaryData
Disposes all allocated data if possible.- Specified by:
dispose
in interfaceBinaryData
-
-