org.datanucleus.store.mapped.mapping
Class SingleFieldMapping

java.lang.Object
  extended by org.datanucleus.store.mapped.mapping.JavaTypeMapping
      extended by org.datanucleus.store.mapped.mapping.SingleFieldMapping
Direct Known Subclasses:
AbstractContainerMapping, BigDecimalMapping, BigIntegerMapping, BitSetMapping, BooleanMapping, BufferedImageMapping, ByteMapping, CharacterMapping, DiscriminatorMapping, DoubleMapping, EmbeddedMapping, EnumMapping, FloatMapping, IndexMapping, IntegerMapping, LongMapping, NullMapping, NumberMapping, ObjectAsIntegerMapping, ObjectAsLongMapping, ObjectAsStringMapping, ObjectAsTimestampMapping, OIDMapping, SerialisedMapping, ShortMapping, StringMapping, TemporalMapping, VersionMapping

public abstract class SingleFieldMapping
extends JavaTypeMapping

Simple mapping for a java field mapping to a single datastore field.


Field Summary
 
Fields inherited from class org.datanucleus.store.mapped.mapping.JavaTypeMapping
datastoreContainer, datastoreMappings, LOCALISER, mmd, referenceMapping, roleForMember, storeMgr, type
 
Constructor Summary
SingleFieldMapping()
           
 
Method Summary
 boolean equals(java.lang.Object obj)
          Equality operator
 boolean getBoolean(ObjectManager om, java.lang.Object resultSet, int[] exprIndex)
          Obtains a value from datastoreResults at position specified by exprIndex.
 byte getByte(ObjectManager om, java.lang.Object resultSet, int[] exprIndex)
          Obtains a value from datastoreResults at position specified by exprIndex.
 char getChar(ObjectManager om, java.lang.Object resultSet, int[] exprIndex)
          Obtains a value from datastoreResults at position specified by exprIndex.
 int getDefaultLength(int index)
          Accessor for the default length for this type in the datastore (if applicable).
 double getDouble(ObjectManager om, java.lang.Object resultSet, int[] exprIndex)
          Obtains a value from datastoreResults at position specified by exprIndex.
 float getFloat(ObjectManager om, java.lang.Object resultSet, int[] exprIndex)
          Obtains a value from datastoreResults at position specified by exprIndex.
 int getInt(ObjectManager om, java.lang.Object resultSet, int[] exprIndex)
          Obtains a value from datastoreResults at position specified by exprIndex.
 java.lang.String getJavaTypeForDatastoreMapping(int index)
          Accessor for the name of the java-type actually used when mapping the particular datastore field.
 long getLong(ObjectManager om, java.lang.Object resultSet, int[] exprIndex)
          Obtains a value from datastoreResults at position specified by exprIndex.
 java.lang.Object getObject(ObjectManager om, java.lang.Object resultSet, int[] exprIndex)
          Obtains a value from datastoreResults at position specified by exprIndex.
 short getShort(ObjectManager om, java.lang.Object resultSet, int[] exprIndex)
          Obtains a value from datastoreResults at position specified by exprIndex.
 java.lang.String getString(ObjectManager om, java.lang.Object resultSet, int[] exprIndex)
          Obtains a value from datastoreResults at position specified by exprIndex.
 java.lang.Object[] getValidValues(int index)
          Accessor for an array of valid values that this type can take.
 void initialize(AbstractMemberMetaData fmd, DatastoreContainerObject container, ClassLoaderResolver clr)
          Initialize this JavaTypeMapping with the given DatastoreAdapter for the given FieldMetaData.
