Package net.sf.saxon.expr
Class NumberSequenceFormatter
- java.lang.Object
-
- net.sf.saxon.expr.Expression
-
- net.sf.saxon.expr.NumberSequenceFormatter
-
- All Implemented Interfaces:
ExportAgent
,Locatable
,IdentityComparable
,Traceable
public class NumberSequenceFormatter extends Expression
This expression performs the formatting part of the logic of the xsl:number instruction It takes as input a sequence of integers, which may either be supplied directly as the value attribute of xsl:number, or may be computed by counting nodes. The expression returns a string.
-
-
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 NumberSequenceFormatter(Expression value, Expression format, Expression groupSize, Expression groupSeparator, Expression letterValue, Expression ordinal, Expression startAt, Expression lang, NumberFormatter formatter, boolean backwardsCompatible)
Construct a NumberSequenceFormatter
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
computeCardinality()
Compute the static cardinality of this expressionExpression
copy(RebindingMap rebindings)
Copy an expression.StringValue
evaluateItem(XPathContext context)
Evaluate an expression as a single item.void
export(ExpressionPresenter out)
Diagnostic print of expression structure.int
getImplementationMethod()
An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().ItemType
getItemType()
Determine the static item type of the expression, as precisely possible.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.Expression
optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo)
Perform optimisation of an expression and its subexpressions.java.util.List<java.lang.Integer>
parseStartAtValue(java.lang.String value)
void
preallocateNumberer(Configuration config)
Expression
simplify()
Simplify an expression.-
Methods inherited from class net.sf.saxon.expr.Expression
addToPathMap, adoptChildExpression, allowExtractingCommonSubexpressions, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeHashCode, computeSpecialProperties, computeStaticProperties, dynamicError, effectiveBooleanValue, equals, evaluateAsString, evaluatePendingUpdates, explain, getCardinality, getConfiguration, getCost, getDependencies, getEvaluationMethod, getExpressionName, 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, simplifyChildren, staticTypeCheck, suppressValidation, toPattern, toShortString, toString, typeCheck, 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
-
NumberSequenceFormatter
public NumberSequenceFormatter(Expression value, Expression format, Expression groupSize, Expression groupSeparator, Expression letterValue, Expression ordinal, Expression startAt, Expression lang, NumberFormatter formatter, boolean backwardsCompatible)
Construct a NumberSequenceFormatter- Parameters:
value
- the expression supplied in the value attribute, or theNumberInstruction
which computes the place-markerformat
- the expression supplied in the format attributegroupSize
- the expression supplied in the group-size attributegroupSeparator
- the expression supplied in the grouping-separator attributeletterValue
- the expression supplied in the letter-value attributeordinal
- the expression supplied in the ordinal attributestartAt
- the expression supplied in the start-at attributelang
- the expression supplied in the lang attributeformatter
- A NumberFormatter to be usedbackwardsCompatible
- true if running in 1.0 compatibility mode with a real value attribute
-
-
Method Detail
-
simplify
public Expression simplify() throws XPathException
Simplify an expression. This performs any static optimization (by rewriting the expression as a different expression). The default implementation simplifies its operands.- Overrides:
simplify
in classExpression
- Returns:
- the simplified expression (or the original if unchanged, or if modified in-situ)
- Throws:
XPathException
- if an error is discovered during expression rewriting
-
preallocateNumberer
public void preallocateNumberer(Configuration config) throws XPathException
- Throws:
XPathException
-
operands
public java.lang.Iterable<Operand> operands()
Description copied from class:Expression
Get the immediate sub-expressions of this expression, with information about the relationship of each expression to its parent expression. Default implementation works off the results of iterateSubExpressions()If the expression is a Callable, then it is required that the order of the operands returned by this function is the same as the order of arguments supplied to the corresponding call() method.
- Overrides:
operands
in classExpression
- Returns:
- an iterator containing the sub-expressions of this expression
-
optimize
public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException
Description copied from class:Expression
Perform 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:
optimize
in classExpression
- Parameters:
visitor
- an expression visitorcontextInfo
- 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 toType.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)
-
copy
public Expression copy(RebindingMap rebindings)
Copy an expression. This makes a deep copy.- Specified by:
copy
in classExpression
- Parameters:
rebindings
- variables that need to be re-bound- Returns:
- the copy of the original expression
-
getItemType
public ItemType getItemType()
Description copied from class:Expression
Determine the static item type of the expression, as precisely possible. All expression return sequences, in general; this method determines the type of the items within the sequence, assuming that (a) this is known in advance, and (b) it is the same for all items in the sequence.This method should always return a result, though it may be the best approximation that is available at the time.
- Specified by:
getItemType
in classExpression
- Returns:
- a value such as Type.STRING, Type.BOOLEAN, Type.NUMBER, Type.NODE, or Type.ITEM (meaning not known at compile time)
-
computeCardinality
public int computeCardinality()
Description copied from class:Expression
Compute the static cardinality of this expression- Specified by:
computeCardinality
in classExpression
- 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 StringValue evaluateItem(XPathContext context) throws XPathException
Description copied from class:Expression
Evaluate an expression as a single item. This always returns either a single Item or null (denoting the empty sequence). No conversion is done. This method should not be used unless the static type of the expression is a subtype of "item" or "item?": that is, it should not be called if the expression may return a sequence. There is no guarantee that this condition will be detected.- 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
-
parseStartAtValue
public java.util.List<java.lang.Integer> parseStartAtValue(java.lang.String value) throws XPathException
- Throws:
XPathException
-
export
public void export(ExpressionPresenter out) throws XPathException
Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.- Specified by:
export
in interfaceExportAgent
- Specified by:
export
in classExpression
- 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.
-
-