org.apache.myfaces.trinidadinternal.convert
Class GenericConverterFactory

java.lang.Object
  extended by org.apache.myfaces.trinidadinternal.convert.GenericConverterFactory

public class GenericConverterFactory
extends java.lang.Object

A factory of GenericConverters. GenericConverters may be registered with this factory. The factory supports converting between the types supported by each individual converter. The factory also supports converting between types supported by combining individual converters.

Author:
The Oracle ADF Faces Team

Method Summary
 java.lang.Object convert(java.lang.Object source, java.lang.Class<?> targetType)
          converts the given source instance into an object of the targetType.
 GenericConverter getConverter(java.lang.Class<?> sourceType, java.lang.Class<?> targetType)
          Gets a converter that is capable of converting from the given sourceType to the given targetType.
static GenericConverterFactory getCurrentInstance()
           
 boolean isConvertible(java.lang.Object source, java.lang.Class<?> targetType)
          Checks to see if it is possible to convert the given instance into the specified targetType
 void registerConverter(GenericConverter converter)
          Registers a converter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getConverter

public GenericConverter getConverter(java.lang.Class<?> sourceType,
                                     java.lang.Class<?> targetType)
Gets a converter that is capable of converting from the given sourceType to the given targetType. This method first searches to see if any of the registered converters are capable of making this conversion alone. If one is found, it is returned. Otherwise, this method will search to see if some combination of registered converters can be used to perform this conversion. If so, a composite converter will be returned.

The returned converter (or lack thereof) is cached so that subsequent requests for the same source and target types will be fast.

Returns:
null if there is no such converter.

registerConverter

public void registerConverter(GenericConverter converter)
Registers a converter. Registering a new converter causes the internal cache to be cleared.


convert

public java.lang.Object convert(java.lang.Object source,
                                java.lang.Class<?> targetType)
converts the given source instance into an object of the targetType.

Parameters:
source - the object to convert
targetType - the required type.
Returns:
null, if the source is null.

isConvertible

public boolean isConvertible(java.lang.Object source,
                             java.lang.Class<?> targetType)
Checks to see if it is possible to convert the given instance into the specified targetType

Returns:
true if conversion is possible.

getCurrentInstance

public static GenericConverterFactory getCurrentInstance()


Copyright © 2001-2007 Apache Software Foundation. All Rights Reserved.