xmlgraphics-commons 1.3.1

org.apache.xmlgraphics.image.loader.impl
Class ImageRawStream

java.lang.Object
  extended by org.apache.xmlgraphics.image.loader.impl.AbstractImage
      extended by org.apache.xmlgraphics.image.loader.impl.ImageRawStream
All Implemented Interfaces:
Image
Direct Known Subclasses:
ImageRawCCITTFax, ImageRawEPS, ImageRawJPEG

public class ImageRawStream
extends AbstractImage

This class is an implementation of the Image interface exposing an InputStream for loading the raw/undecoded image.


Nested Class Summary
static interface ImageRawStream.InputStreamFactory
          Represents a factory for InputStream objects.
 
Constructor Summary
ImageRawStream(ImageInfo info, ImageFlavor flavor, ImageRawStream.InputStreamFactory streamFactory)
          Main constructor.
ImageRawStream(ImageInfo info, ImageFlavor flavor, java.io.InputStream in)
          Constructor for a simple InputStream as parameter.
 
Method Summary
 java.io.InputStream createInputStream()
          Returns a new InputStream to access the raw image.
 ImageFlavor getFlavor()
          Returns the flavor of the image.
 boolean isCacheable()
          Indicates whether the Image instance is cacheable in memory.
 void setInputStreamFactory(ImageRawStream.InputStreamFactory factory)
          Sets the InputStreamFactory to be used by this image.
 void writeTo(java.io.File target)
          Writes the content of the image to a File.
 void writeTo(java.io.OutputStream out)
          Writes the content of the image to an OutputStream.
 
Methods inherited from class org.apache.xmlgraphics.image.loader.impl.AbstractImage
getColorSpace, getICCProfile, getInfo, getSize, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ImageRawStream

public ImageRawStream(ImageInfo info,
                      ImageFlavor flavor,
                      ImageRawStream.InputStreamFactory streamFactory)
Main constructor.

Parameters:
info - the image info object
flavor - the image flavor for the raw image
streamFactory - the InputStreamFactory that is used to create InputStream instances

ImageRawStream

public ImageRawStream(ImageInfo info,
                      ImageFlavor flavor,
                      java.io.InputStream in)
Constructor for a simple InputStream as parameter.

Parameters:
info - the image info object
flavor - the image flavor for the raw image
in - the InputStream with the raw content
Method Detail

getFlavor

public ImageFlavor getFlavor()
Returns the flavor of the image.

Returns:
the image flavor

isCacheable

public boolean isCacheable()
Indicates whether the Image instance is cacheable in memory.

Returns:
true if the Image is cacheable

setInputStreamFactory

public void setInputStreamFactory(ImageRawStream.InputStreamFactory factory)
Sets the InputStreamFactory to be used by this image. This method allows to replace the original factory.

Parameters:
factory - the new InputStreamFactory

createInputStream

public java.io.InputStream createInputStream()
Returns a new InputStream to access the raw image.

Returns:
the InputStream

writeTo

public void writeTo(java.io.OutputStream out)
             throws java.io.IOException
Writes the content of the image to an OutputStream. The OutputStream in NOT closed at the end.

Parameters:
out - the OutputStream
Throws:
java.io.IOException - if an I/O error occurs

writeTo

public void writeTo(java.io.File target)
             throws java.io.IOException
Writes the content of the image to a File.

Parameters:
target - the file to be written
Throws:
java.io.IOException - if an I/O error occurs

xmlgraphics-commons 1.3.1

Copyright 1999-2008 The Apache Software Foundation. All Rights Reserved.