Class OpusBlockHelper.Block

  • All Implemented Interfaces:
    adams.core.logging.LoggingSupporter, adams.core.SizeOfHandler, Serializable
    Enclosing class:
    OpusBlockHelper

    public static class OpusBlockHelper.Block
    extends adams.core.logging.LoggingObject
    Convenience class for handling blocks.
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected byte[] m_Buffer
      the content of the file.
      protected int m_Definition
      the definition the block is based on.
      protected int m_End
      the end of the block (incl).
      protected String m_Name
      the name of the block.
      protected int m_Start
      the start of the block (incl).
      protected int m_Type
      the type of the block.
      • Fields inherited from class adams.core.logging.LoggingObject

        m_Logger, m_LoggingIsEnabled, m_LoggingLevel
    • Constructor Summary

      Constructors 
      Constructor Description
      Block​(byte[] buffer, int def, int start, int end, int type)
      Initializes the block.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int findID​(byte[] id)
      Returns the offset of the ID.
      byte[] getBufferSection()
      Returns the sub-section of the buffer (copy operation!).
      Byte getByte​(byte[] id, int offset)
      Returns the long with the given ID.
      Byte getByte​(int offset)
      Returns the byte at the specified offset.
      int getDefinition()
      Returns the definition that the block is based on.
      Double getDouble​(byte[] id, int offset)
      Returns the double with the given ID.
      Double getDouble​(int offset)
      Returns the double at the specified offset.
      int getEnd()
      Returns the end of the block.
      Long getLong​(byte[] id, int offset)
      Returns the long with the given ID.
      Long getLong​(int offset)
      Returns the long at the specified offset.
      String getName()
      Returns the name of the block.
      int getStart()
      Returns the start of the block.
      String getText​(byte[] id, int offset)
      Returns the text with the given ID.
      String getText​(int offset)
      Returns the text at the specified offset.
      int getType()
      Returns the type of the block.
      boolean hasID​(byte[] id)
      Returns whether the ID is present in the block.
      int size()
      Returns the size of the block.
      String toString()
      Returns a short description of the block.
      • Methods inherited from class adams.core.logging.LoggingObject

        configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
    • Field Detail

      • m_Buffer

        protected byte[] m_Buffer
        the content of the file.
      • m_Definition

        protected int m_Definition
        the definition the block is based on.
      • m_Start

        protected int m_Start
        the start of the block (incl).
      • m_End

        protected int m_End
        the end of the block (incl).
      • m_Type

        protected int m_Type
        the type of the block.
      • m_Name

        protected String m_Name
        the name of the block.
    • Constructor Detail

      • Block

        public Block​(byte[] buffer,
                     int def,
                     int start,
                     int end,
                     int type)
        Initializes the block.
        Parameters:
        buffer - the file content
        def - the definition the block is based on
        start - the start of the block (incl)
        end - the end of the block (incl)
    • Method Detail

      • getDefinition

        public int getDefinition()
        Returns the definition that the block is based on.
        Returns:
        the definition
      • getStart

        public int getStart()
        Returns the start of the block.
        Returns:
        the start
      • getEnd

        public int getEnd()
        Returns the end of the block.
        Returns:
        the end
      • getType

        public int getType()
        Returns the type of the block.
        Returns:
        the type
      • getName

        public String getName()
        Returns the name of the block.
        Returns:
        the name, null if no valid name
      • size

        public int size()
        Returns the size of the block.
        Returns:
        the size
      • hasID

        public boolean hasID​(byte[] id)
        Returns whether the ID is present in the block.
        Parameters:
        id - the ID to check
        Returns:
        true if present
      • findID

        public int findID​(byte[] id)
        Returns the offset of the ID.
        Parameters:
        id - the ID to locate
        Returns:
        the position, -1 if not found
      • getByte

        public Byte getByte​(int offset)
        Returns the byte at the specified offset.
        Parameters:
        offset - the offset to use
        Returns:
        the byte
      • getByte

        public Byte getByte​(byte[] id,
                            int offset)
        Returns the long with the given ID.
        Parameters:
        id - the ID of the float
        offset - the offset to use from the start of the ID
        Returns:
        the long, null if not found
      • getLong

        public Long getLong​(int offset)
        Returns the long at the specified offset.
        Parameters:
        offset - the offset to use
        Returns:
        the long
      • getLong

        public Long getLong​(byte[] id,
                            int offset)
        Returns the long with the given ID.
        Parameters:
        id - the ID of the float
        offset - the offset to use from the start of the ID
        Returns:
        the long, null if not found
      • getDouble

        public Double getDouble​(int offset)
        Returns the double at the specified offset.
        Parameters:
        offset - starting pos
        Returns:
        the double value, null if not found
      • getDouble

        public Double getDouble​(byte[] id,
                                int offset)
        Returns the double with the given ID.
        Parameters:
        id - the ID of the double
        offset - the offset to use from the start of the ID
        Returns:
        the double value, null if not found
      • getText

        public String getText​(int offset)
        Returns the text at the specified offset.
        Parameters:
        offset - starting pos
        Returns:
        the text value
      • getText

        public String getText​(byte[] id,
                              int offset)
        Returns the text with the given ID.
        Parameters:
        id - the ID of the text
        offset - the offset to use from the start of the ID
        Returns:
        the text value, null if not found
      • getBufferSection

        public byte[] getBufferSection()
        Returns the sub-section of the buffer (copy operation!).
        Returns:
        copy of the sub-section of the buffer
      • toString

        public String toString()
        Returns a short description of the block.
        Overrides:
        toString in class Object
        Returns:
        the block