Oracle® Application Server
XML Java API Reference
10g Release 3 (10.1.3)

B28238-01


oracle.xml.pipeline.controller
Class Process

java.lang.Object
  extended byoracle.xml.pipeline.controller.Process

All Implemented Interfaces:
ErrorHandler, PipelineConstants, java.lang.Runnable
Direct Known Subclasses:
CompressReaderProcess, CompressWriterProcess, DOMParserProcess, SAXParserProcess, XPathProcess, XSDSchemaBuilder, XSDValProcess, XSLProcess, XSLStylesheetProcess

public class Process
extends java.lang.Object
implements java.lang.Runnable, PipelineConstants, ErrorHandler

Base class for all pipeline process definitions. To create a custom pipeline process, you need to create a class which extends from the Process class. At the minimum, every custom process should overwrite the initialize() and execute() method of this class. If the custom process takes SAX events as input, it should overwrite the SAXContentHandler() method to return the appropriate ContentHandler which will handle incoming SAX events.


Field Summary

Fields inherited from interface oracle.xml.pipeline.controller.PipelineConstants
COMPSTREAMRESULT, COMPSTREAMSOURCE, DOCFRAG, DOCUMENT, DOMRESULT, DOMSOURCE, ELEMENT, PROCESS_WAITING, SAXRESULT, SAXSOURCE, STREAMRESULT, STREAMSOURCE

Method Summary
void convertFromDOM(DOMResult res, Output output)
Should be called by the Process which outputs DOM.
void convertFromSAX(SAXResult result, Output output)
Should be called by the Process which outputs SAX events.
void convertFromStream(StreamResult res, Output output)
Should be called by the Process which outputs xml as Stream.
void error(int type, java.lang.Exception e)
Called by a custom Process whenever an error occurs.
protected void execute()
Does nothing by default, to be implemented by classes extending from the Process class.
XMLDocument getErrorDocument(java.lang.String errorName, boolean convert)
Get the error element as an XML Document tree
Source getErrorSource(java.lang.String errorName)
Retrieve the error element as Source
java.io.InputStream getErrorStream(java.lang.String errorName, boolean convert)
Get the error element as an Input stream for reading error.
void getErrorStream(java.lang.String errorName, java.io.OutputStream out, boolean convert)
Write the error element to the outputstream provided.
java.lang.Object getInParamValue(java.lang.String name)
Get an input param value based on its name
Input getInput(java.lang.String inputName)
Retrieve the Input object by name
java.lang.Object getOutParamValue(java.lang.String name)
Get the output param value based on its name
Output getOutput(java.lang.String outputName)
Retrieve a particular output by name
java.io.OutputStream getOutputStream(java.lang.String outputName)
Get the output stream for printing to a specific output
java.io.Writer getOutputWriter(java.lang.String outputName)
Get the output writer for writing to a specific output
ContentHandler getSAXContentHandler(Output out)
Get the ContentHandler which will handle the sax events generated.
ErrorHandler getSAXErrorHandler(Output out)
Get the SAX ErrorHandler which will handle the sax error events generated.
void info(java.lang.String msg)
Called by a Process to report an informational message and continue with execution.
protected void initialize()
Does nothing by default, to be implemented by the classes extending from the Process class.
protected ContentHandler SAXContentHandler()
Each Process which handles SAX as input should overwrite this method to return the ContentHandler.
protected ErrorHandler SAXErrorHandler()
Each Process produces SAX events as output can overwrite this method to return the ErrorHandler.
void setOutputResult(java.lang.String outputName, Result res)
All user defined processes (extending from Process) need to create a Result object and set it in the output using this method.

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Methods inherited from interface java.lang.Runnable
run

Methods inherited from interface org.xml.sax.ErrorHandler
error, fatalError, warning

Method Detail

initialize

protected void initialize()
Does nothing by default, to be implemented by the classes extending from the Process class. This method will be called to intialize the process before execution. Use getInput() to fetch a specific input object associated with the process element and call supportType() to indicate the types of the input supported. Similarly call getOutput() to fetch an output object associated with the process element, and call supportType to set the types of output supported by the process.

getInput

public final Input getInput(java.lang.String inputName)
Retrieve the Input object by name
Parameters:
inputName - input name as String
Returns:
Input object if there one by inputName, otherwise null

getOutput

public Output getOutput(java.lang.String outputName)
Retrieve a particular output by name
Parameters:
outputName - as a String
Returns:
Output object, null if no output by this name exists

getInParamValue

public final java.lang.Object getInParamValue(java.lang.String name)
Get an input param value based on its name
Parameters:
name - name of InParam as String
Returns:
InParam value as type Object, null if none exists

getOutParamValue

public final java.lang.Object getOutParamValue(java.lang.String name)
Get the output param value based on its name
Parameters:
name - OutParam name as String
Returns:
OutParam value of type Object

execute

protected void execute()
                throws PipelineException
Does nothing by default, to be implemented by classes extending from the Process class. Use getInParaValue(), getInput() or getInputSource() to fetch the inputs to the process. If a custom process outputs SAX events, it should call getSAXContentHandler() and getSAXErrorHandler methods in execute() to get the SAX handlers of the following process(es) in the pipeline. Set the outputs or outparams generated by this process using setOutputResult(), getOutputStream(), getOutputWriter() or setOutParam(). You can access the pipeline error element associated with this process element by calling getErrorSource(), getErrorStream() or getErrorDocument(). If an exception occurs during execute() it can be propagated to the PipelineErrorHandler by calling error() or info().
Throws:
PipelineException

setOutputResult

public final void setOutputResult(java.lang.String outputName,
                                  Result res)
All user defined processes (extending from Process) need to create a Result object and set it in the output using this method.
Parameters:
outputName - as String
res - Result object

