Package org.smooks.io
Class AbstractOutputStreamResource
- java.lang.Object
-
- org.smooks.io.AbstractOutputStreamResource
-
- All Implemented Interfaces:
org.smooks.api.delivery.ContentHandler,org.smooks.api.delivery.ordering.Consumer,org.smooks.api.lifecycle.PostExecutionLifecycle,org.smooks.api.lifecycle.PostFragmentLifecycle,org.smooks.api.resource.visitor.dom.DOMVisitBefore,org.smooks.api.resource.visitor.dom.DOMVisitor,org.smooks.api.resource.visitor.sax.ng.BeforeVisitor,org.smooks.api.resource.visitor.sax.ng.SaxNgVisitor,org.smooks.api.resource.visitor.Visitor
public abstract class AbstractOutputStreamResource extends Object implements org.smooks.api.resource.visitor.dom.DOMVisitBefore, org.smooks.api.delivery.ordering.Consumer, org.smooks.api.lifecycle.PostFragmentLifecycle, org.smooks.api.lifecycle.PostExecutionLifecycle, org.smooks.api.resource.visitor.sax.ng.BeforeVisitor
AbstractOuputStreamResource is the base class for handling output stream resources in Smooks. Note that aWritercan also be opened on a stream resource. If aWriterhas been opened on a resource, anOutputStreamcannot also be opened (and visa versa). Example configuration:<resource-config selector="#document"> <resource>org.smooks.io.ConcreateImpl</resource> <param name="resourceName">resourceName</param> <param name="writerEncoding">UTF-8</param> <!-- Optional --> </resource-config>Description of configuration properties:
resource: should be a concreate implementation of this classresourceName: the name of this resouce. Will be used to identify this resourcewriterEncoding: (Optional) the encoding to be used by any writers opened on this resource (Default is "UTF-8")
- Author:
- Daniel Bevenius
-
-
Field Summary
Fields Modifier and Type Field Description protected StringresourceNameprotected CharsetwriterEncoding
-
Constructor Summary
Constructors Constructor Description AbstractOutputStreamResource()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidbind(org.smooks.api.ExecutionContext executionContext)protected voidclose(Closeable closeable)protected booleancloseCondition(org.smooks.api.ExecutionContext executionContext)protected voidcloseResource(org.smooks.api.ExecutionContext executionContext)Close the resource output stream.booleanconsumes(Object object)abstract OutputStreamgetOutputStream(org.smooks.api.ExecutionContext executionContext)Retrieve/create an output stream that is appropriate for the concreate implementationStringgetResourceName()Get the name of this resourceCharsetgetWriterEncoding()voidonPostExecution(org.smooks.api.ExecutionContext executionContext)voidonPostFragment(org.smooks.api.delivery.fragment.Fragment<?> fragment, org.smooks.api.ExecutionContext executionContext)AbstractOutputStreamResourcesetResourceName(String resourceName)Set the name of this resourceAbstractOutputStreamResourcesetWriterEncoding(Charset writerEncoding)voidvisitBefore(Element element, org.smooks.api.ExecutionContext executionContext)
-
-
-
Method Detail
-
getOutputStream
public abstract OutputStream getOutputStream(org.smooks.api.ExecutionContext executionContext) throws IOException
Retrieve/create an output stream that is appropriate for the concreate implementation- Parameters:
executionContext- Execution Context.- Returns:
- OutputStream specific to the concreate implementation
- Throws:
IOException
-
getResourceName
public String getResourceName()
Get the name of this resource- Returns:
- The name of the resource
-
consumes
public boolean consumes(Object object)
- Specified by:
consumesin interfaceorg.smooks.api.delivery.ordering.Consumer
-
setResourceName
public AbstractOutputStreamResource setResourceName(String resourceName)
Set the name of this resource- Parameters:
resourceName- The name of the resource
-
setWriterEncoding
public AbstractOutputStreamResource setWriterEncoding(Charset writerEncoding)
-
getWriterEncoding
public Charset getWriterEncoding()
-
visitBefore
public void visitBefore(Element element, org.smooks.api.ExecutionContext executionContext) throws org.smooks.api.SmooksException
- Specified by:
visitBeforein interfaceorg.smooks.api.resource.visitor.sax.ng.BeforeVisitor- Specified by:
visitBeforein interfaceorg.smooks.api.resource.visitor.dom.DOMVisitBefore- Throws:
org.smooks.api.SmooksException
-
onPostFragment
public void onPostFragment(org.smooks.api.delivery.fragment.Fragment<?> fragment, org.smooks.api.ExecutionContext executionContext)- Specified by:
onPostFragmentin interfaceorg.smooks.api.lifecycle.PostFragmentLifecycle
-
onPostExecution
public void onPostExecution(org.smooks.api.ExecutionContext executionContext)
- Specified by:
onPostExecutionin interfaceorg.smooks.api.lifecycle.PostExecutionLifecycle
-
closeCondition
protected boolean closeCondition(org.smooks.api.ExecutionContext executionContext)
-
closeResource
protected void closeResource(org.smooks.api.ExecutionContext executionContext)
Close the resource output stream. Classes overriding this method must call super on this method. This will probably need to be done before performing any aditional cleanup.- Parameters:
executionContext- Smooks ExecutionContext
-
bind
protected void bind(org.smooks.api.ExecutionContext executionContext)
-
close
protected void close(Closeable closeable)
-
-