Class TypeBuilder


  • public class TypeBuilder
    extends Object
    A utility class which fosters the construction of complex type defintions. Its usage should be self-explaining, e.g.:
     import static binio.util.TypeBuilder.*;
     ...
     CompoundType scanlineType =
         COMPOUND("Scanline",
            MEMBER("flags", USHORT),
            MEMBER("samples", SEQUENCE(DOUBLE, 512))
         );
     };
     CompoundType datasetType =
         COMPOUND("Dataset",
            MEMBER("lineCount", UINT),
            MEMBER("scanlines", VAR_SEQUENCE(scanlineType, "lineCount"))
         );
     };
     ...
     
    • Field Detail

      • BYTE

        public static final SimpleType BYTE
        The 8-bit signed integer type.
      • UBYTE

        public static final SimpleType UBYTE
        The 8-bit unsigned integer type.
      • SHORT

        public static final SimpleType SHORT
        The 16-bit signed integer type.
      • USHORT

        public static final SimpleType USHORT
        The 16-bit unsigned integer type.
      • INT

        public static final SimpleType INT
        The 32-bit unsigned integer type.
      • UINT

        public static final SimpleType UINT
        The 32-bit unsigned integer type.
      • LONG

        public static final SimpleType LONG
        The 64-bit signed integer type.
      • ULONG

        public static final SimpleType ULONG
        The 64-bit unsigned integer type.
      • FLOAT

        public static final SimpleType FLOAT
        The 32-bit IEEE floating point type.
      • DOUBLE

        public static final SimpleType DOUBLE
        The 64-bit IEEE floating point type.
    • Method Detail

      • SEQUENCE

        public static SequenceType SEQUENCE​(Type elementType,
                                            int elementCount)
        Creates a sequence type for the given element type and count. If element count is greater or equal to zero, a fixed-length sequence type will be created. If element count is less than zero, a growable sequence type will be created.
        Parameters:
        elementType - The sequence's element type.
        elementCount - The sequence's element count.
        Returns:
        A sequence type.
      • VAR_SEQUENCE

        public static VarSequenceType VAR_SEQUENCE​(Type elementType,
                                                   String memberName)
        Creates a dynamic sequence type whose element count is resolved by a compound member determined by the given member name. The member must have integer type.
        Parameters:
        elementType - The sequence's element type.
        memberName - The parent compount's member name.
        Returns:
        A dynamic sequence type.
      • VAR_SEQUENCE

        public static VarSequenceType VAR_SEQUENCE​(Type elementType,
                                                   int memberIndex)
        Creates a dynamic sequence type whose element count is resolved by a compound member determined by the given member index. The member must have integer type.
        Parameters:
        elementType - The sequence's element type.
        memberIndex - The parent compount's member index.
        Returns:
        A dynamic sequence type.
      • COMPOUND

        public static CompoundType COMPOUND​(String name,
                                            CompoundMember... members)
        Creates a compound type.
        Parameters:
        name - The compound's name.
        members - The compound's members.
        Returns:
        The compound type.