public abstract class NumericValue extends AtomicValue implements Comparable
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 NumericValue |
ceiling()
Implement the XPath ceiling() function
|
abstract int |
compareTo(long other)
Compare the value to a long
|
int |
compareTo(Object other)
Compare the value to another numeric value
|
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
|
abstract 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
|
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
|
abstract 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.
|
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
|
abstract int |
signum()
Determine whether the value is negative, zero, or positive
|
String |
toString()
Produce a string representation of the value
|
asAtomic, checkPermittedContents, copyAsSubType, effectiveBooleanValue, getCanonicalLexicalRepresentation, getCardinality, getComponent, getItemType, getPrimitiveStringValue, getPrimitiveType, getSchemaComparable, getStringValue, getStringValueCS, head, isIdentical, isIdentical, isNaN, itemAt, iterate, process, setTypeLabel
getLength, reduce, subsequence
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getLength
reduce, subsequence
public static NumericValue parseNumber(String in)
in
- the input stringpublic abstract double getDoubleValue()
public abstract float getFloatValue()
public abstract BigDecimal getDecimalValue() throws XPathException
XPathException
- if the value cannot be converted, for example if it is NaN or infinitepublic 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)
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 abstract boolean isWholeNumber()
public abstract NumericValue abs()
public final Object getXPathComparable(boolean ordered, StringCollator collator, XPathContext context)
getXPathComparable
in class AtomicValue
ordered
- collator
- context
- public int compareTo(Object other)
compareTo
in interface Comparable
other
- The other numeric valueClassCastException
- 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(Object other)
equals
in class AtomicValue
other
- the value to be compared with this onepublic abstract int hashCode()
public String toString()
toString
in class AtomicValue
Copyright (c) 2004-2013 Saxonica Limited. All rights reserved.