com.cc.framework.convert
Class ConverterRegistry

java.lang.Object
  extended bycom.cc.framework.convert.ConverterRegistry
All Implemented Interfaces:
Singleton

public class ConverterRegistry
extends java.lang.Object
implements Singleton

The ConverterRegistry is the central place where all converters are registered.

Version:
$Revision$
Author:
Harald Schulz

Field Summary
private  java.util.Map converterCache
          This is a cache for reusable custom Converter instances
private  java.util.Map converters
          This map maps java data types to converters Map
private  java.util.Map customConverters
          This is a Registry for custom Converter classes
private  Converter defaultConverter
          The default converter that should be used when no matching converter is available
private static ConverterRegistry instance
          Singleton instance
private  org.apache.commons.logging.Log log
          Logging instance
 
Constructor Summary
private ConverterRegistry()
          Constructor
 
Method Summary
 void deregister(java.lang.Class dataType)
          Remove any registered Converter for the specified destination Class.
 Converter getCustomConverter(java.lang.String converterId)
          Look up and custom converter.
 void init()
          Register the predefined Converters
static ConverterRegistry instance()
          Returns the singleton instance of this class
 Converter lookup(java.lang.Class dataType)
          Look up and return any registered Converter for the specified destination class; if there is no registered Converter, return a default String Converter.
 void registerCustomConverter(java.lang.String converterId, java.lang.Class converterClass)
          Register a custom Converter for the specified destination Class, replacing any previously registered Converter.
 void registerTypeConverter(java.lang.Class dataType, Converter converter)
          Register a custom Converter for the specified destination Class, replacing any previously registered Converter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private org.apache.commons.logging.Log log
Logging instance


converters

private java.util.Map converters
This map maps java data types to converters Map


customConverters

private java.util.Map customConverters
This is a Registry for custom Converter classes


converterCache

private java.util.Map converterCache
This is a cache for reusable custom Converter instances


defaultConverter

private Converter defaultConverter
The default converter that should be used when no matching converter is available


instance

private static ConverterRegistry instance
Singleton instance

Constructor Detail

ConverterRegistry

private ConverterRegistry()
Constructor

Method Detail

init

public void init()
Register the predefined Converters


instance

public static ConverterRegistry instance()
Returns the singleton instance of this class

Returns:
The HtmlPainterFactory

registerTypeConverter

public void registerTypeConverter(java.lang.Class dataType,
                                  Converter converter)
Register a custom Converter for the specified destination Class, replacing any previously registered Converter.

Parameters:
dataType - Destination class for conversions performed by this Converter
converter - Converter to be registered

registerCustomConverter

public void registerCustomConverter(java.lang.String converterId,
                                    java.lang.Class converterClass)
Register a custom Converter for the specified destination Class, replacing any previously registered Converter.

Parameters:
converterId - The converters identifier or class name
converterClass - Converter class to be registered

deregister

public void deregister(java.lang.Class dataType)
Remove any registered Converter for the specified destination Class.

Parameters:
dataType - Class for which to remove a registered Converter

lookup

public Converter lookup(java.lang.Class dataType)
Look up and return any registered Converter for the specified destination class; if there is no registered Converter, return a default String Converter.

Parameters:
dataType - Class for which to return a registered Converter
Returns:
a matching Converter or the default StringConverter

getCustomConverter

public Converter getCustomConverter(java.lang.String converterId)
                             throws ConverterException
Look up and custom converter.

Parameters:
converterId - The converters identifier or Class name
Returns:
a matching Converter or the default StringConverter
Throws:
ConverterException - is thrown when a conversion error occurs


Copyright © 2000-2005 SCC Informationssysteme GmbH. All Rights Reserved.