public interface PdxInstanceFactory
create()
to produce an actual instance that contains the data.
To create a factory call RegionService.createPdxInstanceFactory(String)
. A factory can
only create a single instance. To create multiple instances create multiple factories or use
PdxInstance.createWriter()
to create subsequent instances. Using
PdxInstance.createWriter()
is usually faster.Modifier and Type | Method and Description |
---|---|
PdxInstance |
create()
Create a
PdxInstance . |
PdxInstanceFactory |
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. |
PdxInstanceFactory |
neverDeserialize()
The instance created by this factory will be one that is never
deserialized to a domain class.
|
PdxInstanceFactory |
writeArrayOfByteArrays(String fieldName,
byte[][] value)
Writes the named field with the given value to the serialized form.
|
PdxInstanceFactory |
writeBoolean(String fieldName,
boolean value)
Writes the named field with the given value to the serialized form.
|
PdxInstanceFactory |
writeBooleanArray(String fieldName,
boolean[] value)
Writes the named field with the given value to the serialized form.
|
PdxInstanceFactory |
writeByte(String fieldName,
byte value)
Writes the named field with the given value to the serialized form.
|
PdxInstanceFactory |
writeByteArray(String fieldName,
byte[] value)
Writes the named field with the given value to the serialized form.
|
PdxInstanceFactory |
writeChar(String fieldName,
char value)
Writes the named field with the given value to the serialized form.
|
PdxInstanceFactory |
writeCharArray(String fieldName,
char[] value)
Writes the named field with the given value to the serialized form.
|
PdxInstanceFactory |
writeDate(String fieldName,
Date value)
Writes the named field with the given value to the serialized form.
|
PdxInstanceFactory |
writeDouble(String fieldName,
double value)
Writes the named field with the given value to the serialized form.
|
PdxInstanceFactory |
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.
|
PdxInstanceFactory |
writeFloat(String fieldName,
float value)
Writes the named field with the given value to the serialized form.
|
PdxInstanceFactory |
writeFloatArray(String fieldName,
float[] value)
Writes the named field with the given value to the serialized form.
|
PdxInstanceFactory |
writeInt(String fieldName,
int value)
Writes the named field with the given value to the serialized form.
|
PdxInstanceFactory |
writeIntArray(String fieldName,
int[] value)
Writes the named field with the given value to the serialized form.
|
PdxInstanceFactory |
writeLong(String fieldName,
long value)
Writes the named field with the given value to the serialized form.
|
PdxInstanceFactory |
writeLongArray(String fieldName,
long[] value)
Writes the named field with the given value to the serialized form.
|
PdxInstanceFactory |
writeObject(String fieldName,
Object value)
Writes the named field with the given value to the serialized form.
|
PdxInstanceFactory |
writeObject(String fieldName,
Object value,
boolean checkPortability)
Writes the named field with the given value to the serialized form.
|
PdxInstanceFactory |
writeObjectArray(String fieldName,
Object[] value)
Writes the named field with the given value to the serialized form.
|
PdxInstanceFactory |
writeObjectArray(String fieldName,
Object[] value,
boolean checkPortability)
Writes the named field with the given value to the serialized form.
|
PdxInstanceFactory |
writeShort(String fieldName,
short value)
Writes the named field with the given value to the serialized form.
|
PdxInstanceFactory |
writeShortArray(String fieldName,
short[] value)
Writes the named field with the given value to the serialized form.
|
PdxInstanceFactory |
writeString(String fieldName,
String value)
Writes the named field with the given value to the serialized form.
|
PdxInstanceFactory |
writeStringArray(String fieldName,
String[] value)
Writes the named field with the given value to the serialized form.
|
PdxInstance create()
PdxInstance
. The instance will contain any data written to this factory using
the write methods.IllegalStateException
- if called more than oncePdxInstanceFactory 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.PdxInstanceFactory 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.PdxInstanceFactory 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.PdxInstanceFactory 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.PdxInstanceFactory 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.PdxInstanceFactory 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.PdxInstanceFactory 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.PdxInstanceFactory 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.PdxInstanceFactory 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.PdxInstanceFactory 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.PdxInstanceFactory 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.PdxInstanceFactory 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 writtenPdxSerializationException
- if checkPortability is true and a non-portable object is
serializedPdxSerializationException
- if serialization of the field fails.PdxInstanceFactory 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.PdxInstanceFactory 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.PdxInstanceFactory 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.PdxInstanceFactory 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.PdxInstanceFactory 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.PdxInstanceFactory 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.PdxInstanceFactory 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.PdxInstanceFactory 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.PdxInstanceFactory 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.PdxInstanceFactory 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.PdxInstanceFactory 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
writeObjectArray(String, Object[], boolean)
.
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 writtenPdxSerializationException
- if checkPortability is true and a non-portable element is
serializedPdxSerializationException
- if serialization of the field fails.PdxInstanceFactory 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> PdxInstanceFactory 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> PdxInstanceFactory 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 writtenPdxSerializationException
- if checkPortability is true and a non-portable object is
serializedPdxSerializationException
- if serialization of the field fails.PdxInstanceFactory 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 make 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.PdxInstanceFactory neverDeserialize()