org.apache.cocoon.reading
Class ImageReader

java.lang.Object
  extended byorg.apache.cocoon.util.AbstractLogEnabled
      extended byorg.apache.cocoon.reading.AbstractReader
          extended byorg.apache.cocoon.reading.ResourceReader
              extended byorg.apache.cocoon.reading.ImageReader
All Implemented Interfaces:
org.apache.cocoon.caching.CacheableProcessingComponent, Configurable, Poolable, org.apache.cocoon.reading.Reader, Recyclable, org.apache.cocoon.sitemap.SitemapModelComponent, org.apache.cocoon.sitemap.SitemapOutputComponent

public final class ImageReader
extends ResourceReader

The ImageReader component is used to serve binary image data in a sitemap pipeline. It makes use of HTTP Headers to determine if the requested resource should be written to the OutputStream or if it can signal that it hasn't changed.

Parameters:

<width>
This parameter is optional. When specified, it determines the width of the binary image. If no height parameter is specified, the aspect ratio of the image is kept. The parameter may be expressed as an int or a percentage.
<height>
This parameter is optional. When specified, it determines the height of the binary image. If no width parameter is specified, the aspect ratio of the image is kept. The parameter may be expressed as an int or a percentage.
<scale(Red|Green|Blue)>
This parameter is optional. When specified it will cause the specified color component in the image to be multiplied by the specified floating point value.
<offset(Red|Green|Blue)>
This parameter is optional. When specified it will cause the specified color component in the image to be incremented by the specified floating point value.
<grayscale>
This parameter is optional. When specified and set to true it will cause each image pixel to be normalized. Default is "false".
<allow-enlarging>
This parameter is optional. By default, if the image is smaller than the specified width and height, the image will be enlarged. In some circumstances this behaviour is undesirable, and can be switched off by setting this parameter to "false" so that images will be reduced in size, but not enlarged. The default is "true".
<quality>
This parameter is optional. By default, the quality uses the default for the JVM. If it is specified, the proper JPEG quality compression is used. The range is 0.0 to 1.0, if specified.

Version:
$Id: ImageReader.html 1304280 2012-03-23 11:18:01Z ilgrosso $

Field Summary
 
Fields inherited from class org.apache.cocoon.reading.ResourceReader
bufferSize, byteRanges, configuredBufferSize, configuredByteRanges, configuredExpires, configuredQuickTest, expires, inputSource, quickTest, request, response
 
Fields inherited from class org.apache.cocoon.reading.AbstractReader
objectModel, out, parameters, resolver, source
 
Fields inherited from interface org.apache.cocoon.reading.Reader
ROLE
 
Constructor Summary
ImageReader()
           
 
Method Summary
 Serializable getKey()
          Generate the unique key.
protected  void processStream(InputStream inputStream)
           
protected  byte[] readFully(InputStream in)
           
 void recycle()
          Recyclable
 void setup(org.apache.cocoon.environment.SourceResolver resolver, Map objectModel, String src, Parameters par)
          Setup the reader.
protected  void setupHeaders()
          Setup the response headers: Accept-Ranges, Expires, Last-Modified
 
Methods inherited from class org.apache.cocoon.reading.ResourceReader
configure, generate, getLastModified, getMimeType, getValidity, hasRanges, setBufferSize, setByteRanges, setExpires, setQuickTest
 
Methods inherited from class org.apache.cocoon.reading.AbstractReader
setOutputStream, shouldSetContentLength
 
Methods inherited from class org.apache.cocoon.util.AbstractLogEnabled
getLogger, setLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageReader

public ImageReader()
Method Detail

setup

public void setup(org.apache.cocoon.environment.SourceResolver resolver,
                  Map objectModel,
                  String src,
                  Parameters par)
           throws org.apache.cocoon.ProcessingException,
                  SAXException,
                  IOException
Description copied from class: ResourceReader
Setup the reader. The resource is opened to get an InputStream, the length and the last modification date

Specified by:
setup in interface org.apache.cocoon.sitemap.SitemapModelComponent
Overrides:
setup in class ResourceReader
Throws:
org.apache.cocoon.ProcessingException
SAXException
IOException

setupHeaders

protected void setupHeaders()
Description copied from class: ResourceReader
Setup the response headers: Accept-Ranges, Expires, Last-Modified

Overrides:
setupHeaders in class ResourceReader

readFully

protected byte[] readFully(InputStream in)
                    throws IOException
Throws:
IOException

processStream

protected void processStream(InputStream inputStream)
                      throws IOException,
                             org.apache.cocoon.ProcessingException
Overrides:
processStream in class ResourceReader
Throws:
IOException
org.apache.cocoon.ProcessingException

getKey

public Serializable getKey()
Generate the unique key. This key must be unique inside the space of this component.

Specified by:
getKey in interface org.apache.cocoon.caching.CacheableProcessingComponent
Overrides:
getKey in class ResourceReader
Returns:
The generated key consists of the src and width and height, and the color transform parameters

recycle

public void recycle()
Description copied from class: ResourceReader
Recyclable

Specified by:
recycle in interface Recyclable
Overrides:
recycle in class ResourceReader


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