org.jdesktop.binding.metadata
Class Converters

java.lang.Object
  extended by org.jdesktop.binding.metadata.Converters

public class Converters
extends java.lang.Object

Class containing the static converter registry and a set of static Converter classes for the common Java data types:

Converter instances are retrieved from the registry using the class as the key. Example usage:
    Converter converter = Converters.get(Integer.class);
     try {
         Integer value = (Integer)converter.decode("99", null);
     }
     catch (ConversionException e) {
         // conversion error!
     }
 

Converters can also be added or replaced in the registry:

    Converters.put(Foo.class, new FooConverter());
 

Version:
1.0
Author:
Amy Fowler

Nested Class Summary
static class Converters.DateConverter
          Converter for java.util.Date.
 
Constructor Summary
protected Converters()
           
 
Method Summary
static Converter get(java.lang.Class klass)
          Retrieves the converter for the class.
static java.lang.Class[] getTypes()
          Return all the types which currently have supported type converters.
static void put(java.lang.Class klass, Converter converter)
          Registers the specified converter for the specified class, overriding any prior converter mapping for that class if it existed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Converters

protected Converters()
Method Detail

get

public static Converter get(java.lang.Class klass)
Retrieves the converter for the class.

Parameters:
klass - class used as key for converter lookup
Returns:
Converter instance registered for specified class, or null if no converter is currently registered for that class

put

public static void put(java.lang.Class klass,
                       Converter converter)
Registers the specified converter for the specified class, overriding any prior converter mapping for that class if it existed.

Parameters:
klass - class used as key for converter lookup
converter - Converter instance to be registered for the class

getTypes

public static java.lang.Class[] getTypes()
Return all the types which currently have supported type converters.

Returns:
an non-null array of supported types


Copyright © 2005 Sun Microsystems All Rights Reserved.