|
GemFire 5.5 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.gemstone.gemfire.DataSerializer
public abstract class DataSerializer
Provides static helper methods for reading and writing
non-primitive data when working with a 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, (byte) 42);
}
/**
May be invoked reflectively if instances of Company are
distributed to other VMs.
/
public CompanySerializer() {
}
public Class[] getSupportedClasses() {
return new Class[] { Company.class };
}
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)| Field Summary | |
|---|---|
static boolean |
DUMP_SERIALIZED
If the "DataSerializer.DUMP_SERIALIZED" system
property is set, the class names of the objects that are
serialized by writeObject(Object, DataOutput) using standard Java
serialization are logged to standard out. |
static byte |
NULL
A header byte meaning that the next element in the stream is a null |
| Constructor Summary | |
|---|---|
DataSerializer()
Creates a new DataSerializer. |
|
| Method Summary | |
|---|---|
boolean |
equals(Object o)
Two DataSerializers are consider to be equal if they
have the same id. |
abstract Object |
fromData(DataInput in)
Reads an object from a DataInput. |
byte |
getId()
Returns the id of this DataSerializer. |
abstract Class[] |
getSupportedClasses()
Returns the Classes whose instances are data
serialized by this DataSerializer. |
static ArrayList |
readArrayList(DataInput in)
Reads an ArrayList from a DataInput. |
static Boolean |
readBoolean(DataInput in)
Reads an instance of Boolean from a
DataInput. |
static Byte |
readByte(DataInput in)
Reads an instance of Byte from a
DataInput. |
static byte[] |
readByteArray(DataInput in)
Reads an array of bytes from a
DataInput. |
static Character |
readCharacter(DataInput in)
Reads an instance of Character from a
DataInput. |
static Class |
readClass(DataInput in)
Reads an instance of Class from a
DataInput. |
static Date |
readDate(DataInput in)
Reads an instance of Date from a
DataInput. |
static Double |
readDouble(DataInput in)
Reads an instance of Double from a
DataInput. |
static double[] |
readDoubleArray(DataInput in)
Reads an array of doubles from a
DataInput. |
static File |
readFile(DataInput in)
Reads an instance of File from a
DataInput. |
static Float |
readFloat(DataInput in)
Reads an instance of Float from a
DataInput. |
static float[] |
readFloatArray(DataInput in)
Reads an array of floats from a
DataInput. |
static HashMap |
readHashMap(DataInput in)
Reads a HashMap from a DataInput. |
static HashSet |
readHashSet(DataInput in)
Reads a HashSet from a DataInput. |
static InetAddress |
readInetAddress(DataInput in)
Reads an instance of InetAddress from a
DataInput. |
static int[] |
readIntArray(DataInput in)
Reads an int array from a DataInput. |
static Integer |
readInteger(DataInput in)
Reads an instance of Integer from a
DataInput. |
static LinkedList |
readLinkedList(DataInput in)
Reads an LinkedList from a DataInput. |
static Long |
readLong(DataInput in)
Reads an instance of Long from a
DataInput. |
static long[] |
readLongArray(DataInput in)
Reads an array of longs from a
DataInput. |
static Object |
readObject(DataInput in)
Reads an arbitrary object from a DataInput. |
static Object[] |
readObjectArray(DataInput in)
Reads an array of Objects from a
DataInput. |
static boolean |
readPrimitiveBoolean(DataInput in)
Reads a primitive boolean from a
DataInput. |
static byte |
readPrimitiveByte(DataInput in)
Reads a primitive byte from a
DataInput. |
static char |
readPrimitiveChar(DataInput in)
Reads a primitive char from a
DataInput. |
static double |
readPrimitiveDouble(DataInput in)
Reads a primitive double from a
DataInput. |
static float |
readPrimitiveFloat(DataInput in)
Reads a primitive float from a
DataInput. |
static int |
readPrimitiveInt(DataInput in)
Reads a primitive int from a
DataInput. |
static long |
readPrimitiveLong(DataInput in)
Reads a primitive long from a
DataInput. |
static short |
readPrimitiveShort(DataInput in)
Reads a primitive short from a
DataInput. |
static Properties |
readProperties(DataInput in)
Reads a serialized Properties object from a
DataInput. |
static Region |
readRegion(DataInput in)
Reads an instance of Region. |
static Short |
readShort(DataInput in)
Reads an instance of Short from a
DataInput. |
static short[] |
readShortArray(DataInput in)
Reads an array of shorts from a
DataInput. |
static String |
readString(DataInput in)
Reads an instance of String from a
DataInput. |
static String[] |
readStringArray(DataInput in)
Reads an array of Strings from a
DataInput. |
static com.gemstone.bp.edu.emory.mathcs.backport.java.util.concurrent.TimeUnit |
readTimeUnit(DataInput in)
Reads a TimeUnit from a DataInput. |
static int |
readUnsignedByte(DataInput in)
Reads a primitive int as an unsigned byte from a
DataInput using DataInput.readUnsignedByte(). |
static int |
readUnsignedShort(DataInput in)
Reads a primitive int as an unsigned short from a
DataInput using DataInput.readUnsignedShort(). |
static DataSerializer |
register(Class c,
byte id)
Registers a DataSerializer class with the data
serialization framework. |
abstract boolean |
toData(Object o,
DataOutput out)
Data serializes an object to a DataOutput. |
static void |
writeArrayList(ArrayList list,
DataOutput out)
Writes an ArrayList to a DataOutput. |
static void |
writeBoolean(Boolean value,
DataOutput out)
Writes an instance of Boolean to a
DataOutput. |
static void |
writeByte(Byte value,
DataOutput out)
Writes an instance of Byte to a
DataOutput. |
static void |
writeByteArray(byte[] array,
DataOutput out)
Writes an array of bytes to a
DataOutput. |
static void |
writeByteArray(byte[] array,
int len,
DataOutput out)
Writes the first len elements
of an array of bytes to a
DataOutput. |
static void |
writeCharacter(Character value,
DataOutput out)
Writes an instance of Character to a
DataOutput. |
static void |
writeClass(Class c,
DataOutput out)
Writes an instance of Class to a
DataOutput. |
static void |
writeDate(Date date,
DataOutput out)
Writes an instance of Date to a
DataOutput. |
static void |
writeDouble(Double value,
DataOutput out)
Writes an instance of Double to a
DataOutput. |
static void |
writeDoubleArray(double[] array,
DataOutput out)
Writes an array of doubles to a
DataOutput. |
static void |
writeFile(File file,
DataOutput out)
Writes an instance of File to a
DataOutput. |
static void |
writeFloat(Float value,
DataOutput out)
Writes an instance of Float to a
DataOutput. |
static void |
writeFloatArray(float[] array,
DataOutput out)
Writes an array of floats to a
DataOutput. |
static void |
writeHashMap(HashMap map,
DataOutput out)
Writes a HashMap to a DataOutput. |
static void |
writeHashSet(HashSet set,
DataOutput out)
Writes a HashSet to a DataOutput. |
static void |
writeInetAddress(InetAddress address,
DataOutput out)
Writes an instance of InetAddress to a
DataOutput. |
static void |
writeIntArray(int[] array,
DataOutput out)
Writes an int array to a DataOutput. |
static void |
writeInteger(Integer value,
DataOutput out)
Writes an instance of Integer to a
DataOutput. |
static void |
writeLinkedList(LinkedList list,
DataOutput out)
Writes an LinkedList to a DataOutput. |
static void |
writeLong(Long value,
DataOutput out)
Writes an instance of Long to a
DataOutput. |
static void |
writeLongArray(long[] array,
DataOutput out)
Writes an array of longs to a
DataOutput. |
static void |
writeObject(Object o,
DataOutput out)
Writes an arbitrary object to a DataOutput. |
static void |
writeObject(Object o,
DataOutput out,
boolean allowJavaSerialization)
Writes an arbitrary object to a DataOutput. |
static void |
writeObjectArray(Object[] array,
DataOutput out)
Writes an array of Objects to a
DataOutput. |
static void |
writeObjectAsByteArray(Object obj,
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,
DataOutput out)
Writes a primitive boolean to a
DataOutput. |
static void |
writePrimitiveByte(byte value,
DataOutput out)
Writes a primitive byte to a
DataOutput. |
static void |
writePrimitiveChar(char value,
DataOutput out)
Writes a primitive char to a
DataOutput. |
static void |
writePrimitiveDouble(double value,
DataOutput out)
Writes a primtive double to a
DataOutput. |
static void |
writePrimitiveFloat(float value,
DataOutput out)
Writes a primitive float to a
DataOutput. |
static void |
writePrimitiveInt(int value,
DataOutput out)
Writes a primitive int to a
DataOutput. |
static void |
writePrimitiveLong(long value,
DataOutput out)
Writes a primitive long to a
DataOutput. |
static void |
writePrimitiveShort(short value,
DataOutput out)
Writes a primitive short to a
DataOutput. |
static void |
writeProperties(Properties props,
DataOutput out)
Writes a Properties object to a DataOutput. |
static void |
writeRegion(Region rgn,
DataOutput out)
Writes an instance of Region. |
static void |
writeShort(Short value,
DataOutput out)
Writes an instance of Short to a
DataOutput. |
static void |
writeShortArray(short[] array,
DataOutput out)
Writes an array of shorts to a
DataOutput. |
static void |
writeString(String value,
DataOutput out)
Writes an instance of String to a
DataOutput. |
static void |
writeStringArray(String[] array,
DataOutput out)
Writes an array of Strings to a
DataOutput. |
static void |
writeTimeUnit(com.gemstone.bp.edu.emory.mathcs.backport.java.util.concurrent.TimeUnit unit,
DataOutput out)
Writes a TimeUnit to a DataOutput. |
static void |
writeUnsignedByte(int value,
DataOutput out)
Writes a primitive int as an unsigned byte to a
DataOutput. |
static void |
writeUnsignedShort(int value,
DataOutput out)
Writes a primitive int as an unsigned short to a
DataOutput. |
static void |
writeUserDataSerializableHeader(byte classId,
DataOutput out)
|
| Methods inherited from class java.lang.Object |
|---|
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final boolean DUMP_SERIALIZED
"DataSerializer.DUMP_SERIALIZED" system
property is set, the class names of the objects that are
serialized by writeObject(Object, DataOutput) using standard Java
serialization are logged to standard out.
This aids in determining which classes should implement DataSerializable (or should be special cased by a custom
DataSerializer).
public static final byte NULL
null
| Constructor Detail |
|---|
public DataSerializer()
DataSerializer. All class that
implement DataSerializer must provide a
zero-argument constructor.
register(Class, byte)| Method Detail |
|---|
public static void writeClass(Class c,
DataOutput out)
throws IOException
Class to a
DataOutput.
IOException - A problem occurs while writing to outreadClass(java.io.DataInput)
public static Class readClass(DataInput in)
throws IOException,
ClassNotFoundException
Class from a
DataInput. The class will be loaded using the
current content class
loader.
IOException - A problem occurs while reading from in
ClassNotFoundException - The class cannot be loaded
public static void writeRegion(Region rgn,
DataOutput out)
throws IOException
CacheFactory.getAnyInstance() and then calling
getRegion on it.
IOException
public static Region readRegion(DataInput in)
throws IOException,
ClassNotFoundException
CacheFactory.getAnyInstance() and then calling
getRegion on it.
in - the input stream
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 Cache
IOException
ClassNotFoundException
public static void writeDate(Date date,
DataOutput out)
throws 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.
IOException - A problem occurs while writing to outreadDate(java.io.DataInput)
public static Date readDate(DataInput in)
throws IOException
Date from a
DataInput.
IOException - A problem occurs while reading from in
public static void writeFile(File file,
DataOutput out)
throws 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.
IOException - A problem occurs while writing to outreadFile(java.io.DataInput),
File.getCanonicalPath()
public static File readFile(DataInput in)
throws IOException
File from a
DataInput.
IOException - A problem occurs while reading from in
public static void writeInetAddress(InetAddress address,
DataOutput out)
throws 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.
IOException - A problem occurs while writing to outreadInetAddress(java.io.DataInput)
public static InetAddress readInetAddress(DataInput in)
throws IOException
InetAddress from a
DataInput.
IOException - A problem occurs while reading from in
or the address read from in is unknownInetAddress.getAddress()
public static void writeString(String value,
DataOutput out)
throws IOException
String to a
DataOutput. This method will handle a
null value and not throw a
NullPointerException like DataOutput.writeUTF(java.lang.String), DataOutput.writeChars(java.lang.String), and DataOutput.writeBytes(java.lang.String) do.
IOException - A problem occurs while writing to outreadString(java.io.DataInput)
public static String readString(DataInput in)
throws IOException
String from a
DataInput. The return value may be
null.
IOException - A problem occurs while reading from inwriteString(java.lang.String, java.io.DataOutput)
public static void writeBoolean(Boolean value,
DataOutput out)
throws IOException
Boolean to a
DataOutput.
IOException - A problem occurs while writing to outreadBoolean(java.io.DataInput)
public static Boolean readBoolean(DataInput in)
throws IOException
Boolean from a
DataInput.
IOException - A problem occurs while reading from in
public static void writeCharacter(Character value,
DataOutput out)
throws IOException
Character to a
DataOutput.
IOException - A problem occurs while writing to outreadCharacter(java.io.DataInput)
public static Character readCharacter(DataInput in)
throws IOException
Character from a
DataInput.
IOException - A problem occurs while reading from in
public static void writeByte(Byte value,
DataOutput out)
throws IOException
Byte to a
DataOutput.
IOException - A problem occurs while writing to outreadByte(java.io.DataInput)
public static Byte readByte(DataInput in)
throws IOException
Byte from a
DataInput.
IOException - A problem occurs while reading from in
public static void writeShort(Short value,
DataOutput out)
throws IOException
Short to a
DataOutput.
IOException - A problem occurs while writing to outreadShort(java.io.DataInput)
public static Short readShort(DataInput in)
throws IOException
Short from a
DataInput.
IOException - A problem occurs while reading from in
public static void writeInteger(Integer value,
DataOutput out)
throws IOException
Integer to a
DataOutput.
IOException - A problem occurs while writing to outreadInteger(java.io.DataInput)
public static Integer readInteger(DataInput in)
throws IOException
Integer from a
DataInput.
IOException - A problem occurs while reading from in
public static void writeLong(Long value,
DataOutput out)
throws IOException
Long to a
DataOutput.
IOException - A problem occurs while writing to outreadLong(java.io.DataInput)
public static Long readLong(DataInput in)
throws IOException
Long from a
DataInput.
IOException - A problem occurs while reading from in
public static void writeFloat(Float value,
DataOutput out)
throws IOException
Float to a
DataOutput.
IOException - A problem occurs while writing to outreadFloat(java.io.DataInput)
public static Float readFloat(DataInput in)
throws IOException
Float from a
DataInput.
IOException - A problem occurs while reading from in
public static void writeDouble(Double value,
DataOutput out)
throws IOException
Double to a
DataOutput.
IOException - A problem occurs while writing to outreadDouble(java.io.DataInput)
public static Double readDouble(DataInput in)
throws IOException
Double from a
DataInput.
IOException - A problem occurs while reading from in
public static void writePrimitiveBoolean(boolean value,
DataOutput out)
throws IOException
boolean to a
DataOutput.
IOException - A problem occurs while writing to outDataOutput.writeBoolean(boolean)
public static boolean readPrimitiveBoolean(DataInput in)
throws IOException
boolean from a
DataInput.
IOException - A problem occurs while reading from inDataInput.readBoolean()
public static void writePrimitiveByte(byte value,
DataOutput out)
throws IOException
byte to a
DataOutput.
IOException - A problem occurs while writing to outDataOutput.writeByte(int)
public static byte readPrimitiveByte(DataInput in)
throws IOException
byte from a
DataInput.
IOException - A problem occurs while reading from inDataInput.readByte()
public static void writePrimitiveChar(char value,
DataOutput out)
throws IOException
char to a
DataOutput.
IOException - A problem occurs while writing to outDataOutput.writeChar(int)
public static char readPrimitiveChar(DataInput in)
throws IOException
char from a
DataInput.
IOException - A problem occurs while reading from inDataInput.readChar()
public static void writePrimitiveShort(short value,
DataOutput out)
throws IOException
short to a
DataOutput.
IOException - A problem occurs while writing to outDataOutput.writeShort(int)
public static short readPrimitiveShort(DataInput in)
throws IOException
short from a
DataInput.
IOException - A problem occurs while reading from inDataInput.readShort()
public static void writeUnsignedByte(int value,
DataOutput out)
throws IOException
int as an unsigned byte to a
DataOutput.
IOException - A problem occurs while writing to outDataOutput.writeByte(int),
DataInput.readUnsignedByte()
public static int readUnsignedByte(DataInput in)
throws IOException
int as an unsigned byte from a
DataInput using DataInput.readUnsignedByte().
IOException - A problem occurs while reading from in
public static void writeUnsignedShort(int value,
DataOutput out)
throws IOException
int as an unsigned short to a
DataOutput.
IOException - A problem occurs while writing to outDataOutput.writeShort(int),
DataInput.readUnsignedShort()
public static int readUnsignedShort(DataInput in)
throws IOException
int as an unsigned short from a
DataInput using DataInput.readUnsignedShort().
IOException - A problem occurs while reading from in
public static void writePrimitiveInt(int value,
DataOutput out)
throws IOException
int to a
DataOutput.
IOException - A problem occurs while writing to outDataOutput.writeInt(int)
public static int readPrimitiveInt(DataInput in)
throws IOException
int from a
DataInput.
IOException - A problem occurs while reading from inDataInput.readInt()
public static void writePrimitiveLong(long value,
DataOutput out)
throws IOException
long to a
DataOutput.
IOException - A problem occurs while writing to outDataOutput.writeLong(long)
public static long readPrimitiveLong(DataInput in)
throws IOException
long from a
DataInput.
IOException - A problem occurs while reading from inDataInput.readLong()
public static void writePrimitiveFloat(float value,
DataOutput out)
throws IOException
float to a
DataOutput.
IOException - A problem occurs while writing to outDataOutput.writeFloat(float)
public static float readPrimitiveFloat(DataInput in)
throws IOException
float from a
DataInput.
IOException - A problem occurs while reading from inDataInput.readFloat()
public static void writePrimitiveDouble(double value,
DataOutput out)
throws IOException
double to a
DataOutput.
IOException - A problem occurs while writing to outDataOutput.writeDouble(double)
public static double readPrimitiveDouble(DataInput in)
throws IOException
double from a
DataInput.
IOException - A problem occurs while reading from inDataInput.readDouble()
public static void writeByteArray(byte[] array,
DataOutput out)
throws IOException
bytes to a
DataOutput.
IOException - A problem occurs while writing to outreadByteArray(java.io.DataInput)
public static void writeByteArray(byte[] array,
int len,
DataOutput out)
throws IOException
len elements
of an array of bytes to a
DataOutput.
len - the actual number of entries to write. If len is greater
than then length of the array then the entire array is written.
IOException - A problem occurs while writing to outreadByteArray(java.io.DataInput)
public static void writeObjectAsByteArray(Object obj,
DataOutput out)
throws 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.
obj - the object to serialize and writeout - the data output to write the byte array to
IllegalArgumentException - if a problem occurs while serialize obj
IOException - if a problem occurs while writing to outreadByteArray(java.io.DataInput)
public static byte[] readByteArray(DataInput in)
throws IOException
bytes from a
DataInput.
IOException - A problem occurs while writing to outwriteByteArray(byte[], DataOutput)
public static void writeStringArray(String[] array,
DataOutput out)
throws IOException
Strings to a
DataOutput.
IOException - A problem occurs while writing to outreadStringArray(java.io.DataInput),
writeString(java.lang.String, java.io.DataOutput)
public static String[] readStringArray(DataInput in)
throws IOException
Strings from a
DataInput.
IOException - A problem occurs while writing to outwriteStringArray(java.lang.String[], java.io.DataOutput)
public static void writeShortArray(short[] array,
DataOutput out)
throws IOException
shorts to a
DataOutput.
IOException - A problem occurs while writing to outreadShortArray(java.io.DataInput)
public static short[] readShortArray(DataInput in)
throws IOException
shorts from a
DataInput.
IOException - A problem occurs while writing to outwriteShortArray(short[], java.io.DataOutput)
public static void writeIntArray(int[] array,
DataOutput out)
throws IOException
int array to a DataOutput.
IOException - A problem occurs while writing to outreadIntArray(java.io.DataInput)
public static int[] readIntArray(DataInput in)
throws IOException
int array from a DataInput.
IOException - A problem occurs while writing to outwriteIntArray(int[], java.io.DataOutput)
public static void writeLongArray(long[] array,
DataOutput out)
throws IOException
longs to a
DataOutput.
IOException - A problem occurs while writing to outreadLongArray(java.io.DataInput)
public static long[] readLongArray(DataInput in)
throws IOException
longs from a
DataInput.
IOException - A problem occurs while writing to outwriteLongArray(long[], java.io.DataOutput)
public static void writeFloatArray(float[] array,
DataOutput out)
throws IOException
floats to a
DataOutput.
IOException - A problem occurs while writing to outreadFloatArray(java.io.DataInput)
public static float[] readFloatArray(DataInput in)
throws IOException
floats from a
DataInput.
IOException - A problem occurs while writing to outwriteFloatArray(float[], java.io.DataOutput)
public static void writeDoubleArray(double[] array,
DataOutput out)
throws IOException
doubles to a
DataOutput.
IOException - A problem occurs while writing to outreadDoubleArray(java.io.DataInput)
public static double[] readDoubleArray(DataInput in)
throws IOException
doubles from a
DataInput.
IOException - A problem occurs while writing to outwriteDoubleArray(double[], java.io.DataOutput)
public static void writeObjectArray(Object[] array,
DataOutput out)
throws IOException
Objects to a
DataOutput.
IOException - A problem occurs while writing to outreadObjectArray(java.io.DataInput),
writeObject(Object, DataOutput)
public static Object[] readObjectArray(DataInput in)
throws IOException,
ClassNotFoundException
Objects from a
DataInput.
IOException - A problem occurs while writing to out
ClassNotFoundExceptionwriteObjectArray(java.lang.Object[], java.io.DataOutput),
readObject(java.io.DataInput)
public static void writeArrayList(ArrayList list,
DataOutput out)
throws 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.
IOException - A problem occurs while writing to outreadArrayList(java.io.DataInput)
public static ArrayList readArrayList(DataInput in)
throws IOException,
ClassNotFoundException
ArrayList from a DataInput.
IOException - A problem occurs while writing to out
ClassNotFoundException - The class of one of the ArrayList's
elements cannot be found.writeArrayList(java.util.ArrayList, java.io.DataOutput)
public static void writeLinkedList(LinkedList list,
DataOutput out)
throws 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.
IOException - A problem occurs while writing to outreadLinkedList(java.io.DataInput)
public static LinkedList readLinkedList(DataInput in)
throws IOException,
ClassNotFoundException
LinkedList from a DataInput.
IOException - A problem occurs while writing to out
ClassNotFoundException - The class of one of the LinkedList's
elements cannot be found.writeLinkedList(java.util.LinkedList, java.io.DataOutput)
public static void writeHashSet(HashSet set,
DataOutput out)
throws 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.
IOException - A problem occurs while writing to outreadHashSet(java.io.DataInput)
public static HashSet readHashSet(DataInput in)
throws IOException,
ClassNotFoundException
HashSet from a DataInput.
IOException - A problem occurs while writing to out
ClassNotFoundException - The class of one of the HashSet's
elements cannot be found.writeHashSet(java.util.HashSet, java.io.DataOutput)
public static void writeHashMap(HashMap map,
DataOutput out)
throws 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.
IOException - A problem occurs while writing to outreadHashMap(java.io.DataInput)
public static HashMap readHashMap(DataInput in)
throws IOException,
ClassNotFoundException
HashMap from a DataInput.
IOException - A problem occurs while writing to out
ClassNotFoundException - The class of one of the HashMap's
elements cannot be found.writeHashMap(java.util.HashMap, java.io.DataOutput)
public static void writeProperties(Properties props,
DataOutput out)
throws IOException
Properties object to a DataOutput.
IOException - A problem occurred while writing to outreadProperties(java.io.DataInput)
public static Properties readProperties(DataInput in)
throws IOException,
ClassNotFoundException
Properties object from a
DataInput.
IOException - A problem occurred while reading from
DataInput
ClassNotFoundException - The class of one of the Properties's
elements cannot be found.writeProperties(java.util.Properties, java.io.DataOutput)
public static void writeTimeUnit(com.gemstone.bp.edu.emory.mathcs.backport.java.util.concurrent.TimeUnit unit,
DataOutput out)
throws IOException
TimeUnit to a DataOutput.
IOException - A problem occurs while writing to outreadTimeUnit(java.io.DataInput)
public static com.gemstone.bp.edu.emory.mathcs.backport.java.util.concurrent.TimeUnit readTimeUnit(DataInput in)
throws IOException
TimeUnit from a DataInput.
IOException - A problem occurs while writing to outwriteTimeUnit(com.gemstone.bp.edu.emory.mathcs.backport.java.util.concurrent.TimeUnit, java.io.DataOutput)
public static void writeUserDataSerializableHeader(byte classId,
DataOutput out)
throws IOException
IOException
public static void writeObject(Object o,
DataOutput out,
boolean allowJavaSerialization)
throws 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.
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 client
IOException - A problem occurs while writing o to
outreadObject(DataInput),
Instantiator,
ObjectOutputStream.writeObject(java.lang.Object)
public static void writeObject(Object o,
DataOutput out)
throws 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.
IOException - A problem occurs while writing o to
outreadObject(DataInput),
Instantiator,
ObjectOutputStream.writeObject(java.lang.Object)
public static Object readObject(DataInput in)
throws IOException,
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.
IOException - A problem occured while reading from in
(may wrap another exception)
ClassNotFoundException - The class of an object read from in could
not be foundwriteObject(Object, DataOutput),
ObjectInputStream.readObject()
public static DataSerializer register(Class c,
byte id)
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
the order in which serializers are consulted is not specified.
Therefore, no two serializers should not be able to serialize
instances of the same class.
This method invokes the DataSerializer instance's
getSupportedClasses() method and keeps track of which
classes can have their instances serialized by s.
c - A DataSerializer class whose instance should
be registered with the data serialization framework.id - The unique id of the DataSerializer
DataSerializer that was
registered.
IllegalArgumentException - If c does not subclass
DataSerializer, if c does not
have a zero-argument constructor, if another serializer
instance with id id has already been
registered, if id is 0.getSupportedClasses()public abstract Class[] getSupportedClasses()
Classes whose instances are data
serialized by this DataSerializer. This method is
invoked when this serializer is registered. The information provided by this method allows the
data serialization framework to optimize the behavior of the
writeObject(Object, DataOutput) method. Instead of performing a handful of
instanceof operations and potentially invoking
DataSerializers that cannot serialize the object,
the framework can quickly select which serializer should be
invoked.
public abstract boolean toData(Object o,
DataOutput out)
throws 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.
IOException
public abstract Object fromData(DataInput in)
throws IOException,
ClassNotFoundException
DataInput. An
implementation of this method may take the form:
IOException - If this serializer cannot read an object from
in.
ClassNotFoundExceptiontoData(java.lang.Object, java.io.DataOutput)public byte getId()
DataSerializer.
public boolean equals(Object o)
DataSerializers are consider to be equal if they
have the same id.
equals in class Object
|
GemFire 5.5 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||