net.sf.saxon.value

Class DoubleValue

public final class DoubleValue extends NumericValue

A numeric (double precision floating point) value
Field Summary
static PatternnonExponentialPattern
static DoubleValueNaN
static DoubleValueZERO
Constructor Summary
DoubleValue(CharSequence val)
Constructor supplying a string
DoubleValue(double value)
Constructor supplying a double
Method Summary
NumericValuearithmetic(int operator, NumericValue other, XPathContext context)
Evaluate a binary arithmetic operator.
NumericValueceiling()
Implement the XPath ceiling() function
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 CharSequencedoubleToString(double value)
Internal method used for conversion of a double to a string
static CharSequencedoubleToStringOLD(double value, String javaString)
Internal method used for conversion of a double to a string
booleaneffectiveBooleanValue(XPathContext context)
Get the effective boolean value
NumericValuefloor()
Implement the XPath floor() function
doublegetDoubleValue()
Return this numeric value as a double
ItemTypegetItemType(TypeHierarchy th)
Determine the data type of the expression
StringgetStringValue()
Convert the double to a string according to the XPath 2.0 rules
CharSequencegetStringValueCS()
Convert the double to a string according to the XPath 2.0 rules
inthashCode()
Get the hashCode.
booleanisNaN()
Test whether the value is the double/float value NaN
booleanisWholeNumber()
Determine whether the value is a whole number, that is, whether it compares equal to some integer
NumericValuenegate()
Negate the value
static voidprintInternalForm(double d)
Diagnostic method
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
static Stringzeros(int n)

Field Detail

nonExponentialPattern

static Pattern nonExponentialPattern

NaN

public static final DoubleValue NaN

ZERO

public static final DoubleValue ZERO

Constructor Detail

DoubleValue

public DoubleValue(CharSequence val)
Constructor supplying a string

Throws: ValidationException if the string does not have the correct lexical form for a double. Note that the error will contain no error code or context information.

DoubleValue

public DoubleValue(double value)
Constructor supplying a double

Parameters: value the value of the NumericValue

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

convertPrimitive

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

Parameters: requiredType an integer identifying the required atomic type context

Returns: an AtomicValue, a value of the required type

convertToJava

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

doubleToString

public static CharSequence doubleToString(double value)
Internal method used for conversion of a double to a string

Parameters: value the actual value

Returns: the value converted to a string, according to the XPath casting rules.

doubleToStringOLD

public static CharSequence doubleToStringOLD(double value, String javaString)
Internal method used for conversion of a double to a string

Parameters: value the actual value javaString the result of converting the double to a string using the Java conventions. This value is adjusted as necessary to cater for the differences between the Java and XPath rules.

Returns: the value converted to a string, according to the XPath casting rules.

effectiveBooleanValue

public boolean effectiveBooleanValue(XPathContext context)
Get the effective boolean value

Parameters: context

Returns: the effective boolean value (true unless the value is zero or NaN)

floor

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

getDoubleValue

public double getDoubleValue()
Return this numeric value as a double

Returns: the value as a double

getItemType

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

Parameters: th

Returns: Type.DOUBLE

getStringValue

public String getStringValue()
Convert the double to a string according to the XPath 2.0 rules

Returns: the string value

getStringValueCS

public CharSequence getStringValueCS()
Convert the double to a string according to the XPath 2.0 rules

Returns: the string value

hashCode

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

See Also: NumericValue

isNaN

public boolean isNaN()
Test whether the value is the double/float value NaN

isWholeNumber

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

negate

public NumericValue negate()
Negate the value

printInternalForm

public static void printInternalForm(double d)
Diagnostic method

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 (including negative zero), +1 if positive, NaN if NaN

zeros

static String zeros(int n)