Package marauroa.common.net
Class OutputSerializer
java.lang.Object
marauroa.common.net.OutputSerializer
OutputSerializer is used to serialize classes that implement the Serializable
interface into a OutputStream.
-
Constructor Summary
ConstructorDescriptionOutputSerializer(OutputStream out)
Constructor that defines a specified OutputStream for the serializer -
Method Summary
Modifier and TypeMethodDescriptionstatic String
escapeJsonString(String value)
escapes a JSON stringint
gets the protocolVersionvoid
setProtocolVersion(int protocolVersion)
sets the protocol versionvoid
write(byte a)
Add the byte to the serializervoid
write(byte[] a)
Add the byte array to the serializervoid
write(float a)
Add the float to the serializervoid
write(int a)
Add the int to the serializervoid
write(long a)
Add the long to the serializervoid
write(short a)
Add the short to the serializervoid
Add the String to the serializer, using UTF-8 encodingvoid
Add the String array to the serializer, using UTF-8 encodingvoid
write(Serializable obj)
Add the Object to the serializer, if it implements the marauroa.common.net.Serializable interfacevoid
write(Serializable[] objs)
Add the Object array to the serializer, if it implements the marauroa.common.net.Serializable interfacevoid
write255LongArray(byte[] a)
Add a byte array whose size is smaller than 255 to the serializervoid
Add a short string to the serializer, using UTF-8 encodingvoid
write65536LongArray(byte[] a)
Add a long byte array whose size is smaller than 2^31 to the serializervoid
/** Add a long string to the serializer, using UTF-8 encodingstatic void
writeJson(StringBuilder out, String value)
writes a json key-value-pairstatic void
writeJson(StringBuilder out, String key, String value)
writes a json key-value-pairstatic void
writeObjectCollectionToJson(StringBuilder out, String name, Collection<? extends Attributes> collection, DetailLevel level)
converts a list of objects into a json fragment
-
Constructor Details
-
OutputSerializer
Constructor that defines a specified OutputStream for the serializer- Parameters:
out
- the OutputStream to which objects are serialized
-
-
Method Details
-
write
Add the Object to the serializer, if it implements the marauroa.common.net.Serializable interface- Parameters:
obj
- the object to serialize- Throws:
IOException
- in case of an IO-error
-
write
Add the byte to the serializer- Parameters:
a
- the byte to serialize- Throws:
IOException
- in case of an IO-error
-
write
Add the byte array to the serializer- Parameters:
a
- the byte array to serialize- Throws:
IOException
- in case of an IO-error
-
write255LongArray
Add a byte array whose size is smaller than 255 to the serializer- Parameters:
a
- the byte array to serialize- Throws:
IOException
- in case of an IO-error
-
write65536LongArray
Add a long byte array whose size is smaller than 2^31 to the serializer- Parameters:
a
- the byte array to serialize- Throws:
IOException
- in case of an IO-error
-
write
Add the short to the serializer- Parameters:
a
- the short to serialize- Throws:
IOException
- in case of an IO-error
-
write
Add the int to the serializer- Parameters:
a
- the int to serialize- Throws:
IOException
- in case of an IO-error
-
write
Add the long to the serializer- Parameters:
a
- the long to serialize- Throws:
IOException
- in case of an IO-error
-
write
Add the float to the serializer- Parameters:
a
- the int to serialize- Throws:
IOException
- in case of an IO-error
-
write
Add the String to the serializer, using UTF-8 encoding- Parameters:
a
- the String to serialize- Throws:
IOException
- in case of an IO-error
-
write255LongString
Add a short string to the serializer, using UTF-8 encoding- Parameters:
a
- the String to serialize- Throws:
IOException
- in case of an IO-error
-
write65536LongString
/** Add a long string to the serializer, using UTF-8 encoding- Parameters:
a
- the String to serialize- Throws:
IOException
- in case of an IO-error
-
write
Add the String array to the serializer, using UTF-8 encoding- Parameters:
a
- the String array to serialize- Throws:
IOException
- in case of an IO-error
-
write
Add the Object array to the serializer, if it implements the marauroa.common.net.Serializable interface- Parameters:
objs
- the object array to serialize- Throws:
IOException
- in case of an IO-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
-
escapeJsonString
escapes a JSON string- Parameters:
value
- json string to escape- Returns:
- escaped json string
-
writeJson
writes a json key-value-pair- Parameters:
out
- buffer to write tovalue
- value
-
writeJson
writes a json key-value-pair- Parameters:
out
- buffer to write tokey
- keyvalue
- value
-
writeObjectCollectionToJson
public static void writeObjectCollectionToJson(StringBuilder out, String name, Collection<? extends Attributes> collection, DetailLevel level)converts a list of objects into a json fragment- Parameters:
out
- output buffername
- trusted name of list (will not be escaped).collection
- list of rpobjectslevel
- serialization level
-