Package net.sf.saxon.expr
Class TryCatch
- java.lang.Object
- 
- net.sf.saxon.expr.Expression
- 
- net.sf.saxon.expr.TryCatch
 
 
- 
- All Implemented Interfaces:
- ExportAgent,- Locatable,- IdentityComparable,- Traceable
 
 public class TryCatch extends Expression This class implements a try/catch expression. It consists of a try expression, and a sequence of Nametest/Catch expression pairs. If the try expression succeeds, its result is returned; otherwise the error code of the exception is matched against each of the Nametests in turn, and the first matching catch expression is evaluated.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classTryCatch.CatchClause
 - 
Field Summary- 
Fields inherited from class net.sf.saxon.expr.ExpressionEFFECTIVE_BOOLEAN_VALUE, EVALUATE_METHOD, ITEM_FEED_METHOD, ITERATE_METHOD, MAX_COST, MAX_SEQUENCE_LENGTH, MAX_STRING_LENGTH, PROCESS_METHOD, staticProperties, UNBOUNDED_LOWER, UNBOUNDED_UPPER, UPDATE_METHOD, WATCH_METHOD
 
- 
 - 
Constructor SummaryConstructors Constructor Description TryCatch(Expression tryExpr)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCatchExpression(QNameTest test, Expression catchExpr)booleanallowExtractingCommonSubexpressions()Ask whether common subexpressions found in the operands of this expression can be extracted and evaluated outside the expression itself.intcomputeCardinality()Determine the cardinality of the function.intcomputeHashCode()Hashcode supporting equals()Expressioncopy(RebindingMap rebindings)Copy an expression.booleanequals(java.lang.Object other)Is this expression the same as another expression?ItemevaluateItem(XPathContext c)Evaluate as a singleton itemvoidexport(ExpressionPresenter out)Diagnostic print of expression structure.java.util.List<TryCatch.CatchClause>getCatchClauses()Get the list of catch clausesjava.lang.StringgetExpressionName()Get a name identifying the kind of expression, in terms meaningful to a user.intgetImplementationMethod()An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().ItemTypegetItemType()Determine the item type of the value returned by the functionjava.lang.StringgetStreamerName()Get the (partial) name of a class that supports streaming of this kind of expressionExpressiongetTryExpr()Get the "try" expressionOperandgetTryOperand()Get the "try" operandbooleanisInstruction()Ask whether this expression is an instruction.booleanisRollbackOutput()SequenceIteratoriterate(XPathContext c)Iterate over the results of the functionjava.lang.Iterable<Operand>operands()Get the immediate sub-expressions of this expression, with information about the relationship of each expression to its parent expression.Expressionoptimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo)Perform optimisation of an expression and its subexpressions.voidprocess(Outputter output, XPathContext context)Process the instruction, without returning any tail callsvoidsetRollbackOutput(boolean rollback)- 
Methods inherited from class net.sf.saxon.expr.ExpressionaddToPathMap, adoptChildExpression, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeSpecialProperties, computeStaticProperties, dynamicError, effectiveBooleanValue, evaluateAsString, evaluatePendingUpdates, explain, getCardinality, getConfiguration, getCost, getDependencies, getEvaluationMethod, getExtraProperty, getIntegerBounds, getInterpretedExpression, getIntrinsicDependencies, getLocalRetainedStaticContext, getLocation, getNetCost, getObjectName, getPackageData, getParentExpression, getProperties, getProperty, getRetainedStaticContext, getScopingExpression, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStaticType, getStaticUType, getTracingTag, hasCompatibleStaticContext, hashCode, hasSpecialProperty, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isCallOn, isEqual, isIdentical, isLiftable, isMultiThreaded, isStaticPropertiesKnown, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, markTailFunctionCalls, operandList, operandSparseList, optimizeChildren, prepareForStreaming, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplify, simplifyChildren, staticTypeCheck, suppressValidation, toPattern, toShortString, toString, typeCheck, typeCheckChildren, typeError, unordered, verifyParentPointers
 - 
Methods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface net.sf.saxon.trace.TraceablegatherProperties
 
- 
 
- 
- 
- 
Constructor Detail- 
TryCatchpublic TryCatch(Expression tryExpr) 
 
- 
 - 
Method Detail- 
addCatchExpressionpublic void addCatchExpression(QNameTest test, Expression catchExpr) 
 - 
setRollbackOutputpublic void setRollbackOutput(boolean rollback) 
 - 
isRollbackOutputpublic boolean isRollbackOutput() 
 - 
getTryOperandpublic Operand getTryOperand() Get the "try" operand- Returns:
- the primary operand to be evaluated
 
 - 
getTryExprpublic Expression getTryExpr() Get the "try" expression- Returns:
- the primary expression to be evaluated
 
 - 
getCatchClausespublic java.util.List<TryCatch.CatchClause> getCatchClauses() Get the list of catch clauses- Returns:
- the list of catch clauses
 
 - 
isInstructionpublic boolean isInstruction() Ask whether this expression is an instruction. In XSLT streamability analysis this is used to distinguish constructs corresponding to XSLT instructions from other constructs, typically XPath expressions.- Overrides:
- isInstructionin class- Expression
- Returns:
- true (if this construct exists at all in an XSLT environment, then it represents an instruction)
 
 - 
