Class DatabaseBlobBean
java.lang.Object
org.deltava.beans.DatabaseBean
org.deltava.beans.DatabaseBlobBean
- All Implemented Interfaces:
Serializable, Comparable<Object>, IDBean, Cacheable
- Direct Known Subclasses:
AbstractComment, ACARSError, DatabaseDocumentBean, ImageBean, Person, SignatureImage
An abstract class to implement support for image/file buffers in a bean.
- Since:
- 1.0
- Version:
- 7.5
- Author:
- Luke
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears the buffer.Returns the content of the buffer.intgetSize()Returns the size of the image/file data.booleanisLoaded()Returns whether the buffer has been populated.voidload(byte[] buffer) Replaces the buffer data.voidload(InputStream is) Loads the contents of a stream into the buffer.Methods inherited from class DatabaseBean
cacheKey, compareTo, equals, getHexID, getID, hashCode, setID, validateID, validateIDModifier and TypeMethodDescriptioncacheKey()Returns the cache key for this object.intbooleangetHexID()Returns the hexadecimal database ID of this object.intgetID()Returns the database ID of this object.inthashCode()voidsetID(int id) Update the database row ID of this bean.static voidvalidateID(int oldID, int newID) Validates a database ID.static voidvalidateID(int oldID, int newID, boolean allowZero) Validates a database ID.
-
Field Details
-
_buffer
protected byte[] _bufferThe buffer for the image/file data.
-
-
Constructor Details
-
DatabaseBlobBean
public DatabaseBlobBean()
-
-
Method Details
-
isLoaded
public boolean isLoaded()Returns whether the buffer has been populated.- Returns:
- TRUE if the buffer has any data, otherwise FALSE
-
getInputStream
Returns the content of the buffer. There is no requirement that beans implementing a buffer populate the buffer except when necessary.- Returns:
- an InputStream with the buffer's contents, or an empty stream if the buffer is null
- See Also:
-
getSize
public int getSize()Returns the size of the image/file data.- Returns:
- the size of the data, in bytes. If the buffer is not initialized, returns -1
- See Also:
-
load
Loads the contents of a stream into the buffer. The data should be available at the specified input stream, and the stream is not closed when this method completes.- Parameters:
is- the stream containing the data- Throws:
IOException- if an error occurs reading the stream data- See Also:
-
load
public void load(byte[] buffer) Replaces the buffer data.- Parameters:
buffer- the new buffer data- See Also:
-
clear
public void clear()Clears the buffer.
-