com.xml_project.morganaxproc.core.steptypes
Class AtomicStep

java.lang.Object
  extended by com.xml_project.morganaxproc.core.steptypes.Step
      extended by com.xml_project.morganaxproc.core.steptypes.ContainerStep
          extended by com.xml_project.morganaxproc.core.steptypes.CompoundStep
              extended by com.xml_project.morganaxproc.core.steptypes.RunnableStep
                  extended by com.xml_project.morganaxproc.core.steptypes.BuildInStep
                      extended by com.xml_project.morganaxproc.core.steptypes.AtomicStep
All Implemented Interfaces:
com.xml_project.morganaxproc.xpath.functions.FunctionResolver

public abstract class AtomicStep
extends com.xml_project.morganaxproc.core.steptypes.BuildInStep

This abstract class should be used as base class for XProc extension steps written in java.

For details see the documentation.

Apart from declaring the input ports, options and output ports for the new step, you have to provide two static methods for MorganaXProc to recognize your step. These two methods must have the following signature:


Nested Class Summary
 class AtomicStep.IllegalAccessException
           
 
Nested classes/interfaces inherited from class com.xml_project.morganaxproc.core.steptypes.Step
com.xml_project.morganaxproc.core.steptypes.Step.PortTestModes
 
Field Summary
 
Fields inherited from class com.xml_project.morganaxproc.core.steptypes.BuildInStep
NewInstanceSignature
 
Fields inherited from class com.xml_project.morganaxproc.core.steptypes.Step
stepErrors
 
Constructor Summary
protected AtomicStep(com.xml_project.morganaxproc.core.CompilationContext context, String name, com.xml_project.morganaxproc.core.steptypes.CompoundStep parent, int line, int column, nu.xom.Attribute[] extensionAttributes)
           
 
Method Summary
 XPathInXProcSelector compileXPath(String xpathExpression, String baseUri, com.xml_project.xom.XOMUtilities.NamespaceMap declaredNamespaces)
           Prepares an XPath expression for evaluation
 XPathInXProcSequence compileXPath(String xpathExpression, String baseUri, com.xml_project.xom.XOMUtilities.NamespaceMap declaredNamespaces, nu.xom.Document[] sequence)
           Prepares an XPath expression for a sequence evaluation
 XPathInXProcPattern compileXPathPattern(String patternExpression, String baseUri, com.xml_project.xom.XOMUtilities.NamespaceMap declaredNamespaces)
           Prepares an XPath match pattern for evaluation
 void declareInputPort(String name, boolean sequence, boolean primary)
           Declares a new input port for the step.
 void declareOption(QName name, SequenceType type, String value)
           Declares a new option with a default value.
 void declareOutputPort(String name, boolean sequence, boolean primary)
           Declares a new output port for the step.
 void declareRequiredOption(QName name, SequenceType type)
           Declares a new required option.
protected abstract  void execute(String stepURI)
           This method must be implemented for the new step
 com.xml_project.morganaxproc.core.XProcRuntime.PortValueMap execute(com.xml_project.morganaxproc.core.XProcRuntime runtime, com.xml_project.morganaxproc.core.XProcRuntime.PortValueMap init, com.xml_project.morganaxproc.core.XProcRuntime.ValueMap options, String stepURI)
          This method is a wrapper around the abstract execute method.
protected  nu.xom.Document getInputPortDocument(String portName)
           Returns the first document of the named port.
protected  nu.xom.Document[] getInputPortDocuments(String portName)
           Returns the documents of the named port.
protected  OptionValue getOptionValue(QName name)
           Returns the OptionValue of the named option.
protected  String getOptionValueAsString(QName name)
           Returns the value of the named option as String
protected  void setOutputPortDocument(String portName, nu.xom.Document document)
           Puts a single document on the named port.
protected  void setOutputPortDocuments(String portName, nu.xom.Document[] documents)
           Puts a sequence of documents on the named port.
 
Methods inherited from class com.xml_project.morganaxproc.core.steptypes.BuildInStep
checkStepConnections, discoverDependencies, fixParameterPorts, makeAttribute, makeWrapper, setDocumentConnection, setParameter
 
