org.clapper.curn
Class ReadOnlyOutputHandler

java.lang.Object
  extended by org.clapper.curn.ReadOnlyOutputHandler
All Implemented Interfaces:
OutputHandler

public class ReadOnlyOutputHandler
extends java.lang.Object
implements OutputHandler

Wrapper for an OutputHandler that renders it read-only, for passing to plug-ins.

Version:
$Revision: 6300 $
See Also:
Curn, OutputHandler, PlugIn

Constructor Summary
ReadOnlyOutputHandler(OutputHandler outputHandler)
          Create a new ReadOnlyOutputHandler that wraps the specified output handler.
 
Method Summary
 void displayChannel(RSSChannel channel, FeedInfo feedInfo)
          Display the list of RSSItem news items to whatever output is defined for the underlying class.
 void flush()
          Flush any buffered-up output and close the underlying output stream(s), if any.
 java.lang.String getContentType()
          Get the content (i.e., MIME) type for output produced by this output handler.
 java.io.File getGeneratedOutput()
          Get the File that represents the output produced by the handler, if applicable.
 java.lang.String getName()
          Get the name of this output handler.
 java.lang.String getOutputEncoding()
          Get the output encoding.
 boolean hasGeneratedOutput()
          Determine whether this handler has produced any actual output (i.e., whether getGeneratedOutput() will return a non-null InputStream if called).
 void init(CurnConfig config, ConfiguredOutputHandler cfgHandler)
          Initializes the output handler for another set of RSS channels.
 void setName(java.lang.String name)
          Set the name of this output handler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReadOnlyOutputHandler

public ReadOnlyOutputHandler(OutputHandler outputHandler)
Create a new ReadOnlyOutputHandler that wraps the specified output handler.

Parameters:
outputHandler - the OutputHandler to wrap.
Method Detail

getName

public java.lang.String getName()
Get the name of this output handler. The name must be unique.

Specified by:
getName in interface OutputHandler
Returns:
the name

setName

public void setName(java.lang.String name)
             throws CurnException
Set the name of this output handler. Called by curn.

Specified by:
setName in interface OutputHandler
Parameters:
name - the name
Throws:
CurnException - on error

init

public void init(CurnConfig config,
                 ConfiguredOutputHandler cfgHandler)
          throws org.clapper.util.config.ConfigurationException,
                 CurnException
Initializes the output handler for another set of RSS channels. Note: This version of init() throws an unconditional exception.

Specified by:
init in interface OutputHandler
Parameters:
config - the parsed curn configuration data. The output handler is responsible for retrieving its own parameters from the configuration, by calling config.getOutputHandlerSpecificVariables()
cfgHandler - the ConfiguredOutputHandler wrapper containing this object; the wrapper has some useful metadata, such as the object's configuration section name and extra variables.
Throws:
org.clapper.util.config.ConfigurationException - configuration error
CurnException - some other initialization error
See Also:
CurnConfig, ConfiguredOutputHandler

displayChannel

public void displayChannel(RSSChannel channel,
                           FeedInfo feedInfo)
                    throws CurnException
Display the list of RSSItem news items to whatever output is defined for the underlying class. Output should be written to the PrintWriter that was passed to the init() method. Note: This version of init() throws an unconditional exception.

Specified by:
displayChannel in interface OutputHandler
Parameters:
channel - The parsed channel data
feedInfo - The feed.
Throws:
CurnException - unable to write output

flush

public void flush()
           throws CurnException
Flush any buffered-up output and close the underlying output stream(s), if any. curn calls this method once, after calling displayChannelItems() for all channels. If the output handler doesn't need to flush any output, it can simply return without doing anything. Note: This version of init() throws an unconditional exception.

Specified by:
flush in interface OutputHandler
Throws:
CurnException - unable to write output

getContentType

public java.lang.String getContentType()
Get the content (i.e., MIME) type for output produced by this output handler.

Specified by:
getContentType in interface OutputHandler
Returns:
the content type
See Also:
hasGeneratedOutput(), getGeneratedOutput()

getGeneratedOutput

public java.io.File getGeneratedOutput()
                                throws CurnException
Get the File that represents the output produced by the handler, if applicable. (Use of a File, rather than an InputStream, is more efficient when mailing the output, since the email API ultimately wants files and will create temporary files for InputStreams.)

Specified by:
getGeneratedOutput in interface OutputHandler
Returns:
the output file, or null if no suitable output was produced
Throws:
CurnException - an error occurred

getOutputEncoding

public java.lang.String getOutputEncoding()
Get the output encoding.

Specified by:
getOutputEncoding in interface OutputHandler
Returns:
the encoding

hasGeneratedOutput

public boolean hasGeneratedOutput()
Determine whether this handler has produced any actual output (i.e., whether getGeneratedOutput() will return a non-null InputStream if called).

Specified by:
hasGeneratedOutput in interface OutputHandler
Returns:
true if the handler has produced output, false if not
See Also:
getGeneratedOutput(), getContentType()


Copyright © 2004-2006 Brian M. Clapper. All Rights Reserved.