|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jpox.store.mapping.JavaTypeMapping
public abstract class JavaTypeMapping
Representation of the mapping of a Java type. The java type maps to one or more datastore mappings. This means that a field in a java class can be mapped to many columns in a table (in an RDBMS). A JavaTypeMapping can exist in 2 forms
| Field Summary | |
|---|---|
protected DatastoreContainerObject |
datastoreContainer
The Datastore Container storing this mapping. |
protected DatastoreMapping[] |
datastoreMappings
The Datastore mappings for this Java type. |
protected DatastoreAdapter |
dba
Adapter for the datastore being used. |
protected AbstractPropertyMetaData |
fmd
The field definition, when the type relates specifically to a field. |
protected static Localiser |
LOCALISER
Localiser for messages |
protected JavaTypeMapping |
referenceMapping
Mapping of the reference on the end of the association - Only used when this mapping does not have datastore fields, but the other side of the association has |
protected java.lang.String |
type
Actual type being mapped |
| Constructor Summary | |
|---|---|
protected |
JavaTypeMapping()
Create a new empty JavaTypeMapping. |
protected |
JavaTypeMapping(DatastoreAdapter dba,
java.lang.String type,
AbstractPropertyMetaData fmd,
DatastoreContainerObject container)
Create a new Mapping with the given DatastoreAdapter for the given type. |
| Method Summary | |
|---|---|
void |
addDataStoreMapping(DatastoreMapping datastoreMapping)
Method to add a datastore mapping |
protected java.lang.String |
failureMessage(java.lang.String method)
Utility to output any error message. |
boolean |
getBoolean(PersistenceManager pm,
java.lang.Object datastoreResults,
int[] exprIndex)
Obtains a value from datastoreResults
at position specified by exprIndex. |
byte |
getByte(PersistenceManager pm,
java.lang.Object datastoreResults,
int[] exprIndex)
Obtains a value from datastoreResults
at position specified by exprIndex. |
char |
getChar(PersistenceManager pm,
java.lang.Object datastoreResults,
int[] exprIndex)
Obtains a value from datastoreResults
at position specified by exprIndex. |
DatastoreContainerObject |
getDatastoreContainer()
Accessor for the datastore class (e.g in an RDBMS context, the Table). |
DatastoreMapping |
getDataStoreMapping(int index)
Accessor for a datastore mapping |
DatastoreMapping[] |
getDataStoreMappings()
Accessor for the datastore mappings for this java type |
double |
getDouble(PersistenceManager pm,
java.lang.Object datastoreResults,
int[] exprIndex)
Obtains a value from datastoreResults
at position specified by exprIndex. |
AbstractPropertyMetaData |
getFieldMetaData()
Accessor for the FieldMetaData of the field to be mapped. |
float |
getFloat(PersistenceManager pm,
java.lang.Object datastoreResults,
int[] exprIndex)
Obtains a value from datastoreResults
at position specified by exprIndex. |
int |
getInt(PersistenceManager pm,
java.lang.Object datastoreResults,
int[] exprIndex)
Obtains a value from datastoreResults
at position specified by exprIndex. |
abstract java.lang.Class |
getJavaType()
Accessor for the java type being mapped. |
java.lang.String |
getJavaTypeForDatastoreMapping(int index)
Accessor for the name of the java-type actually used when mapping the particular datastore field. |
long |
getLong(PersistenceManager pm,
java.lang.Object datastoreResults,
int[] exprIndex)
Obtains a value from datastoreResults
at position specified by exprIndex. |
int |
getNumberOfDatastoreFields()
Acessor for the number of datastore fields (e.g. |
java.lang.Object |
getObject(PersistenceManager pm,
java.lang.Object datastoreResults,
int[] exprIndex)
Obtains a value from datastoreResults
at position specified by exprIndex. |
java.lang.Object |
getObject(PersistenceManager pm,
java.lang.Object datastoreResults,
int[] exprIndex,
StateManager ownerSM,
int ownerFieldNumber)
Obtains a value from datastoreResults
at position specified by exprIndex. |
JavaTypeMapping |
getReferenceMapping()
Accessor for the mapping at the other end of a relation when this field is part of a 1-1, 1-N, M-N relation. |
abstract java.lang.Object |
getSampleValue(ClassLoaderResolver clr)
Return a sample value of the mapping type to be used for internal evaluation of type and conversion. |
short |
getShort(PersistenceManager pm,
java.lang.Object datastoreResults,
int[] exprIndex)
Obtains a value from datastoreResults
at position specified by exprIndex. |
java.lang.String |
getString(PersistenceManager pm,
java.lang.Object datastoreResults,
int[] exprIndex)
Obtains a value from datastoreResults
at position specified by exprIndex. |
java.lang.String |
getType()
Accessor for the class name of the object that is being mapped here. |
boolean |
includeInFetchStatement()
Accessor for whether this mapping is to be included in any fetch statement. |
boolean |
includeInInsertStatement()
Accessor for whether this mapping is to be included in the insert statement. |
boolean |
includeInUpdateStatement()
Accessor for whether this mapping is to be included in the update statement. |
void |
initialize(DatastoreAdapter dba,
AbstractPropertyMetaData fmd,
DatastoreContainerObject container,
ClassLoaderResolver clr)
Initialize this JavaTypeMapping with the given DatastoreAdapter for the given FieldMetaData. |
void |
initialize(DatastoreAdapter dba,
java.lang.String type)
Initialize this JavaTypeMapping with the given DatastoreAdapter for the given type. |
boolean |
isNullable()
Accessor for whether this mapping is nullable |
abstract ScalarExpression |
newLiteral(QueryExpression qs,
java.lang.Object value)
Creates a literal from an value. |
abstract ScalarExpression |
newScalarExpression(QueryExpression qs,
LogicSetExpression te)
Creates a expression from a field name/table. |
void |
setBoolean(PersistenceManager pm,
java.lang.Object datastoreStatement,
int[] exprIndex,
boolean value)
Sets a value into datastoreStatement
at position specified by exprIndex. |
void |
setByte(PersistenceManager pm,
java.lang.Object datastoreStatement,
int[] exprIndex,
byte value)
Sets a value into datastoreStatement
at position specified by exprIndex. |
void |
setChar(PersistenceManager pm,
java.lang.Object datastoreStatement,
int[] exprIndex,
char value)
Sets a value into datastoreStatement
at position specified by exprIndex. |
void |
setDefault(PersistenceManager pm,
java.lang.Object datastoreStatement,
int[] exprIndex)
Convenience setter to provide a default value for this field. |
void |
setDouble(PersistenceManager pm,
java.lang.Object datastoreStatement,
int[] exprIndex,
double value)
Sets a value into datastoreStatement
at position specified by exprIndex. |
void |
setFloat(PersistenceManager pm,
java.lang.Object datastoreStatement,
int[] exprIndex,
float value)
Sets a value into datastoreStatement
at position specified by exprIndex. |
void |
setInt(PersistenceManager pm,
java.lang.Object datastoreStatement,
int[] exprIndex,
int value)
Sets a value into datastoreStatement
at position specified by exprIndex. |
void |
setLong(PersistenceManager pm,
java.lang.Object datastoreStatement,
int[] exprIndex,
long value)
Sets a value into datastoreStatement
at position specified by exprIndex. |
void |
setObject(PersistenceManager pm,
java.lang.Object datastoreStatement,
int[] exprIndex,
java.lang.Object value)
Sets a value into datastoreStatement
at position specified by exprIndex. |
void |
setObject(PersistenceManager pm,
java.lang.Object datastoreStatement,
int[] exprIndex,
java.lang.Object value,
StateManager ownerSM,
int ownerFieldNumber)
Sets a value into datastoreStatement
at position specified by exprIndex. |
void |
setReferenceMapping(JavaTypeMapping referenceMapping)
Method to set the mapping at the other end of the relation. |
void |
setShort(PersistenceManager pm,
java.lang.Object datastoreStatement,
int[] exprIndex,
short value)
Sets a value into datastoreStatement
at position specified by exprIndex. |
void |
setString(PersistenceManager pm,
java.lang.Object datastoreStatement,
int[] exprIndex,
java.lang.String value)
Sets a value into datastoreStatement
at position specified by exprIndex. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final Localiser LOCALISER
protected AbstractPropertyMetaData fmd
protected DatastoreMapping[] datastoreMappings
protected DatastoreContainerObject datastoreContainer
protected DatastoreAdapter dba
protected java.lang.String type
protected JavaTypeMapping referenceMapping
| Constructor Detail |
|---|
protected JavaTypeMapping()
The combination of this empty constructor and one of the initialize method is used instead of parameterized constructors for efficientcy purpose, both in execution time and code maintainability. See MappingFactory for how they are used.
Concrete subclasses must have a public accesstable empty constructor.
MappingFactory
protected JavaTypeMapping(DatastoreAdapter dba,
java.lang.String type,
AbstractPropertyMetaData fmd,
DatastoreContainerObject container)
dba - The Datastore Adapter that this Mapping should use.type - The Class that this mapping maps to the database.fmd - FieldMetaData for the field to be mapped (if any)container - The datastore container storing this mapping (if any)| Method Detail |
|---|
public void initialize(DatastoreAdapter dba,
java.lang.String type)
dba - The Datastore Adapter that this Mapping should use.type - The Class that this mapping maps to the database.MappingFactory.createMapping(Class, DatastoreAdapter, String)
public void initialize(DatastoreAdapter dba,
AbstractPropertyMetaData fmd,
DatastoreContainerObject container,
ClassLoaderResolver clr)
dba - The Datastore Adapter that this Mapping should use.fmd - FieldMetaData for the field to be mapped (if any)container - The datastore container storing this mapping (if any)clr - the ClassLoaderResolverMappingFactory.createMapping(Class, DatastoreAdapter, AbstractPropertyMetaData, DatastoreContainerObject, ClassLoaderResolver)public boolean isNullable()
public DatastoreMapping[] getDataStoreMappings()
public DatastoreContainerObject getDatastoreContainer()
public DatastoreMapping getDataStoreMapping(int index)
index - The id of the mapping
public JavaTypeMapping getReferenceMapping()
public void setReferenceMapping(JavaTypeMapping referenceMapping)
referenceMapping - The mapping at the other endpublic void addDataStoreMapping(DatastoreMapping datastoreMapping)
datastoreMapping - The datastore mappingpublic int getNumberOfDatastoreFields()
public AbstractPropertyMetaData getFieldMetaData()
public abstract java.lang.Class getJavaType()
public java.lang.String getJavaTypeForDatastoreMapping(int index)
index - requested datastore field index.
public java.lang.String getType()
public abstract java.lang.Object getSampleValue(ClassLoaderResolver clr)
clr - TODO
public boolean includeInFetchStatement()
public boolean includeInUpdateStatement()
public boolean includeInInsertStatement()
public abstract ScalarExpression newLiteral(QueryExpression qs,
java.lang.Object value)
qs - The Query statementvalue - The object
public abstract ScalarExpression newScalarExpression(QueryExpression qs,
LogicSetExpression te)
qs - The Query statementte - the alias for the table
protected java.lang.String failureMessage(java.lang.String method)
method - The method that failed.
public void setDefault(PersistenceManager pm,
java.lang.Object datastoreStatement,
int[] exprIndex)
pm - The Persistence ManagerdatastoreStatement - Prepared StatementexprIndex - The indices in the statement
public void setBoolean(PersistenceManager pm,
java.lang.Object datastoreStatement,
int[] exprIndex,
boolean value)
value into datastoreStatement
at position specified by exprIndex.
pm - the PersistenceManagerdatastoreStatement - a datastore object that executes statements in the databaseexprIndex - the position of the value in the statementvalue - the value
public boolean getBoolean(PersistenceManager pm,
java.lang.Object datastoreResults,
int[] exprIndex)
datastoreResults
at position specified by exprIndex.
pm - the PersistenceManagerdatastoreResults - an object returned from the datastore with valuesexprIndex - the position of the value in the result
public void setChar(PersistenceManager pm,
java.lang.Object datastoreStatement,
int[] exprIndex,
char value)
value into datastoreStatement
at position specified by exprIndex.
pm - the PersistenceManagerdatastoreStatement - a datastore object that executes statements in the databaseexprIndex - the position of the value in the statementvalue - the value
public char getChar(PersistenceManager pm,
java.lang.Object datastoreResults,
int[] exprIndex)
datastoreResults
at position specified by exprIndex.
pm - the PersistenceManagerdatastoreResults - an object returned from the datastore with valuesexprIndex - the position of the value in the result
public void setByte(PersistenceManager pm,
java.lang.Object datastoreStatement,
int[] exprIndex,
byte value)
value into datastoreStatement
at position specified by exprIndex.
pm - the PersistenceManagerdatastoreStatement - a datastore object that executes statements in the databaseexprIndex - the position of the value in the statementvalue - the value
public byte getByte(PersistenceManager pm,
java.lang.Object datastoreResults,
int[] exprIndex)
datastoreResults
at position specified by exprIndex.
pm - the PersistenceManagerdatastoreResults - an object returned from the datastore with valuesexprIndex - the position of the value in the result
public void setShort(PersistenceManager pm,
java.lang.Object datastoreStatement,
int[] exprIndex,
short value)
value into datastoreStatement
at position specified by exprIndex.
pm - the PersistenceManagerdatastoreStatement - a datastore object that executes statements in the databaseexprIndex - the position of the value in the statementvalue - the value
public short getShort(PersistenceManager pm,
java.lang.Object datastoreResults,
int[] exprIndex)
datastoreResults
at position specified by exprIndex.
pm - the PersistenceManagerdatastoreResults - an object returned from the datastore with valuesexprIndex - the position of the value in the result
public void setInt(PersistenceManager pm,
java.lang.Object datastoreStatement,
int[] exprIndex,
int value)
value into datastoreStatement
at position specified by exprIndex.
pm - the PersistenceManagerdatastoreStatement - a datastore object that executes statements in the databaseexprIndex - the position of the value in the statementvalue - the value
public int getInt(PersistenceManager pm,
java.lang.Object datastoreResults,
int[] exprIndex)
datastoreResults
at position specified by exprIndex.
pm - the PersistenceManagerdatastoreResults - an object returned from the datastore with valuesexprIndex - the position of the value in the result
public void setLong(PersistenceManager pm,
java.lang.Object datastoreStatement,
int[] exprIndex,
long value)
value into datastoreStatement
at position specified by exprIndex.
pm - the PersistenceManagerdatastoreStatement - a datastore object that executes statements in the databaseexprIndex - the position of the value in the statementvalue - the value
public long getLong(PersistenceManager pm,
java.lang.Object datastoreResults,
int[] exprIndex)
datastoreResults
at position specified by exprIndex.
pm - the PersistenceManagerdatastoreResults - an object returned from the datastore with valuesexprIndex - the position of the value in the result
public void setFloat(PersistenceManager pm,
java.lang.Object datastoreStatement,
int[] exprIndex,
float value)
value into datastoreStatement
at position specified by exprIndex.
pm - the PersistenceManagerdatastoreStatement - a datastore object that executes statements in the databaseexprIndex - the position of the value in the statementvalue - the value
public float getFloat(PersistenceManager pm,
java.lang.Object datastoreResults,
int[] exprIndex)
datastoreResults
at position specified by exprIndex.
pm - the PersistenceManagerdatastoreResults - an object returned from the datastore with valuesexprIndex - the position of the value in the result
public void setDouble(PersistenceManager pm,
java.lang.Object datastoreStatement,
int[] exprIndex,
double value)
value into datastoreStatement
at position specified by exprIndex.
pm - the PersistenceManagerdatastoreStatement - a datastore object that executes statements in the databaseexprIndex - the position of the value in the statementvalue - the value
public double getDouble(PersistenceManager pm,
java.lang.Object datastoreResults,
int[] exprIndex)
datastoreResults
at position specified by exprIndex.
pm - the PersistenceManagerdatastoreResults - an object returned from the datastore with valuesexprIndex - the position of the value in the result
public void setString(PersistenceManager pm,
java.lang.Object datastoreStatement,
int[] exprIndex,
java.lang.String value)
value into datastoreStatement
at position specified by exprIndex.
pm - the PersistenceManagerdatastoreStatement - a datastore object that executes statements in the databaseexprIndex - the position of the value in the statementvalue - the value
public java.lang.String getString(PersistenceManager pm,
java.lang.Object datastoreResults,
int[] exprIndex)
datastoreResults
at position specified by exprIndex.
pm - the PersistenceManagerdatastoreResults - an object returned from the datastore with valuesexprIndex - the position of the value in the result
public void setObject(PersistenceManager pm,
java.lang.Object datastoreStatement,
int[] exprIndex,
java.lang.Object value,
StateManager ownerSM,
int ownerFieldNumber)
value into datastoreStatement
at position specified by exprIndex.
pm - the PersistenceManagerdatastoreStatement - a datastore object that executes statements in the databaseexprIndex - the position of the value in the statementvalue - the valueownerSM - the owner StateManagerownerFieldNumber - the owner absolute field number
public void setObject(PersistenceManager pm,
java.lang.Object datastoreStatement,
int[] exprIndex,
java.lang.Object value)
value into datastoreStatement
at position specified by exprIndex.
pm - the PersistenceManagerdatastoreStatement - a datastore object that executes statements in the databaseexprIndex - the position of the value in the statementvalue - the value
public java.lang.Object getObject(PersistenceManager pm,
java.lang.Object datastoreResults,
int[] exprIndex,
StateManager ownerSM,
int ownerFieldNumber)
datastoreResults
at position specified by exprIndex.
pm - the PersistenceManagerdatastoreResults - an object returned from the datastore with valuesexprIndex - the position of the value in the resultownerSM - the owner StateManagerownerFieldNumber - the owner absolute field number
public java.lang.Object getObject(PersistenceManager pm,
java.lang.Object datastoreResults,
int[] exprIndex)
datastoreResults
at position specified by exprIndex.
pm - the PersistenceManagerdatastoreResults - an object returned from the datastore with valuesexprIndex - the position of the value in the result
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||