Package oracle.nosql.driver.values
Class NumberValue
- java.lang.Object
-
- oracle.nosql.driver.values.FieldValue
-
- oracle.nosql.driver.values.NumberValue
-
- All Implemented Interfaces:
Comparable<FieldValue>
public class NumberValue extends FieldValue
AFieldValue
instance representing an arbitrary-precision numeric value. It is stored as a JavaBigDecimal
and the serialized format is the String value of that number.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class oracle.nosql.driver.values.FieldValue
FieldValue.Type
-
-
Constructor Summary
Constructors Constructor Description NumberValue(String value)
Creates a new instance from a String valueNumberValue(BigDecimal value)
Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
castAsDouble()
Casts this number to a double, possibly with loss of information about magnitude, precision or sign.int
compareTo(FieldValue other)
boolean
equals(Object other)
String
getString()
Returns a String value for the field.FieldValue.Type
getType()
Returns the type of the objectBigDecimal
getValue()
Returns the number value of this objectint
hashCode()
String
toJson(JsonOptions options)
Returns a JSON representation of the value using the options, if specified.-
Methods inherited from class oracle.nosql.driver.values.FieldValue
asArray, asBinary, asBoolean, asDouble, asInteger, asJsonNull, asLong, asMap, asNull, asNumber, asString, asTimestamp, createFromJson, createFromJson, createFromJson, getBinary, getBoolean, getDouble, getInt, getLong, getNumber, getSerializedSize, getTimestamp, isAnyNull, isArray, isAtomic, isBinary, isBoolean, isDouble, isInteger, isJsonNull, isLong, isMap, isNull, isNumber, isNumeric, isString, isTimestamp, toJson, toString
-
-
-
-
Constructor Detail
-
NumberValue
public NumberValue(BigDecimal value)
Creates a new instance.- Parameters:
value
- the value to use
-
NumberValue
public NumberValue(String value)
Creates a new instance from a String value- Parameters:
value
- the value to use- Throws:
NumberFormatException
- if the value is not a valid BigDecimal
-
-
Method Detail
-
getType
public FieldValue.Type getType()
Description copied from class:FieldValue
Returns the type of the object- Specified by:
getType
in classFieldValue
- Returns:
- the type
-
getValue
public BigDecimal getValue()
Returns the number value of this object- Returns:
- the number value
-
castAsDouble
public double castAsDouble()
Casts this number to a double, possibly with loss of information about magnitude, precision or sign.- Overrides:
castAsDouble
in classFieldValue
- Returns:
- a double value
-
compareTo
public int compareTo(FieldValue other)
-
getString
public String getString()
Description copied from class:FieldValue
Returns a String value for the field. The String value cannot be created for MapValue, ArrayValue and BinaryValue. String values that are coerced use Java rules for representation.- Overrides:
getString
in classFieldValue
- Returns:
- a String value
-
toJson
public String toJson(JsonOptions options)
Description copied from class:FieldValue
Returns a JSON representation of the value using the options, if specified.- Overrides:
toJson
in classFieldValue
- Parameters:
options
- configurable options used to affect the JSON output format of some data types. May be null.- Returns:
- the JSON representation of this value.
-
-