Interface TokenType

  • All Superinterfaces:
    Serializable, TokenTyped
    All Known Subinterfaces:
    GenericTokenType, RecordTokenType, ScalarTokenType
    All Known Implementing Classes:
    EnumTokenType, ObjectTokenType

    public interface TokenType
    extends TokenTyped, Serializable
    A description of the properties of a token data type.

    Token types are organized in a hierarchy, from most general to most specific. At the root of the type hierarchy is the GenericTokenType generic type, which is primarily used as a place holder denoting any data type. Beneath this type are two major groups of types: scalar types and composite types. Scalars provide the atomic units of the typing system; composites provide the ability extend typing in a structured way.

    Any type can be used as a place holder for the set of its more specific types. Used on the inputs to an operator, it allows multiple input types to be accepted. Used on the output of an operator, it can denote a variably typed output. In this case the true type is determined from the inputs or settings of the operator. The operator documentation will clarify whether this is the case.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void checkComparable​(TokenType type)
      Tests whether tokens of the specified type can be compared to tokens of this type.
      void dispatchByType​(TokenTypeDispatcher dispatcher)
      Dispatches processing to the type-appropriate method of the specified dispatcher.
      int getEncodedByteSize()
      Gets the expected size, in bytes, for tokens of this type.
      boolean isAbstract()
      Indicates whether this type is abstract.
      boolean isAssignableFrom​(TokenType source)
      Indicates whether tokens of the specified type are compatible or implicitly convertible to this type.
      boolean isComposite()
      Indicates whether this type is a composite type.
      boolean isGeneric()
      Indicates whether this type is the generic type.
      boolean isScalar()
      Indicates whether this type is a scalar type.
      String name()
      Gets the printable name of this type.
    • Method Detail

      • name

        String name()
        Gets the printable name of this type.
        Returns:
        a user-friendly name for this type
      • isComposite

        boolean isComposite()
        Indicates whether this type is a composite type. That is, whether this type describes a structure composed from other types.
        Returns:
        whether this type is composite.
      • isGeneric

        boolean isGeneric()
        Indicates whether this type is the generic type.
        Returns:
        whether this type is the generic type.
      • isScalar

        boolean isScalar()
        Indicates whether this type is a scalar type.
        Returns:
        whether this type is scalar.
      • isAbstract

        boolean isAbstract()
        Indicates whether this type is abstract. Scalar types are never abstract. The generic type always is. Composite types are abstract if either: they are comprised of no fields or they contain an abstract type.
        Returns:
        whether this type is abstract.
      • isAssignableFrom

        boolean isAssignableFrom​(TokenType source)
        Indicates whether tokens of the specified type are compatible or implicitly convertible to this type.
        Parameters:
        source - the token type of the source data
        Returns:
        true if the source type can be converted.
      • checkComparable

        void checkComparable​(TokenType type)
        Tests whether tokens of the specified type can be compared to tokens of this type. For two types to be comparable, at least one type must be implicitly convertible to the other.
        Parameters:
        type - the token type of data to compare
        Throws:
        TypesNotComparableException - if the two types are not comparable.
      • getEncodedByteSize

        int getEncodedByteSize()
        Gets the expected size, in bytes, for tokens of this type. For variable sized types, such as binary data or strings, this is a guess of the average size.
        Returns:
        the estimated encoded size of a token of this type.
      • dispatchByType

        void dispatchByType​(TokenTypeDispatcher dispatcher)
        Dispatches processing to the type-appropriate method of the specified dispatcher. This is used in generic code to perform type-specific actions based on other input; a rather common case is object construction, where the dispatcher is usually derived from TypeDispatchedConstructor.
        Parameters:
        dispatcher - the class to which to dispatch control