Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.objectstyle.cayenne.access.types
Class ExtendedTypeMap

    java.lang.Object
      org.objectstyle.cayenne.access.types.ExtendedTypeMap

    public class ExtendedTypeMap

extends java.lang.Object

Stores ExtendedTypes, implementing an algorithm to determine the right type for a given Java class. When an ExtendedType is requested via a call to `getRegisteredType(String)`, ExtendedTypeMap returns the first type found, using the following algorithm:

- a type registered explicitly or implicitly for a given Java class name
- a non-null type returned by a registered factory
- default generic type.

Author:
  Andrus Adamchik

Field Summary
`protected DefaultType` | `defaultType`
`protected java.util.Map` | `typeMap`

Constructor Summary
`ExtendedTypeMap()` Creates new ExtendedTypeMap, populating it with default JDBC-compatible types.

Method Summary
`void` | `addFactory(ExtendedTypeFactory factory)` Adds an ExtendedTypeFactory that will be consulted if no direct mapping for a given class exists.
`ExtendedType` | `getDefaultType()` Returns a default ExtendedType that is used to handle unmapped types.
`protected ExtendedType` | `getDefaultType(java.lang.String javaClassName)` Returns a default type for specific Java classes.
`java.util.Collection` | `getFactories()` Returns ExtendedTypeFactories registered with this instance.
`ExtendedType` | `getRegisteredType(java.lang.Class javaClass)` Returns a type registered for the class name.
`ExtendedType` | `getRegisteredType(java.lang.String javaClassName)` Returns a type registered for the class name.
`java.lang.String[]` | `getRegisteredTypeNames()` Returns array of Java class names supported by Cayenne for JDBC mapping.
`protected void` | `initDefaultTypes()` Registers default extended types.
`void` | `registerType(ExtendedType type)` Adds a new type to the list of registered types.
`void` | `removeFactory(ExtendedTypeFactory factory)` Removes a factory from the regsitered factories if it was previosly added.
`void` | `unregisterType(java.lang.String javaClassName)` Removes registered ExtendedType object corresponding to `javaClassName` parameter.

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

Field Detail

### typeMap

    protected java.util.Map typeMap

### defaultType

    protected DefaultType defaultType

Constructor Detail

### ExtendedTypeMap

    public ExtendedTypeMap()

  Creates new ExtendedTypeMap, populating it with default JDBC-compatible types. If JDK version is at least 1.5, also loads support for enumerated types.

Method Detail

### initDefaultTypes

    protected void initDefaultTypes()

  Registers default extended types. This method is called from constructor.

### getFactories

    public java.util.Collection getFactories()

  Returns ExtendedTypeFactories registered with this instance.

  Since:
    1.2

### addFactory

    public void addFactory(ExtendedTypeFactory factory)

  Adds an ExtendedTypeFactory that will be consulted if no direct mapping for a given class exists. This feature can be used to map interfaces.

  Note that the order in which factories are added is important, as factories are consulted in turn when an ExtendedType is looked up, and lookup is stopped when any factory provides a non-null type.

  Since:
    1.2

### removeFactory

    public void removeFactory(ExtendedTypeFactory factory)

  Removes a factory from the regsitered factories if it was previosly added.

  Since:
    1.2

### registerType

    public void registerType(ExtendedType type)

  Adds a new type to the list of registered types. If there is another type registered for a class described by the `type` argument, the old handler is overwriden by the new one.

### getDefaultType

    public ExtendedType getDefaultType()

  Returns a default ExtendedType that is used to handle unmapped types.

### getRegisteredType

    public ExtendedType getRegisteredType(java.lang.String javaClassName)

  Returns a type registered for the class name. If no such type exists, returns the default type. It is guaranteed that this method returns a non-null ExtendedType instance. Note that for array types class name must be in the form 'MyClass[]'.

### getRegisteredType

    public ExtendedType getRegisteredType(java.lang.Class javaClass)

  Returns a type registered for the class name. If no such type exists, returns the default type. It is guaranteed that this method returns a non-null ExtendedType instance.

### unregisterType

    public void unregisterType(java.lang.String javaClassName)

  Removes registered ExtendedType object corresponding to `javaClassName` parameter.

### getRegisteredTypeNames

    public java.lang.String[] getRegisteredTypeNames()

  Returns array of Java class names supported by Cayenne for JDBC mapping.

### getDefaultType

    protected ExtendedType getDefaultType(java.lang.String javaClassName)

  Returns a default type for specific Java classes. This implementation supports dynamically loading EnumType handlers for concrete Enum classes (assuming the application runs under JDK1.5+).

  Returns:
    a default type for a given class or null if a class has no default type mapping.
  Since:
    1.2

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2006 ObjectStyle.org All Rights Reserved.