getOutputStream

public final java.io.OutputStream getOutputStream(java.lang.String outputName)
                                           throws java.io.FileNotFoundException,
                                                  java.io.IOException
Get the output stream for printing to a specific output
Parameters:
outputName - name of output
Returns:
OutputStream for printing
Throws:
java.io.FileNotFoundException
java.io.IOException

getOutputWriter

public final java.io.Writer getOutputWriter(java.lang.String outputName)
                                     throws java.io.FileNotFoundException,
                                            java.io.IOException
Get the output writer for writing to a specific output
Parameters:
outputName - name of output
Returns:
Writer for printing
Throws:
java.io.FileNotFoundException
java.io.IOException

getErrorSource

public Source getErrorSource(java.lang.String errorName)
Retrieve the error element as Source
Parameters:
errorName - name of error from pipeline document
Returns:
Source error element as a Source object

getErrorStream

public void getErrorStream(java.lang.String errorName,
                           java.io.OutputStream out,
                           boolean convert)
                    throws java.io.IOException
Write the error element to the outputstream provided. If convert is true then convert from error node to stream.
Parameters:
errorName - name of error element
out - outputstream to write to
convert - convert from DOM to stream or not
Throws:
java.io.IOException - while writing to outputstream

getErrorStream

public final java.io.InputStream getErrorStream(java.lang.String errorName,
                                                boolean convert)
                                         throws java.io.IOException
Get the error element as an Input stream for reading error.
Parameters:
errorName - error element name as String
convert - convert from Node to InputStream or not
Returns:
InputStream of of error element
Throws:
java.io.IOException - reading from error element

getErrorDocument

public XMLDocument getErrorDocument(java.lang.String errorName,
                                    boolean convert)
                             throws SAXException,
                                    XMLParseException,
                                    java.io.IOException
Get the error element as an XML Document tree
Parameters:
errorName - error element name as String
convert - convert from stream to DOM if necessary
Returns:
XMLDocument error element as XMLDocument
Throws:
SAXException - while parsing
XMLParseException - while parsing
java.io.IOException

error

public final void error(int type,
                        java.lang.Exception e)
                 throws PipelineException
Called by a custom Process whenever an error occurs.
Parameters:
type - error type as defined in PipelineConstants
e - exception
Throws:
PipelineException

info

public void info(java.lang.String msg)
Called by a Process to report an informational message and continue with execution.
Parameters:
msg - - message to report

getSAXContentHandler

public final ContentHandler getSAXContentHandler(Output out)
                                          throws PipelineException
Get the ContentHandler which will handle the sax events generated. This function will handle the conversion from SAX to DOM or Stream if its necessary. If this method returns null, then call setProcessStatus(PROCESS_WAITING), and return from execute().
Parameters:
out - the Output object which is the SAX source
Returns:
ContentHandler for taking SAX events as input to this process
Throws:
PipelineException

getSAXErrorHandler

public final ErrorHandler getSAXErrorHandler(Output out)
Get the SAX ErrorHandler which will handle the sax error events generated.
Parameters:
out - Output object which is the SAX source
Returns:
ErrorHandler will be called on input SAX error
Throws:
PipelineException

SAXContentHandler

protected ContentHandler SAXContentHandler()
                                    throws PipelineException
Each Process which handles SAX as input should overwrite this method to return the ContentHandler. If any dependencies (i.e. output or outparam from other processes are not available (are null) at this time, please return null. Once these dependencies are available the method will be executed till the end.
Returns:
ContentHandler to be passed on to prevProcess
Throws:
PipelineException

SAXErrorHandler

protected ErrorHandler SAXErrorHandler()
Each Process produces SAX events as output can overwrite this method to return the ErrorHandler. Otherwise the default error handler implemented by this class will be used to handle SAX errors.
Returns:
ErrorHandler to be passed on to prevProcess

convertFromSAX

public final void convertFromSAX(SAXResult result,
                                 Output output)
                          throws java.io.FileNotFoundException,
                                 java.io.IOException
Should be called by the Process which outputs SAX events. It is assumed that the ContentHandler used by the Process has been fetched using getSAXContentHandler. This function will check the input type of the dependent process or processes and perform the conversion from SAX to DOM/Stream. The function will call setOutputResult as there could be multiple results to be set for multiple inputs
Parameters:
result - the process result as a SAXResult object
output - output object to be associated with the SAX, to be piped into the input of the next process in pipeline
Throws:
FileNoFoundException
java.io.IOException
java.io.FileNotFoundException

convertFromDOM

public final void convertFromDOM(DOMResult res,
                                 Output output)
                          throws SAXException,
                                 java.io.IOException,
                                 PipelineException
Should be called by the Process which outputs DOM. This function will check the input type of the dependent process or processes and perform the conversion from DOM to SAX/Stream. The function will call setOutputResult as there could be multiple results to be set for multiple inputs
Parameters:
res - the process result as a DOMResult object
output - output object associated with result, to be piped to the next process in pipeline
Throws:
SAXException
java.io.IOException
PipelineException

convertFromStream

public final void convertFromStream(StreamResult res,
                                    Output output)
                             throws SAXException,
                                    java.io.IOException,
                                    PipelineException
Should be called by the Process which outputs xml as Stream. This function will check the input type of the dependent process or processes and perform the conversion from Stream to DOM/SAX. The function will call setOutputResult as there could be multiple results to be set for multiple inputs.
Parameters:
res - the process result as a StreamResult object
output - output object to be associated with the result, to be piped to the input of the next process in the pipeline
Throws:
SAXException
java.io.IOException
PipelineException

Oracle® Application Server
XML Java API Reference
10g Release 3 (10.1.3)

B28238-01


Copyright © 2003, 2006, Oracle. All rights reserved.