Package uk.ac.starlink.tfcat
Class Datatype<T>
java.lang.Object
uk.ac.starlink.tfcat.Datatype<T>
Characterises the type of data held by a field.
- Since:
- 9 Feb 2022
- Author:
- Mark Taylor
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionabstract T
Decodes a string value that has this type.static Datatype<?>
Returns the datatype instance for a given type name.getName()
Returns the name of this datatype, as used in the datatype member of a field.Returns the object class represented by this datatype.abstract boolean
Indicates whether a string value appears to have this type.toString()
-
Field Details
-
INT
Integer type. -
FLOAT
Floating point type. -
BOOL
Boolean type. -
STRING
String type.
-
-
Method Details
-
getName
Returns the name of this datatype, as used in the datatype member of a field.- Returns:
- type name
-
getTypeClass
Returns the object class represented by this datatype.- Returns:
- class
-
decode
Decodes a string value that has this type.- Parameters:
txt
- JSON string representation of a typed value- Returns:
- typed value
- Throws:
RuntimeException
- if the value cannot be decoded
-
isType
Indicates whether a string value appears to have this type. If this returns true, thendecode(java.lang.String)
should return a value without error.- Parameters:
txt
- JSON string representation of a typed value- Returns:
- true if the string is of the right type
-
toString
-
forName
Returns the datatype instance for a given type name.- Parameters:
name
- datatype name- Returns:
- Datatype instance, or null if none matches name
-