org.apache.commons.convert.conversion
Class IdentityConversionFactory

java.lang.Object
  extended by org.apache.commons.convert.conversion.IdentityConversionFactory
All Implemented Interfaces:
ConversionFactory

public class IdentityConversionFactory
extends Object
implements ConversionFactory

Conversion from TimeZone to String using getID().

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

Field Summary
static ConversionFactory INSTANCE
          Singleton instance of this factory
 
Constructor Summary
protected IdentityConversionFactory()
          Restricted constructor.
 
Method Summary
 Conversion getInstance(Object value, Class fromType, Class toType)
          Create a new conversion object for the specified from and to types.
 int getMatchPercent(Object value, Class fromType, Class toType)
          Checks if the types are equal, if so return 80.
 String toString()
          Gets a string suitable for debugging.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INSTANCE

public static final ConversionFactory INSTANCE
Singleton instance of this factory

Constructor Detail

IdentityConversionFactory

protected IdentityConversionFactory()
Restricted constructor.

Method Detail

getMatchPercent

public int getMatchPercent(Object value,
                           Class fromType,
                           Class toType)
Checks if the types are equal, if so return 80.

Specified by:
getMatchPercent in interface ConversionFactory
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:
80 if types are equal

getInstance

public Conversion getInstance(Object value,
                              Class fromType,
                              Class toType)
Create a new conversion object for the specified from and to types.

This implementation returns the identity conversion.

Specified by:
getInstance in interface ConversionFactory
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

toString

public String toString()
Gets a string suitable for debugging.

Overrides:
toString in class Object
Returns:
a debugging string


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