org.progeeks.meta
Class TypeRegistry

java.lang.Object
  extended by org.progeeks.meta.TypeRegistry
Direct Known Subclasses:
FormatRegistry

public class TypeRegistry
extends java.lang.Object

Class for relating objects to types. This is slightly more involved than a simple map since some types can be broken down further to find better values.

Version:
$Revision: 1.9 $
Author:
Paul Speed

Constructor Summary
TypeRegistry()
           
TypeRegistry(TypeRegistry delegate)
           
 
Method Summary
 java.lang.Object get(java.lang.Class classType)
          Convenience method that will wrap the specified Class in a ClassPropertyType before searching.
 java.lang.Object get(MetaClass metaClassType)
          Convenience method that will wrap the specified MetaClass in a MetaClassPropertyType before searching.
 java.lang.Object get(PropertyType type)
           
 java.lang.Object get(PropertyType type, boolean searchDefaults)
          Returns the object associated with the specified type.
 java.lang.Object getDefault(PropertyType type)
           
 java.lang.Object getDirectMatch(PropertyType type)
          Returns the object associated with the specified type without doing any special type searches.
 java.lang.Object getValueForObject(java.lang.Object obj)
          Convenience method that will lookup a value for the type of the specified object by either wrapping its meta-class in a MetaClassPropertyType or wrapping its class in a ClassPropertyType.
 void put(PropertyType type, java.lang.Object value)
          Maps the value to the specified type.
 void putDefault(java.lang.Class baseType, java.lang.Object value)
          Maps the value with a default base type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypeRegistry

public TypeRegistry()

TypeRegistry

public TypeRegistry(TypeRegistry delegate)
Method Detail

put

public void put(PropertyType type,
                java.lang.Object value)
Maps the value to the specified type.


putDefault

public void putDefault(java.lang.Class baseType,
                       java.lang.Object value)
Maps the value with a default base type. The defaults are checked when a specific property type is not found.


get

public java.lang.Object get(PropertyType type,
                            boolean searchDefaults)
Returns the object associated with the specified type. Search order goes: regular, delegate's regular, compatible super-types, defaults, delegate's defaults. Note: the "compatible super-types" part is not implemented except in the default resolution stage. There is currently no easy way to find a PropertyType's super-types without an exhaustive search.


get

public java.lang.Object get(PropertyType type)

get

public java.lang.Object get(java.lang.Class classType)
Convenience method that will wrap the specified Class in a ClassPropertyType before searching.


get

public java.lang.Object get(MetaClass metaClassType)
Convenience method that will wrap the specified MetaClass in a MetaClassPropertyType before searching.


getValueForObject

public java.lang.Object getValueForObject(java.lang.Object obj)
Convenience method that will lookup a value for the type of the specified object by either wrapping its meta-class in a MetaClassPropertyType or wrapping its class in a ClassPropertyType.


getDefault

public java.lang.Object getDefault(PropertyType type)

getDirectMatch

public java.lang.Object getDirectMatch(PropertyType type)
Returns the object associated with the specified type without doing any special type searches. This registry is checked first and then the delegate registry.



Copyright © 2002-2003 Paul Speed. All Rights Reserved.