Class Storage

  • All Implemented Interfaces:
    java.io.Serializable

    public class Storage
    extends java.lang.Object
    implements java.io.Serializable
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      Storage()  
      Storage​(byte[] packet)  
      Storage​(byte[] packet, int offset, int length)  
      Storage​(short[] packet)  
      Storage​(short[] packet, int offset, int length)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String debug()  
      java.util.List<java.lang.Byte> getStorageList()
      Retrieve the internal list that is used to store the data
      int position()  
      short readByte()
      Read a byte value from the List
      double readDouble()
      Read a Double value, that was split up into 8 bytes
      float readFloat()
      Read a Float value, that was split up into 4 bytes
      int readInt()
      Read a signed integer value, that was split up into 4 bytes
      int readShort()
      Read a short value from the list
      java.lang.String readStringASCII()
      Read a String from the list, that was encoded using ASCII
      java.lang.String readStringISOLATIN1()
      Read a String from the list, that was encoded using ISO-LATIN1
      java.lang.String readStringUTF16BE()
      Read a String from the list, that was encoded using UTF-16 Big Endian
      java.lang.String readStringUTF16LE()
      Read a String from the list, that was encoded using UTF-16 Little Endian
      java.lang.String readStringUTF8()
      Read a String from the list, that was encoded using UTF-8
      short readUnsignedByte()  
      void reset()  
      int size()
      Retrieve the Size of the internal storage list
      java.lang.String toString()  
      boolean validPos()  
      void writeByte​(int value)  
      void writeByte​(short value)
      Write a byte value to the List a signed value will be converted to its unsigned equivalent first
      void writeDouble​(double value)
      Write a Double to the list the value is beeing split up into 8 bytes in msb first order
      void writeFloat​(float value)
      Write a Float to the list the float value is beeing split up into 4 bytes in msb first order
      void writeInt​(int value)
      Write an signed Integer to the list the int value is being split up into 4 bytes in msb first order
      void writeShort​(int value)
      Write a signed short value to the list
      void writeStringASCII​(java.lang.String value)
      Write a string to the list by encoding the characters in ASCII
      void writeStringISOLATIN1​(java.lang.String value)
      Write a string to the list by encoding the characters in ISO-LATIN1
      void writeStringUTF16BE​(java.lang.String value)
      Write a string to the list by encoding the characters in UTF-16 Big Endian
      void writeStringUTF16LE​(java.lang.String value)
      Write a string to the list by encoding the characters in UTF-16 Little Endian
      void writeStringUTF8​(java.lang.String value)
      Write a string to the list by encoding the characters in UTF-8
      void writeUnsignedByte​(int value)  
      void writeUnsignedByte​(short value)  
      • Methods inherited from class java.lang.Object

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

      • Storage

        public Storage()
      • Storage

        public Storage​(byte[] packet)
      • Storage

        public Storage​(byte[] packet,
                       int offset,
                       int length)
      • Storage

        public Storage​(short[] packet)
      • Storage

        public Storage​(short[] packet,
                       int offset,
                       int length)
    • Method Detail

      • validPos

        public boolean validPos()
      • position

        public int position()
      • writeByte

        public void writeByte​(short value)
                       throws java.lang.IllegalArgumentException
        Write a byte value to the List a signed value will be converted to its unsigned equivalent first
        Parameters:
        value - the byte to be written
        Throws:
        java.lang.IllegalArgumentException
      • writeByte

        public void writeByte​(int value)
                       throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException
      • readByte

        public short readByte()
                       throws java.lang.IllegalStateException
        Read a byte value from the List
        Returns:
        the read byte as an Integer value (unsigned)
        Throws:
        java.lang.IllegalStateException
      • writeUnsignedByte

        public void writeUnsignedByte​(short value)
                               throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException
      • writeUnsignedByte

        public void writeUnsignedByte​(int value)
                               throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException
      • readUnsignedByte

        public short readUnsignedByte()
                               throws java.lang.IllegalStateException
        Throws:
        java.lang.IllegalStateException
      • writeShort

        public void writeShort​(int value)
                        throws java.lang.IllegalArgumentException
        Write a signed short value to the list
        Parameters:
        value - the short value to be written
        Throws:
        java.lang.IllegalArgumentException
      • readShort

        public int readShort()
                      throws java.lang.IllegalStateException
        Read a short value from the list
        Returns:
        the read short value as an Integer
        Throws:
        java.lang.IllegalStateException
      • writeInt

        public void writeInt​(int value)
                      throws java.lang.IllegalArgumentException
        Write an signed Integer to the list the int value is being split up into 4 bytes in msb first order
        Parameters:
        value - the int value to be written
        Throws:
        java.lang.IllegalArgumentException
      • readInt

        public int readInt()
                    throws java.lang.IllegalStateException
        Read a signed integer value, that was split up into 4 bytes
        Returns:
        the read int value
        Throws:
        java.lang.IllegalStateException
      • writeFloat

        public void writeFloat​(float value)
                        throws java.lang.IllegalArgumentException
        Write a Float to the list the float value is beeing split up into 4 bytes in msb first order
        Parameters:
        value - the float value to be written
        Throws:
        java.lang.IllegalArgumentException
      • readFloat

        public float readFloat()
                        throws java.lang.IllegalStateException
        Read a Float value, that was split up into 4 bytes
        Returns:
        the read float value
        Throws:
        java.lang.IllegalStateException
      • writeDouble

        public void writeDouble​(double value)
                         throws java.lang.IllegalArgumentException
        Write a Double to the list the value is beeing split up into 8 bytes in msb first order
        Parameters:
        value - the double value to be written
        Throws:
        java.lang.IllegalArgumentException
      • readDouble

        public double readDouble()
                          throws java.lang.IllegalStateException
        Read a Double value, that was split up into 8 bytes
        Returns:
        the read double value
        Throws:
        java.lang.IllegalStateException
      • writeStringUTF8

        public void writeStringUTF8​(java.lang.String value)
                             throws java.lang.IllegalArgumentException
        Write a string to the list by encoding the characters in UTF-8
        Parameters:
        value - the String to be written
        Throws:
        java.lang.IllegalArgumentException
      • writeStringASCII

        public void writeStringASCII​(java.lang.String value)
                              throws java.lang.IllegalArgumentException
        Write a string to the list by encoding the characters in ASCII
        Parameters:
        value - the String to be written
        Throws:
        java.lang.IllegalArgumentException
      • writeStringISOLATIN1

        public void writeStringISOLATIN1​(java.lang.String value)
                                  throws java.lang.IllegalArgumentException
        Write a string to the list by encoding the characters in ISO-LATIN1
        Parameters:
        value - the String to be written
        Throws:
        java.lang.IllegalArgumentException
      • writeStringUTF16BE

        public void writeStringUTF16BE​(java.lang.String value)
                                throws java.lang.IllegalArgumentException
        Write a string to the list by encoding the characters in UTF-16 Big Endian
        Parameters:
        value - the String to be written
        Throws:
        java.lang.IllegalArgumentException
      • writeStringUTF16LE

        public void writeStringUTF16LE​(java.lang.String value)
                                throws java.lang.IllegalArgumentException
        Write a string to the list by encoding the characters in UTF-16 Little Endian
        Parameters:
        value - the String to be written
        Throws:
        java.lang.IllegalArgumentException
      • readStringUTF8

        public java.lang.String readStringUTF8()
                                        throws java.lang.IllegalArgumentException
        Read a String from the list, that was encoded using UTF-8
        Returns:
        the read String
        Throws:
        java.lang.IllegalArgumentException
      • readStringASCII

        public java.lang.String readStringASCII()
                                         throws java.lang.IllegalArgumentException
        Read a String from the list, that was encoded using ASCII
        Returns:
        the read String
        Throws:
        java.lang.IllegalArgumentException
      • readStringISOLATIN1

        public java.lang.String readStringISOLATIN1()
                                             throws java.lang.IllegalArgumentException
        Read a String from the list, that was encoded using ISO-LATIN1
        Returns:
        the read String
        Throws:
        java.lang.IllegalArgumentException
      • readStringUTF16BE

        public java.lang.String readStringUTF16BE()
                                           throws java.lang.IllegalArgumentException
        Read a String from the list, that was encoded using UTF-16 Big Endian
        Returns:
        the read String
        Throws:
        java.lang.IllegalArgumentException
      • readStringUTF16LE

        public java.lang.String readStringUTF16LE()
                                           throws java.lang.IllegalArgumentException
        Read a String from the list, that was encoded using UTF-16 Little Endian
        Returns:
        the read String
        Throws:
        java.lang.IllegalArgumentException
      • reset

        public void reset()
      • size

        public int size()
        Retrieve the Size of the internal storage list
        Returns:
        size of the storage list
      • getStorageList

        public java.util.List<java.lang.Byte> getStorageList()
        Retrieve the internal list that is used to store the data
        Returns:
        the internal storage list
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • debug

        public java.lang.String debug()