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 TypeMethodDescriptionvoid
clear()
Clears the buffer.Returns the content of the buffer.int
getSize()
Returns the size of the image/file data.boolean
isLoaded()
Returns whether the buffer has been populated.void
load
(byte[] buffer) Replaces the buffer data.void
load
(InputStream is) Loads the contents of a stream into the buffer.Methods inherited from class org.deltava.beans.DatabaseBean
cacheKey, compareTo, equals, getHexID, getID, hashCode, setID, validateID, validateID
-
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.
-