public abstract class Convert
extends java.lang.Object
Constructor and Description |
---|
Convert() |
Modifier and Type | Method and Description |
---|---|
static java.lang.Object |
convert(DapType dsttype,
DapType srctype,
java.lang.Object value)
Convert Object to a value consistent with the given type.
|
static double |
doubleValue(DapType srctype,
java.lang.Object value)
Special case of convertValue restricted to numeric conversions
Convert numeric value to a double value
|
static double |
forceRange(AtomicType basetype,
double value)
Force a double value into either float or double range
|
static long |
forceRange(AtomicType basetype,
long value)
Force a numeric value to be in a specified range
Only defined for simple integers (ValueClass LONG)
WARNING: unsigned values are forced into the
signed size, but the proper bit pattern is maintained.
|
static java.lang.Object |
fromString(java.lang.String value,
DapType dsttype)
Convert string to a value consistent with the base type.
|
static int |
getJavaSize(AtomicType atomtype) |
static int |
getJavaSize(DapType daptype) |
static long |
longValue(DapType srctype,
java.lang.Object value)
Special case of convertValue restricted to integer conversions
Convert numeric value to a value consistent with the given type.
|
static java.math.BigInteger |
toBigInteger(long l)
UInt64 long values are kept as longs,
but to properly process them,
it is necessary to convert them
to a correct form of BigInteger
|
static java.lang.String |
toString(java.lang.Object value,
DapType srctype)
Convert a value to a string constant
|
static java.lang.Object |
upcast(java.lang.Object o,
DapType srctype)
Given an value from a DapAttribute,
convert it to avoid losing information.
|
static DapType |
upcastType(DapType basetype)
Given a DapAttribute basetype
convert it to avoid losing information.
|
public static DapType upcastType(DapType basetype)
basetype
- the basetype of the DapAttributepublic static java.lang.Object upcast(java.lang.Object o, DapType srctype)
o
- the object to upcastsrctype
- the basetype of the DapAttributepublic static int getJavaSize(DapType daptype)
public static int getJavaSize(AtomicType atomtype)
public static java.lang.Object convert(DapType dsttype, DapType srctype, java.lang.Object value)
dsttype
- Type to which the object is to be converted.srctype
- Assumed type of the value; must be consistent
in sense that if srctype == float32, then
e.g value instanceof double must be true.value
- The object to convertConversionException
- if cannot convertpublic static long longValue(DapType srctype, java.lang.Object value)
srctype
- Assumed type of the value; must be a numeric typevalue
- The object to convert; it is an instance of
Long or DoubleConversionException
- if cannot convert
(including out of range)public static double doubleValue(DapType srctype, java.lang.Object value)
srctype
- Assumed type of the value; must be a numeric typevalue
- The object to convertConversionException
- if cannot convert
(including out of range)public static java.math.BigInteger toBigInteger(long l)
l
- The long valuepublic static long forceRange(AtomicType basetype, long value)
basetype
- the type to force value to in rangevalue
- the value to forceConversionException
- if forcing is not possiblepublic static double forceRange(AtomicType basetype, double value) throws DapException
basetype
- the type to force value to in rangevalue
- the value to forceDapException
- if forcing is not possiblepublic static java.lang.Object fromString(java.lang.String value, DapType dsttype)
value
- the string to convertdsttype
- target type for the conversionConversionException
- if cannot convertpublic static java.lang.String toString(java.lang.Object value, DapType srctype)
value
- The object to convertsrctype
- The assumed type of the value