T - the serializable typepublic class Binary<T extends Serializable> extends Object implements Serializable, Cloneable, Freezable
It uses the XXXBinaryStream-methods to read and write the data avoiding
the transactional limits of blobs, because blobs usually are only valid within a transaction.
Binary instead provides a blob-like interface while remaining valid outside transactions.
Furthermore, binaries can be frozen, i.e. made immutable.
Keep in mind that the wrapped object is serialized when the Binary is created or setObject is invoked. Any subsequent changes to the object are not reflected in the internal byte array.
| Constructor and Description |
|---|
Binary()
Creates an empty binary.
|
Binary(T object)
Creates a Binary from a
Serializable. |
| Modifier and Type | Method and Description |
|---|---|
Binary<T> |
clone() |
static <T extends Serializable> |
createBinary(InputStream stream,
int bufSize,
boolean frozen)
Creates a Binary out of an InputStream.
|
boolean |
equals(Object o) |
void |
freeze()
Makes this object immutable.
|
InputStream |
getInputStream()
Gets the stream to store the
Binary in the database. |
int |
getLength()
Gets the length in bytes of this
Binary. |
T |
getObject()
Retrieves the object encapsulated by the
Binary. |
int |
hashCode() |
void |
setObject(T object)
Sets the serializable.
|
public Binary(T object) throws IOException
Serializable.object - the Serializable to be stored in the databaseIOException - if some serialization error.public Binary()
public void freeze()
Freezablepublic static <T extends Serializable> Binary<T> createBinary(InputStream stream, int bufSize, boolean frozen) throws IOException
Binary from the database.
Notice that stream.available() cannot be used according to sun's spec.
The stream is closed after creating the Binary.T - the serializable typestream - the InputStream (associated to the database) to read from, may be nullbufSize - the initial buffer size, 0 = default size (bufSize)frozen - true if binary is frozenIOException - if reading from the input stream failedpublic int getLength()
Binary.
The length of a Binary is either the length of a byte-array (if Binary(byte[]) used)
or the length of the serialized object (if Binary(Object) used)Binary in bytespublic InputStream getInputStream()
Binary in the database.public T getObject() throws IOException, ClassNotFoundException
Binary.IOException - if reading the object failedClassNotFoundException - if class of a serialized object cannot be found.public void setObject(T object) throws IOException
object - the serializable object.IOException - if object could not be serializedTentackle - distributed, domain- and model-driven