Class StringSerializer

java.lang.Object
com.jme3.network.serializing.Serializer
com.jme3.network.serializing.serializers.StringSerializer

public class StringSerializer extends Serializer
String serializer.
Author:
Lars Wesselius, Paul Speed
  • Constructor Details

    • StringSerializer

      public StringSerializer()
      Creates a string serializer.
  • Method Details

    • writeString

      public static void writeString(String s, ByteBuffer buffer) throws IOException
      Writes a UTF-8 string with a compact length prefix.
      Parameters:
      s - the string to write
      buffer - the target buffer
      Throws:
      IOException - if the string cannot be encoded
    • readString

      public static String readString(ByteBuffer data) throws IOException
      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

      public String readObject(ByteBuffer data, Class c) throws IOException
      Description copied from class: Serializer
      Read an object from the buffer, effectively deserializing it.
      Specified by:
      readObject in class Serializer
      Parameters:
      data - The buffer to read from.
      c - The class of the object.
      Returns:
      The object read.
      Throws:
      IOException - If deserializing fails.
    • writeObject

      public void writeObject(ByteBuffer buffer, Object object) throws IOException
      Description copied from class: Serializer
      Write an object to the buffer, effectively serializing it.
      Specified by:
      writeObject in class Serializer
      Parameters:
      buffer - The buffer to write to.
      object - The object to serialize.
      Throws:
      IOException - If serializing fails.