Class ElementarySeg

  • All Implemented Interfaces:
    java.lang.Comparable<PathSegment>

    public class ElementarySeg
    extends DataDefinitionSeg
    Encapsulates an elementary data type annotation within a CIP Path definition. Type annotations are generally not passed on the wire, but delimit the path fragment that will go on the wire (before the data type) from the path fragment that will be applied to the payload on the wire.
    • Field Detail

      • typeCode

        public final int typeCode
      • elementaryClass

        public final java.lang.Class<? extends BaseDataType<?>> elementaryClass
      • constructor

        public final java.lang.reflect.Constructor<?> constructor
      • crcName

        public final java.lang.String crcName
      • parseNames

        protected final java.lang.String[] parseNames
      • boolHost

        protected final boolean boolHost
    • Method Detail

      • lookup

        public static ElementarySeg lookup​(java.lang.Class<?> clazz)
      • lookup

        public static ElementarySeg lookup​(java.lang.String token)
      • isBoolHost

        public boolean isBoolHost()
        Description copied from class: DataDefinitionSeg
        Some elementary data types (the integer and word types) can be hosts for named bits within structures. This method is overridden in the necessary places to support this. It corresponds to subclasses of BaseDataType that implement the BoolHost interface.
        Overrides:
        isBoolHost in class DataDefinitionSeg
        Returns:
      • getSizeImpl

        public int getSizeImpl​(DataContext ctx)
        Description copied from class: DataDefinitionSeg
        Return the number of bytes occupied by a single instance of the given data type. When the data is indirect, size is zero. When the data is variable length, size is -1;
        Specified by:
        getSizeImpl in class DataDefinitionSeg
        Returns:
        Number of bytes.
      • minSize

        public int minSize​(DataContext ctx)
        Description copied from class: DataDefinitionSeg
        Some data types need to offer a range of sizes for the encoded form of their data. The common case is fixed.
        Overrides:
        minSize in class DataDefinitionSeg
        Returns:
      • maxSize

        public int maxSize​(DataContext ctx)
        Description copied from class: DataDefinitionSeg
        Some data types need to offer a range of sizes for the encoded form of their data. The common case is fixed.
        Overrides:
        maxSize in class DataDefinitionSeg
        Returns:
      • alignment

        public int alignment​(DataContext ctx)
        Description copied from class: DataDefinitionSeg
        Alignment is normally the natural size of a primitive element. Structured types and variable length types must override this method.
        Overrides:
        alignment in class DataDefinitionSeg
        Returns:
      • isBoolImpl

        public boolean isBoolImpl()
        Description copied from class: DataDefinitionSeg
        Size calculations for boolean min and max must defer to .getSize() to get the right answer for boolean arrays.
        Overrides:
        isBoolImpl in class DataDefinitionSeg
        Returns:
      • getSize

        public int getSize​(DataContext ctx,
                           int... dims)
        Description copied from class: DataDefinitionSeg
        Return the number of bytes occupied by the given data type. When the data is indirect (hosted elsewhere), or variable length, size is -1.

        When dimensions are provided, compute the bytes the complete array will occupy. Otherwise report the size of a singleton.

        Overrides:
        getSize in class DataDefinitionSeg
        Returns:
        Number of bytes.
      • construct

        protected BaseDataType<?> construct​(int[] dimensions,
                                            DataContext ctx)
        Description copied from class: DataDefinitionSeg
        Construct an instance of the type represented by this definition, using the given dimensions. This is an implementation detail that permits a DecoratedDefSeg to create arrays.

        Use the provided context to look up any ambiguous data types.

        Specified by:
        construct in class DataDefinitionSeg
        Returns:
      • getCrcName

        public java.lang.String getCrcName()
      • simpleString

        public java.lang.String simpleString()
        Description copied from class: PathSegment
        Supply s simple descriptive name usable when browsing a hierarchy. A simple type name for elementary types, a non-detailed description for complex types.
        Specified by:
        simpleString in class PathSegment
        Returns:
      • getParseNames

        public java.lang.String[] getParseNames()
      • set

        public PathSegment set​(java.nio.ByteBuffer source,
                               boolean padded)
        Description copied from class: PathSegment
        Replace the current instance content with the decoded source bytes.

        The caller must ensure that the instance is appropriate for the bytes supplied. This permits instance re-use in optimized applications.

        Specified by:
        set in class PathSegment
        Parameters:
        source - The bytes to be decoded. The position will be left after the last byte of the decoded segment.
        padded - Alternate format selection. Packed format when false.
        Returns:
        The same instance.
      • put

        public void put​(java.nio.ByteBuffer dest,
                        boolean padded)
        Description copied from class: PathSegment
        Encode the current instance to the given destination.
        Specified by:
        put in class PathSegment
        Parameters:
        dest - The buffer receiving the complete encoded instance.
        padded - Alternate format selection. Packed format when false.
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class PathSegment
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • getBytes

        public int getBytes()
        Description copied from class: PathSegment
        Obtain the number of bytes needed to encode this segment instance in packed format.
        Specified by:
        getBytes in class PathSegment
        Returns:
        Number of bytes, assuming put() will be called with padded false.
      • getTokens

        public java.util.List<java.lang.String> getTokens()
        Specified by:
        getTokens in class PathSegment
      • main

        public static void main​(java.lang.String[] args)