org.apache.cocoon.components.source
Class AbstractStreamSource

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.components.source.AbstractStreamSource
All Implemented Interfaces:
Poolable, Recyclable, LogEnabled, ModifiableSource, Source, XMLizable
Direct Known Subclasses:
AbstractStreamWriteableSource, URLSource

Deprecated. Use the new Avalon Excalibur Source Resolving

public abstract class AbstractStreamSource
extends AbstractLogEnabled
implements ModifiableSource

This abstract class provides convenience methods to implement a stream based Source. Implement getInputStream(), getSystemId() and optionally override refresh(), recycle(), getLastModified() and getContentLength() to obtain a valid Source implementation.

This base implementation provides services to parse HTML sources (HTML is not valid XML) using JTidy, if present. The source is considered to contain HTML if isHTMLContent() returns true.

Version:
CVS $Id: AbstractStreamSource.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Sylvain Wallez, Carsten Ziegeler

Field Summary
protected  ComponentManager manager
          Deprecated. The ComponentManager needed for streaming
static TransformerFactory transformerFactory
          Deprecated. The TrAX factory for serializing xml
 
Constructor Summary
protected AbstractStreamSource(ComponentManager manager)
          Deprecated. Construct a new object
 
Method Summary
 boolean exists()
          Deprecated. Returns true if getInputStream() succeeds.
 long getContentLength()
          Deprecated. Override this method to set the Content Length
 InputSource getInputSource()
          Deprecated. Return a new InputSource object
 long getLastModified()
          Deprecated. Override this method to set the Last Modification date
protected  boolean isHTMLContent()
          Deprecated. Does this source contain HTML ?
 void recycle()
          Deprecated. To be overriden in concrete subclasses if needed.
 void refresh()
          Deprecated. To be overriden in concrete subclasses if needed.
 void toSAX(ContentHandler handler)
          Deprecated. Stream content to a content handler or to an XMLConsumer.
 
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.environment.Source
getInputStream, getSystemId
 

Field Detail

transformerFactory

public static TransformerFactory transformerFactory
Deprecated. 
The TrAX factory for serializing xml


manager

protected ComponentManager manager
Deprecated. 
The ComponentManager needed for streaming

Constructor Detail

AbstractStreamSource

protected AbstractStreamSource(ComponentManager manager)
Deprecated. 
Construct a new object

Method Detail

isHTMLContent

protected boolean isHTMLContent()
Deprecated. 
Does this source contain HTML ? If true, JTidy will be used (if available) to parse the input as XML.

The default here is to return false. Concrete subclasses should override this if needed.


getInputSource

public InputSource getInputSource()
                           throws IOException,
                                  ProcessingException
Deprecated. 
Return a new InputSource object

Specified by:
getInputSource in interface Source
Returns:
an InputSource value
Throws:
IOException - if an error occurs
ProcessingException - if an error occurs

toSAX

public void toSAX(ContentHandler handler)
           throws SAXException
Deprecated. 
Stream content to a content handler or to an XMLConsumer.

Specified by:
toSAX in interface XMLizable
Throws:
SAXException - if failed to parse source document.

getContentLength

public long getContentLength()
Deprecated. 
Override this method to set the Content Length

Specified by:
getContentLength in interface Source

getLastModified

public long getLastModified()
Deprecated. 
Override this method to set the Last Modification date

Specified by:
getLastModified in interface Source

exists

public boolean exists()
Deprecated. 
Returns true if getInputStream() succeeds. Subclasses can provide a more efficient implementation.


recycle

public void recycle()
Deprecated. 
To be overriden in concrete subclasses if needed.

Specified by:
recycle in interface Recyclable

refresh

public void refresh()
Deprecated. 
To be overriden in concrete subclasses if needed.

Specified by:
refresh in interface ModifiableSource


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