org.apache.cocoon.reading
Class ImageReader

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.reading.AbstractReader
          extended by org.apache.cocoon.reading.ResourceReader
              extended by org.apache.cocoon.reading.ImageReader
All Implemented Interfaces:
Poolable, Recyclable, Component, Configurable, LogEnabled, CacheableProcessingComponent, Reader, SitemapModelComponent, 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 1304258 2012-03-23 10:09:27Z 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(SourceResolver resolver, Map objectModel, String src, Parameters par)
          Setup the reader.
protected  void setupHeaders()
          Setup the response headers: Accept-Ranges, Expires
 
Methods inherited from class org.apache.cocoon.reading.ResourceReader
configure, generate, getLastModified, getMimeType, getValidity, hasRanges, parameterize
 
Methods inherited from class org.apache.cocoon.reading.AbstractReader
setOutputStream, shouldSetContentLength
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
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(SourceResolver resolver,
                  Map objectModel,
                  String src,
                  Parameters par)
           throws 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 SitemapModelComponent
Overrides:
setup in class ResourceReader
Throws:
ProcessingException
SAXException
IOException

setupHeaders

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

Overrides:
setupHeaders in class ResourceReader

readFully

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

processStream

protected void processStream(InputStream inputStream)
                      throws IOException,
                             ProcessingException
Overrides:
processStream in class ResourceReader
Throws:
IOException
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 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-2010 The Apache Software Foundation. All Rights Reserved.