org.jpox.store.mapping
Class DiscriminatorMapping

java.lang.Object
  extended byorg.jpox.store.mapping.JavaTypeMapping
      extended byorg.jpox.store.mapping.SingleFieldMapping
          extended byorg.jpox.store.mapping.DiscriminatorMapping

public final class DiscriminatorMapping
extends SingleFieldMapping

Mapping for a discriminator column in a table used in inheritance. The discriminator column is, by default, a String type, typically VARCHAR. It can however be "long" based if the user specifies INTEGER, BIGINT, or NUMERIC as the jdbc-type. In the latter case we make the necessary conversions between value types in this mapping class. This class is for internal use only. It should not be used in user mappings nor extended.

Version:
$Revision: 1.23 $

Field Summary
 
Fields inherited from class org.jpox.store.mapping.SingleFieldMapping
datastoreContainer, typeInfo
 
Fields inherited from class org.jpox.store.mapping.JavaTypeMapping
datastoreMappings, dba, fmd, LOCALISER, referenceMapping, type
 
Constructor Summary
DiscriminatorMapping(DatastoreAdapter dba, DatastoreContainerObject datastoreContainer, JavaTypeMapping delegate)
          Constructor.
 
Method Summary
 void addDataStoreMapping(DatastoreMapping datastoreMapping)
          Mutator to add a datastore mapping
 DatastoreMapping getDataStoreMapping(int index)
          Accessor for a datastore mapping
 java.lang.Class getJavaType()
          Accessor for the type represented here, returning the class itself
 int getNumberOfDatastoreFields()
          Accessor for the number of datastore fields.
 java.lang.Object getObject(PersistenceManager pm, java.lang.Object resultSet, int[] exprIndex)
          Accessor for the object in this column
 java.lang.Object getSampleValue()
          Accessor for a sample value for this type.
 ScalarExpression newLiteral(QueryExpression qs, java.lang.Object value)
          Accessor for a new literal for this mapping.
 ScalarExpression newScalarExpression(QueryExpression qs, LogicSetExpression te)
          Accessor for a new scalar expression including this mapping.
 void setObject(PersistenceManager pm, java.lang.Object preparedStatement, int[] exprIndex, java.lang.Object value)
          Mutator for the object in this column
 
Methods inherited from class org.jpox.store.mapping.SingleFieldMapping
equals, getBoolean, getByte, getChar, getDatastoreContainer, getDouble, getFloat, getInt, getLong, getShort, getString, hasValue, includeInFetchStatement, includeInInsertStatement, includeInUpdateStatement, prepareDatastoreMapping, setBoolean, setByte, setChar, setDouble, setFloat, setInt, setLong, setShort, setString
 
Methods inherited from class org.jpox.store.mapping.JavaTypeMapping
failureMessage, getDataStoreMappings, getFieldMetaData, getObject, getReferenceMapping, getType, isNullable, setDefault, setObject, setReferenceMapping
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DiscriminatorMapping

public DiscriminatorMapping(DatastoreAdapter dba,
                            DatastoreContainerObject datastoreContainer,
                            JavaTypeMapping delegate)
Constructor.

Parameters:
dba - Datastore Adapter
datastoreContainer - Datastore table
delegate - The JavaTypeMapping to delegate storage
Method Detail

getJavaType

public java.lang.Class getJavaType()
Accessor for the type represented here, returning the class itself

Specified by:
getJavaType in class JavaTypeMapping
Returns:
This class.

getSampleValue

public java.lang.Object getSampleValue()
Accessor for a sample value for this type.

Specified by:
getSampleValue in class JavaTypeMapping
Returns:
Sample value

newLiteral

public ScalarExpression newLiteral(QueryExpression qs,
                                   java.lang.Object value)
Accessor for a new literal for this mapping.

Specified by:
newLiteral in class JavaTypeMapping
Parameters:
qs - The QueryStatement
value - The value of the object
Returns:
The new literal

newScalarExpression

public ScalarExpression newScalarExpression(QueryExpression qs,
                                            LogicSetExpression te)
Accessor for a new scalar expression including this mapping.

Specified by:
newScalarExpression in class JavaTypeMapping
Parameters:
qs - The QueryStatement
te - The table Expression
Returns:
The new scalar expression

setObject

public void setObject(PersistenceManager pm,
                      java.lang.Object preparedStatement,
                      int[] exprIndex,
                      java.lang.Object value)
Mutator for the object in this column

Overrides:
setObject in class SingleFieldMapping
Parameters:
pm - The Persistence Manager
preparedStatement - The statement
exprIndex - The indexes
value - The value to set it to

getObject

public java.lang.Object getObject(PersistenceManager pm,
                                  java.lang.Object resultSet,
                                  int[] exprIndex)
Accessor for the object in this column

Overrides:
getObject in class SingleFieldMapping
Parameters:
pm - The Persistence manager
resultSet - The ResultSet to get the value from
exprIndex - The indexes
Returns:
The object

getNumberOfDatastoreFields

public int getNumberOfDatastoreFields()
Accessor for the number of datastore fields.

Overrides:
getNumberOfDatastoreFields in class JavaTypeMapping
Returns:
Number of datastore fields

getDataStoreMapping

public DatastoreMapping getDataStoreMapping(int index)
Accessor for a datastore mapping

Overrides:
getDataStoreMapping in class JavaTypeMapping
Parameters:
index - Index of the mapping
Returns:
The datastore mapping.

addDataStoreMapping

public void addDataStoreMapping(DatastoreMapping datastoreMapping)
Mutator to add a datastore mapping

Overrides:
addDataStoreMapping in class JavaTypeMapping
Parameters:
datastoreMapping - Datastore mapping


Copyright © -2007 . All Rights Reserved.