protected  void prepareDatastoreMapping()
          Method to prepare a field mapping for use in the datastore.
 void setBoolean(ObjectManager om, java.lang.Object preparedStatement, int[] exprIndex, boolean value)
          Sets a value into datastoreStatement at position specified by exprIndex.
 void setByte(ObjectManager om, java.lang.Object preparedStatement, int[] exprIndex, byte value)
          Sets a value into datastoreStatement at position specified by exprIndex.
 void setChar(ObjectManager om, java.lang.Object preparedStatement, int[] exprIndex, char value)
          Sets a value into datastoreStatement at position specified by exprIndex.
 void setDouble(ObjectManager om, java.lang.Object preparedStatement, int[] exprIndex, double value)
          Sets a value into datastoreStatement at position specified by exprIndex.
 void setFloat(ObjectManager om, java.lang.Object preparedStatement, int[] exprIndex, float value)
          Sets a value into datastoreStatement at position specified by exprIndex.
 void setInt(ObjectManager om, java.lang.Object preparedStatement, int[] exprIndex, int value)
          Sets a value into datastoreStatement at position specified by exprIndex.
 void setLong(ObjectManager om, java.lang.Object preparedStatement, int[] exprIndex, long value)
          Sets a value into datastoreStatement at position specified by exprIndex.
 void setObject(ObjectManager om, java.lang.Object preparedStatement, int[] exprIndex, java.lang.Object value)
          Sets a value into datastoreStatement at position specified by exprIndex.
 void setShort(ObjectManager om, java.lang.Object preparedStatement, int[] exprIndex, short value)
          Sets a value into datastoreStatement at position specified by exprIndex.
 void setString(ObjectManager om, java.lang.Object preparedStatement, int[] exprIndex, java.lang.String value)
          Sets a value into datastoreStatement at position specified by exprIndex.
 
Methods inherited from class org.datanucleus.store.mapped.mapping.JavaTypeMapping
addDatastoreMapping, failureMessage, getColumnMetaDataForMember, getDatastoreContainer, getDatastoreMapping, getDatastoreMappings, getJavaType, getMemberMetaData, getNumberOfDatastoreMappings, getObject, getReferenceMapping, getRoleForMember, getSampleValue, getType, getValueForDatastoreMapping, hashCode, hasSimpleDatastoreRepresentation, includeInFetchStatement, includeInInsertStatement, includeInUpdateStatement, initialize, isNullable, isSerialised, newLiteral, newScalarExpression, setDatastoreContainer, setDefault, setMemberMetaData, setObject, setReferenceMapping, setRoleForMember
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SingleFieldMapping

public SingleFieldMapping()
Method Detail

initialize

public void initialize(AbstractMemberMetaData fmd,
                       DatastoreContainerObject container,
                       ClassLoaderResolver clr)
Initialize this JavaTypeMapping with the given DatastoreAdapter for the given FieldMetaData.

Overrides:
initialize in class JavaTypeMapping
Parameters:
container - The datastore container storing this mapping (if any)
clr - the ClassLoaderResolver
fmd - FieldMetaData for the field to be mapped (if any)

prepareDatastoreMapping

protected void prepareDatastoreMapping()
Method to prepare a field mapping for use in the datastore. This creates the column in the table.


getDefaultLength

public int getDefaultLength(int index)
Accessor for the default length for this type in the datastore (if applicable).

Parameters:
index - requested datastore field index.
Returns:
Default length

getValidValues

public java.lang.Object[] getValidValues(int index)
Accessor for an array of valid values that this type can take. This can be used at the datastore side for restricting the values to be inserted.

Parameters:
index - requested datastore field index.
Returns:
The valid values

getJavaTypeForDatastoreMapping

public java.lang.String getJavaTypeForDatastoreMapping(int index)
Accessor for the name of the java-type actually used when mapping the particular datastore field. This java-type must have an entry in the datastore mappings.

Overrides:
getJavaTypeForDatastoreMapping in class JavaTypeMapping
Parameters:
index - requested datastore field index.
Returns:
the name of java-type for the requested datastore field.

equals

public boolean equals(java.lang.Object obj)
Equality operator

Overrides:
equals in class JavaTypeMapping
Parameters:
obj - The object to compare with
Returns:
Whether the objects are equal

setBoolean

public void setBoolean(ObjectManager om,
                       java.lang.Object preparedStatement,
                       int[] exprIndex,
                       boolean value)
Description copied from class: JavaTypeMapping
Sets a value into datastoreStatement at position specified by exprIndex.

Overrides:
setBoolean in class JavaTypeMapping
Parameters:
om - the ObjectManager
preparedStatement - a datastore object that executes statements in the database
exprIndex - the position of the value in the statement
value - the value

