net.sf.saxon.value
public abstract class NumericValue extends AtomicValue implements Comparable
Method Summary | |
---|---|
abstract NumericValue | abs()
Get the absolute value as defined by the XPath abs() function |
abstract NumericValue | ceiling()
Implement the XPath ceiling() function
|
int | compareTo(Object other)
Compare the value to another numeric value
|
abstract int | compareTo(long other)
Compare the value to a long |
boolean | equals(Object other)
The equals() function compares numeric equality among integers, decimals, floats, doubles, and
their subtypes
|
abstract NumericValue | floor()
Implement the XPath floor() function
|
BigDecimal | getDecimalValue()
Get the numeric value converted to a decimal |
double | getDoubleValue()
Get the numeric value as a double
|
float | getFloatValue()
Get the numeric value converted to a float |
Object | getXPathComparable(boolean ordered, StringCollator collator, XPathContext context)
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) |
abstract 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.
|
abstract NumericValue | negate()
Change the sign of the number
|
static NumericValue | parseNumber(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. |
static ItemType | promote(ItemType v1, ItemType v2, TypeHierarchy typeHierarchy)
Identify lowest common supertype of two numeric values for promotion purposes
|
abstract NumericValue | round()
Implement the XPath round() function
|
abstract NumericValue | roundHalfToEven(int scale)
Implement the XPath 2.0 round-half-to-even() function
|
abstract double | signum()
Determine whether the value is negative, zero, or positive |
String | toString()
Produce a string representation of the value |
Returns: the absolute value
Since: 9.2
Returns: a value, of the same type as that supplied, rounded towards plus infinity
Parameters: other The other numeric value
Returns: -1 if this one is the lower, 0 if they are numerically equal, +1 if this one is the higher, or if either value is NaN. Where NaN values are involved, they should be handled by the caller before invoking this method.
Throws: ClassCastException if the other value is not a NumericValue (the parameter is declared as Object to satisfy the Comparable interface)
Parameters: other the value to be compared with
Returns: -1 if this is less, 0 if this is equal, +1 if this is greater or if this is NaN
Parameters: other the value to be compared with this one
Returns: true if the two values are numerically equal
Returns: a value, of the same type as that supplied, rounded towards minus infinity
Returns: a decimal representing this numeric value;
Throws: XPathException if the value cannot be converted, for example if it is NaN or infinite
Returns: A double representing this numeric value; NaN if it cannot be converted
Returns: a float representing this numeric value; NaN if it cannot be converted
Parameters: ordered collator context
Returns: the hash code of the numeric value
Parameters: value the value being tested
Returns: true if the value is an instance of xs:integer or a type derived therefrom
Returns: true if the value is a whole number
Returns: the numeric value as a Java long. This performs truncation towards zero.
Throws: net.sf.saxon.trans.XPathException if the value cannot be converted
Returns: a value, of the same type as the original, with its sign inverted
Parameters: in the input string
Returns: a NumericValue representing the value of the string. Returns Double.NaN if the value cannot be parsed as a string.
Parameters: v1 the item type of the first operand v2 the item type of the second operand typeHierarchy the type hierarchy cache
Returns: the item type that should be used for arithmetic between operands of the two specified item types
Returns: a value, of the same type as that supplied, rounded towards the nearest whole number (0.5 rounded up)
Parameters: scale the decimal position for rounding: e.g. 2 rounds to a multiple of 0.01, while -2 rounds to a multiple of 100
Returns: a value, of the same type as the original, rounded towards the nearest multiple of 10**(-scale), with rounding towards the nearest even number if two values are equally near
Returns: -1 if negative, 0 if zero (including negative zero), +1 if positive, NaN if NaN
Returns: The result of casting the number to a string