Package marauroa.common.net
Class InputSerializer
java.lang.Object
marauroa.common.net.InputSerializer
InputSerializer is used to serialize classes that implement the Serializable
interface from an InputStream.
-
Constructor Summary
ConstructorDescriptionConstructor that passes the InputStream to the serializer -
Method Summary
Modifier and TypeMethodDescriptionint
Number of bytes available to be read.void
close()
closes the underlying input streamint
gets the protocolVersionbyte[]
This method reads a byte array of a maximum length of 255 entriesThis method reads a short string (whose size is smaller than 255 bytes long)byte[]
This method reads a byte array of a maximum length of 65536 entriesThis method reads a long string (whose size is smaller than 65536 bytes long)byte
readByte()
This method reads a byte from the Serializerbyte[]
This method reads a byte array from the Serializerfloat
This method reads a float from the Serializerint
readInt()
This method reads a int from the Serializerlong
readLong()
This method reads a long integer from Serializer.readObject(Serializable obj)
This method serializes an object that implements the interface Serializable, allowing to implement this behaviour in several classesObject[]
readObjectArray(Class<? extends Serializable> clazz)
This method reads a String array from the Serializershort
This method reads a short from the SerializerThis method reads a String from the SerializerString[]
This method reads a String array from the Serializervoid
setProtocolVersion(int protocolVersion)
sets the protocol version
-
Constructor Details
-
InputSerializer
Constructor that passes the InputStream to the serializer- Parameters:
in
- the InputStream
-
-
Method Details
-
readObject
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
This method reads a byte from the Serializer- Returns:
- the byte serialized
- Throws:
IOException
- if there is an IO error
-
readByteArray
This method reads a byte array from the Serializer- Returns:
- the byte array serialized
- Throws:
IOException
- if there is an IO error
-
read255LongByteArray
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
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
This method reads a short from the Serializer- Returns:
- the short serialized
- Throws:
IOException
- if there is an IO error
-
readInt
This method reads a int from the Serializer- Returns:
- the int serialized
- Throws:
IOException
- if there is an IO error
-
readLong
This method reads a long integer from Serializer.- Returns:
- The long integer serialized
- Throws:
IOException
- If there is an IO error
-
readFloat
This method reads a float from the Serializer- Returns:
- the float serialized
- Throws:
IOException
- if there is an IO error
-
readString
This method reads a String from the Serializer- Returns:
- the String serialized
- Throws:
IOException
- if there is an IO error
-
read255LongString
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
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
This method reads a String array from the Serializer- Returns:
- the String array serialized
- Throws:
IOException
- if there is an IO error
-
readObjectArray
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
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
-