net.sf.saxon.functions
Class FormatNumber
- SequenceIterable, Serializable, EvaluableItem, InstructionInfoProvider, SourceLocator, XSLTFunction
public class FormatNumber
XSLT 2.0 implementation of format-number() function - removes the dependence on the JDK.
addContextDocumentArgument , addDocToPathMap , checkArguments , computeCardinality , computeSpecialProperties , copy , getDetails , getErrorCodeForTypeErrors , getItemType , getRequiredType , makeSystemFunction , optimize , setDetails , useContextItemAsDefault |
addExternalFunctionCallToPathMap , checkArgumentCount , checkArguments , equals , explain , getArguments , getDisplayName , getFunctionName , getNumberOfArguments , hashCode , iterateSubExpressions , optimize , preEvaluate , promote , replaceSubExpression , setArguments , setFunctionName , simplify , simplifyArguments , toString , typeCheck |
addToPathMap , adoptChildExpression , checkPermittedContents , computeCardinality , computeDependencies , computeSpecialProperties , computeStaticProperties , copy , display , doPromotion , dynamicError , effectiveBooleanValue , evaluateAsString , evaluateItem , explain , explain , findParentOf , getCardinality , getColumnNumber , getConstructType , getContainer , getDependencies , getExecutable , getHostLanguage , getImplementationMethod , getInstructionInfo , getIntrinsicDependencies , getItemType , getLineNumber , getLocationId , getLocationProvider , getPublicId , getSlotsUsed , getSpecialProperties , getSystemId , hasLoopingSubexpression , implementsStaticTypeCheck , iterate , iterateEvents , iterateSubExpressions , markTailFunctionCalls , optimize , process , promote , replaceSubExpression , resetLocalStaticProperties , setContainer , setFiltered , setFlattened , setLocationId , simplify , staticTypeCheck , suppressValidation , toString , typeCheck , typeError |
adjustToDecimal
public static BigDecimal adjustToDecimal(double value,
int precision)
Convert a double to a BigDecimal. In general there will be several BigDecimal values that
are equal to the supplied value, and the one we want to choose is the one with fewest non-zero
digits. The algorithm used is rather pragmatic: look for a string of zeroes or nines, try rounding
the number down or up as approriate, then convert the adjusted value to a double to see if it's
equal to the original: if not, use the original value unchanged.
value
- the double to be convertedprecision
- 2 for a double, 1 for a float
- the result of conversion to a double
fixup
public void fixup(DecimalSymbols dfs)
Fixup: this is a callback from the DecimalFormatManager used once the xsl:decimal-format
element is identified
dfs
- the decimal symbols to be used