|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.tentackle.db.Binary
public class Binary
Datatype for storing arbitrary (binary) data in a database.
Its primary use is to store Serializables but it can handle arbitrary byte-data as well.
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.
| Field Summary | |
|---|---|
static int |
BUF_SIZE
initial default buffersize when reading from the database. |
| Constructor Summary | |
|---|---|
Binary()
Creates an empty binary |
|
Binary(byte[] data)
Creates a Binary out of an array of arbitrary bytes. |
|
Binary(Object object)
Creates a Binary from a Serializable. |
|
| Method Summary | |
|---|---|
Binary |
clone()
Clones the binary |
static Binary |
createBinary(InputStream stream,
int bufSize)
Creates a Binary out of an InputStream. |
byte[] |
getData()
Retrieves the @{code Binary} data as a byte[]-array. |
InputStream |
getInputStream()
Gets the stream to store the Binary in the database. |
int |
getLength()
Gets the length in bytes of this Binary. |
Object |
getObject()
Retrieves the object encapsulated by the Binary. |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static int BUF_SIZE
| Constructor Detail |
|---|
public Binary(Object object)
throws IOException
Serializable.
object - the Serializable to be stored in the database
IOException - if some serialization error.public Binary(byte[] data)
data - the byte array to be stored in the database.public Binary()
| Method Detail |
|---|
public Binary clone()
clone in class ObjectCloneable
public static Binary createBinary(InputStream stream,
int bufSize)
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.
stream - the InputStream (associated to the database) to read from, may be nullbufSize - the initial buffer size, 0 = default size (BUF_SIZE)
IOException - 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 Object getObject()
throws IOException,
ClassNotFoundException
Binary.
IOException - if reading the object failed
ClassNotFoundException - if class of a serialized object cannot be found.public byte[] getData()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||