Class InputSerializer

java.lang.Object
marauroa.common.net.InputSerializer

public class InputSerializer extends Object
InputSerializer is used to serialize classes that implement the Serializable interface from an InputStream.
  • Constructor Details

    • InputSerializer

      public InputSerializer(InputStream in)
      Constructor that passes the InputStream to the serializer
      Parameters:
      in - the InputStream
  • Method Details

    • readObject

      public Object readObject(Serializable obj) throws IOException
      This method serializes an object that implements the interface Serializable, allowing to implement this behaviour in several classes
      Parameters:
      obj - the object where we will serialize the data
      Returns:
      the object serialized, just for interface coherence
      Throws:
      IOException - if there is an IO error
    • readByte

      public byte readByte() throws IOException
      This method reads a byte from the Serializer
      Returns:
      the byte serialized
      Throws:
      IOException - if there is an IO error
    • readByteArray

      public byte[] readByteArray() throws IOException
      This method reads a byte array from the Serializer
      Returns:
      the byte array serialized
      Throws:
      IOException - if there is an IO error
    • read255LongByteArray

      public byte[] read255LongByteArray() throws IOException
      This method reads a byte array of a maximum length of 255 entries
      Returns:
      the byte array serialized
      Throws:
      IOException - if there is an IO error
    • read65536LongByteArray

      public byte[] read65536LongByteArray() throws IOException
      This method reads a byte array of a maximum length of 65536 entries
      Returns:
      the byte array serialized
      Throws:
      IOException - if there is an IO error
    • readShort

      public short readShort() throws IOException
      This method reads a short from the Serializer
      Returns:
      the short serialized
      Throws:
      IOException - if there is an IO error
    • readInt

      public int readInt() throws IOException
      This method reads a int from the Serializer
      Returns:
      the int serialized
      Throws:
      IOException - if there is an IO error
    • readLong

      public long readLong() throws IOException
      This method reads a long integer from Serializer.
      Returns:
      The long integer serialized
      Throws:
      IOException - If there is an IO error
    • readFloat

      public float readFloat() throws IOException
      This method reads a float from the Serializer
      Returns:
      the float serialized
      Throws:
      IOException - if there is an IO error
    • readString

      public String readString() throws IOException
      This method reads a String from the Serializer
      Returns:
      the String serialized
      Throws:
      IOException - if there is an IO error
    • read255LongString

      public String read255LongString() throws IOException
      This method reads a short string (whose size is smaller than 255 bytes long)
      Returns:
      the String serialized
      Throws:
      IOException - if there is an IO error
    • read65536LongString

      public String read65536LongString() throws IOException
      This method reads a long string (whose size is smaller than 65536 bytes long)
      Returns:
      the String serialized
      Throws:
      IOException - if there is an IO error
    • readStringArray

      public String[] readStringArray() throws IOException
      This method reads a String array from the Serializer
      Returns:
      the String array serialized
      Throws:
      IOException - if there is an IO error
    • readObjectArray

      public Object[] readObjectArray(Class<? extends Serializable> clazz) throws IOException
      This method reads a String array from the Serializer
      Parameters:
      clazz - class of the object
      Returns:
      the object array
      Throws:
      IOException - if there is an IO error
    • close

      public void close() throws IOException
      closes the underlying input stream
      Throws:
      IOException - in case of an input/output error
    • getProtocolVersion

      public int getProtocolVersion()
      gets the protocolVersion
      Returns:
      protocol version
    • setProtocolVersion

      public void setProtocolVersion(int protocolVersion)
      sets the protocol version
      Parameters:
      protocolVersion - protocol version
    • available

      public int available()
      Number of bytes available to be read. Important Note: This includes data which may be designated for the following objects in the stream
      Returns:
      number of bytes