allowExtractingCommonSubexpressionspublic boolean allowExtractingCommonSubexpressions() Ask whether common subexpressions found in the operands of this expression can be extracted and evaluated outside the expression itself. The result is irrelevant in the case of operands evaluated with a different focus, which will never be extracted in this way, even if they have no focus dependency.- Overrides:
- allowExtractingCommonSubexpressionsin class- Expression
- Returns:
- false for this kind of expression
 
 - 
computeCardinalitypublic int computeCardinality() Determine the cardinality of the function.- Specified by:
- computeCardinalityin class- Expression
- Returns:
- the computed cardinality, as one of the values StaticProperty.ALLOWS_ZERO_OR_ONE,StaticProperty.EXACTLY_ONE,StaticProperty.ALLOWS_ONE_OR_MORE,StaticProperty.ALLOWS_ZERO_OR_MORE. May also returnStaticProperty.ALLOWS_ZEROif the result is known to be an empty sequence, orStaticProperty.ALLOWS_MANYif if is known to return a sequence of length two or more.
 
 - 
getItemTypepublic ItemType getItemType() Determine the item type of the value returned by the function- Specified by:
- getItemTypein class- Expression
- Returns:
- a value such as Type.STRING, Type.BOOLEAN, Type.NUMBER, Type.NODE, or Type.ITEM (meaning not known at compile time)
 
 - 
operandspublic java.lang.Iterable<Operand> operands() Get the immediate sub-expressions of this expression, with information about the relationship of each expression to its parent expression. Default implementation returns a zero-length array, appropriate for an expression that has no sub-expressions.- Overrides:
- operandsin class- Expression
- Returns:
- an iterator containing the sub-expressions of this expression
 
 - 
optimizepublic Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException Description copied from class:ExpressionPerform optimisation of an expression and its subexpressions. This is the third and final phase of static optimization.This method is called after all references to functions and variables have been resolved to the declaration of the function or variable, and after all type checking has been done. - Overrides:
- optimizein class- Expression
- Parameters:
- visitor- an expression visitor
- contextInfo- the static type of "." at the point where this expression is invoked. The parameter is set to null if it is known statically that the context item will be undefined. If the type of the context item is not known statically, the argument is set to- Type.ITEM_TYPE
- Returns:
- the original expression, rewritten if appropriate to optimize execution
- Throws:
- XPathException- if an error is discovered during this phase (typically a type error)
 
 - 
getImplementationMethodpublic int getImplementationMethod() An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process(). This method indicates which of these methods is provided directly. The other methods will always be available indirectly, using an implementation that relies on one of the other methods.- Specified by:
- getImplementationMethodin class- Expression
- Returns:
- the implementation method, for example Expression.ITERATE_METHODorExpression.EVALUATE_METHODorExpression.PROCESS_METHOD
 
 - 
equalspublic boolean equals(java.lang.Object other) Is this expression the same as another expression?- Overrides:
- equalsin class- Expression
- Parameters:
- other- the expression to be compared with this one
- Returns:
- true if the two expressions are statically equivalent
 
 - 
computeHashCodepublic int computeHashCode() Hashcode supporting equals()- Overrides:
- computeHashCodein class- Expression
- Returns:
- a computed hash code
 
 - 
copypublic Expression copy(RebindingMap rebindings) Copy an expression. This makes a deep copy.- Specified by:
- copyin class- Expression
- Parameters:
- rebindings- variables that need to be re-bound
- Returns:
- the copy of the original expression
 
 - 
evaluateItempublic Item evaluateItem(XPathContext c) throws XPathException Evaluate as a singleton item- Overrides:
- evaluateItemin class- Expression
- Parameters:
- c- the dynamic XPath evaluation context
- Returns:
- the node or atomic value that results from evaluating the expression; or null to indicate that the result is an empty sequence
- Throws:
- XPathException- if any dynamic error occurs evaluating the expression
 
 - 
iteratepublic SequenceIterator iterate(XPathContext c) throws XPathException Iterate over the results of the function- Overrides:
- iteratein class- Expression
- Parameters:
- c- supplies the context for evaluation
- Returns:
- a SequenceIterator that can be used to iterate over the result of the expression
- Throws:
- XPathException- if any dynamic error occurs evaluating the expression
 
 - 
processpublic void process(Outputter output, XPathContext context) throws XPathException Description copied from class:ExpressionProcess the instruction, without returning any tail calls- Overrides:
- processin class- Expression
- Parameters:
- output- the destination for the result
- context- The dynamic context, giving access to the current node, the current variables, etc.
- Throws:
- XPathException- if a dynamic error occurs
 
 - 
getExpressionNamepublic java.lang.String getExpressionName() Get a name identifying the kind of expression, in terms meaningful to a user.- Overrides:
- getExpressionNamein class- Expression
- Returns:
- a name identifying the kind of expression, in terms meaningful to a user. The name will always be in the form of a lexical XML QName, and should match the name used in explain() output displaying the expression.
 
 - 
exportpublic void export(ExpressionPresenter out) throws XPathException Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.- Specified by:
- exportin interface- ExportAgent
- Specified by:
- exportin class- Expression
- Parameters:
- out- the expression presenter used to display the structure
- Throws:
- XPathException- if the export fails, for example if an expression is found that won't work in the target environment.
 
 - 
getStreamerNamepublic java.lang.String getStreamerName() Get the (partial) name of a class that supports streaming of this kind of expression- Overrides:
- getStreamerNamein class- Expression
- Returns:
- the partial name of a class that can be instantiated to provide streaming support in Saxon-EE, or null if there is no such class
 
 
- 
 
-