Methods inherited from class com.xml_project.morganaxproc.core.steptypes.RunnableStep
checkAllOptionsDeclared, compileDeclareStep, compileLibrary, declareOption, dumpPorts, fixBinding, getAllDeclaredPipeline, getAllDeclaredPipeline, getDeclaredOptionNames, getDeclaredOptions, getExcludeInlinePrefixes, getFunction, getLoadedStep, getLoadErrorMessage, getLocalDeclaredPipeline, getOptionDeclaration, getOptionValues, getRequiredXPathVersion, getSerializer, getSubpipelineContainer, getType, getXProcPrefix, getXProcVersion, isDeclaredOption, isImportHead, PSVI_is_Required, run, setSubpipeline
 
Methods inherited from class com.xml_project.morganaxproc.core.steptypes.CompoundStep
addStep, checkSpecialConnections, compilePipelineCall, compileSubpipeline, compileSubpipeline, finish, getDefaultReadablePort, getNumberOfSteps, getStep, getStep, getStepNr
 
Methods inherited from class com.xml_project.morganaxproc.core.steptypes.ContainerStep
addVariable, evaluateVariables, fixVariableBinding, fixVariableBinding, getNumberOfVariables, getVariableDeclaration, isDeclaredOptionOrVariable, parseNamespacesElements, parseVariableDeclaration
 
Methods inherited from class com.xml_project.morganaxproc.core.steptypes.Step
checkAndPutResult, checkAndPutResult, checkForLoops, declareImplicitOutputPort, declareInputPort, declareOutputPort, declareParameterPort, dumpPorts, findStepWithReadableOutputPort, getColumnNumber, getDeclaredInputAndParameterPorts, getDeclaredInputPorts, getDeclaredOutputPorts, getDeclaredParameterPorts, getExtensionAttribute, getExtensionAttributes, getInputPort, getLineNumber, getName, getOutputPort, getParameterPort, getParent, getPrimaryInputPort, getPrimaryOutputPort, getPrimaryParameterPort, getStepType, getStepWithFunctionLibrary, getURI, handleXPathException, hasInputPort, hasName, hasOutputPort, hasParameterPort, hasParent, isParentInputPort, isRunnable, makePortValueMap, parseLogStep, registerConnection, searchPrimaryInputPort, setOutputPortToSequence
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AtomicStep

protected AtomicStep(com.xml_project.morganaxproc.core.CompilationContext context,
                     String name,
                     com.xml_project.morganaxproc.core.steptypes.CompoundStep parent,
                     int line,
                     int column,
                     nu.xom.Attribute[] extensionAttributes)
Method Detail

declareInputPort

public final void declareInputPort(String name,
                                   boolean sequence,
                                   boolean primary)

Declares a new input port for the step. Always set primary for the primary input step even if this is implicitly clear.

Parameters:
name - new port's name
sequence - new port's sequence attribute
primary - new port's primary attribute

declareOutputPort

public final void declareOutputPort(String name,
                                    boolean sequence,
                                    boolean primary)

Declares a new output port for the step. Always set primary for the primary output step even if this is implicitly clear.

Parameters:
name - new port's name
sequence - new port's sequence attribute
primary - new port's primary attribute

declareOption

public final void declareOption(QName name,
                                SequenceType type,
                                String value)

Declares a new option with a default value.

Parameters:
name - new option's name
type - new option's XPathSequenceType
value - new option's default value or null for no default value.

declareRequiredOption

public final void declareRequiredOption(QName name,
                                        SequenceType type)

Declares a new required option.

Parameters:
name - new option's name.
type - new option's type

execute

public final com.xml_project.morganaxproc.core.XProcRuntime.PortValueMap execute(com.xml_project.morganaxproc.core.XProcRuntime runtime,
                                                                                 com.xml_project.morganaxproc.core.XProcRuntime.PortValueMap init,
                                                                                 com.xml_project.morganaxproc.core.XProcRuntime.ValueMap options,
                                                                                 String stepURI)
                                                                          throws com.xml_project.morganaxproc.core.XProcRuntimeException,
                                                                                 com.xml_project.morganaxproc.core.StepException
This method is a wrapper around the abstract execute method.

Specified by:
execute in class com.xml_project.morganaxproc.core.steptypes.BuildInStep
Throws:
com.xml_project.morganaxproc.core.XProcRuntimeException
com.xml_project.morganaxproc.core.StepException

compileXPathPattern

public final XPathInXProcPattern compileXPathPattern(String patternExpression,
                                                     String baseUri,
                                                     com.xml_project.xom.XOMUtilities.NamespaceMap declaredNamespaces)
                                              throws AtomicStep.IllegalAccessException,
                                                     XPathException

Prepares an XPath match pattern for evaluation

