Class ImageBean

All Implemented Interfaces:
Serializable, Comparable<Object>, IDBean, Cacheable
Direct Known Subclasses:
Chart, Event, Image, News, PartnerInfo, Question

public abstract class ImageBean extends DatabaseBlobBean
An abstract bean class to store common image code.
Since:
1.0
Version:
10.6
Author:
Luke
See Also:
  • Constructor Details

    • ImageBean

      public ImageBean()
  • Method Details

    • getFormat

      public ImageBean.ImageFormat getFormat()
      Returns the type of image. This uses constants found in ImageInfo.
      Returns:
      the image type code
      See Also:
    • getImageType

      public abstract ImageType getImageType()
      Returns the database image type.
      Returns:
      an ImageType
    • getWidth

      public int getWidth()
      Returns the width of the image.
      Returns:
      the width of the image, in pixels
      See Also:
    • getHeight

      public int getHeight()
      Returns the height of the image.
      Returns:
      the height of the image, in pixels
      See Also:
    • getSize

      public int getSize()
      Returns the size of the image.
      Overrides:
      getSize in class DatabaseBlobBean
      Returns:
      the size of the image, in bytes
      See Also:
    • getHasImage

      public boolean getHasImage()
      Queries if the bean has an associated Image.
      Returns:
      TRUE if the bean has an image, otherwise FALSE
    • load

      public final void load(InputStream is) throws IOException
      Loads an image into the buffer. The image data should be available at the specified input stream, and the stream is not closed when this method completes. This method populates the size, X, Y and type properties if the stream is loaded successfully.
      Overrides:
      load in class DatabaseBlobBean
      Parameters:
      is - the stream containing the image data
      Throws:
      IOException - if an error occurs loading the data
      UnsupportedOperationException - if ImageInfo cannot identify the image format
      See Also:
    • load

      public final void load(byte[] buffer)
      Updates the image buffer. This method populates the size, X, Y and type properties.
      Overrides:
      load in class DatabaseBlobBean
      Parameters:
      buffer - an array containing the image data
      Throws:
      UnsupportedOperationException - if ImageInfo cannot identify the image format
      See Also:
    • checkParam

      protected static void checkParam(int param, String msg) throws IllegalArgumentException
      Helper method to check for negative numeric parameters.
      Parameters:
      param - the parameter value
      msg - the field description
      Throws:
      IllegalArgumentException - if param is negative
    • setWidth

      public void setWidth(int x)
      Updates the width of this image. Note that this method does not change the image date (ie. resize the image)
      Parameters:
      x - the new width of the image, in pixels
      Throws:
      IllegalArgumentException - if the image width has already been set
      See Also:
    • setHeight

      public void setHeight(int y)
      Updates the height of this image. Note that this method does not change the image date (ie. resize the image)
      Parameters:
      y - the new height of the image, in pixels
      Throws:
      IllegalArgumentException - if the image height has already been set
      See Also:
    • setSize

      public void setSize(int newSize)
      Updates the size of this image.
      Parameters:
      newSize - the size of the image, in bytes
      Throws:
      IllegalStateException - if the size of the image has already been set
      IllegalArgumentException - if the image size is negative
      See Also:
    • setFormat

      public void setFormat(ImageBean.ImageFormat t)
      Updates the image format. Note that this method does not change the image data (ie. convert formats).
      Parameters:
      t - an ImageFormat
      Throws:
      IllegalStateException - if the image type has already been set
      See Also: