Package com.amazon.ion
Interface IonNumber
-
- All Superinterfaces:
java.lang.Cloneable,IonValue
- All Known Subinterfaces:
IonDecimal,IonFloat,IonInt
public interface IonNumber extends IonValue
Common functionality of Ionint,decimal, andfloattypes.WARNING: This interface should not be implemented or extended by code outside of this library.
-
-
Field Summary
-
Fields inherited from interface com.amazon.ion.IonValue
EMPTY_ARRAY
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.math.BigDecimalbigDecimalValue()Gets the value of this Ion number as aBigDecimal.booleanisNumericValue()Determines whether this value is numeric.-
Methods inherited from interface com.amazon.ion.IonValue
accept, addTypeAnnotation, clearTypeAnnotations, clone, equals, getContainer, getFieldId, getFieldName, getFieldNameSymbol, getSymbolTable, getSystem, getType, getTypeAnnotations, getTypeAnnotationSymbols, hashCode, hasTypeAnnotation, isNullValue, isReadOnly, makeReadOnly, removeFromContainer, removeTypeAnnotation, setTypeAnnotations, setTypeAnnotationSymbols, topLevelValue, toPrettyString, toString, toString, writeTo
-
-
-
-
Method Detail
-
bigDecimalValue
java.math.BigDecimal bigDecimalValue()
Gets the value of this Ion number as aBigDecimal.This method will throw an exception for non-null, non-numeric values. It's recommended to call
isNumericValue()before calling this method.Negative zero is supported by
IonDecimalandIonFloat, but not byBigDecimal. If you need to distinguish positive and negative zero, you should callIonDecimal.decimalValue()orIonFloat.doubleValue()after casting to the appropriate type.- Returns:
- the
BigDecimalvalue, ornullifthis.isNullValue(). - Throws:
java.lang.NumberFormatException- if this value isnan,+inf, or-inf, becauseBigDecimalcannot represent those values.
-
isNumericValue
boolean isNumericValue()
Determines whether this value is numeric. Returns true if this value is none ofnull,nan,+inf, and-inf, and false if it is any of them.- Returns:
- a checked condition whether this value is numeric.
-
-