public interface PdxWriter
toData
or
PdxSerializer toData
by GemFire when it is
serializing the domain class. The domain class needs to serialize instance fields using this
interface. This interface is implemented by GemFire.
The order in which the fields are written must match the order in which they are read by
PdxReader
.
Field names are case sensitive.
All methods on this interface return itself to allow method calls to be chained together.
Modifier and Type | Method and Description |
---|---|
PdxWriter |
markIdentityField(String fieldName)
Indicate that the named field should be included in hashCode and equals checks of this object
on a server that is accessing
PdxInstance or when a client executes a query on a
server. |
PdxWriter |
writeArrayOfByteArrays(String fieldName,
byte[][] value)
Writes the named field with the given value to the serialized form.
|
PdxWriter |
writeBoolean(String fieldName,
boolean value)
Writes the named field with the given value to the serialized form.
|
PdxWriter |
writeBooleanArray(String fieldName,
boolean[] value)
Writes the named field with the given value to the serialized form.
|
PdxWriter |
writeByte(String fieldName,
byte value)
Writes the named field with the given value to the serialized form.
|
PdxWriter |
writeByteArray(String fieldName,
byte[] value)
Writes the named field with the given value to the serialized form.
|
PdxWriter |
writeChar(String fieldName,
char value)
Writes the named field with the given value to the serialized form.
|
PdxWriter |
writeCharArray(String fieldName,
char[] value)
Writes the named field with the given value to the serialized form.
|
PdxWriter |
writeDate(String fieldName,
Date value)
Writes the named field with the given value to the serialized form.
|
PdxWriter |
writeDouble(String fieldName,
double value)
Writes the named field with the given value to the serialized form.
|
PdxWriter |
writeDoubleArray(String fieldName,
double[] value)
Writes the named field with the given value to the serialized form.
|
<CT,VT extends CT> |
writeField(String fieldName,
VT fieldValue,
Class<CT> fieldType)
Writes the named field with the given value and type to the serialized form.
|
<CT,VT extends CT> |
writeField(String fieldName,
VT fieldValue,
Class<CT> fieldType,
boolean checkPortability)
Writes the named field with the given value and type to the serialized form.
|
PdxWriter |
writeFloat(String fieldName,
float value)
Writes the named field with the given value to the serialized form.
|
PdxWriter |
writeFloatArray(String fieldName,
float[] value)
Writes the named field with the given value to the serialized form.
|
PdxWriter |
writeInt(String fieldName,
int value)
Writes the named field with the given value to the serialized form.
|
PdxWriter |
writeIntArray(String fieldName,
int[] value)
Writes the named field with the given value to the serialized form.
|
PdxWriter |
writeLong(String fieldName,
long value)
Writes the named field with the given value to the serialized form.
|
PdxWriter |
writeLongArray(String fieldName,
long[] value)
Writes the named field with the given value to the serialized form.
|
PdxWriter |
writeObject(String fieldName,
Object value)
Writes the named field with the given value to the serialized form.
|
PdxWriter |
writeObject(String fieldName,
Object value,
boolean checkPortability)
Writes the named field with the given value to the serialized form.
|
PdxWriter |
writeObjectArray(String fieldName,
Object[] value)
Writes the named field with the given value to the serialized form.
|
PdxWriter |
writeObjectArray(String fieldName,
Object[] value,
boolean checkPortability)
Writes the named field with the given value to the serialized form.
|
PdxWriter |
writeShort(String fieldName,
short value)
Writes the named field with the given value to the serialized form.
|
PdxWriter |
writeShortArray(String fieldName,
short[] value)
Writes the named field with the given value to the serialized form.
|
PdxWriter |
writeString(String fieldName,
String value)
Writes the named field with the given value to the serialized form.
|
PdxWriter |
writeStringArray(String fieldName,
String[] value)
Writes the named field with the given value to the serialized form.
|
PdxWriter |
writeUnreadFields(PdxUnreadFields unread)
Writes the given unread fields to the serialized form.
|
PdxWriter writeChar(String fieldName, char value)
char
.
Java char is mapped to .NET System.Char.
fieldName
- the name of the field to writevalue
- the value of the field to writePdxFieldAlreadyExistsException
- if the named field has already been writtenPdxSerializationException
- if serialization of the field fails.PdxWriter writeBoolean(String fieldName, boolean value)
boolean
.
Java boolean is mapped to .NET System.Boolean.
fieldName
- the name of the field to writevalue
- the value of the field to writePdxFieldAlreadyExistsException
- if the named field has already been writtenPdxSerializationException
- if serialization of the field fails.PdxWriter writeByte(String fieldName, byte value)
byte
.
Java byte is mapped to .NET System.SByte.
fieldName
- the name of the field to writevalue
- the value of the field to writePdxFieldAlreadyExistsException
- if the named field has already been writtenPdxSerializationException
- if serialization of the field fails.PdxWriter writeShort(String fieldName, short value)
short
.
Java short is mapped to .NET System.Int16.
fieldName
- the name of the field to writevalue
- the value of the field to writePdxFieldAlreadyExistsException
- if the named field has already been writtenPdxSerializationException
- if serialization of the field fails.PdxWriter writeInt(String fieldName, int value)
int
.
Java int is mapped to .NET System.Int32.
fieldName
- the name of the field to writevalue
- the value of the field to writePdxFieldAlreadyExistsException
- if the named field has already been writtenPdxSerializationException
- if serialization of the field fails.PdxWriter writeLong(String fieldName, long value)
long
.
Java long is mapped to .NET System.Int64.
fieldName
- the name of the field to writevalue
- the value of the field to writePdxFieldAlreadyExistsException
- if the named field has already been writtenPdxSerializationException
- if serialization of the field fails.PdxWriter writeFloat(String fieldName, float value)
float
.
Java float is mapped to .NET System.Float.
fieldName
- the name of the field to writevalue
- the value of the field to writePdxFieldAlreadyExistsException
- if the named field has already been writtenPdxSerializationException
- if serialization of the field fails.PdxWriter writeDouble(String fieldName, double value)
double
.
Java double is mapped to .NET System.Double.
fieldName
- the name of the field to writevalue
- the value of the field to writePdxFieldAlreadyExistsException
- if the named field has already been writtenPdxSerializationException
- if serialization of the field fails.PdxWriter writeDate(String fieldName, Date value)
Date
.
Java Date is mapped to .NET System.DateTime.
fieldName
- the name of the field to writevalue
- the value of the field to writePdxFieldAlreadyExistsException
- if the named field has already been writtenPdxSerializationException
- if serialization of the field fails.PdxWriter writeString(String fieldName, String value)
String
.
Java String is mapped to .NET System.String.
fieldName
- the name of the field to writevalue
- the value of the field to writePdxFieldAlreadyExistsException
- if the named field has already been writtenPdxSerializationException
- if serialization of the field fails.PdxWriter writeObject(String fieldName, Object value)
Object
.
It is best to use one of the other writeXXX methods if your field type will always be XXX. This method allows the field value to be anything that is an instance of Object. This gives you more flexibility but more space is used to store the serialized field.
Note that some Java objects serialized with this method may not be compatible with non-java
languages. To ensure that only portable objects are serialized use
writeObject(String, Object, boolean)
.
fieldName
- the name of the field to writevalue
- the value of the field to writePdxFieldAlreadyExistsException
- if the named field has already been writtenPdxSerializationException
- if serialization of the field fails.PdxWriter writeObject(String fieldName, Object value, boolean checkPortability)
Object
.
It is best to use one of the other writeXXX methods if your field type will always be XXX. This method allows the field value to be anything that is an instance of Object. This gives you more flexibility but more space is used to store the serialized field.
Note that some Java objects serialized with this method may not be compatible with non-java
languages. To ensure that only portable objects are serialized set the
checkPortability
parameter to true. The following is a list of the Java classes
that are portable and the .NET class they are mapped to:
PdxSerializable
: .NET class of same name
PdxInstance
: .NET class of same name
PdxSerializer
: .NET class of same name
fieldName
- the name of the field to writevalue
- the value of the field to writecheckPortability
- if true then an exception is thrown if a non-portable object is
serializedPdxFieldAlreadyExistsException
- if the named field has already been writtenNonPortableClassException
- if checkPortability is true and a non-portable object is
serializedPdxSerializationException
- if serialization of the field fails.PdxWriter writeBooleanArray(String fieldName, boolean[] value)
boolean[]
.
Java boolean[] is mapped to .NET System.Boolean[].
fieldName
- the name of the field to writevalue
- the value of the field to writePdxFieldAlreadyExistsException
- if the named field has already been writtenPdxSerializationException
- if serialization of the field fails.PdxWriter writeCharArray(String fieldName, char[] value)
char[]
.
Java char[] is mapped to .NET System.Char[].
fieldName
- the name of the field to writevalue
- the value of the field to writePdxFieldAlreadyExistsException
- if the named field has already been writtenPdxSerializationException
- if serialization of the field fails.PdxWriter writeByteArray(String fieldName, byte[] value)
byte[]
.
Java byte[] is mapped to .NET System.Byte[].
fieldName
- the name of the field to writevalue
- the value of the field to writePdxFieldAlreadyExistsException
- if the named field has already been writtenPdxSerializationException
- if serialization of the field fails.PdxWriter writeShortArray(String fieldName, short[] value)
short[]
.
Java short[] is mapped to .NET System.Int16[].
fieldName
- the name of the field to writevalue
- the value of the field to writePdxFieldAlreadyExistsException
- if the named field has already been writtenPdxSerializationException
- if serialization of the field fails.PdxWriter writeIntArray(String fieldName, int[] value)
int[]
.
Java int[] is mapped to .NET System.Int32[].
fieldName
- the name of the field to writevalue
- the value of the field to writePdxFieldAlreadyExistsException
- if the named field has already been writtenPdxSerializationException
- if serialization of the field fails.PdxWriter writeLongArray(String fieldName, long[] value)
long[]
.
Java long[] is mapped to .NET System.Int64[].
fieldName
- the name of the field to writevalue
- the value of the field to writePdxFieldAlreadyExistsException
- if the named field has already been writtenPdxSerializationException
- if serialization of the field fails.PdxWriter writeFloatArray(String fieldName, float[] value)
float[]
.
Java float[] is mapped to .NET System.Float[].
fieldName
- the name of the field to writevalue
- the value of the field to writePdxFieldAlreadyExistsException
- if the named field has already been writtenPdxSerializationException
- if serialization of the field fails.PdxWriter writeDoubleArray(String fieldName, double[] value)
double[]
.
Java double[] is mapped to .NET System.Double[].
fieldName
- the name of the field to writevalue
- the value of the field to writePdxFieldAlreadyExistsException
- if the named field has already been writtenPdxSerializationException
- if serialization of the field fails.PdxWriter writeStringArray(String fieldName, String[] value)
String[]
.
Java String[] is mapped to .NET System.String[].
fieldName
- the name of the field to writevalue
- the value of the field to writePdxFieldAlreadyExistsException
- if the named field has already been writtenPdxSerializationException
- if serialization of the field fails.PdxWriter writeObjectArray(String fieldName, Object[] value)
Object[]
.
Java Object[] is mapped to .NET System.Collections.Generic.List<Object>
. For how each
element
of the array is a mapped to .NET see writeObject
.
Note that this call may serialize elements that are not compatible with non-java languages. To
ensure that only portable objects are serialized use
writeObjectArray(String, Object[], boolean)
.
fieldName
- the name of the field to writevalue
- the value of the field to writePdxFieldAlreadyExistsException
- if the named field has already been writtenPdxSerializationException
- if serialization of the field fails.PdxWriter writeObjectArray(String fieldName, Object[] value, boolean checkPortability)
Object[]
.
Java Object[] is mapped to .NET System.Collections.Generic.List<Object>. For how each
element
of the array is a mapped to .NET see writeObject
.
Note that this call may serialize elements that are not compatible with non-java languages. To
ensure that only portable objects are serialized use this method
fieldName
- the name of the field to writevalue
- the value of the field to writecheckPortability
- if true then an exception is thrown if a non-portable object is
serializedPdxFieldAlreadyExistsException
- if the named field has already been writtenNonPortableClassException
- if checkPortability is true and a non-portable element is
serializedPdxSerializationException
- if serialization of the field fails.PdxWriter writeArrayOfByteArrays(String fieldName, byte[][] value)
byte[][]
.
Java byte[][] is mapped to .NET System.Byte[][].
fieldName
- the name of the field to writevalue
- the value of the field to writePdxFieldAlreadyExistsException
- if the named field has already been writtenPdxSerializationException
- if serialization of the field fails.<CT,VT extends CT> PdxWriter writeField(String fieldName, VT fieldValue, Class<CT> fieldType)
fieldType
to determine which writeXXX method it should call. If it can not
find a specific match to a writeXXX method it will call writeObject
. This method may serialize objects that are not portable to non-java languages. To
ensure that only objects that are portable to non-java languages are serialized use
writeField(String, Object, Class, boolean)
instead.
The fieldTypes that map to a specific method are:
writeBoolean(java.lang.String, boolean)
writeByte(java.lang.String, byte)
writeChar(java.lang.String, char)
writeShort(java.lang.String, short)
writeInt(java.lang.String, int)
writeLong(java.lang.String, long)
writeFloat(java.lang.String, float)
writeDouble(java.lang.String, double)
writeString(java.lang.String, java.lang.String)
writeDate(java.lang.String, java.util.Date)
writeBooleanArray(java.lang.String, boolean[])
writeByteArray(java.lang.String, byte[])
writeCharArray(java.lang.String, char[])
writeShortArray(java.lang.String, short[])
writeIntArray(java.lang.String, int[])
writeLongArray(java.lang.String, long[])
writeFloatArray(java.lang.String, float[])
writeDoubleArray(java.lang.String, double[])
writeStringArray(java.lang.String, java.lang.String[])
writeArrayOfByteArrays(java.lang.String, byte[][])
writeObjectArray(java.lang.String, java.lang.Object[])
writeObject
.CT
- the type associated with the class of the field to writeVT
- the type associated with the value of the field to writefieldName
- the name of the field to writefieldValue
- the value of the field to write; this parameter's class must extend the
fieldType
fieldType
- the type of the field to writePdxFieldAlreadyExistsException
- if the named field has already been writtenPdxSerializationException
- if serialization of the field fails.<CT,VT extends CT> PdxWriter writeField(String fieldName, VT fieldValue, Class<CT> fieldType, boolean checkPortability)
fieldType
to determine which writeXXX method it should call. If it can not
find a specific match to a writeXXX method it will call
writeObject
. To ensure that only objects that are
portable to non-java languages are serialized set the checkPortability
parameter
to true.
The fieldTypes that map to a specific method are:
writeBoolean(java.lang.String, boolean)
writeByte(java.lang.String, byte)
writeChar(java.lang.String, char)
writeShort(java.lang.String, short)
writeInt(java.lang.String, int)
writeLong(java.lang.String, long)
writeFloat(java.lang.String, float)
writeDouble(java.lang.String, double)
writeString(java.lang.String, java.lang.String)
writeDate(java.lang.String, java.util.Date)
writeBooleanArray(java.lang.String, boolean[])
writeByteArray(java.lang.String, byte[])
writeCharArray(java.lang.String, char[])
writeShortArray(java.lang.String, short[])
writeIntArray(java.lang.String, int[])
writeLongArray(java.lang.String, long[])
writeFloatArray(java.lang.String, float[])
writeDoubleArray(java.lang.String, double[])
writeStringArray(java.lang.String, java.lang.String[])
writeArrayOfByteArrays(java.lang.String, byte[][])
writeObjectArray(String, Object[], boolean)
writeObject
.CT
- the type associated with the class of the field to writeVT
- the type associated with the value of the field to writefieldName
- the name of the field to writefieldValue
- the value of the field to write; this parameter's class must extend the
fieldType
fieldType
- the type of the field to writecheckPortability
- if true then an exception is thrown if a non-portable object is
serializedPdxFieldAlreadyExistsException
- if the named field has already been writtenNonPortableClassException
- if checkPortability is true and a non-portable object is
serializedPdxSerializationException
- if serialization of the field fails.PdxWriter writeUnreadFields(PdxUnreadFields unread)
readUnreadFields
.
This method must be called first before any of the writeXXX methods is called.
unread
- the object that was returned from readUnreadFields
.PdxFieldAlreadyExistsException
- if one of the writeXXX methods has already been called.PdxWriter markIdentityField(String fieldName)
PdxInstance
or when a client executes a query on a
server.
The fields that are marked as identity fields are used to generate the hashCode and equals
methods of PdxInstance
. Because of this, the identity fields should themselves either
be primitives, or implement hashCode and equals.
If no fields are set as identity fields, then all fields will be used in hashCode and equals
checks.
The identity fields should be marked after they are written using a write* method.fieldName
- the name of the field to mark as an identity field.PdxFieldDoesNotExistException
- if the named field has not already been written.