net.sf.saxon.value

Class DecimalValue

public final class DecimalValue extends NumericValue

A decimal value
Field Summary
static BigDecimalONE
static BigDecimalONE_MILLION
static BigIntegerTEN
Constructor Summary
DecimalValue(BigDecimal value)
Constructor supplying a BigDecimal
DecimalValue(double in)
Constructor supplying a double
DecimalValue(long in)
Constructor supplying a long integer
Method Summary
NumericValuearithmetic(int operator, NumericValue other, XPathContext context)
Evaluate a binary arithmetic operator.
NumericValueceiling()
Implement the XPath ceiling() function
intcompareTo(Object other)
Compare the value to another numeric value
AtomicValueconvertPrimitive(BuiltInAtomicType requiredType, boolean validate, XPathContext context)
Convert to target data type
ObjectconvertToJava(Class target, XPathContext context)
Convert to Java object (for passing to external functions)
static StringdecimalToString(BigDecimal value)
booleaneffectiveBooleanValue(XPathContext context)
NumericValuefloor()
Implement the XPath floor() function
ItemTypegetItemType(TypeHierarchy th)
Determine the data type of the expression
StringgetStringValue()
Get the value as a String
BigDecimalgetValue()
Get the value
inthashCode()
Get the hashCode.
booleanisWholeNumber()
Determine whether the value is a whole number, that is, whether it compares equal to some integer
static AtomicValuemakeDecimalValue(CharSequence in, boolean validate)
Factory method to construct a DecimalValue from a string
NumericValuenegate()
Negate the value
NumericValueround()
Implement the XPath round() function
NumericValueroundToHalfEven(int scale)
Implement the XPath round-to-half-even() function
booleanschemaEquals(Value obj)
Compare two values for equality.
doublesignum()
Determine whether the value is negative, zero, or positive

Field Detail

ONE

public static final BigDecimal ONE

ONE_MILLION

public static final BigDecimal ONE_MILLION

TEN

public static final BigInteger TEN

Constructor Detail

DecimalValue

public DecimalValue(BigDecimal value)
Constructor supplying a BigDecimal

Parameters: value the value of the DecimalValue

DecimalValue

public DecimalValue(double in)
Constructor supplying a double

Parameters: in the value of the DecimalValue

DecimalValue

public DecimalValue(long in)
Constructor supplying a long integer

Parameters: in the value of the DecimalValue

Method Detail

arithmetic

public NumericValue arithmetic(int operator, NumericValue other, XPathContext context)
Evaluate a binary arithmetic operator.

ceiling

public NumericValue ceiling()
Implement the XPath ceiling() function

compareTo

public int compareTo(Object other)
Compare the value to another numeric value

convertPrimitive

public AtomicValue convertPrimitive(BuiltInAtomicType requiredType, boolean validate, XPathContext context)
Convert to target data type

convertToJava

public Object convertToJava(Class target, XPathContext context)
Convert to Java object (for passing to external functions)

decimalToString

public static String decimalToString(BigDecimal value)

effectiveBooleanValue

public boolean effectiveBooleanValue(XPathContext context)

floor

public NumericValue floor()
Implement the XPath floor() function

getItemType

public ItemType getItemType(TypeHierarchy th)
Determine the data type of the expression

Parameters: th

Returns: Type.DECIMAL

getStringValue

public String getStringValue()
Get the value as a String

Returns: a String representation of the value

getValue

public BigDecimal getValue()
Get the value

hashCode

public int hashCode()
Get the hashCode. This must conform to the rules for other NumericValue hashcodes

See Also: NumericValue

isWholeNumber

public boolean isWholeNumber()
Determine whether the value is a whole number, that is, whether it compares equal to some integer

makeDecimalValue

public static AtomicValue makeDecimalValue(CharSequence in, boolean validate)
Factory method to construct a DecimalValue from a string

Parameters: in the value of the DecimalValue validate true if validation is required; false if the caller knows that the value is valid

Returns: the required DecimalValue if the input is valid, or an ErrorValue encapsulating the error message if not.

negate

public NumericValue negate()
Negate the value

round

public NumericValue round()
Implement the XPath round() function

roundToHalfEven

public NumericValue roundToHalfEven(int scale)
Implement the XPath round-to-half-even() function

schemaEquals

public boolean schemaEquals(Value obj)
Compare two values for equality. This supports identity constraints in XML Schema, which allow list-valued elements and attributes to participate in key and uniqueness constraints. This method returns false if any error occurs during the comparison, or if any of the items in either sequence is a node rather than an atomic value. The default implementation of schemaEquals() is the same as equals(), but subclasses can override this.

signum

public double signum()
Determine whether the value is negative, zero, or positive

Returns: -1 if negative, 0 if zero, +1 if positive, NaN if NaN