org.compass.core.converter
Class DefaultConverterLookup

java.lang.Object
  extended by org.compass.core.converter.DefaultConverterLookup
All Implemented Interfaces:
CompassConfigurable, ConverterLookup

public class DefaultConverterLookup
extends Object
implements ConverterLookup

Acts as a Converter registry based on all the converters supplied in the module.

Author:
kimchy

Constructor Summary
DefaultConverterLookup()
           
 
Method Summary
 void configure(CompassSettings settings)
          Configure using the given settings.
 CompassSettings getSettings()
          Return the settings that this converter was created with.
 Converter lookupConverter(Class type)
          Looks up a converter based on the type.
 Converter lookupConverter(String name)
          Looks up a converter based on the converter name (or class name).
 void registerConverter(String converterName, Converter converter)
          Registers a Converter under a converter name.
 void registerConverter(String converterName, Converter converter, Class registerType)
          Registers a Converter under the converter name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultConverterLookup

public DefaultConverterLookup()
Method Detail

getSettings

public CompassSettings getSettings()
Description copied from interface: ConverterLookup
Return the settings that this converter was created with.

Specified by:
getSettings in interface ConverterLookup

configure

public void configure(CompassSettings settings)
               throws CompassException
Description copied from interface: CompassConfigurable
Configure using the given settings.

Specified by:
configure in interface CompassConfigurable
Parameters:
settings - The settings for the configured object
Throws:
CompassException

registerConverter

public void registerConverter(String converterName,
                              Converter converter)
Description copied from interface: ConverterLookup
Registers a Converter under a converter name.

Specified by:
registerConverter in interface ConverterLookup
Parameters:
converterName - The converter name to be registered against
converter - The converter to use

registerConverter

public void registerConverter(String converterName,
                              Converter converter,
                              Class registerType)
Description copied from interface: ConverterLookup
Registers a Converter under the converter name. Also associates the converter with the given type.

Specified by:
registerConverter in interface ConverterLookup
Parameters:
converterName - The converter name to be registered against
converter - The converter to use
registerType - The type to associate the converter with

lookupConverter

public Converter lookupConverter(String name)
Description copied from interface: ConverterLookup
Looks up a converter based on the converter name (or class name). The converter should have been registered with the converter lookup using the ConverterLookup.registerConverter(String, Converter).

Specified by:
lookupConverter in interface ConverterLookup
Parameters:
name - The lookup name of the converter
Returns:
The converter that match for the given name.

lookupConverter

public Converter lookupConverter(Class type)
Looks up a converter based on the type. If there is a direct hit, than it is returned, else it checks for a converter based on the interfaces, and than recursive on the super class.

Specified by:
lookupConverter in interface ConverterLookup
Parameters:
type - The class to look the converter for
Returns:
The converter that match for the given class type.


Copyright (c) 2004-2008 The Compass Project.