net.sf.saxon.value

Class FloatValue

public final class FloatValue extends NumericValue

A numeric (single precision floating point) value
Field Summary
static PatternroundablePattern
Regex indicating that a number may be worth rounding
Constructor Summary
FloatValue(CharSequence val)
Constructor supplying a string
FloatValue(float value)
Constructor supplying a float
Method Summary
NumericValuearithmetic(int operator, NumericValue other, XPathContext context)
Evaluate a binary arithmetic operator.
NumericValueceiling()
Implement the XPath ceiling() function
intcompareTo(Object other)
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)
booleaneffectiveBooleanValue(XPathContext context)
Get the effective boolean value
static CharSequencefloatToString(float value)
Internal method used for conversion of a float to a string
static CharSequencefloatToStringOLD(float value, String javaString)
Internal method used for conversion of a float to a string
NumericValuefloor()
Implement the XPath floor() function
doublegetDoubleValue()
floatgetFloatValue()
Get the value
ItemTypegetItemType(TypeHierarchy th)
Determine the data type of the expression
StringgetStringValue()
Get the value as a String
CharSequencegetStringValueCS()
Get the value as a String
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
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

roundablePattern

static Pattern roundablePattern
Regex indicating that a number may be worth rounding

Constructor Detail

FloatValue

public FloatValue(CharSequence val)
Constructor supplying a string

FloatValue

public FloatValue(float value)
Constructor supplying a float

Parameters: value the value of the float

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)

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; or an ErrorValue

convertToJava

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

effectiveBooleanValue

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

Parameters: context

Returns: true unless the value is zero or NaN

floatToString

static CharSequence floatToString(float value)
Internal method used for conversion of a float to a string

Parameters: value the actual value

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

floatToStringOLD

static CharSequence floatToStringOLD(float value, String javaString)
Internal method used for conversion of a float to a string

Parameters: value the actual value javaString the result of converting the float 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.

floor

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

getDoubleValue

public double getDoubleValue()

getFloatValue

public float getFloatValue()
Get the value

getItemType

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

Parameters: th

Returns: Type.DOUBLE

getStringValue

public String getStringValue()
Get the value as a String

Returns: a String representation of the value

getStringValueCS

public CharSequence getStringValueCS()
Get the value as a String

Returns: a String representation of the 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

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