Package org.apache.geode.pdx
Interface PdxReader
public interface PdxReader
A PdxReader will be passed to
fromData or
PdxSerializer fromData by GemFire during
deserialization of a PDX. The domain class needs to deserialize field members using this
interface. This interface is implemented by GemFire. Each readXXX call will return the field's
value. If the serialized PDX does not contain the named field then a default value will be
returned. Standard Java defaults are used. For Objects this is null and for
primitives it is 0 or 0.0.
You must read fields in the same order they were written by PdxWriter.
The methods on this interface are not thread safe so do not call them concurrently, on the same instance, from more than one thread.
- Since:
- GemFire 6.6
-
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if the named field exists and returns the result.booleanisIdentityField(String fieldName) Checks if the named field wasmarkedas an identity field.byte[][]readArrayOfByteArrays(String fieldName) Reads the named field and returns its value.booleanreadBoolean(String fieldName) Reads the named field and returns its value.boolean[]readBooleanArray(String fieldName) Reads the named field and returns its value.byteReads the named field and returns its value.byte[]readByteArray(String fieldName) Reads the named field and returns its value.charReads the named field and returns its value.char[]readCharArray(String fieldName) Reads the named field and returns its value.Reads the named field and returns its value.doublereadDouble(String fieldName) Reads the named field and returns its value.double[]readDoubleArray(String fieldName) Reads the named field and returns its value.Reads the named field and returns its value.floatReads the named field and returns its value.float[]readFloatArray(String fieldName) Reads the named field and returns its value.intReads the named field and returns its value.int[]readIntArray(String fieldName) Reads the named field and returns its value.longReads the named field and returns its value.long[]readLongArray(String fieldName) Reads the named field and returns its value.readObject(String fieldName) Reads the named field and returns its value.Object[]readObjectArray(String fieldName) Reads the named field and returns its value.shortReads the named field and returns its value.short[]readShortArray(String fieldName) Reads the named field and returns its value.readString(String fieldName) Reads the named field and returns its value.String[]readStringArray(String fieldName) Reads the named field and returns its value.This method returns an object that represents all the unread fields which must be passed towriteUnreadFieldsin the toData code.
-
Method Details
-
readChar
Reads the named field and returns its value.- Parameters:
fieldName- the name of the field to read- Returns:
- the value of the field if the field exists; otherwise a default value
- Throws:
PdxFieldTypeMismatchException- if the named field exists and is not acharfield.PdxSerializationException- if deserialization of the field fails.
-
readBoolean
Reads the named field and returns its value.- Parameters:
fieldName- the name of the field to read- Returns:
- the value of the field if the field exists; otherwise a default value
- Throws:
PdxFieldTypeMismatchException- if the named field exists and is not abooleanfield.PdxSerializationException- if deserialization of the field fails.
-
readByte
Reads the named field and returns its value.- Parameters:
fieldName- the name of the field to read- Returns:
- the value of the field if the field exists; otherwise a default value
- Throws:
PdxFieldTypeMismatchException- if the named field exists and is not abytefield.PdxSerializationException- if deserialization of the field fails.
-
readShort
Reads the named field and returns its value.- Parameters:
fieldName- the name of the field to read- Returns:
- the value of the field if the field exists; otherwise a default value
- Throws:
PdxFieldTypeMismatchException- if the named field exists and is not ashortfield.PdxSerializationException- if deserialization of the field fails.
-
readInt
Reads the named field and returns its value.- Parameters:
fieldName- the name of the field to read- Returns:
- the value of the field if the field exists; otherwise a default value
- Throws:
PdxFieldTypeMismatchException- if the named field exists and is not aintfield.PdxSerializationException- if deserialization of the field fails.
-
readLong
Reads the named field and returns its value.- Parameters:
fieldName- the name of the field to read- Returns:
- the value of the field if the field exists; otherwise a default value
- Throws:
PdxFieldTypeMismatchException- if the named field exists and is not alongfield.PdxSerializationException- if deserialization of the field fails.
-
readFloat
Reads the named field and returns its value.- Parameters:
fieldName- the name of the field to read- Returns:
- the value of the field if the field exists; otherwise a default value
- Throws:
PdxFieldTypeMismatchException- if the named field exists and is not afloatfield.PdxSerializationException- if deserialization of the field fails.
-
readDouble
Reads the named field and returns its value.- Parameters:
fieldName- the name of the field to read- Returns:
- the value of the field if the field exists; otherwise a default value
- Throws:
PdxFieldTypeMismatchException- if the named field exists and is not adoublefield.PdxSerializationException- if deserialization of the field fails.
-
readString
Reads the named field and returns its value.- Parameters:
fieldName- the name of the field to read- Returns:
- the value of the field if the field exists; otherwise a default value
- Throws:
PdxFieldTypeMismatchException- if the named field exists and is not aStringfield.PdxSerializationException- if deserialization of the field fails.
-
readObject
Reads the named field and returns its value.- Parameters:
fieldName- the name of the field to read- Returns:
- the value of the field if the field exists; otherwise a default value
- Throws:
PdxSerializationException- if deserialization of the field fails.PdxFieldTypeMismatchException- if the named field exists and is not anObjectfield.
-
readCharArray
Reads the named field and returns its value.- Parameters:
fieldName- the name of the field to read- Returns:
- the value of the field if the field exists; otherwise a default value
- Throws:
PdxSerializationException- if deserialization of the field fails.PdxFieldTypeMismatchException- if the named field exists and is not achar[]field.
-
readBooleanArray
Reads the named field and returns its value.- Parameters:
fieldName- the name of the field to read- Returns:
- the value of the field if the field exists; otherwise a default value
- Throws:
PdxSerializationException- if deserialization of the field fails.PdxFieldTypeMismatchException- if the named field exists and is not aboolean[]field.
-
readByteArray
Reads the named field and returns its value.- Parameters:
fieldName- the name of the field to read- Returns:
- the value of the field if the field exists; otherwise a default value
- Throws:
PdxSerializationException- if deserialization of the field fails.PdxFieldTypeMismatchException- if the named field exists and is not abyte[]field.
-
readShortArray
Reads the named field and returns its value.- Parameters:
fieldName- the name of the field to read- Returns:
- the value of the field if the field exists; otherwise a default value
- Throws:
PdxSerializationException- if deserialization of the field fails.PdxFieldTypeMismatchException- if the named field exists and is not ashort[]field.
-
readIntArray
Reads the named field and returns its value.- Parameters:
fieldName- the name of the field to read- Returns:
- the value of the field if the field exists; otherwise a default value
- Throws:
PdxSerializationException- if deserialization of the field fails.PdxFieldTypeMismatchException- if the named field exists and is not aint[]field.
-
readLongArray
Reads the named field and returns its value.- Parameters:
fieldName- the name of the field to read- Returns:
- the value of the field if the field exists; otherwise a default value
- Throws:
PdxSerializationException- if deserialization of the field fails.PdxFieldTypeMismatchException- if the named field exists and is not along[]field.
-
readFloatArray
Reads the named field and returns its value.- Parameters:
fieldName- the name of the field to read- Returns:
- the value of the field if the field exists; otherwise a default value
- Throws:
PdxSerializationException- if deserialization of the field fails.PdxFieldTypeMismatchException- if the named field exists and is not afloat[]field.
-
readDoubleArray
Reads the named field and returns its value.- Parameters:
fieldName- the name of the field to read- Returns:
- the value of the field if the field exists; otherwise a default value
- Throws:
PdxSerializationException- if deserialization of the field fails.PdxFieldTypeMismatchException- if the named field exists and is not adouble[]field.
-
readStringArray
Reads the named field and returns its value.- Parameters:
fieldName- the name of the field to read- Returns:
- the value of the field if the field exists; otherwise a default value
- Throws:
PdxSerializationException- if deserialization of the field fails.PdxFieldTypeMismatchException- if the named field exists and is not aString[]field.
-
readObjectArray
Reads the named field and returns its value.- Parameters:
fieldName- the name of the field to read- Returns:
- the value of the field if the field exists; otherwise a default value
- Throws:
PdxSerializationException- if deserialization of the field fails.PdxFieldTypeMismatchException- if the named field exists and is not aObject[]field.
-
readArrayOfByteArrays
Reads the named field and returns its value.- Parameters:
fieldName- the name of the field to read- Returns:
- the value of the field if the field exists; otherwise a default value
- Throws:
PdxSerializationException- if deserialization of the field fails.PdxFieldTypeMismatchException- if the named field exists and is not abyte[][]field.
-
readDate
Reads the named field and returns its value.- Parameters:
fieldName- the name of the field to read- Returns:
- the value of the field if the field exists; otherwise a default value
- Throws:
PdxSerializationException- if deserialization of the field fails.PdxFieldTypeMismatchException- if the named field exists and is not aDatefield.
-
hasField
Checks if the named field exists and returns the result.This can be useful when writing code that handles more than one version of a PDX class.
- Parameters:
fieldName- the name of the field to check- Returns:
trueif the named field exists; otherwisefalse
-
isIdentityField
Checks if the named field wasmarkedas an identity field.Note that if no fields have been marked then all the fields are used as identity fields even though this method will return
falsesince none of them have been marked.- Parameters:
fieldName- the name of the field to check- Returns:
trueif the named field exists and was marked as an identify field; otherwisefalse
-
readField
Reads the named field and returns its value.- Parameters:
fieldName- the name of the field to read- Returns:
- the value of the field if the field exists; otherwise a default value
- Throws:
PdxSerializationException- if deserialization of the field fails.
-
readUnreadFields
PdxUnreadFields readUnreadFields()This method returns an object that represents all the unread fields which must be passed towriteUnreadFieldsin the toData code.Note that if
setPdxIgnoreUnreadFieldsorclient setPdxIgnoreUnreadFieldsare set totruethen this method will always return an object that has no unread fields.- Returns:
- an object that represents the unread fields.
-