org.apache.cocoon.reading
Class AbstractReader

java.lang.Object
  extended byorg.apache.avalon.framework.logger.AbstractLogEnabled
      extended byorg.apache.cocoon.reading.AbstractReader
All Implemented Interfaces:
LogEnabled, Poolable, Reader, Recyclable, SitemapModelComponent, SitemapOutputComponent
Direct Known Subclasses:
CaptchaReader, DirectoryZipArchiver, ResourceReader, ServiceableReader

public abstract class AbstractReader
extends AbstractLogEnabled
implements Reader, Recyclable

A reader can be used to generate binary output for a request. This abstract class helps in implementing a custom reader.

Version:
CVS $Id: AbstractReader.java 30941 2004-07-29 19:56:58Z vgritsenko $
Author:
Giacomo Pati

Field Summary
protected  Map objectModel
          The current Map of the object model.
protected  OutputStream out
          The OutputStream to write on.
protected  Parameters parameters
          The current Parameters.
protected  SourceResolver resolver
          The current SourceResolver.
protected  String source
          The source URI associated with the request or null.
 
Fields inherited from interface org.apache.cocoon.reading.Reader
ROLE
 
Constructor Summary
AbstractReader()
           
 
Method Summary
 long getLastModified()
           
 String getMimeType()
          Get the mime-type of the output of this Reader This default implementation returns null to indicate that the mime-type specified in the sitemap is to be used
 void recycle()
          Recycle the component
 void setOutputStream(OutputStream out)
          Set the OutputStream
 void setup(SourceResolver resolver, Map objectModel, String src, Parameters par)
          Set the SourceResolver the object model Map, the source and sitemap Parameters used to process the request.
 boolean shouldSetContentLength()
          Test if the component wants to set the content length
 
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
 
Methods inherited from interface org.apache.cocoon.reading.Reader
generate
 

Field Detail

resolver

protected SourceResolver resolver
The current SourceResolver.


objectModel

protected Map objectModel
The current Map of the object model.


parameters

protected Parameters parameters
The current Parameters.


source

protected String source
The source URI associated with the request or null.


out

protected OutputStream out
The OutputStream to write on.

Constructor Detail

AbstractReader

public AbstractReader()
Method Detail

setup

public void setup(SourceResolver resolver,
                  Map objectModel,
                  String src,
                  Parameters par)
           throws ProcessingException,
                  SAXException,
                  IOException
Set the SourceResolver the object model Map, the source and sitemap Parameters used to process the request.

Specified by:
setup in interface SitemapModelComponent
Parameters:
resolver - The SourceResolver to find resources within your context.
objectModel - A java.util.Map that contains the request and session information.
src - The value of the "src" attribute in the sitemap.
par - The sitemap parameters passed into your component.
Throws:
ProcessingException - if there is any other unexpected problem.
IOException - if there is a problem reading files.
SAXException - if there is a problem reading a SAX stream.

setOutputStream

public void setOutputStream(OutputStream out)
Set the OutputStream

Specified by:
setOutputStream in interface SitemapOutputComponent
Parameters:
out - The OutputStream target for the rendered results.

getMimeType

public String getMimeType()
Get the mime-type of the output of this Reader This default implementation returns null to indicate that the mime-type specified in the sitemap is to be used

Specified by:
getMimeType in interface SitemapOutputComponent
Returns:
the mime-type for the results.

getLastModified

public long getLastModified()
Specified by:
getLastModified in interface Reader
Returns:
the time the read source was last modified or 0 if it is not possible to detect

recycle

public void recycle()
Recycle the component

Specified by:
recycle in interface Recyclable

shouldSetContentLength

public boolean shouldSetContentLength()
Test if the component wants to set the content length

Specified by:
shouldSetContentLength in interface SitemapOutputComponent
Returns:
true if the content length needs to be set.


Copyright ? 1999-2005 The Apache Software Foundation. All Rights Reserved.