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

public abstract class DatabaseBlobBean extends DatabaseBean
An abstract class to implement support for image/file buffers in a bean.
Since:
1.0
Version:
7.5
Author:
Luke
See Also:
  • Field Details

    • _buffer

      protected byte[] _buffer
      The 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

      public InputStream 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

      public void load(InputStream is) throws IOException
      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.