Class CliBlob

  • All Implemented Interfaces:
    StructConverter
    Direct Known Subclasses:
    CliAbstractSig, CliBlobCustomAttrib, CliBlobMarshalSpec

    public class CliBlob
    extends java.lang.Object
    implements StructConverter
    Describes a blob in the #Blob heap. Format is a coded size then the blob contents.

    Paraphrasing from ISO 23271:2012 11.24.2.4 (p272): - If the first one byte of the 'blob' is 0bbbbbbb_2: size is bbbbbbb_2 bytes. - If the first two bytes are 10bbbbbb_2 and x: size is (bbbbbb_2 << 8 + x) bytes. - If the first four bytes are 110bbbbb_2, x, y, and z: size is (bbbbb_2<<24 + x<<16 + y<<8 + z) bytes. The first entry in the heap is the empty 'blob' consisting of a single zero byte.

    • Field Detail

      • blobOffset

        protected long blobOffset
      • contentsOffset

        protected long contentsOffset
      • contentsSize

        protected int contentsSize
    • Constructor Detail

      • CliBlob

        public CliBlob​(int streamIndex,
                       BinaryReader reader)
                throws java.io.IOException
        Creates a new blob from the given reader, which should be positioned at the start of the blob. The reader will be positioned directly after the blob upon completion of the constructor.
        Parameters:
        streamIndex - The blob's stream index.
        reader - The reader to use to read the blob.
        Throws:
        java.io.IOException - if there was a problem reading the blob.
      • CliBlob

        protected CliBlob​(CliBlob blob)
        Creates a new blob that is a copy of the given blob.
        Parameters:
        blob - The blob to copy.
      • CliBlob

        protected CliBlob​(CliBlob blob,
                          BinaryReader reader)
        Creates a new blob that is a copy of the given blob but with a new reader. The provided reader must be positioned to the start of the new blob.
        Parameters:
        blob - The blob to copy.
        reader - The reader to use to read the new blob. It must be positioned to the start of the new blob.
    • Method Detail

      • getSize

        public int getSize()
        Gets the blob's size in bytes (includes all fields).
        Returns:
        The blob's size in bytes.
      • getContentsReader

        public BinaryReader getContentsReader()
        Gets a new binary reader positioned at the start of this blob's contents.
        Returns:
        A new binary reader positioned at the start of this blob's contents.
      • getContentsSize

        public int getContentsSize()
        Gets the blob's contents size in bytes.
        Returns:
        The blob's contents size in bytes.
      • getContents

        public byte[] getContents()
        Gets the blob's contents.
        Returns:
        the blob's contents. Could be null if there was a problem reading the contents.
      • getRepresentation

        public java.lang.String getRepresentation()
        Gets the string representation of this blob.
        Returns:
        The string representation of this blob.
      • isLittleEndian

        public boolean isLittleEndian()
        Checks to see whether or not this blob is little endian.
        Returns:
        True if this blob is little endian; false if big endian.
      • toDataType

        public DataType toDataType()
        Description copied from interface: StructConverter
        Returns a structure datatype representing the contents of the implementor of this interface.

        For example, given:

         class A {
             int foo;
             double bar;
         }
         

        The return value should be a structure data type with two data type components; an INT and a DOUBLE. The structure should contain field names and, if possible, field comments.

        Specified by:
        toDataType in interface StructConverter
        Returns:
        returns a structure datatype representing the implementor of this interface
        See Also:
        StructureDataType
      • getStreamIndex

        public int getStreamIndex()
        Gets the index into the blob stream of this blob.
        Returns:
        The index into the blob stream of this blob.
      • getName

        public java.lang.String getName()
        Gets the name of this blob.
        Returns:
        The name of this blob.
      • getContentsName

        public java.lang.String getContentsName()
        Gets the name associated with this blob's contents.
        Returns:
        The name associated with this blob's contents.
      • getContentsDataType

        public DataType getContentsDataType()
        Gets the data type associated with this blob's contents.
        Returns:
        The data type associated with this blob's contents.
      • getContentsComment

        public java.lang.String getContentsComment()
        Gets the comment associated with this blob's contents.
        Returns:
        The comment associated with this blob's contents.
      • getSizeDataType

        public DataType getSizeDataType()
        Gets the proper data type for the blob's size field.
        Returns:
        The proper data type for the blob's size field.
      • testSizeDecoding

        public static void testSizeDecoding()
      • decodeCompressedSigned

        public static int decodeCompressedSigned​(byte codedSize)
      • decodeCompressedSigned

        public static int decodeCompressedSigned​(short codedSize)
      • decodeCompressedSigned

        public static int decodeCompressedSigned​(int codedSize)
      • decodeCompressedUnsigned

        public static int decodeCompressedUnsigned​(byte codedSize)
      • decodeCompressedUnsigned

        public static int decodeCompressedUnsigned​(short codedSize)
      • decodeCompressedUnsigned

        public static int decodeCompressedUnsigned​(int codedSize)
      • decodeCompressedSignedInt

        public static int decodeCompressedSignedInt​(BinaryReader reader)
                                             throws java.io.IOException
        Throws:
        java.io.IOException
      • decodeCompressedUnsignedInt

        public static int decodeCompressedUnsignedInt​(BinaryReader reader)
                                               throws java.io.IOException
        Throws:
        java.io.IOException
      • getDataTypeForBytes

        public static DataType getDataTypeForBytes​(int numBytes)