getBoolean

public boolean getBoolean(ObjectManager om,
                          java.lang.Object resultSet,
                          int[] exprIndex)
Description copied from class: JavaTypeMapping
Obtains a value from datastoreResults at position specified by exprIndex.

Overrides:
getBoolean in class JavaTypeMapping
Parameters:
om - the ObjectManager
resultSet - an object returned from the datastore with values
exprIndex - the position of the value in the result
Returns:
the value

setChar

public void setChar(ObjectManager om,
                    java.lang.Object preparedStatement,
                    int[] exprIndex,
                    char value)
Description copied from class: JavaTypeMapping
Sets a value into datastoreStatement at position specified by exprIndex.

Overrides:
setChar in class JavaTypeMapping
Parameters:
om - the ObjectManager
preparedStatement - a datastore object that executes statements in the database
exprIndex - the position of the value in the statement
value - the value

getChar

public char getChar(ObjectManager om,
                    java.lang.Object resultSet,
                    int[] exprIndex)
Description copied from class: JavaTypeMapping
Obtains a value from datastoreResults at position specified by exprIndex.

Overrides:
getChar in class JavaTypeMapping
Parameters:
om - the ObjectManager
resultSet - an object returned from the datastore with values
exprIndex - the position of the value in the result
Returns:
the value

setByte

public void setByte(ObjectManager om,
                    java.lang.Object preparedStatement,
                    int[] exprIndex,
                    byte value)
Description copied from class: JavaTypeMapping
Sets a value into datastoreStatement at position specified by exprIndex.

Overrides:
setByte in class JavaTypeMapping
Parameters:
om - the ObjectManager
preparedStatement - a datastore object that executes statements in the database
exprIndex - the position of the value in the statement
value - the value

getByte

public byte getByte(ObjectManager om,
                    java.lang.Object resultSet,
                    int[] exprIndex)
Description copied from class: JavaTypeMapping
Obtains a value from datastoreResults at position specified by exprIndex.

Overrides:
getByte in class JavaTypeMapping
Parameters:
om - the ObjectManager
resultSet - an object returned from the datastore with values
exprIndex - the position of the value in the result
Returns:
the value

setShort

public void setShort(ObjectManager om,
                     java.lang.Object preparedStatement,
                     int[] exprIndex,
                     short value)
Description copied from class: JavaTypeMapping
Sets a value into datastoreStatement at position specified by exprIndex.

Overrides:
setShort in class JavaTypeMapping
Parameters:
om - the ObjectManager
preparedStatement - a datastore object that executes statements in the database
exprIndex - the position of the value in the statement
value - the value

getShort

public short getShort(ObjectManager om,
                      java.lang.Object resultSet,
                      int[] exprIndex)
Description copied from class: JavaTypeMapping
Obtains a value from datastoreResults at position specified by exprIndex.

Overrides:
getShort in class JavaTypeMapping
Parameters:
om - the ObjectManager
resultSet - an object returned from the datastore with values
exprIndex - the position of the value in the result
Returns:
the value

setInt

public void setInt(ObjectManager om,
                   java.lang.Object preparedStatement,
                   int[] exprIndex,
                   int value)
Description copied from class: JavaTypeMapping
Sets a value into datastoreStatement at position specified by exprIndex.

Overrides:
setInt in class JavaTypeMapping
Parameters:
om - the ObjectManager
preparedStatement - a datastore object that executes statements in the database
exprIndex - the position of the value in the statement
value - the value

getInt

public int getInt(ObjectManager om,
                  java.lang.Object resultSet,
                  int[] exprIndex)
Description copied from class: JavaTypeMapping
Obtains a value from datastoreResults at position specified by exprIndex.

Overrides:
getInt in class JavaTypeMapping
Parameters:
om - the ObjectManager
resultSet - an object returned from the datastore with values
exprIndex - the position of the value in the result
Returns:
the value

setLong

public void setLong(ObjectManager om,
                    java.lang.Object preparedStatement,
                    int[] exprIndex,
                    long value)
Description copied from class: JavaTypeMapping
Sets a value into datastoreStatement at position specified by exprIndex.

