public abstract class NumericValue extends AtomicValue implements XPathComparable, AtomicMatchKey, ContextFreeAtomicValue
typeLabel
Constructor and Description |
---|
NumericValue() |
Modifier and Type | Method and Description |
---|---|
abstract NumericValue |
abs()
Get the absolute value as defined by the XPath abs() function
|
abstract 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
|
abstract NumericValue |
ceiling()
Implement the XPath ceiling() function
|
abstract int |
compareTo(long other)
Compare the value to a long
|
int |
compareTo(XPathComparable other)
Compare the value to another numeric value
|
abstract boolean |
effectiveBooleanValue()
Get the effective boolean value of the value.
|
boolean |
equals(java.lang.Object other)
The equals() function compares numeric equality among integers, decimals, floats, doubles, and
their subtypes.
|
abstract NumericValue |
floor()
Implement the XPath floor() function
|
abstract java.math.BigDecimal |
getDecimalValue()
Get the numeric value converted to a decimal
|
abstract double |
getDoubleValue()
Get the numeric value as a double
|
abstract float |
getFloatValue()
Get the numeric value converted to a float
|
XPathComparable |
getXPathComparable()
Get an XPathComparable object that supports the semantics of context-free
eq and lt comparisons between atomic values.
|
XPathComparable |
getXPathComparable(StringCollator collator,
int implicitTimezone)
Get an object value that implements the XPath equality and ordering comparison semantics for this value.
|
AtomicMatchKey |
getXPathMatchKey(StringCollator collator,
int implicitTimezone)
Get a Comparable value that implements the XPath ordering comparison semantics for this value.
|
abstract int |
hashCode()
hashCode() must be the same for two values that are equal.
|
static boolean |
isInteger(AtomicValue value)
Test whether a value is an integer (an instance of a subtype of xs:integer)
|
boolean |
isNegativeZero()
Ask whether this value is negative zero
|
abstract boolean |
isWholeNumber()
Ask whether the value is a whole number, that is, whether it compares
equal to some integer
|
abstract long |
longValue()
Return the numeric value as a Java long.
|
abstract NumericValue |
negate()
Change the sign of the number
|
static NumericValue |
parseNumber(java.lang.String in)
Get a numeric value by parsing a string; the type of numeric value depends
on the lexical form of the string, following the rules for XPath numeric
literals.
|
abstract NumericValue |
round(int scale)
Implement the XPath round() function
|
abstract NumericValue |
roundHalfToEven(int scale)
Implement the XPath 2.0 round-half-to-even() function
|
java.lang.String |
show()
Produce a string representation of the value
|
abstract int |
signum()
Ask whether the value is negative, zero, or positive
|
asAtomic, asMapKey, atomize, checkPermittedContents, checkValidInJavascript, copyAsSubType, getCanonicalLexicalRepresentation, getCardinality, getComponent, getGenre, getItemType, getLength, getPrimitiveStringValue, getPrimitiveType, getUnicodeStringValue, getUType, head, identityHashCode, isIdentical, isIdentical, isNaN, isUntypedAtomic, itemAt, iterate, iterator, setTypeLabel, toShortString, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
asAtomic
getStringValue, isStreamed, reduce, subsequence
asIterable, concatenate, containsNode, materialize
makeRepeatable
public static NumericValue parseNumber(java.lang.String in)
in
- the input stringpublic abstract double getDoubleValue()
public abstract float getFloatValue()
public abstract java.math.BigDecimal getDecimalValue() throws ValidationException
ValidationException
- if the value cannot be converted, for example if it is NaN or infinitepublic abstract boolean effectiveBooleanValue()
effectiveBooleanValue
in interface GroundedValue
effectiveBooleanValue
in class AtomicValue
public static boolean isInteger(AtomicValue value)
value
- the value being testedpublic abstract long longValue() throws XPathException
XPathException
- if the value cannot be convertedpublic abstract NumericValue negate()
public abstract NumericValue floor()
public abstract NumericValue ceiling()
public abstract NumericValue round(int scale)
scale
- the number of decimal places required in the result (supply 0 for rounding to an integer)public abstract NumericValue roundHalfToEven(int scale)
scale
- the decimal position for rounding: e.g. 2 rounds to a
multiple of 0.01, while -2 rounds to a multiple of 100public abstract int signum()
public boolean isNegativeZero()
public abstract boolean isWholeNumber()
public abstract int asSubscript()
public abstract NumericValue abs()
public final AtomicMatchKey getXPathMatchKey(StringCollator collator, int implicitTimezone)
getXPathMatchKey
in class AtomicValue
collator
- the collation to be used when comparing stringsimplicitTimezone
- the implicit timezone in the dynamic context, used when comparing
dates/times with and without timezonepublic XPathComparable getXPathComparable(StringCollator collator, int implicitTimezone) throws NoDynamicContextException
AtomicValue
getXPathComparable
in class AtomicValue
collator
- the collation to be used when comparing stringsimplicitTimezone
- the implicit timezone in the dynamic context, used when comparing
dates/times with and without timezoneNoDynamicContextException
- if the supplied implicit timezone is "NO_TIMEZONE" (meaning
unknown), and the implicit timezone is actually required because the value in question is a date/time
value with no timezone. This can cause a failure to evaluate expressions statically (because the implicit
timezone is not known statically), and it will then be caught, meaning that the expression has to be
evaluated dynamically.public XPathComparable getXPathComparable()
ContextFreeAtomicValue
Comparable
interface, this
cannot be assumed.getXPathComparable
in interface ContextFreeAtomicValue
public int compareTo(XPathComparable other)
compareTo
in interface java.lang.Comparable<XPathComparable>
other
- The other numeric valuejava.lang.ClassCastException
- if the other value is not a NumericValue
(the parameter is declared as Object to satisfy the Comparable
interface)public abstract int compareTo(long other)
other
- the value to be compared withpublic final boolean equals(java.lang.Object other)
equals
in class AtomicValue
other
- the value to be compared with this onepublic abstract int hashCode()
hashCode
in class AtomicValue
public java.lang.String show()
show
in class AtomicValue
Copyright (c) 2004-2022 Saxonica Limited. All rights reserved.