com.jme3.network.serializing
Class Serializer

java.lang.Object
  extended by com.jme3.network.serializing.Serializer
Direct Known Subclasses:
ArraySerializer, BooleanSerializer, ByteSerializer, CharSerializer, ClientRegistrationMessage.ClientRegistrationSerializer, CollectionSerializer, DateSerializer, DisconnectMessage.DisconnectSerializer, DoubleSerializer, EnumSerializer, FieldSerializer, FloatSerializer, GZIPSerializer, IntSerializer, LongSerializer, MapSerializer, RmiSerializer, SavableSerializer, SerializableSerializer, ShortSerializer, StringSerializer, Vector3Serializer, ZIPSerializer

public abstract class Serializer
extends java.lang.Object

The main serializer class, which will serialize objects such that they can be sent across the network. Serializing classes should extend this to provide their own serialization.


Field Summary
protected static java.util.logging.Logger log
           
 
Constructor Summary
Serializer()
           
 
Method Summary
static Serializer getExactSerializer(java.lang.Class cls)
           
static SerializerRegistration getExactSerializerRegistration(java.lang.Class cls)
           
static Serializer getSerializer(java.lang.Class cls)
           
static Serializer getSerializer(java.lang.Class cls, boolean failOnMiss)
           
static SerializerRegistration getSerializerRegistration(java.lang.Class cls)
           
static SerializerRegistration getSerializerRegistration(java.lang.Class cls, boolean failOnMiss)
           
 void initialize(java.lang.Class clazz)
          Registration for when a serializer may need to cache something.
static SerializerRegistration readClass(java.nio.ByteBuffer buffer)
          Read the class from given buffer and return its SerializerRegistration.
static java.lang.Object readClassAndObject(java.nio.ByteBuffer buffer)
          Read the class and the object.
abstract
<T> T
readObject(java.nio.ByteBuffer data, java.lang.Class<T> c)
          Read an object from the buffer, effectively deserializing it.
static SerializerRegistration registerClass(java.lang.Class cls)
           
static SerializerRegistration registerClass(java.lang.Class cls, boolean failOnMiss)
          Registers the specified class.
static SerializerRegistration registerClass(java.lang.Class cls, Serializer serializer)
           
static void registerClasses(java.lang.Class... classes)
           
protected static SerializerRegistration registerClassForId(short id, java.lang.Class cls, Serializer serializer)
           
static SerializerRegistration[] registerPackage(java.lang.String pkgName)
          Deprecated. This cannot be implemented in a reasonable way that works in all deployment methods.
static void setStrictRegistration(boolean b)
          When set to true, classes that do not have intrinsic IDs in their
static SerializerRegistration writeClass(java.nio.ByteBuffer buffer, java.lang.Class type)
          Write a class and return its SerializerRegistration.
static void writeClassAndObject(java.nio.ByteBuffer buffer, java.lang.Object object)
          Write the class and object.
abstract  void writeObject(java.nio.ByteBuffer buffer, java.lang.Object object)
          Write an object to the buffer, effectively serializing it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final java.util.logging.Logger log
Constructor Detail

Serializer

public Serializer()
Method Detail

setStrictRegistration

public static void setStrictRegistration(boolean b)
When set to true, classes that do not have intrinsic IDs in their


registerClass

public static SerializerRegistration registerClass(java.lang.Class cls)

registerClasses

public static void registerClasses(java.lang.Class... classes)

registerClassForId

protected static SerializerRegistration registerClassForId(short id,
                                                           java.lang.Class cls,
                                                           Serializer serializer)

registerClass

public static SerializerRegistration registerClass(java.lang.Class cls,
                                                   boolean failOnMiss)
Registers the specified class. The failOnMiss flag controls whether or not this method returns null for failed registration or throws an exception.


registerPackage

@Deprecated
public static SerializerRegistration[] registerPackage(java.lang.String pkgName)
Deprecated. This cannot be implemented in a reasonable way that works in all deployment methods.


registerClass

public static SerializerRegistration registerClass(java.lang.Class cls,
                                                   Serializer serializer)

getExactSerializer

public static Serializer getExactSerializer(java.lang.Class cls)

getSerializer

public static Serializer getSerializer(java.lang.Class cls)

getSerializer

public static Serializer getSerializer(java.lang.Class cls,
                                       boolean failOnMiss)

getExactSerializerRegistration

public static SerializerRegistration getExactSerializerRegistration(java.lang.Class cls)

getSerializerRegistration

public static SerializerRegistration getSerializerRegistration(java.lang.Class cls)

getSerializerRegistration

public static SerializerRegistration getSerializerRegistration(java.lang.Class cls,
                                                               boolean failOnMiss)

readClass

public static SerializerRegistration readClass(java.nio.ByteBuffer buffer)
Read the class from given buffer and return its SerializerRegistration.

Parameters:
buffer - The buffer to read from.
Returns:
The SerializerRegistration, or null if non-existent.

readClassAndObject

public static java.lang.Object readClassAndObject(java.nio.ByteBuffer buffer)
                                           throws java.io.IOException
Read the class and the object.

Parameters:
buffer - Buffer to read from.
Returns:
The Object that was read.
Throws:
java.io.IOException - If serialization failed.

writeClass

public static SerializerRegistration writeClass(java.nio.ByteBuffer buffer,
                                                java.lang.Class type)
                                         throws java.io.IOException
Write a class and return its SerializerRegistration.

Parameters:
buffer - The buffer to write the given class to.
type - The class to write.
Returns:
The SerializerRegistration that's registered to the class.
Throws:
java.io.IOException

writeClassAndObject

public static void writeClassAndObject(java.nio.ByteBuffer buffer,
                                       java.lang.Object object)
                                throws java.io.IOException
Write the class and object.

Parameters:
buffer - The buffer to write to.
object - The object to write.
Throws:
java.io.IOException - If serializing fails.

readObject

public abstract <T> T readObject(java.nio.ByteBuffer data,
                                 java.lang.Class<T> c)
                      throws java.io.IOException
Read an object from the buffer, effectively deserializing it.

Parameters:
data - The buffer to read from.
c - The class of the object.
Returns:
The object read.
Throws:
java.io.IOException - If deserializing fails.

writeObject

public abstract void writeObject(java.nio.ByteBuffer buffer,
                                 java.lang.Object object)
                          throws java.io.IOException
Write an object to the buffer, effectively serializing it.

Parameters:
buffer - The buffer to write to.
object - The object to serialize.
Throws:
java.io.IOException - If serializing fails.

initialize

public void initialize(java.lang.Class clazz)
Registration for when a serializer may need to cache something. Override to use.

Parameters:
clazz - The class that has been registered to the serializer.