org.cdlib.xtf.saxonExt.exec
Class RunInstruction

Object
  extended by Expression
      extended by SimpleExpression
          extended by RunInstruction
All Implemented Interfaces:
Serializable, SourceLocator, Container, EvaluableItem, SequenceIterable, InstructionInfoProvider
Direct Known Subclasses:
PipeImageInstruction

 class RunInstruction
extends SimpleExpression

Utility class that does most of the work for RunElement.


Field Summary
protected  Expression command
           
protected  InputElement.InputInstruction inputExpr
           
protected  int nArgs
           
protected  int timeout
           
 
Fields inherited from class SimpleExpression
arguments, NO_ARGUMENTS
 
Fields inherited from class Expression
EVALUATE_METHOD, ITERATE_METHOD, locationId, PROCESS_METHOD, staticProperties
 
Constructor Summary
RunInstruction(Expression command, int timeout, List args)
           
 
Method Summary
 Item evaluateItem(XPathContext context)
           
protected  String[] gatherArgs(XPathContext context)
          Gather all the arguments for this instruction and make them into a convenient array.
 String getExpressionType()
           
 int getImplementationMethod()
          A subclass must provide one of the methods evaluateItem(), iterate(), or process().
protected  byte[] runAndGrab(XPathContext context, String[] argArray)
          Run the external process, applying a timeout if specified, feeding it input on stdin and gathering the results from stdout.
 
Methods inherited from class SimpleExpression
computeCardinality, computeDependencies, display, getItemType, iterate, iterateSubExpressions, optimize, process, promote, replaceSubExpression, setArguments, simplify, typeCheck
 
Methods inherited from class Expression
adoptChildExpression, checkPermittedContents, computeSpecialProperties, computeStaticProperties, doPromotion, dynamicError, effectiveBooleanValue, evaluateAsString, getCardinality, getColumnNumber, getConstructType, getContainingProcedure, getDependencies, getExecutable, getHostLanguage, getInstructionInfo, getIntrinsicDependencies, getLineNumber, getLocationId, getLocationProvider, getParentExpression, getPublicId, getSlotsUsed, getSpecialProperties, getSystemId, hasBadParentPointer, markTailFunctionCalls, resetStaticProperties, setLocationId, setParentExpression, setParentExpression, suppressValidation, typeError
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

command

protected Expression command

timeout

protected int timeout

nArgs

protected int nArgs

inputExpr

protected InputElement.InputInstruction inputExpr
Constructor Detail

RunInstruction

public RunInstruction(Expression command,
                      int timeout,
                      List args)
Method Detail

getImplementationMethod

public int getImplementationMethod()
A subclass must provide one of the methods evaluateItem(), iterate(), or process(). This method indicates which of the three is provided.

Overrides:
getImplementationMethod in class Expression

getExpressionType

public String getExpressionType()
Overrides:
getExpressionType in class SimpleExpression

evaluateItem

public Item evaluateItem(XPathContext context)
                  throws XPathException
Specified by:
evaluateItem in interface EvaluableItem
Overrides:
evaluateItem in class SimpleExpression
Throws:
XPathException

runAndGrab

protected byte[] runAndGrab(XPathContext context,
                            String[] argArray)
                     throws XPathException,
                            DynamicError
Run the external process, applying a timeout if specified, feeding it input on stdin and gathering the results from stdout. If a non-zero exit status is returned, we throw an exception containing the output string from stderr.

Throws:
XPathException
DynamicError

gatherArgs

protected String[] gatherArgs(XPathContext context)
                       throws XPathException
Gather all the arguments for this instruction and make them into a convenient array.

Throws:
XPathException