Overview | Package | Class | Tree | Deprecated | Index | Help
| SolarMetric Kodo JDO 2.5.8 generated on January 11 2004
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.solarmetric.kodo.impl.jdbc.ormapping
Class IntegerSubclassProvider

    java.lang.Object
      |
      +--com.solarmetric.kodo.impl.jdbc.ormapping.SubclassProviderImpl
            |
            +--com.solarmetric.kodo.impl.jdbc.ormapping.IntegerSubclassProvider

All Implemented Interfaces:
  SubclassProvider

public class IntegerSubclassProvider
extends SubclassProviderImpl

`SubclassProvider` implementation that uses an integer as a subclass indicator value in the database rather than the full classname. This requires that a class-to-integer mapping be specified in the metadata for the types that use this subclass provider.

These mappings are specified as demonstrated in the following example, in which rows representing `com.acme.object.Foo` have a value of `1` stored in the `JDOCLASSX` column, and rows representing `com.acme.object.Bar` have a value of `2`:

This class should probably be refactored to allow for easier extension for non-integer subclass indicator values. But for now, that task is left as an exercise for the reader.

Field Summary
`static String` | `INDICATOR_VALUE` The JDO metadata extension key under which the integer indicator value is stored.

Fields inherited from class com.solarmetric.kodo.impl.jdbc.ormapping.SubclassProviderImpl
`CLASS_COL`

Constructor Summary
`IntegerSubclassProvider()`

Method Summary
`protected String` | `getClassName(Object val)` Return the String name of the class corresponding to `val`, or `null` if no mapping exists for `val`.
`protected int` | `getIndicatorColumnSQLType()` Returns the `SQLTypes` type constant for the indicator column used by this mapping/provider combination.
`Class` | `getType(PersistenceManagerImpl pm, ClassResolver resolver, Object indicatorVal)` Return a Class object given that `val` was stored in this mapping's indicator column.
`Object` | `getValue(PersistenceManagerImpl pm)` Return an object to be stored in this mapping's indicator column.
`protected void` | `initialize(ClassMapping cm)` Ensure that an integer value is specified for this class mapping.
`void` | `initialize(ClassMapping cm, Column[] cols)` Intercept the initialization routines so we can extract a reference to the class mapping and do some validation.
`void` | `initialize(ClassMapping cm, Table primaryTable)` Intercept the initialization routines so we can extract a reference to the class mapping and do some validation.
`protected void` | `registerSubclassMapping(Class cls, Object val)` Register the mapping from `cls` to `val`.

Methods inherited from class com.solarmetric.kodo.impl.jdbc.ormapping.SubclassProviderImpl
`addClassCondition, addClassCondition, addSubclassConditions, addSubclassConditions, getIndicatorColumnName, getIndicatorColumns, getSubclasses, getType, insert, select, select`

Methods inherited from class java.lang.Object
`, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### INDICATOR_VALUE

    public static final String INDICATOR_VALUE

  The JDO metadata extension key under which the integer indicator value is stored. This has the value `subclass-indicator-value`.

Constructor Detail

### IntegerSubclassProvider

    public IntegerSubclassProvider()

Method Detail

### initialize

    public void initialize(ClassMapping cm,
                           Table primaryTable)

  Intercept the initialization routines so we can extract a reference to the class mapping and do some validation.
  Overrides:
    `initialize` in class `SubclassProviderImpl`

### initialize

    public void initialize(ClassMapping cm,
                           Column[] cols)

  Intercept the initialization routines so we can extract a reference to the class mapping and do some validation.
  Overrides:
    `initialize` in class `SubclassProviderImpl`

### initialize

    protected void initialize(ClassMapping cm)

  Ensure that an integer value is specified for this class mapping. Additionally, if the class mapping represents a subclass of another persistent type, notify the superclass type's IntegerSubclassProvider of the integer mapping. This lets us lazily ensure that no two classes in the same hierarchy use the same mapping value.

### getType

    public Class getType(PersistenceManagerImpl pm,
                         ClassResolver resolver,
                         Object indicatorVal)

  Description copied from class: `SubclassProviderImpl`
  Return a Class object given that `val` was stored in this mapping's indicator column. The class should be loaded with `resolver`. `pm` is a reference to the `PersistenceManagerImpl` that requested that this class be loaded.
  Overrides:
    `getType` in class `SubclassProviderImpl`

### getValue

    public Object getValue(PersistenceManagerImpl pm)

  Description copied from interface: `SubclassProvider`

  Return an object to be stored in this mapping's indicator column. `pm` is a reference to the PersistenceManagerImpl that requested that this class be loaded.

  This method should generate values from which `SubclassProvider.getType(PersistenceManagerImpl,ResultSet,int,ClassResolver)` can correctly determine a class.

  Overrides:
    `getValue` in class `SubclassProviderImpl`

### getIndicatorColumnSQLType

    protected int getIndicatorColumnSQLType()

  Description copied from class: `SubclassProviderImpl`
  Returns the `SQLTypes` type constant for the indicator column used by this mapping/provider combination.
  Overrides:
    `getIndicatorColumnSQLType` in class `SubclassProviderImpl`

### registerSubclassMapping

    protected void registerSubclassMapping(Class cls,
                                           Object val)

  Register the mapping from `cls` to `val`. This ensures that no two classes in the same inheritance hierarchy have the same mapping value.

### getClassName

    protected String getClassName(Object val)

  Return the String name of the class corresponding to `val`, or `null` if no mapping exists for `val`.

Overview | Package | Class | Tree | Deprecated | Index | Help
| SolarMetric Kodo JDO 2.5.8 generated on January 11 2004
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright 2001,2002,2003 SolarMetric, Inc. All Rights Reserved.