net.sourceforge.jparam.conversion
Class ConverterRegistry

java.lang.Object
  |
  +--net.sourceforge.jparam.conversion.ConverterRegistry

public class ConverterRegistry
extends java.lang.Object

This registry maintains a list of all possible conversions that are currently supported by JParam, if new conversions are added than the list is updated accordingly

Author:
ron_sidi

Method Summary
static void clearSingleton()
           
 java.lang.Object convert(java.lang.Class targetType, java.lang.Object sourceObject)
          Convert the source object to the given target class, an exception is thrown either when there is no exception/exception is ambigous or when the conversion process itself failed
 ScalarConversionWeight getConversionWeight(java.lang.Class sourceType, java.lang.Class targetType)
          Return the weight of the conversion between the given source and target type
static ConverterRegistry getInstance()
           
 void registerConverter(IConverter c)
          This method is used to register a new converter, it shouldn't be used externally, but is defined public to support special cases that might arise It will perform all needed changes to the registry that are introduced by the new converter
 void registerHelperClass(java.lang.Class helperClass)
          Register all conversion methods in the given helper class, a method is considered a conversion if:
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ConverterRegistry getInstance()

registerHelperClass

public void registerHelperClass(java.lang.Class helperClass)
Register all conversion methods in the given helper class, a method is considered a conversion if:

  • The method name is:
    • convert/user_convert for performing user conversions
    • promote_convert for promotion conversion
    • std_convert for standard conversion
  • The method is public
  • The method is static
  • The method has exactly one argument
  • The method has a typed return value and not void
  • Parameters:
    helperClass -  

    registerConverter

    public void registerConverter(IConverter c)
    This method is used to register a new converter, it shouldn't be used externally, but is defined public to support special cases that might arise It will perform all needed changes to the registry that are introduced by the new converter
    Parameters:
    c -  

    convert

    public java.lang.Object convert(java.lang.Class targetType,
                                    java.lang.Object sourceObject)
                             throws JParamException
    Convert the source object to the given target class, an exception is thrown either when there is no exception/exception is ambigous or when the conversion process itself failed
    Parameters:
    targetType -  
    sourceObject -  
    Returns:
    the converted object
    Throws:
    JParamException -  

    clearSingleton

    public static void clearSingleton()

    getConversionWeight

    public ScalarConversionWeight getConversionWeight(java.lang.Class sourceType,
                                                      java.lang.Class targetType)
    Return the weight of the conversion between the given source and target type
    Parameters:
    sourceType -  
    targetType -  
    Returns:
     


    Copyright © 2004 SourceForge. All Rights Reserved.