Class Datatype<T>

java.lang.Object
uk.ac.starlink.tfcat.Datatype<T>

public abstract class Datatype<T> extends Object
Characterises the type of data held by a field.
Since:
9 Feb 2022
Author:
Mark Taylor
  • Field Details

  • Method Details

    • getName

      public String getName()
      Returns the name of this datatype, as used in the datatype member of a field.
      Returns:
      type name
    • getTypeClass

      public Class<T> getTypeClass()
      Returns the object class represented by this datatype.
      Returns:
      class
    • decode

      public abstract T decode(String txt)
      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

      public abstract boolean isType(String txt)
      Indicates whether a string value appears to have this type. If this returns true, then decode(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

      public String toString()
      Overrides:
      toString in class Object
    • forName

      public static Datatype<?> forName(String name)
      Returns the datatype instance for a given type name.
      Parameters:
      name - datatype name
      Returns:
      Datatype instance, or null if none matches name