org.apache.cocoon.components.source
abstract public class: AbstractStreamWriteableSource [javadoc |
source]
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.cocoon.components.source.AbstractStreamSource
org.apache.cocoon.components.source.AbstractStreamWriteableSource
All Implemented Interfaces:
WriteableSource, ModifiableSource
Direct Known Subclasses:
FileSource
Deprecated! Use - the new Avalon Excalibur Source Resolving
This abstract class provides convenience methods to implement
a stream based
org.apache.cocoon.environment.WriteableSource.
Implement getOutputStream() to obtain a valid implementation.
This base implementation creates a ContentHandler by using
the sitemap 'xml' serializer to write SAX events to the stream returned by
getOutputStream().
- author:
< - a href="mailto:sylvain@apache.org">Sylvain Wallez
- version:
CVS - $Id: AbstractStreamWriteableSource.java 433543 2006-08-22 06:22:54Z crossley $
| Method from org.apache.cocoon.components.source.AbstractStreamWriteableSource Detail: |
public boolean canCancel(ContentHandler handler) {
if (handler instanceof WritingPipe) {
WritingPipe pipe = (WritingPipe)handler;
if (pipe.getSource() == this) {
return pipe.canCancel();
}
}
// Not a valid handler for this source
throw new IllegalArgumentException("The handler is not associated to this source");
} Deprecated!Checks if the OutputStream under handler can be cancelled. |
public boolean canCancel(OutputStream stream) {
return false;
} Deprecated!Always return false. To be redefined by implementations that support
cancel(). |
public void cancel(ContentHandler handler) throws Exception {
if (handler instanceof WritingPipe) {
WritingPipe pipe = (WritingPipe)handler;
if (pipe.getSource() == this) {
pipe.cancel();
return;
}
}
// Not a valid handler for this source
throw new IllegalArgumentException("The handler is not associated to this source");
} Deprecated!Cancels the OutputStream under handler. |
public void cancel(OutputStream stream) throws Exception {
throw new UnsupportedOperationException("Cancel is not implemented on " +
this.getClass().getName());
} Deprecated!Always throw UnsupportedOperationException. To be redefined by
implementations that support cancel(). |
public ContentHandler getContentHandler() throws SAXException, ProcessingException {
Serializer serializer;
ComponentSelector selector;
String serializerName = this.isHTMLContent() ? "html" : "xml";
// Get the serializer
try {
selector =
(ComponentSelector)this.manager.lookup(Serializer.ROLE + "Selector");
serializer = (Serializer)selector.select(serializerName);
} catch(ComponentException ce) {
throw new ProcessingException("Cannot get '" + serializerName + "' serializer");
}
try {
return new WritingPipe(getOutputStream(), selector, serializer);
} catch(IOException ioe) {
selector.release(serializer);
throw new ProcessingException("Cannot open stream for " + this.getSystemId(), ioe);
}
} Deprecated!Get a ContentHandler to write a SAX stream to this source. It
uses either the 'xml' or 'html' serializer depending on the result of
#isHTMLContent() to serialize events, and thus these serializers must
exist in this source's component manager. |