GemFire 7.0

com.gemstone.gemfire.pdx
Interface PdxInstanceFactory


public interface PdxInstanceFactory

PdxInstanceFactory gives you a way to create PdxInstances. Call the write methods to populate the field data and then call 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.

Since:
6.6.2

Method Summary
 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 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>
PdxInstanceFactory
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>
PdxInstanceFactory
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.
 

Method Detail

create

PdxInstance create()
Create a PdxInstance. The instance will contain any data written to this factory using the write methods.

Returns:
the created instance
Throws:
IllegalStateException - if called more than once

writeChar

PdxInstanceFactory writeChar(String fieldName,
                             char value)
Writes the named field with the given value to the serialized form. The fields type is char.

Java char is mapped to .NET System.Char.

Parameters:
fieldName - the name of the field to write
value - the value of the field to write
Returns:
this PdxInstanceFactory
Throws:
PdxFieldAlreadyExistsException - if the named field has already been written
PdxSerializationException - if serialization of the field fails.

writeBoolean

PdxInstanceFactory writeBoolean(String fieldName,
                                boolean value)
Writes the named field with the given value to the serialized form. The fields type is boolean.

Java boolean is mapped to .NET System.Boolean.

Parameters:
fieldName - the name of the field to write
value - the value of the field to write
Returns:
this PdxInstanceFactory
Throws:
PdxFieldAlreadyExistsException - if the named field has already been written
PdxSerializationException - if serialization of the field fails.

writeByte

PdxInstanceFactory writeByte(String fieldName,
                             byte value)
Writes the named field with the given value to the serialized form. The fields type is byte.

Java byte is mapped to .NET System.SByte.

Parameters:
fieldName - the name of the field to write
value - the value of the field to write
Returns:
this PdxInstanceFactory
Throws:
PdxFieldAlreadyExistsException - if the named field has already been written
PdxSerializationException - if serialization of the field fails.

writeShort

PdxInstanceFactory writeShort(String fieldName,
                              short value)
Writes the named field with the given value to the serialized form. The fields type is short.

Java short is mapped to .NET System.Int16.

Parameters:
fieldName - the name of the field to write
value - the value of the field to write
Returns:
this PdxInstanceFactory
Throws:
PdxFieldAlreadyExistsException - if the named field has already been written
PdxSerializationException - if serialization of the field fails.

writeInt

PdxInstanceFactory writeInt(String fieldName,
                            int value)
Writes the named field with the given value to the serialized form. The fields type is int.

Java int is mapped to .NET System.Int32.

Parameters:
fieldName - the name of the field to write
value - the value of the field to write
Returns:
this PdxInstanceFactory
Throws:
PdxFieldAlreadyExistsException - if the named field has already been written
PdxSerializationException - if serialization of the field fails.

writeLong

PdxInstanceFactory writeLong(String fieldName,
                             long value)
Writes the named field with the given value to the serialized form. The fields type is long.

Java long is mapped to .NET System.Int64.

Parameters:
fieldName - the name of the field to write
value - the value of the field to write
Returns:
this PdxInstanceFactory
Throws:
PdxFieldAlreadyExistsException - if the named field has already been written
PdxSerializationException - if serialization of the field fails.

writeFloat

PdxInstanceFactory writeFloat(String fieldName,
                              float value)
Writes the named field with the given value to the serialized form. The fields type is float.

Java float is mapped to .NET System.Float.

Parameters:
fieldName - the name of the field to write
value - the value of the field to write
Returns:
this PdxInstanceFactory
Throws:
PdxFieldAlreadyExistsException - if the named field has already been written
PdxSerializationException - if serialization of the field fails.

writeDouble

PdxInstanceFactory writeDouble(String fieldName,
                               double value)
Writes the named field with the given value to the serialized form. The fields type is double.

Java double is mapped to .NET System.Double.

Parameters:
fieldName - the name of the field to write
value - the value of the field to write
Returns:
this PdxInstanceFactory
Throws:
PdxFieldAlreadyExistsException - if the named field has already been written
PdxSerializationException - if serialization of the field fails.

writeDate

PdxInstanceFactory writeDate(String fieldName,
                             Date value)
Writes the named field with the given value to the serialized form. The fields type is Date.

Java Date is mapped to .NET System.DateTime.

Parameters:
fieldName - the name of the field to write
value - the value of the field to write
Returns:
this PdxInstanceFactory
Throws:
PdxFieldAlreadyExistsException - if the named field has already been written
PdxSerializationException - if serialization of the field fails.

writeString

PdxInstanceFactory writeString(String fieldName,
                               String value)
Writes the named field with the given value to the serialized form. The fields type is String.

Java String is mapped to .NET System.String.

Parameters:
fieldName - the name of the field to write
value - the value of the field to write
Returns:
this PdxInstanceFactory
Throws:
PdxFieldAlreadyExistsException - if the named field has already been written
PdxSerializationException - if serialization of the field fails.

writeObject

PdxInstanceFactory writeObject(String fieldName,
                               Object value)
Writes the named field with the given value to the serialized form. The fields type is 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).

Parameters:
fieldName - the name of the field to write
value - the value of the field to write
Returns:
this PdxInstanceFactory
Throws:
PdxFieldAlreadyExistsException - if the named field has already been written
PdxSerializationException - if serialization of the field fails.

writeObject

PdxInstanceFactory writeObject(String fieldName,
                               Object value,
                               boolean checkPortability)
Writes the named field with the given value to the serialized form. The fields type is 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: