Class TBinary<T>
java.lang.Object
org.tentackle.common.AbstractBinary<T>
org.tentackle.common.TBinary<T>
- Type Parameters:
T- the object type
- All Implemented Interfaces:
Serializable, Cloneable, Freezable
Datatype for storing an object in a database.
Same as
Same as
Binary, but uses the application-specific ObjectSerializer implementation.
Since tentackle-core is part of any Tentackle application, org.tentackle.trip.impl.TripObjectSerializer
will be used by default.
Does not require the objects to be serializable implement Serializable.
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionTBinary()Creates an empty binary.TBinary(InputStream stream, int bufSize, boolean frozen) Creates a binary from anInputStream.
Used to read a binary from the database.Creates a Binary from an object. -
Method Summary
Methods inherited from class AbstractBinary
assertNotFrozen, equals, freeze, getData, getInputStream, getLength, hashCode, isFrozen
-
Constructor Details
-
TBinary
Creates a Binary from an object.- Parameters:
object- the object to be stored in the database- Throws:
IOException- if some serialization error.
-
TBinary
Creates a binary from anInputStream.
Used to read a binary from the database. The stream is closed after creating the binary.- Parameters:
stream- the InputStream (associated with the database) to read from may be nullbufSize- the initial buffer size, 0 = default sizefrozen- true if binary is frozen- Throws:
IOException- if reading from the input stream failed
-
TBinary
public TBinary()Creates an empty binary.
-
-
Method Details
-
create
public static <T> TBinary<T> create(InputStream stream, int bufSize, boolean frozen) throws IOException Creates aTBinaryout of an InputStream. Used to read aTBinaryfrom the database. The stream is closed after creating theTBinary.- Type Parameters:
T- the serializable type- Parameters:
stream- the InputStream (associated with the database) to read from may be nullbufSize- the initial buffer size, 0 = default sizefrozen- true ifTBinaryis frozen- Returns:
- the new
TBinaryor null if the stream is null or empty. - Throws:
IOException- if reading from the input stream failed
-
clone
Cloned binaries are always not frozen.
Cloned binaries are always not frozen.
- Overrides:
clonein classAbstractBinary<T>
-
getObject
Retrieves the object encapsulated by theBinary.- Specified by:
getObjectin classAbstractBinary<T>- Returns:
- the deserialized object (retrieved from the db), or null if NULL-value
- Throws:
IOException- if reading the object failedClassNotFoundException- if the class of a serialized object cannot be found.
-
setObject
Sets the serializable.- Specified by:
setObjectin classAbstractBinary<T>- Parameters:
object- the serializable object.- Throws:
IOException- if the object could not be serialized
-