Package dap4.core.util
Class CoreTypeFcns
- java.lang.Object
-
- dap4.core.util.CoreTypeFcns
-
public abstract class CoreTypeFcns extends Object
-
-
Constructor Summary
Constructors Constructor Description CoreTypeFcns()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ObjectattributeConvert(DapType type, Object value)Force an attribute value (typically string) to match a given basetypestatic ObjectcreateVector(TypeSort type, long count)static longforceRange(TypeSort 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 Objectget(DapType type, Object v, int n)static Objectget(TypeSort sort, ByteBuffer b, int n)static intgetJavaSize(TypeSort atomtype)protected static longminmax(long value, long min, long max)Peg a value to either the min or max depending on sign.static voidput(TypeSort sort, Object v, int n, Object value)static intputVector(TypeSort sort, Object v, int offset, Object vec)
-
-
-
Method Detail
-
attributeConvert
public static Object attributeConvert(DapType type, Object value)
Force an attribute value (typically string) to match a given basetype- Parameters:
type- expected typevalue- actual value- Returns:
- the value as made to conform to the expected type
-
getJavaSize
public static int getJavaSize(TypeSort atomtype)
-
forceRange
public static long forceRange(TypeSort 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. The term "force" means that if the value is outside the typed min/max values, it is pegged to the min or max value depending on the sign. Note that truncation is not used.- Parameters:
basetype- the type to force value to in rangevalue- the value to force- Returns:
- forced value
- Throws:
ConversionException- if forcing is not possible
-
minmax
protected static long minmax(long value, long min, long max)Peg a value to either the min or max depending on sign.- Parameters:
value- the value to pegmin- peg to this if value is < minmax- peg to this if value is > max- Returns:
- pegg'ed value
-
get
public static Object get(TypeSort sort, ByteBuffer b, int n)
-
-