y.util
Class ObjectStringConversion

java.lang.Object
  |
  +--y.util.ObjectStringConversion
All Implemented Interfaces:
ObjectStringConverter

public class ObjectStringConversion
extends Object
implements ObjectStringConverter

This class serves as a basic implementation of the ObjectStringConverter interface. It is capable of converting a large number of objects to Strings and vice versa.


Constructor Summary
protected ObjectStringConversion()
          Creates a new instance of ObjectStringConversion
 
Method Summary
 Object convertToObject(String o, Class asClass)
          This method takes a String, and tries to interpret it as a String representation of the given classtype, which it will then create.
 String convertToString(Object o, Class asClass)
          This method takes an object, treats it as an object of the given class type and produces a String representation.
static ObjectStringConversion getInstance()
          Provides access to the singleton instance
protected  void registerObjectStringConverter(Class clazz, ObjectStringConverter s)
          Registers another handler for the given class type
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectStringConversion

protected ObjectStringConversion()
Creates a new instance of ObjectStringConversion

Method Detail

registerObjectStringConverter

protected void registerObjectStringConverter(Class clazz,
                                             ObjectStringConverter s)
Registers another handler for the given class type

Parameters:
clazz - the type of class
s - the converter

getInstance

public static ObjectStringConversion getInstance()
Provides access to the singleton instance

Returns:
an instance of ObjectStringConversion

convertToObject

public Object convertToObject(String o,
                              Class asClass)
                       throws IllegalArgumentException
Description copied from interface: ObjectStringConverter
This method takes a String, and tries to interpret it as a String representation of the given classtype, which it will then create.

Specified by:
convertToObject in interface ObjectStringConverter
IllegalArgumentException
Parameters:
o - the String to convert
asClass - the type which should be generated by this method. the method is free to create a more specific type, but that type must be assignment compatible
Returns:
an object which can safely be cast to the given type

convertToString

public String convertToString(Object o,
                              Class asClass)
                       throws IllegalArgumentException
Description copied from interface: ObjectStringConverter
This method takes an object, treats it as an object of the given class type and produces a String representation.

Specified by:
convertToString in interface ObjectStringConverter
IllegalArgumentException
Parameters:
o - the object to convert
asClass - the type which should be used to interpret the object, may be less specific than the actual object's type
Returns:
a string representation of the object

© Copyright 2000-2003,
yWorks GmbH.
All rights reserved.

2003