Class ExtraField.AlignmentSegment

  • All Implemented Interfaces:
    ExtraField.Segment
    Enclosing class:
    ExtraField

    public static class ExtraField.AlignmentSegment
    extends java.lang.Object
    implements ExtraField.Segment
    Segment with information on an alignment: this segment contains information on how an entry should be aligned and contains zero-filled data to force alignment.

    An alignment segment contains the header ID, the size of the data, the alignment value and zero bytes to pad

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int MINIMUM_SIZE
      Minimum size for an alignment segment.
    • Constructor Summary

      Constructors 
      Constructor Description
      AlignmentSegment​(int headerId, byte[] data)
      Creates a new alignment segment from extra data.
      AlignmentSegment​(int alignment, int totalSize)
      Creates a new alignment segment.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getHeaderId()
      Obtains the segment's header ID.
      int size()
      Obtains the size of the segment including the header ID.
      void write​(java.nio.ByteBuffer out)
      Writes the segment to a buffer.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • MINIMUM_SIZE

        public static final int MINIMUM_SIZE
        Minimum size for an alignment segment.
        See Also:
        Constant Field Values
    • Constructor Detail

      • AlignmentSegment

        public AlignmentSegment​(int alignment,
                                int totalSize)
        Creates a new alignment segment.
        Parameters:
        alignment - the alignment value
        totalSize - how many bytes should this segment take?
      • AlignmentSegment

        public AlignmentSegment​(int headerId,
                                byte[] data)
                         throws java.io.IOException
        Creates a new alignment segment from extra data.
        Parameters:
        headerId - the header ID
        data - the segment data
        Throws:
        java.io.IOException - failed to create the segment from the data
    • Method Detail

      • write

        public void write​(java.nio.ByteBuffer out)
                   throws java.io.IOException
        Description copied from interface: ExtraField.Segment
        Writes the segment to a buffer.
        Specified by:
        write in interface ExtraField.Segment
        Parameters:
        out - the buffer where to write the segment to; exactly ExtraField.Segment.size() bytes will be written
        Throws:
        java.io.IOException - failed to write segment data
      • size

        public int size()
        Description copied from interface: ExtraField.Segment
        Obtains the size of the segment including the header ID.
        Specified by:
        size in interface ExtraField.Segment
        Returns:
        the number of bytes needed to write the segment