magoffin.matt.meta.support
Class BasicMetadataImage

java.lang.Object
  extended by magoffin.matt.meta.support.BasicMetadataImage
All Implemented Interfaces:
MetadataImage

public class BasicMetadataImage
extends java.lang.Object
implements MetadataImage

Basic implementation of MetadataImage.

Version:
$Revision: 3 $ $Date: 2008-12-27 08:09:28 +1300 (Sat, 27 Dec 2008) $
Author:
Matt Magoffin (spamsqr@msqr.us)

Constructor Summary
BasicMetadataImage(java.awt.image.BufferedImage image)
          Construct from an BufferedImage.
BasicMetadataImage(java.awt.Image image)
          Construct from an Image.
BasicMetadataImage(java.lang.String mimeType, byte[] imageData)
          Construct from a MIME type and byte array of image data.
 
Method Summary
 java.awt.image.BufferedImage getAsBufferedImage()
          Get the image as a BufferedImage.
protected  javax.imageio.ImageReader getImageReader()
          Get an ImageReader for the given InputStream for the given MIME type.
 java.lang.String getMimeType()
          Get the image MIME type.
 java.lang.String toString()
           
 void writeToStream(java.io.OutputStream out)
          Write the image data to an output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BasicMetadataImage

public BasicMetadataImage(java.lang.String mimeType,
                          byte[] imageData)
Construct from a MIME type and byte array of image data.

Parameters:
mimeType - the MIME type
imageData - the image data

BasicMetadataImage

public BasicMetadataImage(java.awt.Image image)
Construct from an Image.

Parameters:
image - the image

BasicMetadataImage

public BasicMetadataImage(java.awt.image.BufferedImage image)
Construct from an BufferedImage.

Parameters:
image - the image
Method Detail

getAsBufferedImage

public java.awt.image.BufferedImage getAsBufferedImage()
Description copied from interface: MetadataImage
Get the image as a BufferedImage.

Implementations are not required to support this method, and if not supported should throw a UnsupportedOperationException.

Specified by:
getAsBufferedImage in interface MetadataImage
Returns:
the BufferedImage

getImageReader

protected javax.imageio.ImageReader getImageReader()
Get an ImageReader for the given InputStream for the given MIME type.

This method will create an ImageInputStream from the imageData byte array in this instance.

Returns:
an ImageReader set to the InputStream in, or null if MIME type not supported

getMimeType

public java.lang.String getMimeType()
Description copied from interface: MetadataImage
Get the image MIME type.

Specified by:
getMimeType in interface MetadataImage
Returns:
mime type

writeToStream

public void writeToStream(java.io.OutputStream out)
                   throws java.io.IOException
Description copied from interface: MetadataImage
Write the image data to an output stream.

This method will not flush or close the output stream.

Specified by:
writeToStream in interface MetadataImage
Parameters:
out - the output stream
Throws:
java.io.IOException - if an IO error occurs

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object