Class StringSerializer
java.lang.Object
com.jme3.network.serializing.Serializer
com.jme3.network.serializing.serializers.StringSerializer
String serializer.
- Author:
- Lars Wesselius, Paul Speed
-
Field Summary
Fields inherited from class Serializer
log -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionreadObject(ByteBuffer data, Class c) Read an object from the buffer, effectively deserializing it.static StringreadString(ByteBuffer data) Reads a UTF-8 string with a compact length prefix.voidwriteObject(ByteBuffer buffer, Object object) Write an object to the buffer, effectively serializing it.static voidwriteString(String s, ByteBuffer buffer) Writes a UTF-8 string with a compact length prefix.Methods inherited from class Serializer
getExactSerializer, getExactSerializerRegistration, getSerializer, getSerializer, getSerializerRegistration, getSerializerRegistration, getSerializerRegistrations, initialize, initialize, isReadOnly, readClass, readClassAndObject, registerClass, registerClass, registerClass, registerClasses, registerClassForId, registerPackage, setReadOnly, setStrictRegistration, writeClass, writeClassAndObject
-
Constructor Details
-
StringSerializer
public StringSerializer()Creates a string serializer.
-
-
Method Details
-
writeString
Writes a UTF-8 string with a compact length prefix.- Parameters:
s- the string to writebuffer- the target buffer- Throws:
IOException- if the string cannot be encoded
-
readString
Reads a UTF-8 string with a compact length prefix.- Parameters:
data- the source buffer- Returns:
- the decoded string, or
null - Throws:
IOException- if the encoded value is invalid
-
readObject
Description copied from class:SerializerRead an object from the buffer, effectively deserializing it.- Specified by:
readObjectin classSerializer- Parameters:
data- The buffer to read from.c- The class of the object.- Returns:
- The object read.
- Throws:
IOException- If deserializing fails.
-
writeObject
Description copied from class:SerializerWrite an object to the buffer, effectively serializing it.- Specified by:
writeObjectin classSerializer- Parameters:
buffer- The buffer to write to.object- The object to serialize.- Throws:
IOException- If serializing fails.
-