Parameters:
patternExpression - the match pattern expression to be prepared for evaluation.
baseUri - the base uri for this evaluation
declaredNamespaces - the namespace declarations for this match pattern expression.
Returns:
an XPathInXProcPattern ready to evaluate.
Throws:
AtomicStep.IllegalAccessException - if method is called outside 'execute(String)'.
XPathException - if an error occurred in preparing the xpath.

compileXPath

public final XPathInXProcSelector compileXPath(String xpathExpression,
                                               String baseUri,
                                               com.xml_project.xom.XOMUtilities.NamespaceMap declaredNamespaces)
                                        throws AtomicStep.IllegalAccessException,
                                               XPathException

Prepares an XPath expression for evaluation

Parameters:
xpathExpression - the XPath expression to be prepared for evaluation.
baseUri - the base uri for this evaluation.
declaredNamespaces - the namespace declarations for this xpath expression.
Returns:
an XPathInXProcSelector ready to evaluate.
Throws:
AtomicStep.IllegalAccessException - if method is called outside 'execute(String)'.
XPathException - if an error occurred in preparing the XPath.

compileXPath

public final XPathInXProcSequence compileXPath(String xpathExpression,
                                               String baseUri,
                                               com.xml_project.xom.XOMUtilities.NamespaceMap declaredNamespaces,
                                               nu.xom.Document[] sequence)
                                        throws AtomicStep.IllegalAccessException,
                                               XPathException

Prepares an XPath expression for a sequence evaluation

Parameters:
xpathExpression - the XPath expression to be prepared for evaluation.
baseUri - the base uri for this evaluation.
declaredNamespaces - the namespace declaration for this expression.
sequence - the sequence of documents to be evaluated.
Returns:
an XPathInProcSequence representing the results.
Throws:
AtomicStep.IllegalAccessException - if method is called outside 'execute(String)'.
XPathException - if an error occurred in preparing the XPath.

execute

protected abstract void execute(String stepURI)
                         throws com.xml_project.morganaxproc.core.XProcRuntimeException,
                                com.xml_project.morganaxproc.core.StepException,
                                AtomicStep.IllegalAccessException

This method must be implemented for the new step

Parameters:
stepURI - the uri of this step
Throws:
com.xml_project.morganaxproc.core.XProcRuntimeException - if a dynamic error occurred
com.xml_project.morganaxproc.core.StepException - if a step error (c:xxxx) occurred
AtomicStep.IllegalAccessException - if your implementation tries to access a port or an option not declared for this step.

getInputPortDocument

protected final nu.xom.Document getInputPortDocument(String portName)
                                              throws AtomicStep.IllegalAccessException

Returns the first document of the named port.

Parameters:
portName - the port name
Returns:
the first document on the named port or null if the port contains an empty sequence.
Throws:
AtomicStep.IllegalAccessException - if the port's name is not declared for this step.

getInputPortDocuments

protected final nu.xom.Document[] getInputPortDocuments(String portName)
                                                 throws AtomicStep.IllegalAccessException

Returns the documents of the named port.

Parameters:
portName - the port name
Returns:
the documents found on this port.
Throws:
AtomicStep.IllegalAccessException - if the port's name is not declared for this step.

getOptionValue

protected final OptionValue getOptionValue(QName name)
                                    throws AtomicStep.IllegalAccessException

Returns the OptionValue of the named option.

Parameters:
name - the option name.
Returns:
the OptionValue for this option.
Throws:
AtomicStep.IllegalAccessException - if the option's name is not declared for this step.

getOptionValueAsString

protected final String getOptionValueAsString(QName name)
                                       throws AtomicStep.IllegalAccessException

Returns the value of the named option as String

Parameters:
name - the option name
Returns:
the option'value or null, if no value is found.
Throws:
AtomicStep.IllegalAccessException - if the option's name is not declared for this step.

setOutputPortDocuments

protected final void setOutputPortDocuments(String portName,
                                            nu.xom.Document[] documents)
                                     throws AtomicStep.IllegalAccessException

Puts a sequence of documents on the named port.

Parameters:
portName - the port's name
documents - the documents to put on the port.
Throws:
AtomicStep.IllegalAccessException - if the port's name is not declared for this step.

setOutputPortDocument

protected final void setOutputPortDocument(String portName,
                                           nu.xom.Document document)
                                    throws AtomicStep.IllegalAccessException

Puts a single document on the named port.

Parameters:
portName - the ports name
document - the document to put on the port.
Throws:
AtomicStep.IllegalAccessException - if the port's name is not declared for this step.