Overrides:
setLong in class JavaTypeMapping
Parameters:
om - the ObjectManager
preparedStatement - a datastore object that executes statements in the database
exprIndex - the position of the value in the statement
value - the value

getLong

public long getLong(ObjectManager om,
                    java.lang.Object resultSet,
                    int[] exprIndex)
Description copied from class: JavaTypeMapping
Obtains a value from datastoreResults at position specified by exprIndex.

Overrides:
getLong in class JavaTypeMapping
Parameters:
om - the ObjectManager
resultSet - an object returned from the datastore with values
exprIndex - the position of the value in the result
Returns:
the value

setFloat

public void setFloat(ObjectManager om,
                     java.lang.Object preparedStatement,
                     int[] exprIndex,
                     float value)
Description copied from class: JavaTypeMapping
Sets a value into datastoreStatement at position specified by exprIndex.

Overrides:
setFloat in class JavaTypeMapping
Parameters:
om - the ObjectManager
preparedStatement - a datastore object that executes statements in the database
exprIndex - the position of the value in the statement
value - the value

getFloat

public float getFloat(ObjectManager om,
                      java.lang.Object resultSet,
                      int[] exprIndex)
Description copied from class: JavaTypeMapping
Obtains a value from datastoreResults at position specified by exprIndex.

Overrides:
getFloat in class JavaTypeMapping
Parameters:
om - the ObjectManager
resultSet - an object returned from the datastore with values
exprIndex - the position of the value in the result
Returns:
the value

setDouble

public void setDouble(ObjectManager om,
                      java.lang.Object preparedStatement,
                      int[] exprIndex,
                      double value)
Description copied from class: JavaTypeMapping
Sets a value into datastoreStatement at position specified by exprIndex.

Overrides:
setDouble in class JavaTypeMapping
Parameters:
om - the ObjectManager
preparedStatement - a datastore object that executes statements in the database
exprIndex - the position of the value in the statement
value - the value

getDouble

public double getDouble(ObjectManager om,
                        java.lang.Object resultSet,
                        int[] exprIndex)
Description copied from class: JavaTypeMapping
Obtains a value from datastoreResults at position specified by exprIndex.

Overrides:
getDouble in class JavaTypeMapping
Parameters:
om - the ObjectManager
resultSet - an object returned from the datastore with values
exprIndex - the position of the value in the result
Returns:
the value

setString

public void setString(ObjectManager om,
                      java.lang.Object preparedStatement,
                      int[] exprIndex,
                      java.lang.String value)
Description copied from class: JavaTypeMapping
Sets a value into datastoreStatement at position specified by exprIndex.

Overrides:
setString in class JavaTypeMapping
Parameters:
om - the ObjectManager
preparedStatement - a datastore object that executes statements in the database
exprIndex - the position of the value in the statement
value - the value

getString

public java.lang.String getString(ObjectManager om,
                                  java.lang.Object resultSet,
                                  int[] exprIndex)
Description copied from class: JavaTypeMapping
Obtains a value from datastoreResults at position specified by exprIndex.

Overrides:
getString in class JavaTypeMapping
Parameters:
om - the ObjectManager
resultSet - an object returned from the datastore with values
exprIndex - the position of the value in the result
Returns:
the value

setObject

public void setObject(ObjectManager om,
                      java.lang.Object preparedStatement,
                      int[] exprIndex,
                      java.lang.Object value)
Description copied from class: JavaTypeMapping
Sets a value into datastoreStatement at position specified by exprIndex.

Overrides:
setObject in class JavaTypeMapping
Parameters:
om - the ObjectManager
preparedStatement - a datastore object that executes statements in the database
exprIndex - the position of the value in the statement
value - the value

getObject

public java.lang.Object getObject(ObjectManager om,
                                  java.lang.Object resultSet,
                                  int[] exprIndex)
Description copied from class: JavaTypeMapping
Obtains a value from datastoreResults at position specified by exprIndex.

Overrides:
getObject in class JavaTypeMapping
Parameters:
om - the ObjectManager
resultSet - an object returned from the datastore with values
exprIndex - the position of the value in the result
Returns:
the value


Copyright © 2010. All Rights Reserved.