Package net.sf.saxon.expr
Class NegateExpression
- java.lang.Object
-
- net.sf.saxon.expr.Expression
-
- net.sf.saxon.expr.UnaryExpression
-
- net.sf.saxon.expr.NegateExpression
-
- All Implemented Interfaces:
ExportAgent
,Locatable
,IdentityComparable
,Traceable
public class NegateExpression extends UnaryExpression
Negate Expression: implements the unary minus operator. This expression is initially created as an ArithmeticExpression (or in backwards compatibility mode, an ArithmeticExpression10) to take advantage of the type checking code. So we don't need to worry about type checking or argument conversion.
-
-
Field Summary
-
Fields inherited from class net.sf.saxon.expr.Expression
EFFECTIVE_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 Summary
Constructors Constructor Description NegateExpression(Expression base)
Create a NegateExpression
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
computeCardinality()
Determine the static cardinality.Expression
copy(RebindingMap rebindings)
Copy an expression.protected java.lang.String
displayOperator(Configuration config)
Give a string representation of the operator for use in diagnosticsNumericValue
evaluateItem(XPathContext context)
Evaluate the expression.void
export(ExpressionPresenter out)
Diagnostic print of expression structure.java.lang.String
getExpressionName()
Get a name identifying the kind of expression, in terms meaningful to a user.int
getImplementationMethod()
An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().ItemType
getItemType()
Determine the data type of the expression, if this is known staticallyprotected OperandRole
getOperandRole()
Get the usage (in terms of streamability analysis) of the single operandboolean
isBackwardsCompatible()
Ask whether the expression is to be evaluated in XPath 1.0 compatibility modevoid
setBackwardsCompatible(boolean compatible)
Set whether the expression is to be evaluated in XPath 1.0 compatibility modeExpression
typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo)
Type-check the expression.-
Methods inherited from class net.sf.saxon.expr.UnaryExpression
computeHashCode, computeSpecialProperties, emitExtraAttributes, equals, getBaseExpression, getOperand, operands, optimize, setBaseExpression, toShortString, toString
-
Methods inherited from class net.sf.saxon.expr.Expression
addToPathMap, adoptChildExpression, allowExtractingCommonSubexpressions, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, 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, getStreamerName, getTracingTag, hasCompatibleStaticContext, hashCode, hasSpecialProperty, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isCallOn, isEqual, isIdentical, isInstruction, isLiftable, isMultiThreaded, isStaticPropertiesKnown, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, iterate, markTailFunctionCalls, operandList, operandSparseList, optimizeChildren, prepareForStreaming, process, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplify, simplifyChildren, staticTypeCheck, suppressValidation, toPattern, typeCheckChildren, typeError, unordered, verifyParentPointers
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.sf.saxon.trace.Traceable
gatherProperties
-
-
-
-
Constructor Detail
-
NegateExpression
public NegateExpression(Expression base)
Create a NegateExpression- Parameters:
base
- the expression that computes the value whose sign is to be reversed
-
-
Method Detail
-
setBackwardsCompatible
public void setBackwardsCompatible(boolean compatible)
Set whether the expression is to be evaluated in XPath 1.0 compatibility mode- Parameters:
compatible
- true if XPath 1.0 compatibility mode is enabled
-
isBackwardsCompatible
public boolean isBackwardsCompatible()
Ask whether the expression is to be evaluated in XPath 1.0 compatibility mode- Returns:
- true if XPath 1.0 compatibility mode is enabled
-
getOperandRole
protected OperandRole getOperandRole()
Description copied from class:UnaryExpression
Get the usage (in terms of streamability analysis) of the single operand- Specified by:
getOperandRole
in classUnaryExpression
- Returns:
- the operand usage
-
typeCheck
public Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException
Description copied from class:UnaryExpression
Type-check the expression. Default implementation for unary operators that accept any kind of operand- Overrides:
typeCheck
in classUnaryExpression
- Parameters:
visitor
- an expression visitorcontextInfo
- Information available statically about the context item: whether it is (possibly) absent; its static type; its streaming posture.- Returns:
- the original expression, rewritten to perform necessary run-time type checks, and to perform other type-related optimizations
- Throws:
XPathException
- if an error is discovered during this phase (typically a type error)
-
getItemType
public ItemType getItemType()
Determine the data type of the expression, if this is known statically- Overrides:
getItemType
in classUnaryExpression
- Returns:
- the item type of the items in the result sequence, insofar as this is known statically.
-
computeCardinality
public int computeCardinality()
Description copied from class:UnaryExpression
Determine the static cardinality. Default implementation returns the cardinality of the operand- Overrides:
computeCardinality
in classUnaryExpression
- 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_ZERO
if the result is known to be an empty sequence, orStaticProperty.ALLOWS_MANY
if if is known to return a sequence of length two or more.
-
getImplementationMethod
public 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:
getImplementationMethod
in classExpression
- Returns:
- the implementation method, for example
Expression.ITERATE_METHOD
orExpression.EVALUATE_METHOD
orExpression.PROCESS_METHOD
-
evaluateItem
public NumericValue evaluateItem(XPathContext context) throws XPathException
Evaluate the expression.- Overrides:
evaluateItem
in classExpression
- Parameters:
context
- The context in which the expression is to be evaluated- 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
-
copy
public Expression copy(RebindingMap rebindings)
Copy an expression. This makes a deep copy.- Specified by:
copy
in classExpression
- Parameters:
rebindings
-- Returns:
- the copy of the original expression
-
displayOperator
protected java.lang.String displayOperator(Configuration config)
Description copied from class:UnaryExpression
Give a string representation of the operator for use in diagnostics- Overrides:
displayOperator
in classUnaryExpression
- Parameters:
config
- the Saxon configuration- Returns:
- the operator, as a string
-
getExpressionName
public java.lang.String getExpressionName()
Get a name identifying the kind of expression, in terms meaningful to a user.- Overrides:
getExpressionName
in classExpression
- 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.
-
export
public void export(ExpressionPresenter out) throws XPathException
Description copied from class:UnaryExpression
Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.- Specified by:
export
in interfaceExportAgent
- Overrides:
export
in classUnaryExpression
- 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.
-
-