public abstract class DataSerializer
extends java.lang.Object
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.writeObject(Object, DataOutput),
readObject(java.io.DataInput)| Modifier and Type | Field and Description |
|---|---|
protected static java.lang.ThreadLocal<java.lang.Boolean> |
DISALLOW_JAVA_SERIALIZATION |
protected static boolean |
TRACE_SERIALIZABLE |
| Constructor and Description |
|---|
DataSerializer()
Creates a new
DataSerializer. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object o)
Two
DataSerializers are consider to be equal if they
have the same id and the same class |
abstract java.lang.Object |
fromData(java.io.DataInput in)
Reads an object from a
DataInput. |
java.lang.Object |
getContext()
For internal use only.
|
java.lang.Object |
getEventId()
For internal use only.
|
abstract int |
getId()
Returns the id of this
DataSerializer. |
abstract java.lang.Class<?>[] |
getSupportedClasses()
Returns the
Classes whose instances are data
serialized by this DataSerializer. |
int |
hashCode() |
static <E> java.util.ArrayList<E> |
readArrayList(java.io.DataInput in)
Reads an
ArrayList from a DataInput. |
static byte[][] |
readArrayOfByteArrays(java.io.DataInput in)
Reads an array of
byte[]s from a
DataInput. |
static java.lang.Boolean |
readBoolean(java.io.DataInput in)
Reads an instance of
Boolean from a
DataInput. |
static boolean[] |
readBooleanArray(java.io.DataInput in)
Reads an array of
booleans from a
DataInput. |
static java.lang.Byte |
readByte(java.io.DataInput in)
Reads an instance of
Byte from a
DataInput. |
static byte[] |
readByteArray(java.io.DataInput in)
Reads an array of
bytes from a
DataInput. |
static java.lang.Character |
readCharacter(java.io.DataInput in)
Reads an instance of
Character from a
DataInput. |
static char[] |
readCharArray(java.io.DataInput in)
Reads an array of
chars from a
DataInput. |
static java.lang.Class<?> |
readClass(java.io.DataInput in)
Reads an instance of
Class from a
DataInput. |
static <K,V> java.util.concurrent.ConcurrentHashMap<K,V> |
readConcurrentHashMap(java.io.DataInput in)
Reads a
ConcurrentHashMap from a DataInput. |
static java.util.Date |
readDate(java.io.DataInput in)
Reads an instance of
Date from a
DataInput. |
static java.lang.Double |
readDouble(java.io.DataInput in)
Reads an instance of
Double from a
DataInput. |
static double[] |
readDoubleArray(java.io.DataInput in)
Reads an array of
doubles from a
DataInput. |
static <E extends java.lang.Enum<E>> |
readEnum(java.lang.Class<E> clazz,
java.io.DataInput in)
Reads a
Enum constant from DataInput. |
static java.io.File |
readFile(java.io.DataInput in)
Reads an instance of
File from a
DataInput. |
static java.lang.Float |
readFloat(java.io.DataInput in)
Reads an instance of
Float from a
DataInput. |
static float[] |
readFloatArray(java.io.DataInput in)
Reads an array of
floats from a
DataInput. |
static <K,V> java.util.HashMap<K,V> |
readHashMap(java.io.DataInput in)
Reads a
HashMap from a DataInput. |
static <E> java.util.HashSet<E> |
readHashSet(java.io.DataInput in)
Reads a
HashSet from a DataInput. |
static <K,V> java.util.Hashtable<K,V> |
readHashtable(java.io.DataInput in)
Reads a
Hashtable from a DataInput. |
static <K,V> java.util.IdentityHashMap<K,V> |
readIdentityHashMap(java.io.DataInput in)
Reads a
IdentityHashMap from a DataInput. |
static java.net.InetAddress |
readInetAddress(java.io.DataInput in)
Reads an instance of
InetAddress from a
DataInput. |
static int[] |
readIntArray(java.io.DataInput in)
Reads an
int array from a DataInput. |
static java.lang.Integer |
readInteger(java.io.DataInput in)
Reads an instance of
Integer from a
DataInput. |
static <E> java.util.LinkedHashSet<E> |
readLinkedHashSet(java.io.DataInput in)
Reads a
LinkedHashSet from a DataInput. |
static <E> java.util.LinkedList<E> |
readLinkedList(java.io.DataInput in)
Reads an
LinkedList from a DataInput. |
static java.lang.Long |
readLong(java.io.DataInput in)
Reads an instance of
Long from a
DataInput. |
static long[] |
readLongArray(java.io.DataInput in)
Reads an array of
longs from a
DataInput. |
static java.lang.String |
readNonPrimitiveClassName(java.io.DataInput in)
Reads name of an instance of
Class from a
DataInput. |
static <T> T |
readObject(java.io.DataInput in)
Reads an arbitrary object from a
DataInput. |
static java.lang.Object[] |
readObjectArray(java.io.DataInput in)
Reads an array of
Objects from a
DataInput. |
static boolean |
readPrimitiveBoolean(java.io.DataInput in)
Reads a primitive
boolean from a
DataInput. |
static byte |
readPrimitiveByte(java.io.DataInput in)
Reads a primitive
byte from a
DataInput. |
static char |
readPrimitiveChar(java.io.DataInput in)
Reads a primitive
char from a
DataInput. |
static double |
readPrimitiveDouble(java.io.DataInput in)
Reads a primitive
double from a
DataInput. |
static float |
readPrimitiveFloat(java.io.DataInput in)
Reads a primitive
float from a
DataInput. |
static int |
readPrimitiveInt(java.io.DataInput in)
Reads a primitive
int from a
DataInput. |
static long |
readPrimitiveLong(java.io.DataInput in)
Reads a primitive
long from a
DataInput. |
static short |
readPrimitiveShort(java.io.DataInput in)
Reads a primitive
short from a
DataInput. |
static java.util.Properties |
readProperties(java.io.DataInput in)
Reads a
Properties from a DataInput. |
static <K,V> Region<K,V> |
readRegion(java.io.DataInput in)
Reads an instance of Region.
|
static java.lang.Short |
readShort(java.io.DataInput in)
Reads an instance of
Short from a
DataInput. |
static short[] |
readShortArray(java.io.DataInput in)
Reads an array of
shorts from a
DataInput. |
static <E> java.util.Stack<E> |
readStack(java.io.DataInput in)
Reads an
Stack from a DataInput. |
static java.lang.String |
readString(java.io.DataInput in)
Reads an instance of
String from a
DataInput. |
static java.lang.String[] |
readStringArray(java.io.DataInput in)
Reads an array of
Strings from a
DataInput. |
static <K,V> java.util.TreeMap<K,V> |
readTreeMap(java.io.DataInput in)
Reads a
TreeMap from a DataInput. |
static <E> java.util.TreeSet<E> |
readTreeSet(java.io.DataInput in)
Reads a
TreeSet from a DataInput. |
static int |
readUnsignedByte(java.io.DataInput in)
Reads a primitive
int as an unsigned byte from a
DataInput using DataInput.readUnsignedByte(). |
static int |
readUnsignedShort(java.io.DataInput in)
Reads a primitive
int as an unsigned short from a
DataInput using DataInput.readUnsignedShort(). |
static <E> java.util.Vector<E> |
readVector(java.io.DataInput in)
Reads an
Vector from a DataInput. |
static DataSerializer |
register(java.lang.Class<?> c)
Registers a
DataSerializer class with the data
serialization framework. |
static DataSerializer |
register(java.lang.Class<?> c,
byte b)
Deprecated.
as of 5.7 use
register(Class) instead |
void |
setContext(java.lang.Object context)
For internal use only.
|
void |
setEventId(java.lang.Object eventId)
For internal use only.
|
abstract boolean |
toData(java.lang.Object o,
java.io.DataOutput out)
Data serializes an object to a
DataOutput. |
static void |
writeArrayList(java.util.ArrayList<?> list,
java.io.DataOutput out)
Writes an
ArrayList to a DataOutput. |
static void |
writeArrayOfByteArrays(byte[][] array,
java.io.DataOutput out)
Writes an array of byte[] to a DataOutput.
|
static void |
writeBoolean(java.lang.Boolean value,
java.io.DataOutput out)
Writes an instance of
Boolean to a
DataOutput. |
static void |
writeBooleanArray(boolean[] array,
java.io.DataOutput out)
Writes an array of
booleans to a
DataOutput. |
static void |
writeByte(java.lang.Byte value,
java.io.DataOutput out)
Writes an instance of
Byte to a
DataOutput. |
static void |
writeByteArray(byte[] array,
java.io.DataOutput out)
Writes an array of
bytes to a
DataOutput. |
static void |
writeByteArray(byte[] array,
int len,
java.io.DataOutput out)
Writes the first
len elements
of an array of bytes to a
DataOutput. |
static void |
writeCharacter(java.lang.Character value,
java.io.DataOutput out)
Writes an instance of
Character to a
DataOutput. |
static void |
writeCharArray(char[] array,
java.io.DataOutput out)
Writes an array of
chars to a
DataOutput. |
static void |
writeClass(java.lang.Class<?> c,
java.io.DataOutput out)
Writes an instance of
Class to a
DataOutput. |
static void |
writeConcurrentHashMap(java.util.concurrent.ConcurrentHashMap<?,?> map,
java.io.DataOutput out)
Writes a
ConcurrentHashMap to a DataOutput. |
static void |
writeDate(java.util.Date date,
java.io.DataOutput out)
Writes an instance of
Date to a
DataOutput. |
static void |
writeDouble(java.lang.Double value,
java.io.DataOutput out)
Writes an instance of
Double to a
DataOutput. |
static void |
writeDoubleArray(double[] array,
java.io.DataOutput out)
Writes an array of
doubles to a
DataOutput. |
static void |
writeEnum(java.lang.Enum e,
java.io.DataOutput out)
Writes the
Enum constant to DataOutput. |
static void |
writeFile(java.io.File file,
java.io.DataOutput out)
Writes an instance of
File to a
DataOutput. |
static void |
writeFloat(java.lang.Float value,
java.io.DataOutput out)
Writes an instance of
Float to a
DataOutput. |
static void |
writeFloatArray(float[] array,
java.io.DataOutput out)
Writes an array of
floats to a
DataOutput. |
static void |
writeHashMap(java.util.Map<?,?> map,
java.io.DataOutput out)
Writes a
HashMap to a DataOutput. |
static void |
writeHashSet(java.util.HashSet<?> set,
java.io.DataOutput out)
Writes a
HashSet to a DataOutput. |
static void |
writeHashtable(java.util.Hashtable<?,?> map,
java.io.DataOutput out)
Writes a
Hashtable to a DataOutput. |
static void |
writeIdentityHashMap(java.util.IdentityHashMap<?,?> map,
java.io.DataOutput out)
Writes a
IdentityHashMap to a DataOutput. |
static void |
writeInetAddress(java.net.InetAddress address,
java.io.DataOutput out)
Writes an instance of
InetAddress to a
DataOutput. |
static void |
writeIntArray(int[] array,
java.io.DataOutput out)
Writes an
int array to a DataOutput. |
static void |
writeInteger(java.lang.Integer value,
java.io.DataOutput out)
Writes an instance of
Integer to a
DataOutput. |
static void |
writeLinkedHashSet(java.util.LinkedHashSet<?> set,
java.io.DataOutput out)
Writes a
LinkedHashSet to a DataOutput. |
static void |
writeLinkedList(java.util.LinkedList<?> list,
java.io.DataOutput out)
Writes an
LinkedList to a DataOutput. |
static void |
writeLong(java.lang.Long value,
java.io.DataOutput out)
Writes an instance of
Long to a
DataOutput. |
static void |
writeLongArray(long[] array,
java.io.DataOutput out)
Writes an array of
longs to a
DataOutput. |
static void |
writeNonPrimitiveClassName(java.lang.String className,
java.io.DataOutput out)
Writes class name to a
DataOutput. |
static void |
writeObject(java.lang.Object o,
java.io.DataOutput out)
Writes an arbitrary object to a
DataOutput. |
static void |
writeObject(java.lang.Object o,
java.io.DataOutput out,
boolean allowJavaSerialization)
Writes an arbitrary object to a
DataOutput. |
static void |
writeObjectArray(java.lang.Object[] array,
java.io.DataOutput out)
Writes an array of
Objects to a
DataOutput. |
static void |
writeObjectAsByteArray(java.lang.Object obj,
java.io.DataOutput out)
Serialize the given object
obj into a byte array
using writeObject(Object, DataOutput) and then writes the byte array
to the given data output out in the same format
writeByteArray(byte[], DataOutput) does. |
static void |
writePrimitiveBoolean(boolean value,
java.io.DataOutput out)
Writes a primitive
boolean to a
DataOutput. |
static void |
writePrimitiveByte(byte value,
java.io.DataOutput out)
Writes a primitive
byte to a
DataOutput. |
static void |
writePrimitiveChar(char value,
java.io.DataOutput out)
Writes a primitive
char to a
DataOutput. |
static void |
writePrimitiveDouble(double value,
java.io.DataOutput out)
Writes a primtive
double to a
DataOutput. |
static void |
writePrimitiveFloat(float value,
java.io.DataOutput out)
Writes a primitive
float to a
DataOutput. |
static void |
writePrimitiveInt(int value,
java.io.DataOutput out)
Writes a primitive
int to a
DataOutput. |
static void |
writePrimitiveLong(long value,
java.io.DataOutput out)
Writes a primitive
long to a
DataOutput. |
static void |
writePrimitiveShort(short value,
java.io.DataOutput out)
Writes a primitive
short to a
DataOutput. |
static void |
writeProperties(java.util.Properties props,
java.io.DataOutput out)
Writes a
Properties to a DataOutput. |
static void |
writeRegion(Region<?,?> rgn,
java.io.DataOutput out)
Writes an instance of Region.
|
static void |
writeShort(java.lang.Short value,
java.io.DataOutput out)
Writes an instance of
Short to a
DataOutput. |
static void |
writeShortArray(short[] array,
java.io.DataOutput out)
Writes an array of
shorts to a
DataOutput. |
static void |
writeStack(java.util.Stack<?> list,
java.io.DataOutput out)
Writes an
Stack to a DataOutput. |
static void |
writeString(java.lang.String value,
java.io.DataOutput out)
Writes an instance of
String to a
DataOutput. |
static void |
writeStringArray(java.lang.String[] array,
java.io.DataOutput out)
Writes an array of
Strings to a
DataOutput. |
static void |
writeTreeMap(java.util.TreeMap<?,?> map,
java.io.DataOutput out)
Writes a
TreeMap to a DataOutput. |
static void |
writeTreeSet(java.util.TreeSet<?> set,
java.io.DataOutput out)
Writes a
TreeSet to a DataOutput. |
static void |
writeUnsignedByte(int value,
java.io.DataOutput out)
Writes a primitive
int as an unsigned byte to a
DataOutput. |
static void |
writeUnsignedShort(int value,
java.io.DataOutput out)
Writes a primitive
int as an unsigned short to a
DataOutput. |
static void |
writeVector(java.util.Vector<?> list,
java.io.DataOutput out)
Writes an
Vector to a DataOutput. |
protected static final boolean TRACE_SERIALIZABLE
protected static final java.lang.ThreadLocal<java.lang.Boolean> DISALLOW_JAVA_SERIALIZATION
public DataSerializer()
DataSerializer. All class that
implement DataSerializer must provide a
zero-argument constructor.register(Class)public static void writeClass(java.lang.Class<?> c,
java.io.DataOutput out)
throws java.io.IOException
Class to a
DataOutput.
This method will handle a
null value and not throw a
NullPointerException.java.io.IOException - A problem occurs while writing to outreadClass(java.io.DataInput)public static void writeNonPrimitiveClassName(java.lang.String className,
java.io.DataOutput out)
throws java.io.IOException
DataOutput. This method will handle a
null value and not throw a NullPointerException.java.io.IOException - A problem occurs while writing to outreadNonPrimitiveClassName(DataInput)public static java.lang.Class<?> readClass(java.io.DataInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
Class from a
DataInput. The class will be loaded using the
current content class
loader.
The return value may be null.java.io.IOException - A problem occurs while reading from injava.lang.ClassNotFoundException - The class cannot be loadedpublic static java.lang.String readNonPrimitiveClassName(java.io.DataInput in)
throws java.io.IOException
Class from a
DataInput.
The return value may be null.java.io.IOException - A problem occurs while reading from inwriteNonPrimitiveClassName(String, DataOutput)public static void writeRegion(Region<?,?> rgn, java.io.DataOutput out) throws java.io.IOException
CacheFactory.getAnyInstance() and then calling
getRegion on it.
This method will handle a
null value and not throw a
NullPointerException.java.io.IOExceptionpublic static <K,V> Region<K,V> readRegion(java.io.DataInput in) throws java.io.IOException, java.lang.ClassNotFoundException
CacheFactory.getAnyInstance() and then calling
getRegion on it.
The return value may be null.in - the input streamCacheClosedException - 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 Cachejava.io.IOExceptionjava.lang.ClassNotFoundExceptionpublic static void writeDate(java.util.Date date,
java.io.DataOutput out)
throws java.io.IOException
Date to a
DataOutput. Note that even though date
may be an instance of a subclass of Date,
readDate will always return an instance of
Date, not an instance of the subclass. To
preserve the class type of date,\
writeObject(Object, DataOutput) should be used for data serialization.
This method will handle a
null value and not throw a
NullPointerException.java.io.IOException - A problem occurs while writing to outreadDate(java.io.DataInput)public static java.util.Date readDate(java.io.DataInput in)
throws java.io.IOException
Date from a
DataInput.
The return value may be null.java.io.IOException - A problem occurs while reading from inpublic static void writeFile(java.io.File file,
java.io.DataOutput out)
throws java.io.IOException
File to a
DataOutput. Note that even though file
may be an instance of a subclass of File,
readFile will always return an instance of
File, not an instance of the subclass. To
preserve the class type of file,
writeObject(Object, DataOutput) should be used for data serialization.
This method will handle a
null value and not throw a
NullPointerException.java.io.IOException - A problem occurs while writing to outreadFile(java.io.DataInput),
File.getCanonicalPath()public static java.io.File readFile(java.io.DataInput in)
throws java.io.IOException
File from a
DataInput.
The return value may be null.java.io.IOException - A problem occurs while reading from inpublic static void writeInetAddress(java.net.InetAddress address,
java.io.DataOutput out)
throws java.io.IOException
InetAddress to a
DataOutput. The InetAddress is data
serialized by writing its byte
representation to the DataOutput. readInetAddress(java.io.DataInput) converts the byte representation
to an instance of InetAddress using InetAddress.getAddress(). As a result, if address
is an instance of a user-defined subclass of
InetAddress (that is, not an instance of one of the
subclasses from the java.net package), 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 a
null value and not throw a
NullPointerException.java.io.IOException - A problem occurs while writing to outreadInetAddress(java.io.DataInput)public static java.net.InetAddress readInetAddress(java.io.DataInput in)
throws java.io.IOException
InetAddress from a
DataInput.
The return value may be null.java.io.IOException - A problem occurs while reading from in
or the address read from in is unknownInetAddress.getAddress()public static void writeString(java.lang.String value,
java.io.DataOutput out)
throws java.io.IOException
String to a
DataOutput.
This method will handle a
null value and not throw a
NullPointerException.
As of 5.7 strings longer than 0xFFFF can be serialized.
java.io.IOException - A problem occurs while writing to outreadString(java.io.DataInput)public static java.lang.String readString(java.io.DataInput in)
throws java.io.IOException
String from a
DataInput. The return value may be
null.java.io.IOException - A problem occurs while reading from inwriteString(java.lang.String, java.io.DataOutput)public static void writeBoolean(java.lang.Boolean value,
java.io.DataOutput out)
throws java.io.IOException
Boolean to a
DataOutput.java.io.IOException - A problem occurs while writing to outjava.lang.NullPointerException - if value is null.readBoolean(java.io.DataInput)public static java.lang.Boolean readBoolean(java.io.DataInput in)
throws java.io.IOException
Boolean from a
DataInput.java.io.IOException - A problem occurs while reading from inpublic static void writeCharacter(java.lang.Character value,
java.io.DataOutput out)
throws java.io.IOException
Character to a
DataOutput.java.io.IOException - A problem occurs while writing to outjava.lang.NullPointerException - if value is null.readCharacter(java.io.DataInput)public static java.lang.Character readCharacter(java.io.DataInput in)
throws java.io.IOException
Character from a
DataInput.java.io.IOException - A problem occurs while reading from inpublic static void writeByte(java.lang.Byte value,
java.io.DataOutput out)
throws java.io.IOException
Byte to a
DataOutput.java.io.IOException - A problem occurs while writing to outjava.lang.NullPointerException - if value is null.readByte(java.io.DataInput)public static java.lang.Byte readByte(java.io.DataInput in)
throws java.io.IOException
Byte from a
DataInput.java.io.IOException - A problem occurs while reading from inpublic static void writeShort(java.lang.Short value,
java.io.DataOutput out)
throws java.io.IOException
Short to a
DataOutput.java.io.IOException - A problem occurs while writing to outjava.lang.NullPointerException - if value is null.readShort(java.io.DataInput)public static java.lang.Short readShort(java.io.DataInput in)
throws java.io.IOException
Short from a
DataInput.java.io.IOException - A problem occurs while reading from inpublic static void writeInteger(java.lang.Integer value,
java.io.DataOutput out)
throws java.io.IOException
Integer to a
DataOutput.java.io.IOException - A problem occurs while writing to outjava.lang.NullPointerException - if value is null.readInteger(java.io.DataInput)public static java.lang.Integer readInteger(java.io.DataInput in)
throws java.io.IOException
Integer from a
DataInput.java.io.IOException - A problem occurs while reading from inpublic static void writeLong(java.lang.Long value,
java.io.DataOutput out)
throws java.io.IOException
Long to a
DataOutput.java.io.IOException - A problem occurs while writing to outjava.lang.NullPointerException - if value is null.readLong(java.io.DataInput)public static java.lang.Long readLong(java.io.DataInput in)
throws java.io.IOException
Long from a
DataInput.java.io.IOException - A problem occurs while reading from inpublic static void writeFloat(java.lang.Float value,
java.io.DataOutput out)
throws java.io.IOException
Float to a
DataOutput.java.io.IOException - A problem occurs while writing to outjava.lang.NullPointerException - if value is null.readFloat(java.io.DataInput)public static java.lang.Float readFloat(java.io.DataInput in)
throws java.io.IOException
Float from a
DataInput.java.io.IOException - A problem occurs while reading from inpublic static void writeDouble(java.lang.Double value,
java.io.DataOutput out)
throws java.io.IOException
Double to a
DataOutput.java.io.IOException - A problem occurs while writing to outjava.lang.NullPointerException - if value is null.readDouble(java.io.DataInput)public static java.lang.Double readDouble(java.io.DataInput in)
throws java.io.IOException
Double from a
DataInput.java.io.IOException - A problem occurs while reading from inpublic static void writePrimitiveBoolean(boolean value,
java.io.DataOutput out)
throws java.io.IOException
boolean to a
DataOutput.java.io.IOException - A problem occurs while writing to outDataOutput.writeBoolean(boolean)public static boolean readPrimitiveBoolean(java.io.DataInput in)
throws java.io.IOException
boolean from a
DataInput.java.io.IOException - A problem occurs while reading from inDataInput.readBoolean()public static void writePrimitiveByte(byte value,
java.io.DataOutput out)
throws java.io.IOException
byte to a
DataOutput.java.io.IOException - A problem occurs while writing to outDataOutput.writeByte(int)public static byte readPrimitiveByte(java.io.DataInput in)
throws java.io.IOException
byte from a
DataInput.java.io.IOException - A problem occurs while reading from inDataInput.readByte()public static void writePrimitiveChar(char value,
java.io.DataOutput out)
throws java.io.IOException
char to a
DataOutput.java.io.IOException - A problem occurs while writing to outDataOutput.writeChar(int)public static char readPrimitiveChar(java.io.DataInput in)
throws java.io.IOException
char from a
DataInput.java.io.IOException - A problem occurs while reading from inDataInput.readChar()public static void writePrimitiveShort(short value,
java.io.DataOutput out)
throws java.io.IOException
short to a
DataOutput.java.io.IOException - A problem occurs while writing to outDataOutput.writeShort(int)public static short readPrimitiveShort(java.io.DataInput in)
throws java.io.IOException
short from a
DataInput.java.io.IOException - A problem occurs while reading from inDataInput.readShort()public static void writeUnsignedByte(int value,
java.io.DataOutput out)
throws java.io.IOException
int as an unsigned byte to a
DataOutput.java.io.IOException - A problem occurs while writing to outDataOutput.writeByte(int),
DataInput.readUnsignedByte()public static int readUnsignedByte(java.io.DataInput in)
throws java.io.IOException
int as an unsigned byte from a
DataInput using DataInput.readUnsignedByte().java.io.IOException - A problem occurs while reading from inpublic static void writeUnsignedShort(int value,
java.io.DataOutput out)
throws java.io.IOException
int as an unsigned short to a
DataOutput.java.io.IOException - A problem occurs while writing to outDataOutput.writeShort(int),
DataInput.readUnsignedShort()public static int readUnsignedShort(java.io.DataInput in)
throws java.io.IOException
int as an unsigned short from a
DataInput using DataInput.readUnsignedShort().java.io.IOException - A problem occurs while reading from inpublic static void writePrimitiveInt(int value,
java.io.DataOutput out)
throws java.io.IOException
int to a
DataOutput.java.io.IOException - A problem occurs while writing to outDataOutput.writeInt(int)public static int readPrimitiveInt(java.io.DataInput in)
throws java.io.IOException
int from a
DataInput.java.io.IOException - A problem occurs while reading from inDataInput.readInt()public static void writePrimitiveLong(long value,
java.io.DataOutput out)
throws java.io.IOException
long to a
DataOutput.java.io.IOException - A problem occurs while writing to outDataOutput.writeLong(long)public static long readPrimitiveLong(java.io.DataInput in)
throws java.io.IOException
long from a
DataInput.java.io.IOException - A problem occurs while reading from inDataInput.readLong()public static void writePrimitiveFloat(float value,
java.io.DataOutput out)
throws java.io.IOException
float to a
DataOutput.java.io.IOException - A problem occurs while writing to outDataOutput.writeFloat(float)public static float readPrimitiveFloat(java.io.DataInput in)
throws java.io.IOException
float from a
DataInput.java.io.IOException - A problem occurs while reading from inDataInput.readFloat()public static void writePrimitiveDouble(double value,
java.io.DataOutput out)
throws java.io.IOException
double to a
DataOutput.java.io.IOException - A problem occurs while writing to outDataOutput.writeDouble(double)public static double readPrimitiveDouble(java.io.DataInput in)
throws java.io.IOException
double from a
DataInput.java.io.IOException - A problem occurs while reading from inDataInput.readDouble()public static void writeByteArray(byte[] array,
java.io.DataOutput out)
throws java.io.IOException
bytes to a
DataOutput.
This method will serialize a
null array and not throw a
NullPointerException.java.io.IOException - A problem occurs while writing to outreadByteArray(java.io.DataInput)public static void writeByteArray(byte[] array,
int len,
java.io.DataOutput out)
throws java.io.IOException
len elements
of an array of bytes to a
DataOutput.
This method will serialize a
null array and not throw a
NullPointerException.len - the actual number of entries to write. If len is greater
than then length of the array then the entire array is written.java.io.IOException - A problem occurs while writing to outreadByteArray(java.io.DataInput)public static void writeObjectAsByteArray(java.lang.Object obj,
java.io.DataOutput out)
throws java.io.IOException
obj into a byte array
using writeObject(Object, DataOutput) and then writes the byte array
to the given data output out in the same format
writeByteArray(byte[], DataOutput) does.
This method will serialize a
null obj and not throw a
NullPointerException.obj - the object to serialize and writeout - the data output to write the byte array tojava.lang.IllegalArgumentException - if a problem occurs while serialize objjava.io.IOException - if a problem occurs while writing to outreadByteArray(java.io.DataInput)public static byte[] readByteArray(java.io.DataInput in)
throws java.io.IOException
bytes from a
DataInput.java.io.IOException - A problem occurs while reading from inwriteByteArray(byte[], DataOutput)public static void writeStringArray(java.lang.String[] array,
java.io.DataOutput out)
throws java.io.IOException
Strings to a
DataOutput.
This method will serialize a
null array and not throw a
NullPointerException.java.io.IOException - A problem occurs while writing to outreadStringArray(java.io.DataInput),
writeString(java.lang.String, java.io.DataOutput)public static java.lang.String[] readStringArray(java.io.DataInput in)
throws java.io.IOException
Strings from a
DataInput.java.io.IOException - A problem occurs while reading from inwriteStringArray(java.lang.String[], java.io.DataOutput)public static void writeShortArray(short[] array,
java.io.DataOutput out)
throws java.io.IOException
shorts to a
DataOutput.
This method will serialize a
null array and not throw a
NullPointerException.java.io.IOException - A problem occurs while writing to outreadShortArray(java.io.DataInput)public static short[] readShortArray(java.io.DataInput in)
throws java.io.IOException
shorts from a
DataInput.java.io.IOException - A problem occurs while reading from inwriteShortArray(short[], java.io.DataOutput)public static void writeCharArray(char[] array,
java.io.DataOutput out)
throws java.io.IOException
chars to a
DataOutput.java.io.IOException - A problem occurs while writing to outreadCharArray(java.io.DataInput)public static char[] readCharArray(java.io.DataInput in)
throws java.io.IOException
chars from a
DataInput.java.io.IOException - A problem occurs while reading from inwriteCharArray(char[], java.io.DataOutput)public static void writeBooleanArray(boolean[] array,
java.io.DataOutput out)
throws java.io.IOException
booleans to a
DataOutput.java.io.IOException - A problem occurs while writing to outreadBooleanArray(java.io.DataInput)public static boolean[] readBooleanArray(java.io.DataInput in)
throws java.io.IOException
booleans from a
DataInput.java.io.IOException - A problem occurs while reading from inwriteBooleanArray(boolean[], java.io.DataOutput)public static void writeIntArray(int[] array,
java.io.DataOutput out)
throws java.io.IOException
int array to a DataOutput.
This method will serialize a
null array and not throw a
NullPointerException.java.io.IOException - A problem occurs while writing to outreadIntArray(java.io.DataInput)public static int[] readIntArray(java.io.DataInput in)
throws java.io.IOException
int array from a DataInput.java.io.IOException - A problem occurs while reading from inwriteIntArray(int[], java.io.DataOutput)public static void writeLongArray(long[] array,
java.io.DataOutput out)
throws java.io.IOException
longs to a
DataOutput.
This method will serialize a
null array and not throw a
NullPointerException.java.io.IOException - A problem occurs while writing to outreadLongArray(java.io.DataInput)public static long[] readLongArray(java.io.DataInput in)
throws java.io.IOException
longs from a
DataInput.java.io.IOException - A problem occurs while reading from inwriteLongArray(long[], java.io.DataOutput)public static void writeFloatArray(float[] array,
java.io.DataOutput out)
throws java.io.IOException
floats to a
DataOutput.
This method will serialize a
null array and not throw a
NullPointerException.java.io.IOException - A problem occurs while writing to outreadFloatArray(java.io.DataInput)public static float[] readFloatArray(java.io.DataInput in)
throws java.io.IOException
floats from a
DataInput.java.io.IOException - A problem occurs while reading from inwriteFloatArray(float[], java.io.DataOutput)public static void writeDoubleArray(double[] array,
java.io.DataOutput out)
throws java.io.IOException
doubles to a
DataOutput.
This method will serialize a
null array and not throw a
NullPointerException.java.io.IOException - A problem occurs while writing to outreadDoubleArray(java.io.DataInput)public static double[] readDoubleArray(java.io.DataInput in)
throws java.io.IOException
doubles from a
DataInput.java.io.IOException - A problem occurs while reading from inwriteDoubleArray(double[], java.io.DataOutput)public static void writeObjectArray(java.lang.Object[] array,
java.io.DataOutput out)
throws java.io.IOException
Objects to a
DataOutput.
This method will serialize a
null array and not throw a
NullPointerException.java.io.IOException - A problem occurs while writing to outreadObjectArray(java.io.DataInput),
writeObject(Object, DataOutput)public static java.lang.Object[] readObjectArray(java.io.DataInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
Objects from a
DataInput.java.io.IOException - A problem occurs while reading from injava.lang.ClassNotFoundExceptionwriteObjectArray(java.lang.Object[], java.io.DataOutput),
readObject(java.io.DataInput)public static void writeArrayOfByteArrays(byte[][] array,
java.io.DataOutput out)
throws java.io.IOException
java.io.IOException - A problem occurs while writing to out.public static byte[][] readArrayOfByteArrays(java.io.DataInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
byte[]s from a
DataInput.java.io.IOException - A problem occurs while reading from injava.lang.ClassNotFoundExceptionpublic static void writeArrayList(java.util.ArrayList<?> list,
java.io.DataOutput out)
throws java.io.IOException
ArrayList to a DataOutput.
Note that even though list may be an instance of a
subclass of ArrayList, readArrayList
will always return an instance of ArrayList,
not an instance of the subclass. To preserve the class
type of list, writeObject(Object, DataOutput) should be used
for data serialization.
This method will serialize a
null list and not throw a
NullPointerException.java.io.IOException - A problem occurs while writing to outreadArrayList(java.io.DataInput)public static <E> java.util.ArrayList<E> readArrayList(java.io.DataInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
ArrayList from a DataInput.java.io.IOException - A problem occurs while reading from injava.lang.ClassNotFoundException - The class of one of the ArrayList's
elements cannot be found.writeArrayList(java.util.ArrayList<?>, java.io.DataOutput)public static void writeVector(java.util.Vector<?> list,
java.io.DataOutput out)
throws java.io.IOException
Vector to a DataOutput.
Note that even though list may be an instance of a
subclass of Vector, readVector
will always return an instance of Vector,
not an instance of the subclass. To preserve the class
type of list, writeObject(Object, DataOutput) should be used
for data serialization.java.io.IOException - A problem occurs while writing to outreadVector(java.io.DataInput)public static <E> java.util.Vector<E> readVector(java.io.DataInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
Vector from a DataInput.java.io.IOException - A problem occurs while reading from injava.lang.ClassNotFoundException - The class of one of the Vector's
elements cannot be found.writeVector(java.util.Vector<?>, java.io.DataOutput)public static void writeStack(java.util.Stack<?> list,
java.io.DataOutput out)
throws java.io.IOException
Stack to a DataOutput.
Note that even though list may be an instance of a
subclass of Stack, readStack
will always return an instance of Stack,
not an instance of the subclass. To preserve the class
type of list, writeObject(Object, DataOutput) should be used
for data serialization.java.io.IOException - A problem occurs while writing to outreadStack(java.io.DataInput)public static <E> java.util.Stack<E> readStack(java.io.DataInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
Stack from a DataInput.java.io.IOException - A problem occurs while reading from injava.lang.ClassNotFoundException - The class of one of the Stack's
elements cannot be found.writeStack(java.util.Stack<?>, java.io.DataOutput)public static void writeLinkedList(java.util.LinkedList<?> list,
java.io.DataOutput out)
throws java.io.IOException
LinkedList to a DataOutput.
Note that even though list may be an instance of a
subclass of LinkedList, readLinkedList
will always return an instance of LinkedList,
not an instance of the subclass. To preserve the class
type of list, writeObject(Object, DataOutput) should be used
for data serialization.
This method will serialize a
null list and not throw a
NullPointerException.java.io.IOException - A problem occurs while writing to outreadLinkedList(java.io.DataInput)public static <E> java.util.LinkedList<E> readLinkedList(java.io.DataInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
LinkedList from a DataInput.java.io.IOException - A problem occurs while reading from injava.lang.ClassNotFoundException - The class of one of the LinkedList's
elements cannot be found.writeLinkedList(java.util.LinkedList<?>, java.io.DataOutput)public static void writeHashSet(java.util.HashSet<?> set,
java.io.DataOutput out)
throws java.io.IOException
HashSet to a DataOutput. Note
that even though set may be an instance of a
subclass of HashSet, readHashSet will
always return an instance of HashSet, not an
instance of the subclass. To preserve the class type of
set, writeObject(Object, DataOutput) should be used for data
serialization.
This method will serialize a
null set and not throw a
NullPointerException.java.io.IOException - A problem occurs while writing to outreadHashSet(java.io.DataInput)public static <E> java.util.HashSet<E> readHashSet(java.io.DataInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
HashSet from a DataInput.java.io.IOException - A problem occurs while reading from injava.lang.ClassNotFoundException - The class of one of the HashSet's
elements cannot be found.writeHashSet(java.util.HashSet<?>, java.io.DataOutput)public static void writeLinkedHashSet(java.util.LinkedHashSet<?> set,
java.io.DataOutput out)
throws java.io.IOException
LinkedHashSet to a DataOutput. Note
that even though set may be an instance of a
subclass of LinkedHashSet, readLinkedHashSet will
always return an instance of LinkedHashSet, not an
instance of the subclass. To preserve the class type of
set, writeObject(Object, DataOutput) should be used for data
serialization.java.io.IOException - A problem occurs while writing to outreadLinkedHashSet(java.io.DataInput)public static <E> java.util.LinkedHashSet<E> readLinkedHashSet(java.io.DataInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
LinkedHashSet from a DataInput.java.io.IOException - A problem occurs while reading from injava.lang.ClassNotFoundException - The class of one of the LinkedHashSet's
elements cannot be found.writeLinkedHashSet(java.util.LinkedHashSet<?>, java.io.DataOutput)public static void writeHashMap(java.util.Map<?,?> map,
java.io.DataOutput out)
throws java.io.IOException
HashMap to a DataOutput. Note
that even though map may be an instance of a
subclass of HashMap, readHashMap will
always return an instance of HashMap, not an
instance of the subclass. To preserve the class type of
map, writeObject(Object, DataOutput) should be used for data
serialization.
This method will serialize a
null map and not throw a
NullPointerException.java.io.IOException - A problem occurs while writing to outreadHashMap(java.io.DataInput)public static <K,V> java.util.HashMap<K,V> readHashMap(java.io.DataInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
HashMap from a DataInput.java.io.IOException - A problem occurs while reading from injava.lang.ClassNotFoundException - The class of one of the HashMap's
elements cannot be found.writeHashMap(java.util.Map<?, ?>, java.io.DataOutput)public static void writeIdentityHashMap(java.util.IdentityHashMap<?,?> map,
java.io.DataOutput out)
throws java.io.IOException
IdentityHashMap to a DataOutput. Note
that even though map may be an instance of a
subclass of IdentityHashMap, readIdentityHashMap will
always return an instance of IdentityHashMap, not an
instance of the subclass. To preserve the class type of
map, writeObject(Object, DataOutput) should be used for data
serialization.java.io.IOException - A problem occurs while writing to outreadIdentityHashMap(java.io.DataInput)public static <K,V> java.util.IdentityHashMap<K,V> readIdentityHashMap(java.io.DataInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
IdentityHashMap from a DataInput.
Note that key identity is not preserved unless the keys belong to a class
whose serialization preserves identity.java.io.IOException - A problem occurs while reading from injava.lang.ClassNotFoundException - The class of one of the IdentityHashMap's
elements cannot be found.writeIdentityHashMap(java.util.IdentityHashMap<?, ?>, java.io.DataOutput)public static void writeConcurrentHashMap(java.util.concurrent.ConcurrentHashMap<?,?> map,
java.io.DataOutput out)
throws java.io.IOException
ConcurrentHashMap to a DataOutput. Note
that even though map may be an instance of a
subclass of ConcurrentHashMap, readConcurrentHashMap will
always return an instance of ConcurrentHashMap, not an
instance of the subclass. To preserve the class type of
map, 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.
java.io.IOException - A problem occurs while writing to outreadConcurrentHashMap(java.io.DataInput)public static <K,V> java.util.concurrent.ConcurrentHashMap<K,V> readConcurrentHashMap(java.io.DataInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
ConcurrentHashMap from a DataInput.java.io.IOException - A problem occurs while reading from injava.lang.ClassNotFoundException - The class of one of the ConcurrentHashMap's
elements cannot be found.writeConcurrentHashMap(java.util.concurrent.ConcurrentHashMap<?, ?>, java.io.DataOutput)public static void writeHashtable(java.util.Hashtable<?,?> map,
java.io.DataOutput out)
throws java.io.IOException
Hashtable to a DataOutput. Note
that even though map may be an instance of a
subclass of Hashtable, readHashtable will
always return an instance of Hashtable, not an
instance of the subclass. To preserve the class type of
map, writeObject(Object, DataOutput) should be used for data
serialization.java.io.IOException - A problem occurs while writing to outreadHashtable(java.io.DataInput)public static <K,V> java.util.Hashtable<K,V> readHashtable(java.io.DataInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
Hashtable from a DataInput.java.io.IOException - A problem occurs while reading from injava.lang.ClassNotFoundException - The class of one of the Hashtable's
elements cannot be found.writeHashtable(java.util.Hashtable<?, ?>, java.io.DataOutput)public static void writeTreeMap(java.util.TreeMap<?,?> map,
java.io.DataOutput out)
throws java.io.IOException
TreeMap to a DataOutput. Note
that even though map may be an instance of a
subclass of TreeMap, readTreeMap will
always return an instance of TreeMap, not an
instance of the subclass. To preserve the class type of
map, writeObject(Object, DataOutput) should be used for data
serialization.
If the map has a comparator then it must also be serializable.
java.io.IOException - A problem occurs while writing to outreadTreeMap(java.io.DataInput)public static <K,V> java.util.TreeMap<K,V> readTreeMap(java.io.DataInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
TreeMap from a DataInput.java.io.IOException - A problem occurs while reading from injava.lang.ClassNotFoundException - The class of one of the TreeMap's
elements cannot be found.writeTreeMap(java.util.TreeMap<?, ?>, java.io.DataOutput)public static void writeTreeSet(java.util.TreeSet<?> set,
java.io.DataOutput out)
throws java.io.IOException
TreeSet to a DataOutput. Note
that even though set may be an instance of a
subclass of TreeSet, readTreeSet will
always return an instance of TreeSet, not an
instance of the subclass. To preserve the class type of
set, writeObject(Object, DataOutput) should be used for data
serialization.
If the set has a comparator then it must also be serializable.
java.io.IOException - A problem occurs while writing to outreadTreeSet(java.io.DataInput)public static <E> java.util.TreeSet<E> readTreeSet(java.io.DataInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
TreeSet from a DataInput.java.io.IOException - A problem occurs while reading from injava.lang.ClassNotFoundException - The class of one of the TreeSet's
elements cannot be found.writeTreeSet(java.util.TreeSet<?>, java.io.DataOutput)public static void writeProperties(java.util.Properties props,
java.io.DataOutput out)
throws java.io.IOException
Properties to a DataOutput.
NOTE: The defaults of the specified props
are not serialized.
Note that even though props may be an instance of a
subclass of Properties, readProperties will
always return an instance of Properties, not an
instance of the subclass. To preserve the class type of
props, writeObject(Object, DataOutput) should be used for data
serialization.
java.io.IOException - A problem occurs while writing to outreadProperties(java.io.DataInput)public static java.util.Properties readProperties(java.io.DataInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
Properties from a DataInput.
NOTE: the defaults are always empty in the returned Properties.
java.io.IOException - A problem occurs while reading from injava.lang.ClassNotFoundExceptionwriteProperties(java.util.Properties, java.io.DataOutput)public static final void writeObject(java.lang.Object o,
java.io.DataOutput out,
boolean allowJavaSerialization)
throws java.io.IOException
DataOutput. If
o is not an instance of a specially-handled
standard Java class (see the list in getSupportedClasses()),
the toData method of each
registered DataSerializer is invoked until the object
is serialized. If no registered serializer can serialize the
object and o does not implement
DataSerializable, then it is serialized to
out using standard Java serialization.
This method will serialize a
null o and not throw a
NullPointerException.allowJavaSerialization - If false, then a NotSerializableException is thrown
in the case where standard Java serialization would
otherwise be used for object o or for any nested
subobject of o. This is used to prevent
Java serialization from being used when sending data
to a non-Java clientjava.io.IOException - A problem occurs while writing o to
outreadObject(DataInput),
Instantiator,
ObjectOutputStream.writeObject(java.lang.Object)public static final void writeObject(java.lang.Object o,
java.io.DataOutput out)
throws java.io.IOException
DataOutput. If
o is not an instance of a specially-handled
standard Java class (such as Date,
Integer, or ArrayList), the toData method of each
registered DataSerializer is invoked until the object
is serialized. If no registered serializer can serialize the
object and o does not implement
DataSerializable, then it is serialized to
out using standard Java serialization.
This method will serialize a
null o and not throw a
NullPointerException.java.io.IOException - A problem occurs while writing o to
outreadObject(DataInput),
DataSerializer,
ObjectOutputStream.writeObject(java.lang.Object)public static final <T> T readObject(java.io.DataInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
DataInput.
Instances of classes that are not handled specially (such as
String, Class, and
DataSerializable) 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
loader before the one normally used by Java serialization is
consulted.
java.io.IOException - A problem occured while reading from in
(may wrap another exception)java.lang.ClassNotFoundException - The class of an object read from in could
not be foundwriteObject(Object, DataOutput),
ObjectInputStream.readObject()public static final DataSerializer register(java.lang.Class<?> c)
DataSerializer class with the data
serialization framework. This method uses reflection to create
an instance of the DataSerializer class by invoking
its zero-argument constructor.
The DataSerializer instance will be consulted by the
writeObject(Object, DataOutput) and readObject(java.io.DataInput) methods.
Note that no two serializers can support the same class.
This method invokes the DataSerializer instance's
getSupportedClasses() method and keeps track of which
classes can have their instances serialized by by this data serializer.
c - the DataSerializer class to create and
register with the data serialization framework.java.lang.IllegalArgumentException - If c does not subclass
DataSerializer, if c does not
have a zero-argument constructor,
if id is 0,
if getSupportedClasses returns null or an empty array,
if getSupportedClasses returns and array with null elementsjava.lang.IllegalStateException - if another serializer
instance with id id has 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
(see getSupportedClasses() for a list).getSupportedClasses()@Deprecated public static final DataSerializer register(java.lang.Class<?> c, byte b)
register(Class) insteadpublic abstract java.lang.Class<?>[] getSupportedClasses()
Classes whose instances are data
serialized by this DataSerializer. This method is
invoked when this serializer is registered. This method is not allowed to return null
nor an empty array.
Only instances whose class name is the same as one of the class names
in the result will be serialized by this DataSerializer.
Two DataSerializers 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:
Class
String
Boolean
Byte
Character
Short
Integer
Long
Float
Double
File
InetAddress
Inet4Address
Inet6Address
ArrayList
Date
HashMap
IdentityHashMap
HashSet
Hashtable
LinkedHashSet
LinkedList
Properties
TreeMap
TreeSet
Vector
any array class
public abstract boolean toData(java.lang.Object o,
java.io.DataOutput out)
throws java.io.IOException
DataOutput. It is
very important that when performing the "switch" on
o'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.o - The object to data serialize. It will never be
null.false if this DataSerializer does
not know how to data serialize o.java.io.IOExceptionpublic abstract java.lang.Object fromData(java.io.DataInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
DataInput.
This implementation must support deserializing everything serialized by
the matching toData(java.lang.Object, java.io.DataOutput).java.io.IOException - If this serializer cannot read an object from
in.java.lang.ClassNotFoundExceptiontoData(java.lang.Object, java.io.DataOutput)public abstract int getId()
DataSerializer.
Returns an int instead of a byte since 5.7.
public boolean equals(java.lang.Object o)
DataSerializers are consider to be equal if they
have the same id and the same classequals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic final void setEventId(java.lang.Object eventId)
eventId of this
DataSerializer.public final java.lang.Object getEventId()
eventId of this
DataSerializer.public final void setContext(java.lang.Object context)
DataSerializer.public final java.lang.Object getContext()
DataSerializer.public static void writeEnum(java.lang.Enum e,
java.io.DataOutput out)
throws java.io.IOException
Enum constant to DataOutput. 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.DataSerializer.writeEnum(DAY_OF_WEEK.SUN, out);java.io.IOExceptionreadEnum(Class, DataInput)public static <E extends java.lang.Enum<E>> E readEnum(java.lang.Class<E> clazz,
java.io.DataInput in)
throws java.io.IOException
Enum constant from DataInput. 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.DAY_OF_WEEK d = DataSerializer.readEnum(DAY_OF_WEEK.class, in);java.io.IOException - A problem occurs while writing to outjava.lang.ArrayIndexOutOfBoundsException - if the wrong enum class/enum class with a different version and
less enum constants is usedwriteEnum(Enum, DataOutput)