Class ReadOnlyByteArray


  • public class ReadOnlyByteArray
    extends java.lang.Object
    Implements access to an array in a read-only fashion.
    • Constructor Summary

      Constructors 
      Constructor Description
      ReadOnlyByteArray​(byte[] array)
      Creates a new instance based on the given array.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte get​(int index)
      Gets the element at the given index.
      int length()
      Returns the length of the array.
      • Methods inherited from class java.lang.Object

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

      • ReadOnlyByteArray

        public ReadOnlyByteArray​(byte[] array)
        Creates a new instance based on the given array.
        Parameters:
        array - Array to provide read-only access to. The array will not be copied by this class.
    • Method Detail

      • length

        public int length()
        Returns the length of the array.
        Returns:
        The length of the array. Always >= 0.
      • get

        public byte get​(int index)
        Gets the element at the given index.
        Parameters:
        index - The index to get the element at.
        Returns:
        The byte at the given index.
        Throws:
        java.lang.IndexOutOfBoundsException - if the index is < 0 or > length()