|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.java.ao.types.TypeManager
public class TypeManager
Central managing class for the ActiveObjects type system. The type system in AO is designed to allow extensibility and control over how specific data types are handled internally. All database-agnostic, type-specific tasks are delegated to the actual type instances. This class acts as a singleton container for every available type, indexing them based on corresponding Java type and JDBC integer type.
This container is thread safe and so may be used from within multiple contexts.
DatabaseType
Method Summary | ||
---|---|---|
void |
addType(DatabaseType<?> type)
Adds a new type to the container. |
|
static TypeManager |
getInstance()
Retrieves the singleton instance of the container. |
|
|
getType(Class<T> javaType)
Returns the corresponding DatabaseType for a given Java
class. |
|
DatabaseType<?> |
getType(int sqlType)
Returns the corresponding DatabaseType for a given JDBC
integer type. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public void addType(DatabaseType<?> type)
EntityManager
instance.
This method is used internally to set up the default types
(such as int
, String
and so on). Any
custom types should be added using this method.
type
- The type instance to add to the container.public <T> DatabaseType<T> getType(Class<T> javaType)
Returns the corresponding DatabaseType
for a given Java
class. This is the primary mechanism used by ActiveObjects
internally to obtain type instances. Code external to the
framework may also make use of this method to obtain the relevant
type information or to just test if a type is in fact
available. Types are internally prioritized by entry order. The
first type to respond true
to the DatabaseType.isHandlerFor(Class)
method will be returned.
It's worth noting that this method worst case runs in O(n)
time. This is because a linear search must be made through the
raw list of available types. However, once the type has been found
it is placed into a hash indexed by class type. Thus for most types,
this method will run in constant time (O(1)
).
javaType
- The Class
type for which a type instance
should be returned.
RuntimeException
- If no type was found correspondant to the
given class.getType(int)
public DatabaseType<?> getType(int sqlType)
Returns the corresponding DatabaseType
for a given JDBC
integer type. Code external to the framework may also make use of
this method to obtain the relevant type information or to just test
if a type is in fact available. Types are internally prioritized by
entry order. The first type to respond true
to the
DatabaseType.isHandlerFor(int)
method will be returned.
It's worth noting that this method worst case runs in O(n)
time. This is because a linear search must be made through the
raw list of available types. However, once the type has been found
it is placed into a hash indexed by int value. Thus for most types,
this method will run in constant time (O(1)
).
sqlType
- The JDBC Types
constant for which a type
instance should be retrieved.
RuntimeException
- If no type was found correspondant to the
given type constant.getType(Class)
public static TypeManager getInstance()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |