public abstract class Convert
extends java.lang.Object
Additionally: since we need to pass arbitrary values of primitive types, we pass an Object which is assumed to be a vector of the primitive type. So we pass int[] instead of int or Integer. This is because the primitive type values are not a subclass of Object. We could use the wrapper types (e.g. Integer) but using a vector is more closely aligned with the way CDM does it.
Constructor and Description |
---|
Convert() |
Modifier and Type | Method and Description |
---|---|
static java.lang.Object |
convert(DapType dsttype,
DapType srctype,
java.lang.Object values)
Convert Object to a value consistent with the given type.
|
protected static long[] |
double2long(double[] in) |
protected static double[] |
long2double(long[] in) |
protected static double[] |
string2double(java.lang.String[] in) |
protected static long[] |
string2long(java.lang.String[] in) |
static DapType |
vectorType(java.lang.Object o) |
public static java.lang.Object convert(DapType dsttype, DapType srctype, java.lang.Object values)
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 float[] must be true.values
- The vector of values to convertConversionException
- if cannot convert (runtime exception)protected static long[] double2long(double[] in)
protected static double[] long2double(long[] in)
protected static long[] string2long(java.lang.String[] in)
protected static double[] string2double(java.lang.String[] in)
public static DapType vectorType(java.lang.Object o)