Class ByteArray

    • Constructor Detail

      • ByteArray

        protected ByteArray()
        Creates an empty byte array.
      • ByteArray

        public ByteArray​(byte[] bytes)
        Creates a byte array from given data.
        Parameters:
        bytes - the given byte array
      • ByteArray

        public ByteArray​(String s)
        Creates a byte array from the given string.
        Parameters:
        s - a String containing ASCII bytes
    • Method Detail

      • readBytes

        protected void readBytes​(RandomAccessData randomAccessData,
                                 int length)
                          throws RandomAccessDataException
        Reads the given number of bytes into this ByteArray object.
        Parameters:
        randomAccessData - the data to read from
        length - the number of bytes to read
        Throws:
        RandomAccessDataException - if data source is null
      • getSize

        public int getSize()
        Returns the size of this byte array.
        Returns:
        the size of this byte array
      • getByteArray

        public byte[] getByteArray()
        Returns the encapsulated byte array. This method will never return null.
        Returns:
        the encapsulated byte array
      • getAsHexBytes

        public String getAsHexBytes()
        Returns a string representation of this ByteArray containing each byte formatted as hex string.
        Returns:
        a string representation as hex bytes
      • getAsHexBytes

        public String getAsHexBytes​(int numCols)
        Returns a string representation of this ByteArray containing each byte formatted as hex string.
        Parameters:
        numCols - if numCols>0, adds a new line after the given number of columns
        Returns:
        a string representation as hex bytes
      • getMultiLineHexView

        public List<String> getMultiLineHexView()
        Returns a Hex editor like multiline output with a default number of columns per line. Same as getMultiLineHexView(16).
        Returns:
        a Hex editor like multiline output
        Since:
        2.0
      • getMultiLineHexView

        public List<String> getMultiLineHexView​(int numbBytesPerLine)
        Returns a Hex editor like multiline output.
        Parameters:
        numbBytesPerLine - the number of bytes per output line (less or equal to zero will default to 16)
        Returns:
        a Hex editor like multiline output
        Since:
        2.0
      • getUTF16z

        public String getUTF16z​(int offset)
                         throws RandomAccessDataException
        Get UTF-16 encoded zero terminated substring.
        Parameters:
        offset - position within byte array to start reading from
        Returns:
        a decoded substring
        Throws:
        RandomAccessDataException - if an error occurs through decoding