org.apache.commons.convert
Interface ConversionFactory

All Known Implementing Classes:
AbstractConversionFactory, IdentityConversionFactory, NumberToIntegerConversionFactory, ObjectToStringConversionFactory, TimeZoneToStringConversionFactory

public interface ConversionFactory

Defines a factory for Conversion objects that will create a conversion on demand or return a singleton.

Since:
1.0
Version:
$Id: ConversionFactory.java 155441 2005-02-26 13:19:22Z dirkv $
Author:
Stephen Colebourne

Method Summary
 Conversion getInstance(Object value, Class fromType, Class toType)
          Create a conversion object for the conversion.
 int getMatchPercent(Object value, Class fromType, Class toType)
          Checks if this factory supports the required conversion returning a percentage match.
 

Method Detail

getMatchPercent

int getMatchPercent(Object value,
                    Class fromType,
                    Class toType)
Checks if this factory supports the required conversion returning a percentage match.

The returned int represents the percentage by which this factory matches the required conversion. The percentage (ie 0-100) is used to determine which conversion factory to use when a conflict arises.

Parameters:
value - the value to be converted, read only, may be null
fromType - the type to convert from, may be null
toType - the type to convert to, may be null
Returns:
a value between 0 and 100 inclusive, 0 means no match, 100 perfact match

getInstance

Conversion getInstance(Object value,
                       Class fromType,
                       Class toType)
Create a conversion object for the conversion.

The returned conversion must not store the value. The conversion object will be used repeatedly for all future conversions between these two types without further reference to the factory.

Parameters:
value - the value to be converted, read only, may be null
fromType - the type to convert from, may be null
toType - the type to convert to, may be null
Returns:
a Conversion object for repeatedly performing conversions


Copyright © 2003-2010 The Apache Software Foundation. All Rights Reserved.