public final class BigDecimalValue extends DecimalValue
| Modifier and Type | Field and Description |
|---|---|
static java.math.BigDecimal |
BIG_DECIMAL_ONE_BILLION |
static java.math.BigDecimal |
BIG_DECIMAL_ONE_MILLION |
static int |
DIVIDE_PRECISION |
static java.math.BigDecimal |
MAX_INT |
static BigDecimalValue |
ONE |
static BigDecimalValue |
THREE |
static BigDecimalValue |
TWO |
static BigDecimalValue |
ZERO |
typeLabel| Constructor and Description |
|---|
BigDecimalValue(java.math.BigDecimal value)
Constructor supplying a BigDecimal
|
BigDecimalValue(double in)
Constructor supplying a double
|
BigDecimalValue(long in)
Constructor supplying a long integer
|
| Modifier and Type | Method and Description |
|---|---|
NumericValue |
abs()
Get the absolute value as defined by the XPath abs() function
|
int |
asSubscript()
Test whether a number is a possible subscript into a sequence, that is,
a whole number greater than zero and less than 2^31
|
static boolean |
castableAsDecimal(java.lang.String in)
Test whether a string is castable to a decimal value
|
NumericValue |
ceiling()
Implement the XPath ceiling() function
|
int |
compareTo(long other)
Compare the value to a long
|
int |
compareTo(XPathComparable other)
Compare the value to another numeric value
|
AtomicValue |
copyAsSubType(AtomicType typeLabel)
Create a copy of this atomic value, with a different type label
|
static java.lang.StringBuilder |
decimalToString(java.math.BigDecimal value,
java.lang.StringBuilder fsb)
Convert a decimal value to a string, using the XPath rules for formatting
|
boolean |
effectiveBooleanValue()
Get the effective boolean value of the value.
|
NumericValue |
floor()
Implement the XPath floor() function
|
UnicodeString |
getCanonicalLexicalRepresentation()
Get the canonical lexical representation as defined in XML Schema.
|
java.math.BigDecimal |
getDecimalValue()
Get the value
|
double |
getDoubleValue()
Get the numeric value as a double
|
float |
getFloatValue()
Get the numeric value converted to a float
|
UnicodeString |
getPrimitiveStringValue()
Get the value as a String
|
BuiltInAtomicType |
getPrimitiveType()
Determine the primitive type of the value.
|
XPathComparable |
getXPathComparable(StringCollator collator,
int implicitTimezone)
Get an object value that implements the XPath equality and ordering comparison semantics for this value.
|
int |
hashCode()
Get the hashCode.
|
boolean |
isIdentical(AtomicValue v)
Determine whether two atomic values are identical, as determined by XML Schema rules.
|
boolean |
isWholeNumber()
Determine whether the value is a whole number, that is, whether it compares
equal to some integer
|
long |
longValue()
Return the numeric value as a Java long.
|
static ConversionResult |
makeDecimalValue(java.lang.String in,
boolean validate)
Factory method to construct a DecimalValue from a string
|
NumericValue |
negate()
Negate the value
|
static BigDecimalValue |
parse(java.lang.CharSequence in)
Factory method to construct a DecimalValue from a string, throwing an unchecked exception
if the value is invalid
|
NumericValue |
round(int scale)
Implement the XPath round() function
|
NumericValue |
roundHalfToEven(int scale)
Implement the XPath round-half-to-even() function
|
int |
signum()
Determine whether the value is negative, zero, or positive
|
equals, getXPathComparable, getXPathMatchKey, isInteger, isNegativeZero, parseNumber, showasAtomic, asMapKey, atomize, checkPermittedContents, checkValidInJavascript, getCardinality, getComponent, getGenre, getItemType, getLength, getUnicodeStringValue, getUType, head, identityHashCode, isIdentical, isNaN, isUntypedAtomic, itemAt, iterate, iterator, setTypeLabel, toShortString, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitasAtomicgetStringValue, isStreamed, reduce, subsequenceasIterable, concatenate, containsNode, materializemakeRepeatablepublic static final int DIVIDE_PRECISION
public static final java.math.BigDecimal BIG_DECIMAL_ONE_MILLION
public static final java.math.BigDecimal BIG_DECIMAL_ONE_BILLION
public static final BigDecimalValue ZERO
public static final BigDecimalValue ONE
public static final BigDecimalValue TWO
public static final BigDecimalValue THREE
public static final java.math.BigDecimal MAX_INT
public BigDecimalValue(java.math.BigDecimal value)
value - the value of the DecimalValuepublic BigDecimalValue(double in)
throws ValidationException
in - the value of the DecimalValueValidationException - if the supplied value cannot be converted, typically because it is INF or NaN.public BigDecimalValue(long in)
in - the value of the DecimalValuepublic static ConversionResult makeDecimalValue(java.lang.String in, boolean validate)
in - the value of the DecimalValuevalidate - true if validation is required; false if the caller knows that the value is validpublic static BigDecimalValue parse(java.lang.CharSequence in) throws java.lang.NumberFormatException
in - the lexical representation of the DecimalValuejava.lang.NumberFormatException - if the value is invalidpublic static boolean castableAsDecimal(java.lang.String in)
in - the string to be testedpublic AtomicValue copyAsSubType(AtomicType typeLabel)
copyAsSubType in class AtomicValuetypeLabel - the type label of the new copy. The caller is responsible for checking that
the value actually conforms to this type.public BuiltInAtomicType getPrimitiveType()
getPrimitiveType in class AtomicValuepublic double getDoubleValue()
getDoubleValue in class NumericValuepublic float getFloatValue()
getFloatValue in class NumericValuepublic long longValue()
throws XPathException
longValue in class NumericValueXPathException - if the value cannot be convertedpublic java.math.BigDecimal getDecimalValue()
getDecimalValue in class DecimalValuepublic int hashCode()
hashCode in class NumericValueNumericValue.hashCode()public boolean effectiveBooleanValue()
NumericValueeffectiveBooleanValue in interface GroundedValueeffectiveBooleanValue in class NumericValuepublic UnicodeString getCanonicalLexicalRepresentation()
getCanonicalLexicalRepresentation in interface AtomicSequencegetCanonicalLexicalRepresentation in class AtomicValuepublic UnicodeString getPrimitiveStringValue()
getPrimitiveStringValue in class AtomicValuepublic static java.lang.StringBuilder decimalToString(java.math.BigDecimal value,
java.lang.StringBuilder fsb)
value - the decimal value to be convertedfsb - the StringBuilder to which the value is to be appendedpublic NumericValue negate()
negate in class NumericValuepublic NumericValue floor()
floor in class NumericValuepublic NumericValue ceiling()
ceiling in class NumericValuepublic NumericValue round(int scale)
round in class NumericValuescale - the number of decimal places required in the result (supply 0 for rounding to an integer)public NumericValue roundHalfToEven(int scale)
roundHalfToEven in class NumericValuescale - the decimal position for rounding: e.g. 2 rounds to a
multiple of 0.01, while -2 rounds to a multiple of 100public int signum()
signum in class NumericValuepublic boolean isWholeNumber()
isWholeNumber in class NumericValuepublic int asSubscript()
asSubscript in class NumericValuepublic NumericValue abs()
abs in class NumericValuepublic XPathComparable getXPathComparable(StringCollator collator, int implicitTimezone)
AtomicValuegetXPathComparable in class NumericValuecollator - the collation to be used when comparing stringsimplicitTimezone - the implicit timezone in the dynamic context, used when comparing
dates/times with and without timezonepublic int compareTo(XPathComparable other)
compareTo in interface java.lang.Comparable<XPathComparable>compareTo in class NumericValueother - The other numeric valuepublic int compareTo(long other)
compareTo in class NumericValueother - the value to be compared withpublic boolean isIdentical(AtomicValue v)
Note that even this check ignores the type annotation of the value. The integer 3 and the short 3 are considered identical, even though they are not fully interchangeable. "Identical" means the same point in the value space, regardless of type annotation.
NaN is identical to itself.
isIdentical in class AtomicValuev - the other value to be compared with this oneCopyright (c) 2004-2022 Saxonica Limited. All rights reserved.