com.hazelcast.nio.serialization
Interface StreamSerializer<T>

Type Parameters:
T - type of the serialized object
All Superinterfaces:
Serializer
All Known Implementing Classes:
ArrayListSerializerHook.ArrayListStreamSerializer, ConstantSerializers.BooleanSerializer, ConstantSerializers.ByteSerializer, ConstantSerializers.CharArraySerializer, ConstantSerializers.CharSerializer, ConstantSerializers.DoubleArraySerializer, ConstantSerializers.DoubleSerializer, ConstantSerializers.FloatArraySerializer, ConstantSerializers.FloatSerializer, ConstantSerializers.IntegerArraySerializer, ConstantSerializers.IntegerSerializer, ConstantSerializers.LongArraySerializer, ConstantSerializers.LongSerializer, ConstantSerializers.ShortArraySerializer, ConstantSerializers.ShortSerializer, ConstantSerializers.StringSerializer, DefaultSerializers.BigDecimalSerializer, DefaultSerializers.BigIntegerSerializer, DefaultSerializers.ClassSerializer, DefaultSerializers.DateSerializer, DefaultSerializers.EnumSerializer, DefaultSerializers.Externalizer, DefaultSerializers.ObjectSerializer, LinkedListSerializerHook.LinkedListStreamSerializer

public interface StreamSerializer<T>
extends Serializer

A base class for custom serialization. User can register custom serializer like following:

     final SerializerConfig serializerConfig = new SerializerConfig();
     serializerConfig.setImplementation(new StreamSerializer() {
          public int getTypeId() {

          }

          public void destroy() {

          }

          public void write(ObjectDataOutput out, Person object) throws IOException {

          }

          public Person read(ObjectDataInput in) throws IOException {

          });

     serializerConfig.setTypeClass(Person.class);
     config.getSerializationConfig().addSerializerConfig(serializerConfig);

 

There is another class with byte arrays can be used instead ıf this interface see ByteArraySerializer.

C++ and C# clients also have compatible methods so that with custom serialization client can also be used

Note that read and write methods should be compatible


Method Summary
 T read(ObjectDataInput in)
          Reads object from objectDataInputStream
 void write(ObjectDataOutput out, T object)
          This method writes object to ObjectDataOutput
 
Methods inherited from interface com.hazelcast.nio.serialization.Serializer
destroy, getTypeId
 

Method Detail

write

void write(ObjectDataOutput out,
           T object)
           throws IOException
This method writes object to ObjectDataOutput

Parameters:
out - ObjectDataOutput stream that object will be written to
object - that will be written to out
Throws:
IOException - in case of failure to write

read

T read(ObjectDataInput in)
       throws IOException
Reads object from objectDataInputStream

Parameters:
in - ObjectDataInput stream that object will read from
Returns:
read object
Throws:
IOException - in case of failure to read


Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.