Class DataSerializer
DataSerializable. For instance, classes that implement DataSerializable can
use the DataSerializer in their toData and fromData
methods:
public class Employee implements DataSerializable {
private int id;
private String name;
private Date birthday;
private Company employer;
public void toData(DataOutput out) throws IOException {
out.writeInt(this.id);
out.writeUTF(this.name);
DataSerializer.writeDate(this.birthday, out);
DataSerializer.writeObject(this.employer, out);
}
public void fromData(DataInput in) throws IOException, ClassNotFoundException {
this.id = in.readInt();
this.name = in.readUTF();
this.birthday = DataSerializer.readDate(in);
this.employer = (Company) DataSerializer.readObject(in);
}
}
Instances of DataSerializer are used to data serialize objects (such as instances of
standard Java classes or third-party classes for which the source code is not available) that do
not implement the DataSerializable interface.
The following DataSerializer data serializes instances of Company. In
order for the data serialization framework to consult this custom serializer, it must be
registered with the framework.
public class CompanySerializer extends DataSerializer {
static {
DataSerializer.register(CompanySerializer.class);
}
/**
May be invoked reflectively if instances of Company are
distributed to other VMs.
/
public CompanySerializer() {
}
public Class[] getSupportedClasses() {
return new Class[] { Company.class };
}
public int getId() {
return 42;
}
public boolean toData(Object o, DataOutput out)
throws IOException {
if (o instanceof Company) {
Company company = (Company) o;
out.writeUTF(company.getName());
// Let's assume that Address is java.io.Serializable
Address address = company.getAddress();
writeObject(address, out);
return true;
} else {
return false;
}
}
public Object fromData(DataInput in)
throws IOException, ClassNotFoundException {
String name = in.readUTF();
Address address = (Address) readObject(in);
return new Company(name, address);
}
}
Just like Instantiators, a DataSerializer may be sent to other members of
the distributed system when it is registered. The data
serialization framework does not require that a DataSerializer be
Serializable, but it does require that it provide a zero-argument constructor.- Since:
- GemFire 3.5
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final ThreadLocal<Boolean>protected static final booleanDeprecated.Use Boolean.getBoolean("DataSerializer.TRACE_SERIALIZABLE") instead. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanTwoDataSerializers are consider to be equal if they have the same id and the same classabstract ObjectReads an object from aDataInput.For internal use only.For internal use only.abstract intgetId()Returns the id of thisDataSerializer.abstract Class<?>[]Returns theClasses whose instances are data serialized by thisDataSerializer.inthashCode()static <E> ArrayList<E>Reads anArrayListfrom aDataInput.static byte[][]Reads an array ofbyte[]s from aDataInput.static BooleanreadBoolean(DataInput in) Reads an instance ofBooleanfrom aDataInput.static boolean[]Reads an array ofbooleans from aDataInput.static ByteReads an instance ofBytefrom aDataInput.static byte[]Reads an array ofbytes from aDataInput.static CharacterReads an instance ofCharacterfrom aDataInput.static char[]Reads an array ofchars from aDataInput.static Class<?>Reads an instance ofClassfrom aDataInput.static <K,V> ConcurrentHashMap<K, V> Reads aConcurrentHashMapfrom aDataInput.static DateReads an instance ofDatefrom aDataInput.static DoublereadDouble(DataInput in) Reads an instance ofDoublefrom aDataInput.static double[]Reads an array ofdoubles from aDataInput.static <E extends Enum<E>>
EReads aEnum constantfromDataInput.static FileReads an instance ofFilefrom aDataInput.static FloatReads an instance ofFloatfrom aDataInput.static float[]Reads an array offloats from aDataInput.static <K,V> HashMap<K, V> readHashMap(DataInput in) Reads aHashMapfrom aDataInput.static <E> HashSet<E>readHashSet(DataInput in) Reads aHashSetfrom aDataInput.static <K,V> Hashtable<K, V> Reads aHashtablefrom aDataInput.static <K,V> IdentityHashMap<K, V> Reads aIdentityHashMapfrom aDataInput.static InetAddressReads an instance ofInetAddressfrom aDataInput.static int[]Reads anintarray from aDataInput.static IntegerreadInteger(DataInput in) Reads an instance ofIntegerfrom aDataInput.static <K,V> LinkedHashMap<K, V> Reads aLinkedHashMapfrom aDataInput.static <E> LinkedHashSet<E>Reads aLinkedHashSetfrom aDataInput.static <E> LinkedList<E>Reads anLinkedListfrom aDataInput.static LongReads an instance ofLongfrom aDataInput.static long[]Reads an array oflongs from aDataInput.static StringReads name of an instance ofClassfrom aDataInput.static <T> TreadObject(DataInput in) Reads an arbitrary object from aDataInput.static Object[]Reads an array ofObjects from aDataInput.static booleanReads a primitivebooleanfrom aDataInput.static byteReads a primitivebytefrom aDataInput.static charReads a primitivecharfrom aDataInput.static doubleReads a primitivedoublefrom aDataInput.static floatReads a primitivefloatfrom aDataInput.static intReads a primitiveintfrom aDataInput.static longReads a primitivelongfrom aDataInput.static shortReads a primitiveshortfrom aDataInput.static PropertiesReads aPropertiesfrom aDataInput.static <K,V> Region<K, V> readRegion(DataInput in) Reads an instance of Region.static ShortReads an instance ofShortfrom aDataInput.static short[]Reads an array ofshorts from aDataInput.static <E> Stack<E>Reads anStackfrom aDataInput.static StringreadString(DataInput in) Reads an instance ofStringfrom aDataInput.static String[]Reads an array ofStrings from aDataInput.static <K,V> TreeMap<K, V> readTreeMap(DataInput in) Reads aTreeMapfrom aDataInput.static <E> TreeSet<E>readTreeSet(DataInput in) Reads aTreeSetfrom aDataInput.static intstatic intstatic <E> Vector<E>readVector(DataInput in) Reads anVectorfrom aDataInput.static DataSerializerRegisters aDataSerializerclass with the data serialization framework.voidsetContext(Object context) For internal use only.voidsetEventId(Object eventId) For internal use only.abstract booleantoData(Object o, DataOutput out) Data serializes an object to aDataOutput.static voidwriteArrayList(ArrayList<?> list, DataOutput out) Writes anArrayListto aDataOutput.static voidwriteArrayOfByteArrays(byte[][] array, DataOutput out) Writes an array of byte[] to a DataOutput.static voidwriteBoolean(Boolean value, DataOutput out) Writes an instance ofBooleanto aDataOutput.static voidwriteBooleanArray(boolean[] array, DataOutput out) Writes an array ofbooleans to aDataOutput.static voidwriteByte(Byte value, DataOutput out) Writes an instance ofByteto aDataOutput.static voidwriteByteArray(byte[] array, int len, DataOutput out) Writes the firstlenelements of an array ofbytes to aDataOutput.static voidwriteByteArray(byte[] array, DataOutput out) Writes an array ofbytes to aDataOutput.static voidwriteCharacter(Character value, DataOutput out) Writes an instance ofCharacterto aDataOutput.static voidwriteCharArray(char[] array, DataOutput out) Writes an array ofchars to aDataOutput.static voidwriteClass(Class<?> c, DataOutput out) Writes an instance ofClassto aDataOutput.static voidwriteConcurrentHashMap(ConcurrentHashMap<?, ?> map, DataOutput out) Writes aConcurrentHashMapto aDataOutput.static voidwriteDate(Date date, DataOutput out) Writes an instance ofDateto aDataOutput.static voidwriteDouble(Double value, DataOutput out) Writes an instance ofDoubleto aDataOutput.static voidwriteDoubleArray(double[] array, DataOutput out) Writes an array ofdoubles to aDataOutput.static voidwriteEnum(Enum e, DataOutput out) Writes theEnum constanttoDataOutput.static voidwriteFile(File file, DataOutput out) Writes an instance ofFileto aDataOutput.static voidwriteFloat(Float value, DataOutput out) Writes an instance ofFloatto aDataOutput.static voidwriteFloatArray(float[] array, DataOutput out) Writes an array offloats to aDataOutput.static voidwriteHashMap(Map<?, ?> map, DataOutput out) Writes aHashMapto aDataOutput.static voidwriteHashSet(HashSet<?> set, DataOutput out) Writes aHashSetto aDataOutput.static voidwriteHashtable(Hashtable<?, ?> map, DataOutput out) Writes aHashtableto aDataOutput.static voidwriteIdentityHashMap(IdentityHashMap<?, ?> map, DataOutput out) Writes aIdentityHashMapto aDataOutput.static voidwriteInetAddress(InetAddress address, DataOutput out) Writes an instance ofInetAddressto aDataOutput.static voidwriteIntArray(int[] array, DataOutput out) Writes anintarray to aDataOutput.static voidwriteInteger(Integer value, DataOutput out) Writes an instance ofIntegerto aDataOutput.static voidwriteLinkedHashMap(Map<?, ?> map, DataOutput out) Writes aLinkedHashMapto aDataOutput.static voidwriteLinkedHashSet(LinkedHashSet<?> set, DataOutput out) Writes aLinkedHashSetto aDataOutput.static voidwriteLinkedList(LinkedList<?> list, DataOutput out) Writes anLinkedListto aDataOutput.static voidwriteLong(Long value, DataOutput out) Writes an instance ofLongto aDataOutput.static voidwriteLongArray(long[] array, DataOutput out) Writes an array oflongs to aDataOutput.static voidwriteNonPrimitiveClassName(String className, DataOutput out) Writes class name to aDataOutput.static voidwriteObject(Object o, DataOutput out) Writes an arbitrary object to aDataOutput.static voidwriteObject(Object o, DataOutput out, boolean allowJavaSerialization) Writes an arbitrary object to aDataOutput.static voidwriteObjectArray(Object[] array, DataOutput out) Writes an array ofObjects to aDataOutput.static voidwriteObjectAsByteArray(Object obj, DataOutput out) Serialize the given objectobjinto a byte array usingwriteObject(Object, DataOutput)and then writes the byte array to the given data outputoutin the same formatwriteByteArray(byte[], DataOutput)does.static voidwritePrimitiveBoolean(boolean value, DataOutput out) Writes a primitivebooleanto aDataOutput.static voidwritePrimitiveByte(byte value, DataOutput out) Writes a primitivebyteto aDataOutput.static voidwritePrimitiveChar(char value, DataOutput out) Writes a primitivecharto aDataOutput.static voidwritePrimitiveDouble(double value, DataOutput out) Writes a primtivedoubleto aDataOutput.static voidwritePrimitiveFloat(float value, DataOutput out) Writes a primitivefloatto aDataOutput.static voidwritePrimitiveInt(int value, DataOutput out) Writes a primitiveintto aDataOutput.static voidwritePrimitiveLong(long value, DataOutput out) Writes a primitivelongto aDataOutput.static voidwritePrimitiveShort(short value, DataOutput out) Writes a primitiveshortto aDataOutput.static voidwriteProperties(Properties props, DataOutput out) Writes aPropertiesto aDataOutput.static voidwriteRegion(Region<?, ?> rgn, DataOutput out) Writes an instance of Region.static voidwriteShort(Short value, DataOutput out) Writes an instance ofShortto aDataOutput.static voidwriteShortArray(short[] array, DataOutput out) Writes an array ofshorts to aDataOutput.static voidwriteStack(Stack<?> list, DataOutput out) Writes anStackto aDataOutput.static voidwriteString(String value, DataOutput out) Writes an instance ofStringto aDataOutput.static voidwriteStringArray(String[] array, DataOutput out) Writes an array ofStrings to aDataOutput.static voidwriteTreeMap(TreeMap<?, ?> map, DataOutput out) Writes aTreeMapto aDataOutput.static voidwriteTreeSet(TreeSet<?> set, DataOutput out) Writes aTreeSetto aDataOutput.static voidwriteUnsignedByte(int value, DataOutput out) Writes a primitiveintas an unsigned byte to aDataOutput.static voidwriteUnsignedShort(int value, DataOutput out) Writes a primitiveintas an unsigned short to aDataOutput.static voidwriteVector(Vector<?> list, DataOutput out) Writes anVectorto aDataOutput.
-
Field Details
-
TRACE_SERIALIZABLE
Deprecated.Use Boolean.getBoolean("DataSerializer.TRACE_SERIALIZABLE") instead. -
DISALLOW_JAVA_SERIALIZATION
-
-
Constructor Details
-
DataSerializer
public DataSerializer()Creates a newDataSerializer. All class that implementDataSerializermust provide a zero-argument constructor.- See Also:
-
-
Method Details
-
writeClass
Writes an instance ofClassto aDataOutput. This method will handle anullvalue and not throw aNullPointerException.- Parameters:
c- theClassto writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing toout- See Also:
-
writeNonPrimitiveClassName
Writes class name to aDataOutput. This method will handle anullvalue and not throw aNullPointerException.- Parameters:
className- the class name to writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing toout- See Also:
-
readClass
Reads an instance ofClassfrom aDataInput. The class will be loaded using the current content class loader. The return value may benull.- Parameters:
in- theDataInputto read from- Returns:
- the deserialized
Class - Throws:
IOException- A problem occurs while reading frominClassNotFoundException- The class cannot be loaded
-
readNonPrimitiveClassName
Reads name of an instance ofClassfrom aDataInput. The return value may benull.- Parameters:
in- theDataInputto read from- Returns:
- the deserialized Class name
- Throws:
IOException- A problem occurs while reading fromin- See Also:
-
writeRegion
Writes an instance of Region. A Region is serialized as just a reference to a full path only. It will be recreated on the other end by callingCacheFactory.getAnyInstance()and then callinggetRegionon it. This method will handle anullvalue and not throw aNullPointerException.- Parameters:
rgn- the Region to writeout- theDataInputto write to- Throws:
IOException- if a problem occurs while reading fromin
-
readRegion
public static <K,V> Region<K,V> readRegion(DataInput in) throws IOException, ClassNotFoundException Reads an instance of Region. A Region is serialized as a reference to a full path only. It is recreated on the other end by callingCacheFactory.getAnyInstance()and then callinggetRegionon it. The return value may benull.- Type Parameters:
K- the type of keys in the regionV- the type of values in the region- Parameters:
in- the input stream- Returns:
- the Region instance
- Throws:
CacheClosedException- if a cache has not been created or the only created one is closed.RegionNotFoundException- if there is no region by this name in the CacheIOException- if a problem occurs while reading frominClassNotFoundException- if the class of one of the Region's elements cannot be found.
-
writeDate
Writes an instance ofDateto aDataOutput. Note that even thoughdatemay be an instance of a subclass ofDate,readDatewill always return an instance ofDate, not an instance of the subclass. To preserve the class type ofdate,\writeObject(Object, DataOutput)should be used for data serialization. This method will handle anullvalue and not throw aNullPointerException.- Parameters:
date- theDateto writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing toout- See Also:
-
readDate
Reads an instance ofDatefrom aDataInput. The return value may benull.- Parameters:
in- theDataInputto read from- Returns:
- the deserialized
Date - Throws:
IOException- A problem occurs while reading fromin
-
writeFile
Writes an instance ofFileto aDataOutput. Note that even thoughfilemay be an instance of a subclass ofFile,readFilewill always return an instance ofFile, not an instance of the subclass. To preserve the class type offile,writeObject(Object, DataOutput)should be used for data serialization. This method will handle anullvalue and not throw aNullPointerException.- Parameters:
file- theFileto writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing toout- See Also:
-
readFile
Reads an instance ofFilefrom aDataInput. The return value may benull.- Parameters:
in- theDataInputto read from- Returns:
- the deserialized
File - Throws:
IOException- A problem occurs while reading fromin
-
writeInetAddress
Writes an instance ofInetAddressto aDataOutput. TheInetAddressis data serialized by writing itsbyterepresentation to theDataOutput.readInetAddress(java.io.DataInput)converts thebyterepresentation to an instance ofInetAddressusingInetAddress.getAddress(). As a result, ifaddressis an instance of a user-defined subclass ofInetAddress(that is, not an instance of one of the subclasses from thejava.netpackage), its class will not be preserved. In order to be able to read an instance of the user-defined class,writeObject(Object, DataOutput)should be used. This method will handle anullvalue and not throw aNullPointerException.- Parameters:
address- theInetAddressto writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing toout- See Also:
-
readInetAddress
Reads an instance ofInetAddressfrom aDataInput. The return value may benull.- Parameters:
in- theDataInputto read from- Returns:
- the deserialized
InetAddress - Throws:
IOException- A problem occurs while reading frominor the address read frominis unknown- See Also:
-
writeString
Writes an instance ofStringto aDataOutput. This method will handle anullvalue and not throw aNullPointerException.As of 5.7 strings longer than 0xFFFF can be serialized.
- Parameters:
value- theStringto writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing toout- See Also:
-
readString
Reads an instance ofStringfrom aDataInput. The return value may benull.- Parameters:
in- theDataInputto read from- Returns:
- the deserialized
String - Throws:
IOException- A problem occurs while reading fromin- See Also:
-
writeBoolean
Writes an instance ofBooleanto aDataOutput.- Parameters:
value- theBooleanto writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing tooutNullPointerException- if value is null.- See Also:
-
readBoolean
Reads an instance ofBooleanfrom aDataInput.- Parameters:
in- theDataInputto read from- Returns:
- the deserialized
Boolean - Throws:
IOException- A problem occurs while reading fromin
-
writeCharacter
Writes an instance ofCharacterto aDataOutput.- Parameters:
value- theCharacterto writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing tooutNullPointerException- if value is null.- See Also:
-
readCharacter
Reads an instance ofCharacterfrom aDataInput.- Parameters:
in- theDataInputto read from- Returns:
- the deserialized
Character - Throws:
IOException- A problem occurs while reading fromin
-
writeByte
Writes an instance ofByteto aDataOutput.- Parameters:
value- theByteto writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing tooutNullPointerException- if value is null.- See Also:
-
readByte
Reads an instance ofBytefrom aDataInput.- Parameters:
in- theDataInputto read from- Returns:
- the deserialized
Byte - Throws:
IOException- A problem occurs while reading fromin
-
writeShort
Writes an instance ofShortto aDataOutput.- Parameters:
value- theShortto writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing tooutNullPointerException- if value is null.- See Also:
-
readShort
Reads an instance ofShortfrom aDataInput.- Parameters:
in- theDataInputto read from- Returns:
- the deserialized
Short - Throws:
IOException- A problem occurs while reading fromin
-
writeInteger
Writes an instance ofIntegerto aDataOutput.- Parameters:
value- theIntegerto writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing tooutNullPointerException- if value is null.- See Also:
-
readInteger
Reads an instance ofIntegerfrom aDataInput.- Parameters:
in- theDataInputto read from- Returns:
- the deserialized
Integer - Throws:
IOException- A problem occurs while reading fromin
-
writeLong
Writes an instance ofLongto aDataOutput.- Parameters:
value- theLongto writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing tooutNullPointerException- if value is null.- See Also:
-
readLong
Reads an instance ofLongfrom aDataInput.- Parameters:
in- theDataInputto read from- Returns:
- the deserialized
Long - Throws:
IOException- A problem occurs while reading fromin
-
writeFloat
Writes an instance ofFloatto aDataOutput.- Parameters:
value- theFloatto writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing tooutNullPointerException- if value is null.- See Also:
-
readFloat
Reads an instance ofFloatfrom aDataInput.- Parameters:
in- theDataInputto read from- Returns:
- the deserialized
Float - Throws:
IOException- A problem occurs while reading fromin
-
writeDouble
Writes an instance ofDoubleto aDataOutput.- Parameters:
value- theDoubleto writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing tooutNullPointerException- if value is null.- See Also:
-
readDouble
Reads an instance ofDoublefrom aDataInput.- Parameters:
in- theDataInputto read from- Returns:
- the deserialized
Double - Throws:
IOException- A problem occurs while reading fromin
-
writePrimitiveBoolean
Writes a primitivebooleanto aDataOutput.- Parameters:
value- the primitivebooleanto writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing toout- Since:
- GemFire 5.1
- See Also:
-
readPrimitiveBoolean
Reads a primitivebooleanfrom aDataInput.- Parameters:
in- theDataInputto read from- Returns:
- the deserialized primitive
boolean - Throws:
IOException- A problem occurs while reading fromin- Since:
- GemFire 5.1
- See Also:
-
writePrimitiveByte
Writes a primitivebyteto aDataOutput.- Parameters:
value- the primitivebyteto writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing toout- Since:
- GemFire 5.1
- See Also:
-
readPrimitiveByte
Reads a primitivebytefrom aDataInput.- Parameters:
in- theDataInputto read from- Returns:
- the deserialized primitive
byte - Throws:
IOException- A problem occurs while reading fromin- Since:
- GemFire 5.1
- See Also:
-
writePrimitiveChar
Writes a primitivecharto aDataOutput.- Parameters:
value- the primitivecharto writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing toout- Since:
- GemFire 5.1
- See Also:
-
readPrimitiveChar
Reads a primitivecharfrom aDataInput.- Parameters:
in- theDataInputto read from- Returns:
- the deserialized primitive
char - Throws:
IOException- A problem occurs while reading fromin- Since:
- GemFire 5.1
- See Also:
-
writePrimitiveShort
Writes a primitiveshortto aDataOutput.- Parameters:
value- the primitiveshortto writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing toout- Since:
- GemFire 5.1
- See Also:
-
readPrimitiveShort
Reads a primitiveshortfrom aDataInput.- Parameters:
in- theDataInputto read from- Returns:
- the deserialized primitive
short - Throws:
IOException- A problem occurs while reading fromin- Since:
- GemFire 5.1
- See Also:
-
writeUnsignedByte
Writes a primitiveintas an unsigned byte to aDataOutput.- Parameters:
value- the primitiveintas an unsigned byte to writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing toout- Since:
- GemFire 5.1
- See Also:
-
readUnsignedByte
- Parameters:
in- theDataInputto read from- Returns:
- the deserialized primitive
intas an unsigned byte - Throws:
IOException- A problem occurs while reading fromin- Since:
- GemFire 5.1
-
writeUnsignedShort
Writes a primitiveintas an unsigned short to aDataOutput.- Parameters:
value- the primitiveintas an unsigned short to writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing toout- Since:
- GemFire 5.1
- See Also:
-
readUnsignedShort
- Parameters:
in- theDataInputto read from- Returns:
- the deserialized primitive
intas an unsigned short - Throws:
IOException- A problem occurs while reading fromin- Since:
- GemFire 5.1
-
writePrimitiveInt
Writes a primitiveintto aDataOutput.- Parameters:
value- the primitiveintto writeout- theDataOutputto write to- Throws:
IOException- A problem occurs while writing toout- See Also:
-
readPrimitiveInt
Reads a primitiveintfrom aDataInput.- Parameters:
in- theDataInputto read from- Returns:
- a primitive
int - Throws:
IOException- A problem occurs while reading fromin- Since:
- GemFire 5.1
- See Also:
-
writePrimitiveLong
Writes a primitivelongto aDataOutput.- Parameters:
value- the primitivelongto writeout- theDataOutputto write to- Throws:
IOException- A problem occurs while writing toout- Since:
- GemFire 5.1
- See Also:
-
readPrimitiveLong
Reads a primitivelongfrom aDataInput.- Parameters:
in- theDataInputto read from- Returns:
- a primitive
long - Throws:
IOException- A problem occurs while reading fromin- Since:
- GemFire 5.1
- See Also:
-
writePrimitiveFloat
Writes a primitivefloatto aDataOutput.- Parameters:
value- the primitivefloatto writeout- theDataOutputto write to- Throws:
IOException- A problem occurs while writing toout- Since:
- GemFire 5.1
- See Also:
-
readPrimitiveFloat
Reads a primitivefloatfrom aDataInput.- Parameters:
in- theDataInputto read from- Returns:
- a primitive
float - Throws:
IOException- A problem occurs while reading fromin- Since:
- GemFire 5.1
- See Also:
-
writePrimitiveDouble
Writes a primtivedoubleto aDataOutput.- Parameters:
value- the primitivedoubleto writeout- theDataOutputto write to- Throws:
IOException- A problem occurs while writing toout- Since:
- GemFire 5.1
- See Also:
-
readPrimitiveDouble
Reads a primitivedoublefrom aDataInput.- Parameters:
in- theDataInputto read from- Returns:
- a primitive
double - Throws:
IOException- A problem occurs while reading fromin- Since:
- GemFire 5.1
- See Also:
-
writeByteArray
Writes an array ofbytes to aDataOutput. This method will serialize anullarray and not throw aNullPointerException.- Parameters:
array- the array ofbytes to writeout- theDataOutputto write to- Throws:
IOException- A problem occurs while writing toout- See Also:
-
writeByteArray
Writes the firstlenelements of an array ofbytes to aDataOutput. This method will serialize anullarray and not throw aNullPointerException.- Parameters:
array- the array ofbytes to writelen- the actual number of entries to write. If len is greater than then length of theout- theDataOutputto write to array then the entire array is written.- Throws:
IOException- A problem occurs while writing toout- See Also:
-
writeObjectAsByteArray
Serialize the given objectobjinto a byte array usingwriteObject(Object, DataOutput)and then writes the byte array to the given data outputoutin the same formatwriteByteArray(byte[], DataOutput)does. This method will serialize anullobj and not throw aNullPointerException.- Parameters:
obj- the object to serialize and writeout- the data output to write the byte array to- Throws:
IllegalArgumentException- if a problem occurs while serializeobjIOException- if a problem occurs while writing toout- Since:
- GemFire 5.0.2
- See Also:
-
readByteArray
Reads an array ofbytes from aDataInput.- Parameters:
in- theDataInputto read from- Returns:
- the deserialized array of
bytes - Throws:
IOException- A problem occurs while reading fromin- See Also:
-
writeStringArray
Writes an array ofStrings to aDataOutput. This method will serialize anullarray and not throw aNullPointerException.- Parameters:
array- the array ofStrings to writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing toout- See Also:
-
readStringArray
Reads an array ofStrings from aDataInput.- Parameters:
in- theDataInputto read from- Returns:
- the deserialized array of
Strings - Throws:
IOException- A problem occurs while reading fromin- See Also:
-
writeShortArray
Writes an array ofshorts to aDataOutput. This method will serialize anullarray and not throw aNullPointerException.- Parameters:
array- the array ofshorts to writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing toout- See Also:
-
readShortArray
Reads an array ofshorts from aDataInput.- Parameters:
in- theDataInputto read from- Returns:
- the deserialized array of
shorts - Throws:
IOException- A problem occurs while reading fromin- See Also:
-
writeCharArray
Writes an array ofchars to aDataOutput.- Parameters:
array- the array ofchars to writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing toout- Since:
- GemFire 5.7
- See Also:
-
readCharArray
Reads an array ofchars from aDataInput.- Parameters:
in- theDataInputto read from- Returns:
- the deserialized array of
chars - Throws:
IOException- A problem occurs while reading fromin- Since:
- GemFire 5.7
- See Also:
-
writeBooleanArray
Writes an array ofbooleans to aDataOutput.- Parameters:
array- the array ofbooleans to writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing toout- Since:
- GemFire 5.7
- See Also:
-
readBooleanArray
Reads an array ofbooleans from aDataInput.- Parameters:
in- theDataInputto read from- Returns:
- the deserialized array of
booleans - Throws:
IOException- A problem occurs while reading fromin- Since:
- GemFire 5.7
- See Also:
-
writeIntArray
Writes anintarray to aDataOutput. This method will serialize anullarray and not throw aNullPointerException.- Parameters:
array- the array ofints to writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing toout- See Also:
-
readIntArray
Reads anintarray from aDataInput.- Parameters:
in- theDataInputto read from- Returns:
- the deserialized array of
ints - Throws:
IOException- A problem occurs while reading fromin- See Also:
-
writeLongArray
Writes an array oflongs to aDataOutput. This method will serialize anullarray and not throw aNullPointerException.- Parameters:
array- the array oflongs to writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing toout- See Also:
-
readLongArray
Reads an array oflongs from aDataInput.- Parameters:
in- theDataInputto read from- Returns:
- the deserialized array of
longs - Throws:
IOException- A problem occurs while reading fromin- See Also:
-
writeFloatArray
Writes an array offloats to aDataOutput. This method will serialize anullarray and not throw aNullPointerException.- Parameters:
array- the array offloats to writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing toout- See Also:
-
readFloatArray
Reads an array offloats from aDataInput.- Parameters:
in- theDataInputto read from- Returns:
- the deserialized array of
floats - Throws:
IOException- A problem occurs while reading fromin- See Also:
-
writeDoubleArray
Writes an array ofdoubles to aDataOutput. This method will serialize anullarray and not throw aNullPointerException.- Parameters:
array- the array ofdoubles to writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing toout- See Also:
-
readDoubleArray
Reads an array ofdoubles from aDataInput.- Parameters:
in- theDataInputto read from- Returns:
- the deserialized array of
doubles - Throws:
IOException- A problem occurs while reading fromin- See Also:
-
writeObjectArray
Writes an array ofObjects to aDataOutput. This method will serialize anullarray and not throw aNullPointerException.- Parameters:
array- the array ofObjects to writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing toout- See Also:
-
readObjectArray
Reads an array ofObjects from aDataInput.- Parameters:
in- theDataInputto read from- Returns:
- the deserialized array of
Objects - Throws:
IOException- A problem occurs while reading frominClassNotFoundException- if the class of one of the array's elements cannot be found.- See Also:
-
writeArrayOfByteArrays
Writes an array of byte[] to a DataOutput.- Parameters:
array- the array ofbyte[]s to writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing to out.
-
readArrayOfByteArrays
Reads an array ofbyte[]s from aDataInput.- Parameters:
in- theDataInputto read from- Returns:
- the deserialized array of
byte[]s - Throws:
IOException- A problem occurs while reading fromin
-
writeArrayList
Writes anArrayListto aDataOutput. Note that even thoughlistmay be an instance of a subclass ofArrayList,readArrayListwill always return an instance ofArrayList, not an instance of the subclass. To preserve the class type oflist,writeObject(Object, DataOutput)should be used for data serialization. This method will serialize anulllist and not throw aNullPointerException.- Parameters:
list- theArrayListto writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing toout- See Also:
-
readArrayList
public static <E> ArrayList<E> readArrayList(DataInput in) throws IOException, ClassNotFoundException Reads anArrayListfrom aDataInput.- Type Parameters:
E- – the type of elements in the list- Parameters:
in- theDataInputto read from- Returns:
- the deserialized
ArrayList - Throws:
IOException- A problem occurs while reading frominClassNotFoundException- The class of one of theArrayList's elements cannot be found.- See Also:
-
writeVector
Writes anVectorto aDataOutput. Note that even thoughlistmay be an instance of a subclass ofVector,readVectorwill always return an instance ofVector, not an instance of the subclass. To preserve the class type oflist,writeObject(Object, DataOutput)should be used for data serialization.- Parameters:
list- theVectorto writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing toout- Since:
- GemFire 5.7
- See Also:
-
readVector
Reads anVectorfrom aDataInput.- Type Parameters:
E- – the type of elements in the vector- Parameters:
in- theDataInputto read from- Returns:
- the deserialized
Vector - Throws:
IOException- A problem occurs while reading frominClassNotFoundException- The class of one of theVector's elements cannot be found.- Since:
- GemFire 5.7
- See Also:
-
writeStack
Writes anStackto aDataOutput. Note that even thoughlistmay be an instance of a subclass ofStack,readStackwill always return an instance ofStack, not an instance of the subclass. To preserve the class type oflist,writeObject(Object, DataOutput)should be used for data serialization.- Parameters:
list- theStackto writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing toout- Since:
- GemFire 5.7
- See Also:
-
readStack
Reads anStackfrom aDataInput.- Type Parameters:
E- – the type of elements in the stack- Parameters:
in- theDataInputto read from- Returns:
- the deserialized
Stack - Throws:
IOException- A problem occurs while reading frominClassNotFoundException- The class of one of theStack's elements cannot be found.- Since:
- GemFire 5.7
- See Also:
-
writeLinkedList
Writes anLinkedListto aDataOutput. Note that even thoughlistmay be an instance of a subclass ofLinkedList,readLinkedListwill always return an instance ofLinkedList, not an instance of the subclass. To preserve the class type oflist,writeObject(Object, DataOutput)should be used for data serialization. This method will serialize anulllist and not throw aNullPointerException.- Parameters:
list- theLinkedListto writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing toout- See Also:
-
readLinkedList
public static <E> LinkedList<E> readLinkedList(DataInput in) throws IOException, ClassNotFoundException Reads anLinkedListfrom aDataInput.- Type Parameters:
E- – the type of elements in the list- Parameters:
in- theDataInputto read from- Returns:
- the deserialized
LinkedList - Throws:
IOException- A problem occurs while reading frominClassNotFoundException- The class of one of theLinkedList's elements cannot be found.- See Also:
-
writeHashSet
Writes aHashSetto aDataOutput. Note that even thoughsetmay be an instance of a subclass ofHashSet,readHashSetwill always return an instance ofHashSet, not an instance of the subclass. To preserve the class type ofset,writeObject(Object, DataOutput)should be used for data serialization. This method will serialize anullset and not throw aNullPointerException.- Parameters:
set- theHashSetto writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing toout- See Also:
-
readHashSet
Reads aHashSetfrom aDataInput.- Type Parameters:
E- – the type of elements in the set- Parameters:
in- theDataInputto read from- Returns:
- the deserialized
HashSet - Throws:
IOException- A problem occurs while reading frominClassNotFoundException- The class of one of theHashSet's elements cannot be found.- See Also:
-
writeLinkedHashSet
Writes aLinkedHashSetto aDataOutput. Note that even thoughsetmay be an instance of a subclass ofLinkedHashSet,readLinkedHashSetwill always return an instance ofLinkedHashSet, not an instance of the subclass. To preserve the class type ofset,writeObject(Object, DataOutput)should be used for data serialization.- Parameters:
set- theLinkedHashSetto writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing toout- Since:
- GemFire 5.7
- See Also:
-
readLinkedHashSet
public static <E> LinkedHashSet<E> readLinkedHashSet(DataInput in) throws IOException, ClassNotFoundException Reads aLinkedHashSetfrom aDataInput.- Type Parameters:
E- – the type of elements in the set- Parameters:
in- theDataInputto read from- Returns:
- the deserialized
LinkedHashSet - Throws:
IOException- A problem occurs while reading frominClassNotFoundException- The class of one of theLinkedHashSet's elements cannot be found.- Since:
- GemFire 5.7
- See Also:
-
writeHashMap
Writes aHashMapto aDataOutput. Note that even thoughmapmay be an instance of a subclass ofHashMap,readHashMapwill always return an instance ofHashMap, not an instance of the subclass. To preserve the class type ofmap,writeObject(Object, DataOutput)should be used for data serialization. This method will serialize anullmap and not throw aNullPointerException.- Parameters:
map- theHashMapto writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing toout- See Also:
-
readHashMap
public static <K,V> HashMap<K,V> readHashMap(DataInput in) throws IOException, ClassNotFoundException Reads aHashMapfrom aDataInput.- Type Parameters:
K- – the type of keys in the mapV- – the type of mapped values- Parameters:
in- theDataInputto read from- Returns:
- the deserialized
HashMap - Throws:
IOException- A problem occurs while reading frominClassNotFoundException- The class of one of theHashMap's elements cannot be found.- See Also:
-
writeIdentityHashMap
public static void writeIdentityHashMap(IdentityHashMap<?, ?> map, DataOutput out) throws IOExceptionWrites aIdentityHashMapto aDataOutput. Note that even thoughmapmay be an instance of a subclass ofIdentityHashMap,readIdentityHashMapwill always return an instance ofIdentityHashMap, not an instance of the subclass. To preserve the class type ofmap,writeObject(Object, DataOutput)should be used for data serialization.- Parameters:
map- theIdentityHashMapto writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing toout- See Also:
-
readIdentityHashMap
public static <K,V> IdentityHashMap<K,V> readIdentityHashMap(DataInput in) throws IOException, ClassNotFoundException Reads aIdentityHashMapfrom aDataInput. Note that key identity is not preserved unless the keys belong to a class whose serialization preserves identity.- Type Parameters:
K- – the type of keys in the mapV- – the type of mapped values- Parameters:
in- theDataInputto read from- Returns:
- the deserialized
IdentityHashMap - Throws:
IOException- A problem occurs while reading frominClassNotFoundException- The class of one of theIdentityHashMap's elements cannot be found.- See Also:
-
writeConcurrentHashMap
public static void writeConcurrentHashMap(ConcurrentHashMap<?, ?> map, DataOutput out) throws IOExceptionWrites aConcurrentHashMapto aDataOutput. Note that even thoughmapmay be an instance of a subclass ofConcurrentHashMap,readConcurrentHashMapwill always return an instance ofConcurrentHashMap, not an instance of the subclass. To preserve the class type ofmap,writeObject(Object, DataOutput)should be used for data serialization.At this time if
writeObject(Object, DataOutput)is called with an instance of ConcurrentHashMap then it will be serialized with normal java.io Serialization. So if you want the keys and values of a ConcurrentHashMap to take advantage of GemFire serialization it must be serialized with this method.- Parameters:
map- theConcurrentHashMapto writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing toout- Since:
- GemFire 6.6
- See Also:
-
readConcurrentHashMap
public static <K,V> ConcurrentHashMap<K,V> readConcurrentHashMap(DataInput in) throws IOException, ClassNotFoundException Reads aConcurrentHashMapfrom aDataInput.- Type Parameters:
K- – the type of keys in the mapV- – the type of mapped values- Parameters:
in- theDataInputto read from- Returns:
- the deserialized
ConcurrentHashMap - Throws:
IOException- A problem occurs while reading frominClassNotFoundException- The class of one of theConcurrentHashMap's elements cannot be found.- Since:
- GemFire 6.6
- See Also:
-
writeHashtable
Writes aHashtableto aDataOutput. Note that even thoughmapmay be an instance of a subclass ofHashtable,readHashtablewill always return an instance ofHashtable, not an instance of the subclass. To preserve the class type ofmap,writeObject(Object, DataOutput)should be used for data serialization.- Parameters:
map- theHashtableto writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing toout- Since:
- GemFire 5.7
- See Also:
-
readHashtable
public static <K,V> Hashtable<K,V> readHashtable(DataInput in) throws IOException, ClassNotFoundException Reads aHashtablefrom aDataInput.- Type Parameters:
K- – the type of keys in the hashtableV- – the type of values in the hashtable- Parameters:
in- theDataInputto read from- Returns:
- the deserialized
Hashtable - Throws:
IOException- A problem occurs while reading frominClassNotFoundException- The class of one of theHashtable's elements cannot be found.- Since:
- GemFire 5.7
- See Also:
-
writeTreeMap
Writes aTreeMapto aDataOutput. Note that even thoughmapmay be an instance of a subclass ofTreeMap,readTreeMapwill always return an instance ofTreeMap, not an instance of the subclass. To preserve the class type ofmap,writeObject(Object, DataOutput)should be used for data serialization.If the map has a comparator then it must also be serializable.
- Parameters:
map- theTreeMapto writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing toout- Since:
- GemFire 5.7
- See Also:
-
readTreeMap
public static <K,V> TreeMap<K,V> readTreeMap(DataInput in) throws IOException, ClassNotFoundException Reads aTreeMapfrom aDataInput.- Type Parameters:
K- – the type of keys in the mapV- – the type of mapped values- Parameters:
in- theDataInputto read from- Returns:
- the deserialized
TreeMap - Throws:
IOException- A problem occurs while reading frominClassNotFoundException- The class of one of theTreeMap's elements cannot be found.- Since:
- GemFire 5.7
- See Also:
-
writeLinkedHashMap
Writes aLinkedHashMapto aDataOutput. Note that even thoughmapmay be an instance of a subclass ofLinkedHashMap,readLinkedHashMapwill always return an instance ofLinkedHashMap, not an instance of the subclass. To preserve the class type ofmap,writeObject(Object, DataOutput)should be used for data serialization. This method will serialize anullmap and not throw aNullPointerException.- Parameters:
map- theLinkedHashMapto writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing toout- See Also:
-
readLinkedHashMap
public static <K,V> LinkedHashMap<K,V> readLinkedHashMap(DataInput in) throws IOException, ClassNotFoundException Reads aLinkedHashMapfrom aDataInput.- Type Parameters:
K- – the type of keys in the mapV- – the type of mapped values- Parameters:
in- theDataInputto read from- Returns:
- the deserialized
LinkedHashMap - Throws:
IOException- A problem occurs while reading frominClassNotFoundException- The class of one of theHashMap's elements cannot be found.- See Also:
-
writeTreeSet
Writes aTreeSetto aDataOutput. Note that even thoughsetmay be an instance of a subclass ofTreeSet,readTreeSetwill always return an instance ofTreeSet, not an instance of the subclass. To preserve the class type ofset,writeObject(Object, DataOutput)should be used for data serialization.If the set has a comparator then it must also be serializable.
- Parameters:
set- theTreeSetto writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing toout- See Also:
-
readTreeSet
Reads aTreeSetfrom aDataInput.- Type Parameters:
E- the type contained in theTreeSet- Parameters:
in- theDataInputto read from- Returns:
- the deserialized
TreeSet - Throws:
IOException- A problem occurs while reading frominClassNotFoundException- The class of one of theTreeSet's elements cannot be found.- See Also:
-
writeProperties
Writes aPropertiesto aDataOutput.NOTE: The
defaultsof the specifiedpropsare not serialized.Note that even though
propsmay be an instance of a subclass ofProperties,readPropertieswill always return an instance ofProperties, not an instance of the subclass. To preserve the class type ofprops,writeObject(Object, DataOutput)should be used for data serialization.- Parameters:
props- the Properties to writeout- theDataInputto write to- Throws:
IOException- A problem occurs while writing toout- See Also:
-
readProperties
Reads aPropertiesfrom aDataInput.NOTE: the
defaultsare always empty in the returnedProperties.- Parameters:
in- theDataInputto read from- Returns:
- the deserialized Properties
- Throws:
IOException- If this serializer cannot read an object fromin.ClassNotFoundException- If the class cannot be loaded- See Also:
-
writeObject
public static void writeObject(Object o, DataOutput out, boolean allowJavaSerialization) throws IOException Writes an arbitrary object to aDataOutput. Ifois not an instance of a specially-handled standard Java class (see the list ingetSupportedClasses()), thetoDatamethod of each registeredDataSerializeris invoked until the object is serialized. If no registered serializer can serialize the object andodoes not implementDataSerializable, then it is serialized tooutusing standard Java serialization. This method will serialize anullo and not throw aNullPointerException.- Parameters:
o- the object to writeout- theDataOutputto write toallowJavaSerialization- If false, then a NotSerializableException is thrown in the case where standard Java serialization would otherwise be used for objectoor for any nested subobject ofo. This is used to prevent Java serialization from being used when sending data to a non-Java client- Throws:
IOException- A problem occurs while writingotoout- See Also:
-
writeObject
Writes an arbitrary object to aDataOutput. Ifois not an instance of a specially-handled standard Java class (such asDate,Integer, orArrayList), thetoDatamethod of each registeredDataSerializeris invoked until the object is serialized. If no registered serializer can serialize the object andodoes not implementDataSerializable, then it is serialized tooutusing standard Java serialization. This method will serialize anullo and not throw aNullPointerException.- Parameters:
o- the object to writeout- theDataOutputto write to- Throws:
IOException- A problem occurs while writingotoout- See Also:
-
readObject
Reads an arbitrary object from aDataInput. Instances of classes that are not handled specially (such asString,Class, andDataSerializable) are read using standard Java serialization.Note that if an object is deserialized using standard Java serialization, its class will be loaded using the current thread's
context class loaderbefore the one normally used by Java serialization is consulted.- Type Parameters:
T- the type of the Object to read- Parameters:
in- theDataInputto read from- Returns:
- an arbitrary deserialized object
- Throws:
IOException- A problem occurred while reading fromin(may wrap another exception)ClassNotFoundException- The class of an object read fromincould not be found- See Also:
-
register
Registers aDataSerializerclass with the data serialization framework. This method uses reflection to create an instance of theDataSerializerclass by invoking its zero-argument constructor.The
DataSerializerinstance will be consulted by thewriteObject(Object, DataOutput)andreadObject(java.io.DataInput)methods. Note that no two serializers can support the same class.This method invokes the
DataSerializerinstance'sgetSupportedClasses()method and keeps track of which classes can have their instances serialized by by this data serializer.- Parameters:
c- theDataSerializerclass to create and register with the data serialization framework.- Returns:
- the registered serializer instance
- Throws:
IllegalArgumentException- Ifcdoes not subclassDataSerializer, ifcdoes not have a zero-argument constructor, ifidis 0, if getSupportedClasses returns null or an empty array, if getSupportedClasses returns and array with null elementsIllegalStateException- if another serializer instance with ididhas already been registered, if another serializer instance that supports one of this instances classes has already been registered, if an attempt is made to support any of the classes reserved by DataSerializer (seegetSupportedClasses()for a list).- See Also:
-
getSupportedClasses
Returns theClasses whose instances are data serialized by thisDataSerializer. This method is invoked when this serializer is registered. This method is not allowed to returnnullnor an empty array. Only instances whose class name is the same as one of the class names in the result will be serialized by thisDataSerializer. TwoDataSerializers are not allowed to support the same class. The following classes can not be supported by user defined data serializers since they are all supported by the predefined data serializer:- Returns:
- the
Classes whose instances are data serialized by thisDataSerializer
-
toData
Data serializes an object to aDataOutput. It is very important that when performing the "switch" ono's class, your code test for a subclass before it tests for a superclass. Otherwise, the incorrect class id could be written to the serialization stream.- Parameters:
o- The object to data serialize. It will never benull.out- theDataInputto write to- Returns:
falseif thisDataSerializerdoes not know how to data serializeo.- Throws:
IOException- If this serializer cannot write an object toout.
-
fromData
Reads an object from aDataInput. This implementation must support deserializing everything serialized by the matchingtoData(java.lang.Object, java.io.DataOutput).- Parameters:
in- theDataInputto write to- Returns:
- the deserialized Object
- Throws:
IOException- If this serializer cannot read an object fromin.ClassNotFoundException- If the class cannot be loaded- See Also:
-
getId
public abstract int getId()Returns the id of thisDataSerializer.Returns an int instead of a byte
- Returns:
- the id of this
DataSerializer - Since:
- 5.7.
-
equals
TwoDataSerializers are consider to be equal if they have the same id and the same class -
hashCode
public int hashCode() -
setEventId
For internal use only. Sets the uniqueeventIdof thisDataSerializer.- Parameters:
eventId- the uniqueeventIdof thisDataSerializer- Since:
- GemFire 6.5
-
getEventId
For internal use only. Returns the uniqueeventIdof thisDataSerializer.- Returns:
- the unique
eventIdof thisDataSerializer - Since:
- GemFire 6.5
-
setContext
For internal use only. Sets the context of thisDataSerializer.- Parameters:
context- the context of thisDataSerializer- Since:
- GemFire 6.5
-
getContext
For internal use only. Returns the context of thisDataSerializer.- Returns:
- the context of this
DataSerializer - Since:
- GemFire 6.5
-
writeEnum
Writes theEnum constanttoDataOutput. Unlike standard java serialization which serializes both the enum name String and the ordinal, GemFire only serializes the ordinal byte, so for backward compatibility new enum constants should only be added to the end of the enum type.
Example:DataSerializer.writeEnum(DAY_OF_WEEK.SUN, out);- Parameters:
e- the Enum to serializeout- theDataInputto write to- Throws:
IOException- if a problem occurs while writing toout- Since:
- GemFire 6.5
- See Also:
-
readEnum
Reads aEnum constantfromDataInput. Unlike standard java serialization which serializes both the enum name String and the ordinal, GemFire only serializes the ordinal byte, so be careful about using the correct enum class. Also, for backward compatibility new enum constants should only be added to the end of the enum type.
Example:DAY_OF_WEEK d = DataSerializer.readEnum(DAY_OF_WEEK.class, in);- Type Parameters:
E- the type of Enum- Parameters:
clazz- the Enum class to deserialize toin- theDataInputto read from- Returns:
- the deserialized Enum
- Throws:
IOException- if a problem occurs while reading frominArrayIndexOutOfBoundsException- if the wrong enum class/enum class with a different version and less enum constants is used- Since:
- GemFire 6.5
- See Also:
-