VMware GemFire Java API Reference
Interface PdxInstanceFactory
-
public interface PdxInstanceFactoryPdxInstanceFactory gives you a way to create PdxInstances. Call the write methods to populate the field data and then callcreate()to produce an actual instance that contains the data. To create a factory callRegionService.createPdxInstanceFactory(String). A factory can only create a single instance. To create multiple instances create multiple factories or usePdxInstance.createWriter()to create subsequent instances. UsingPdxInstance.createWriter()is usually faster.- Since:
- GemFire 6.6.2
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description PdxInstancecreate()Create aPdxInstance.PdxInstanceFactorymarkIdentityField(java.lang.String fieldName)Indicate that the named field should be included in hashCode and equals checks of this object on a server that is accessingPdxInstanceor when a client executes a query on a server.PdxInstanceFactoryneverDeserialize()The instance created by this factory will be one that is never deserialized to a domain class.PdxInstanceFactorywriteArrayOfByteArrays(java.lang.String fieldName, byte[][] value)Writes the named field with the given value to the serialized form.PdxInstanceFactorywriteBoolean(java.lang.String fieldName, boolean value)Writes the named field with the given value to the serialized form.PdxInstanceFactorywriteBooleanArray(java.lang.String fieldName, boolean[] value)Writes the named field with the given value to the serialized form.PdxInstanceFactorywriteByte(java.lang.String fieldName, byte value)Writes the named field with the given value to the serialized form.PdxInstanceFactorywriteByteArray(java.lang.String fieldName, byte[] value)Writes the named field with the given value to the serialized form.PdxInstanceFactorywriteChar(java.lang.String fieldName, char value)Writes the named field with the given value to the serialized form.PdxInstanceFactorywriteCharArray(java.lang.String fieldName, char[] value)Writes the named field with the given value to the serialized form.PdxInstanceFactorywriteDate(java.lang.String fieldName, java.util.Date value)Writes the named field with the given value to the serialized form.PdxInstanceFactorywriteDouble(java.lang.String fieldName, double value)Writes the named field with the given value to the serialized form.PdxInstanceFactorywriteDoubleArray(java.lang.String fieldName, double[] value)Writes the named field with the given value to the serialized form.<CT,VT extends CT>
PdxInstanceFactorywriteField(java.lang.String fieldName, VT fieldValue, java.lang.Class<CT> fieldType)Writes the named field with the given value and type to the serialized form.<CT,VT extends CT>
PdxInstanceFactorywriteField(java.lang.String fieldName, VT fieldValue, java.lang.Class<CT> fieldType, boolean checkPortability)Writes the named field with the given value and type to the serialized form.PdxInstanceFactorywriteFloat(java.lang.String fieldName, float value)Writes the named field with the given value to the serialized form.PdxInstanceFactorywriteFloatArray(java.lang.String fieldName, float[] value)Writes the named field with the given value to the serialized form.PdxInstanceFactorywriteInt(java.lang.String fieldName, int value)Writes the named field with the given value to the serialized form.PdxInstanceFactorywriteIntArray(java.lang.String fieldName, int[] value)Writes the named field with the given value to the serialized form.PdxInstanceFactorywriteLong(java.lang.String fieldName, long value)Writes the named field with the given value to the serialized form.PdxInstanceFactorywriteLongArray(java.lang.String fieldName, long[] value)Writes the named field with the given value to the serialized form.PdxInstanceFactorywriteObject(java.lang.String fieldName, java.lang.Object value)Writes the named field with the given value to the serialized form.PdxInstanceFactorywriteObject(java.lang.String fieldName, java.lang.Object value, boolean checkPortability)Writes the named field with the given value to the serialized form.PdxInstanceFactorywriteObjectArray(java.lang.String fieldName, java.lang.Object[] value)Writes the named field with the given value to the serialized form.PdxInstanceFactorywriteObjectArray(java.lang.String fieldName, java.lang.Object[] value, boolean checkPortability)Writes the named field with the given value to the serialized form.PdxInstanceFactorywriteShort(java.lang.String fieldName, short value)Writes the named field with the given value to the serialized form.PdxInstanceFactorywriteShortArray(java.lang.String fieldName, short[] value)Writes the named field with the given value to the serialized form.PdxInstanceFactorywriteString(java.lang.String fieldName, java.lang.String value)Writes the named field with the given value to the serialized form.PdxInstanceFactorywriteStringArray(java.lang.String fieldName, java.lang.String[] value)Writes the named field with the given value to the serialized form.
-
-
-
Method Detail
-
create
PdxInstance create()
Create aPdxInstance. The instance will contain any data written to this factory using the write methods.- Returns:
- the created instance
- Throws:
java.lang.IllegalStateException- if called more than once
-
writeChar
PdxInstanceFactory writeChar(java.lang.String fieldName, char value)
Writes the named field with the given value to the serialized form. The fields type ischar.Java char is mapped to .NET System.Char.
- Parameters:
fieldName- the name of the field to writevalue- the value of the field to write- Returns:
- this PdxInstanceFactory
- Throws:
PdxFieldAlreadyExistsException- if the named field has already been writtenPdxSerializationException- if serialization of the field fails.
-
writeBoolean
PdxInstanceFactory writeBoolean(java.lang.String fieldName, boolean value)
Writes the named field with the given value to the serialized form. The fields type isboolean.Java boolean is mapped to .NET System.Boolean.
- Parameters:
fieldName- the name of the field to writevalue- the value of the field to write- Returns:
- this PdxInstanceFactory
- Throws:
PdxFieldAlreadyExistsException- if the named field has already been writtenPdxSerializationException- if serialization of the field fails.
-
writeByte
PdxInstanceFactory writeByte(java.lang.String fieldName, byte value)
Writes the named field with the given value to the serialized form. The fields type isbyte.Java byte is mapped to .NET System.SByte.
- Parameters:
fieldName- the name of the field to writevalue- the value of the field to write- Returns:
- this PdxInstanceFactory
- Throws:
PdxFieldAlreadyExistsException- if the named field has already been writtenPdxSerializationException- if serialization of the field fails.
-
writeShort
PdxInstanceFactory writeShort(java.lang.String fieldName, short value)
Writes the named field with the given value to the serialized form. The fields type isshort.Java short is mapped to .NET System.Int16.
- Parameters:
fieldName- the name of the field to writevalue- the value of the field to write- Returns:
- this PdxInstanceFactory
- Throws:
PdxFieldAlreadyExistsException- if the named field has already been writtenPdxSerializationException- if serialization of the field fails.
-
writeInt
PdxInstanceFactory writeInt(java.lang.String fieldName, int value)
Writes the named field with the given value to the serialized form. The fields type isint.Java int is mapped to .NET System.Int32.
- Parameters:
fieldName- the name of the field to writevalue- the value of the field to write- Returns:
- this PdxInstanceFactory
- Throws:
PdxFieldAlreadyExistsException- if the named field has already been writtenPdxSerializationException- if serialization of the field fails.
-
writeLong
PdxInstanceFactory writeLong(java.lang.String fieldName, long value)
Writes the named field with the given value to the serialized form. The fields type islong.Java long is mapped to .NET System.Int64.
- Parameters:
fieldName- the name of the field to writevalue- the value of the field to write- Returns:
- this PdxInstanceFactory
- Throws:
PdxFieldAlreadyExistsException- if the named field has already been writtenPdxSerializationException- if serialization of the field fails.
-
writeFloat
PdxInstanceFactory writeFloat(java.lang.String fieldName, float value)
Writes the named field with the given value to the serialized form. The fields type isfloat.Java float is mapped to .NET System.Float.
- Parameters:
fieldName- the name of the field to writevalue- the value of the field to write- Returns:
- this PdxInstanceFactory
- Throws:
PdxFieldAlreadyExistsException- if the named field has already been writtenPdxSerializationException- if serialization of the field fails.
-
writeDouble
PdxInstanceFactory writeDouble(java.lang.String fieldName, double value)
Writes the named field with the given value to the serialized form. The fields type isdouble.Java double is mapped to .NET System.Double.
- Parameters:
fieldName- the name of the field to writevalue- the value of the field to write- Returns:
- this PdxInstanceFactory
- Throws:
PdxFieldAlreadyExistsException- if the named field has already been writtenPdxSerializationException- if serialization of the field fails.
-
writeDate
PdxInstanceFactory writeDate(java.lang.String fieldName, java.util.Date value)
Writes the named field with the given value to the serialized form. The fields type isDate.Java Date is mapped to .NET System.DateTime.
- Parameters:
fieldName- the name of the field to writevalue- the value of the field to write- Returns:
- this PdxInstanceFactory
- Throws:
PdxFieldAlreadyExistsException- if the named field has already been writtenPdxSerializationException- if serialization of the field fails.
-
writeString
PdxInstanceFactory writeString(java.lang.String fieldName, java.lang.String value)
Writes the named field with the given value to the serialized form. The fields type isString.Java String is mapped to .NET System.String.
- Parameters:
fieldName- the name of the field to writevalue- the value of the field to write- Returns:
- this PdxInstanceFactory
- Throws:
PdxFieldAlreadyExistsException- if the named field has already been writtenPdxSerializationException- if serialization of the field fails.
-
writeObject
PdxInstanceFactory writeObject(java.lang.String fieldName, java.lang.Object value)
Writes the named field with the given value to the serialized form. The fields type isObject.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 writevalue- the value of the field to write- Returns:
- this PdxInstanceFactory
- Throws:
PdxFieldAlreadyExistsException- if the named field has already been writtenPdxSerializationException- if serialization of the field fails.
-
writeObject
PdxInstanceFactory writeObject(java.lang.String fieldName, java.lang.Object value, boolean checkPortability)
Writes the named field with the given value to the serialized form. The fields type isObject.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
checkPortabilityparameter to true. The following is a list of the Java classes that are portable and the .NET class they are mapped to:- instances of
PdxSerializable: .NET class of same name - instances of
PdxInstance: .NET class of same name - instances serialized by a
PdxSerializer: .NET class of same name - java.lang.Byte: System.SByte
- java.lang.Boolean: System.Boolean
- java.lang.Character: System.Char
- java.lang.Short: System.Int16
- java.lang.Integer: System.Int32
- java.lang.Long: System.Int64
- java.lang.Float: System.Float
- java.lang.Double: System.Double
- java.lang.String: System.String
- java.util.Date: System.DateTime
- byte[]: System.Byte[]
- boolean[]: System.Boolean[]
- char[]: System.Char[]
- short[]: System.Int16[]
- int[]: System.Int32[]
- long[]: System.Int64[]
- float[]: System.Float[]
- double[]: System.Double[]
- String[]: System.String[]
- byte[][]: System.Byte[][]
- Object[]: System.Collections.Generic.List<Object>
- java.util.HashMap: System.Collections.Generics.IDictionary<Object, Object>
- java.util.Hashtable: System.Collections.Hashtable
- java.util.ArrayList: System.Collections.Generic.IList<Object>
- java.util.Vector: System.Collections.ArrayList
- java.util.HashSet: CacheableHashSet
- java.util.LinkedHashSet: CacheableLinkedHashSet
- Parameters:
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 serialized- Returns:
- this PdxInstanceFactory
- Throws:
PdxFieldAlreadyExistsException- 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.- Since:
- GemFire 6.6.2
- instances of
-
writeBooleanArray
PdxInstanceFactory writeBooleanArray(java.lang.String fieldName, boolean[] value)
Writes the named field with the given value to the serialized form. The fields type isboolean[].Java boolean[] is mapped to .NET System.Boolean[].
- Parameters:
fieldName- the name of the field to writevalue- the value of the field to write- Returns:
- this PdxInstanceFactory
- Throws:
PdxFieldAlreadyExistsException- if the named field has already been writtenPdxSerializationException- if serialization of the field fails.
-
writeCharArray
PdxInstanceFactory writeCharArray(java.lang.String fieldName, char[] value)
Writes the named field with the given value to the serialized form. The fields type ischar[].Java char[] is mapped to .NET System.Char[].
- Parameters:
fieldName- the name of the field to writevalue- the value of the field to write- Returns:
- this PdxInstanceFactory
- Throws:
PdxFieldAlreadyExistsException- if the named field has already been writtenPdxSerializationException- if serialization of the field fails.
-
writeByteArray
PdxInstanceFactory writeByteArray(java.lang.String fieldName, byte[] value)
Writes the named field with the given value to the serialized form. The fields type isbyte[].Java byte[] is mapped to .NET System.Byte[].
- Parameters:
fieldName- the name of the field to writevalue- the value of the field to write- Returns:
- this PdxInstanceFactory
- Throws:
PdxFieldAlreadyExistsException- if the named field has already been writtenPdxSerializationException- if serialization of the field fails.
-
writeShortArray
PdxInstanceFactory writeShortArray(java.lang.String fieldName, short[] value)
Writes the named field with the given value to the serialized form. The fields type isshort[].Java short[] is mapped to .NET System.Int16[].
- Parameters:
fieldName- the name of the field to writevalue- the value of the field to write- Returns:
- this PdxInstanceFactory
- Throws:
PdxFieldAlreadyExistsException- if the named field has already been writtenPdxSerializationException- if serialization of the field fails.
-
writeIntArray
PdxInstanceFactory writeIntArray(java.lang.String fieldName, int[] value)
Writes the named field with the given value to the serialized form. The fields type isint[].Java int[] is mapped to .NET System.Int32[].
- Parameters:
fieldName- the name of the field to writevalue- the value of the field to write- Returns:
- this PdxInstanceFactory
- Throws:
PdxFieldAlreadyExistsException- if the named field has already been writtenPdxSerializationException- if serialization of the field fails.
-
writeLongArray
PdxInstanceFactory writeLongArray(java.lang.String fieldName, long[] value)
Writes the named field with the given value to the serialized form. The fields type islong[].Java long[] is mapped to .NET System.Int64[].
- Parameters:
fieldName- the name of the field to writevalue- the value of the field to write- Returns:
- this PdxInstanceFactory
- Throws:
PdxFieldAlreadyExistsException- if the named field has already been writtenPdxSerializationException- if serialization of the field fails.
-
writeFloatArray
PdxInstanceFactory writeFloatArray(java.lang.String fieldName, float[] value)
Writes the named field with the given value to the serialized form. The fields type isfloat[].Java float[] is mapped to .NET System.Float[].
- Parameters:
fieldName- the name of the field to writevalue- the value of the field to write- Returns:
- this PdxInstanceFactory
- Throws:
PdxFieldAlreadyExistsException- if the named field has already been writtenPdxSerializationException- if serialization of the field fails.
-
writeDoubleArray
PdxInstanceFactory writeDoubleArray(java.lang.String fieldName, double[] value)
Writes the named field with the given value to the serialized form. The fields type isdouble[].Java double[] is mapped to .NET System.Double[].
- Parameters:
fieldName- the name of the field to writevalue- the value of the field to write- Returns:
- this PdxInstanceFactory
- Throws:
PdxFieldAlreadyExistsException- if the named field has already been writtenPdxSerializationException- if serialization of the field fails.
-
writeStringArray
PdxInstanceFactory writeStringArray(java.lang.String fieldName, java.lang.String[] value)
Writes the named field with the given value to the serialized form. The fields type isString[].Java String[] is mapped to .NET System.String[].
- Parameters:
fieldName- the name of the field to writevalue- the value of the field to write- Returns:
- this PdxInstanceFactory
- Throws:
PdxFieldAlreadyExistsException- if the named field has already been writtenPdxSerializationException- if serialization of the field fails.
-
writeObjectArray
PdxInstanceFactory writeObjectArray(java.lang.String fieldName, java.lang.Object[] value)
Writes the named field with the given value to the serialized form. The fields type isObject[].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 usewriteObjectArray(String, Object[], boolean).- Parameters:
fieldName- the name of the field to writevalue- the value of the field to write- Returns:
- this PdxInstanceFactory
- Throws:
PdxFieldAlreadyExistsException- if the named field has already been writtenPdxSerializationException- if serialization of the field fails.
-
writeObjectArray
PdxInstanceFactory writeObjectArray(java.lang.String fieldName, java.lang.Object[] value, boolean checkPortability)
Writes the named field with the given value to the serialized form. The fields type isObject[].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 usewriteObjectArray(String, Object[], boolean).- Parameters:
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 serialized- Returns:
- this PdxInstanceFactory
- Throws:
PdxFieldAlreadyExistsException- 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.- Since:
- GemFire 6.6.2
-
writeArrayOfByteArrays
PdxInstanceFactory writeArrayOfByteArrays(java.lang.String fieldName, byte[][] value)
Writes the named field with the given value to the serialized form. The fields type isbyte[][].Java byte[][] is mapped to .NET System.Byte[][].
- Parameters:
fieldName- the name of the field to writevalue- the value of the field to write- Returns:
- this PdxInstanceFactory
- Throws:
PdxFieldAlreadyExistsException- if the named field has already been writtenPdxSerializationException- if serialization of the field fails.
-
writeField
<CT,VT extends CT> PdxInstanceFactory writeField(java.lang.String fieldName, VT fieldValue, java.lang.Class<CT> fieldType)
Writes the named field with the given value and type to the serialized form. This method uses thefieldTypeto determine which writeXXX method it should call. If it can not find a specific match to a writeXXX method it will callwriteObject. 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 usewriteField(String, Object, Class, boolean)instead.The fieldTypes that map to a specific method are:
- boolean.class:
writeBoolean(java.lang.String, boolean) - byte.class:
writeByte(java.lang.String, byte) - char.class:
writeChar(java.lang.String, char) - short.class:
writeShort(java.lang.String, short) - int.class:
writeInt(java.lang.String, int) - long.class:
writeLong(java.lang.String, long) - float.class:
writeFloat(java.lang.String, float) - double.class:
writeDouble(java.lang.String, double) - String.class:
writeString(java.lang.String, java.lang.String) - Date.class:
writeDate(java.lang.String, java.util.Date) - boolean[].class:
writeBooleanArray(java.lang.String, boolean[]) - byte[].class:
writeByteArray(java.lang.String, byte[]) - char[].class:
writeCharArray(java.lang.String, char[]) - short[].class:
writeShortArray(java.lang.String, short[]) - int[].class:
writeIntArray(java.lang.String, int[]) - long[].class:
writeLongArray(java.lang.String, long[]) - float[].class:
writeFloatArray(java.lang.String, float[]) - double[].class:
writeDoubleArray(java.lang.String, double[]) - String[].class:
writeStringArray(java.lang.String, java.lang.String[]) - byte[][].class:
writeArrayOfByteArrays(java.lang.String, byte[][]) - any other array class:
writeObjectArray(java.lang.String, java.lang.Object[])
writeObject.- Type Parameters:
CT- the type associated with the class of the field to writeVT- the type associated with the value of the field to write- Parameters:
fieldName- the name of the field to writefieldValue- the value of the field to write; this parameter's class must extend thefieldTypefieldType- the type of the field to write- Returns:
- this PdxInstanceFactory
- Throws:
PdxFieldAlreadyExistsException- if the named field has already been writtenPdxSerializationException- if serialization of the field fails.
- boolean.class:
-
writeField
<CT,VT extends CT> PdxInstanceFactory writeField(java.lang.String fieldName, VT fieldValue, java.lang.Class<CT> fieldType, boolean checkPortability)
Writes the named field with the given value and type to the serialized form. This method uses thefieldTypeto determine which writeXXX method it should call. If it can not find a specific match to a writeXXX method it will callwriteObject. To ensure that only objects that are portable to non-java languages are serialized set thecheckPortabilityparameter to true.The fieldTypes that map to a specific method are:
- boolean.class:
writeBoolean(java.lang.String, boolean) - byte.class:
writeByte(java.lang.String, byte) - char.class:
writeChar(java.lang.String, char) - short.class:
writeShort(java.lang.String, short) - int.class:
writeInt(java.lang.String, int) - long.class:
writeLong(java.lang.String, long) - float.class:
writeFloat(java.lang.String, float) - double.class:
writeDouble(java.lang.String, double) - String.class:
writeString(java.lang.String, java.lang.String) - Date.class:
writeDate(java.lang.String, java.util.Date) - boolean[].class:
writeBooleanArray(java.lang.String, boolean[]) - byte[].class:
writeByteArray(java.lang.String, byte[]) - char[].class:
writeCharArray(java.lang.String, char[]) - short[].class:
writeShortArray(java.lang.String, short[]) - int[].class:
writeIntArray(java.lang.String, int[]) - long[].class:
writeLongArray(java.lang.String, long[]) - float[].class:
writeFloatArray(java.lang.String, float[]) - double[].class:
writeDoubleArray(java.lang.String, double[]) - String[].class:
writeStringArray(java.lang.String, java.lang.String[]) - byte[][].class:
writeArrayOfByteArrays(java.lang.String, byte[][]) - any other array class:
writeObjectArray(String, Object[], boolean)
writeObject.- Type Parameters:
CT- the type associated with the class of the field to writeVT- the type associated with the value of the field to write- Parameters:
fieldName- the name of the field to writefieldValue- the value of the field to write; this parameter's class must extend thefieldTypefieldType- the type of the field to writecheckPortability- if true then an exception is thrown if a non-portable object is serialized- Returns:
- this PdxInstanceFactory
- Throws:
PdxFieldAlreadyExistsException- 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.- Since:
- GemFire 6.6.2
- boolean.class:
-
markIdentityField
PdxInstanceFactory markIdentityField(java.lang.String fieldName)
Indicate that the named field should be included in hashCode and equals checks of this object on a server that is accessingPdxInstanceor 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 ofPdxInstance. 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.- Parameters:
fieldName- the name of the field to mark as an identity field.- Returns:
- this PdxInstanceFactory
- Throws:
PdxFieldDoesNotExistException- if the named field has not already been written.
-
neverDeserialize
PdxInstanceFactory neverDeserialize()
The instance created by this factory will be one that is never deserialized to a domain class. It will always be a PdxInstance.- Returns:
- this PdxInstanceFactory
- Since:
- Geode 1.9
-
-