|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.util.ObjectStringConversion
public class ObjectStringConversion
This class serves as a basic implementation of the ObjectStringConverter
interface. It is capable of converting objects of different
types to Strings and vice versa.
It provides a default singleton instance that contains a great number of
different implementations for a variety of types.
getInstance()
Constructor Summary | |
---|---|
protected |
ObjectStringConversion()
Creates a new instance of ObjectStringConversion with no converters installed initially. |
Method Summary | |
---|---|
java.lang.Object |
convertToObject(java.lang.String o,
java.lang.Class asClass)
This method takes a String, and tries to interpret it as a String representation of the given class type, which it will then create. |
java.lang.String |
convertToString(java.lang.Object o,
java.lang.Class asClass)
This method takes an object, treats it as an object of the given class type and produces a String representation. |
ObjectStringConverter |
findObjectStringConverter(java.lang.Class forClass)
|
static ObjectStringConversion |
getInstance()
Provides access to the singleton instance |
void |
registerAsSingleton()
Registers this instance as the singleton instance returned by getInstance() . |
protected void |
registerDefaultConverters()
Registers default implementations for this instance for a number of different classes and types including: Integer Float Double Byte Short Boolean Long int float double byte boolean short long String Color File Date Font URL Rectangle2D Point2D Class Locale |
void |
registerObjectStringConverter(java.lang.Class clazz,
ObjectStringConverter s)
Registers another handler for the given class type |
ObjectStringConverter |
removeObjectStringConverter(java.lang.Class forClass)
Removes a handler which was previously registered 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 |
---|
protected ObjectStringConversion()
registerDefaultConverters()
Method Detail |
---|
public void registerAsSingleton()
getInstance()
.
protected void registerDefaultConverters()
public void registerObjectStringConverter(java.lang.Class clazz, ObjectStringConverter s)
clazz
- the type of classs
- the converterpublic ObjectStringConverter removeObjectStringConverter(java.lang.Class forClass)
forClass
- the type of class
null
if there was no such handler registeredpublic static ObjectStringConversion getInstance()
public java.lang.Object convertToObject(java.lang.String o, java.lang.Class asClass) throws java.lang.IllegalArgumentException
ObjectStringConverter
convertToObject
in interface ObjectStringConverter
o
- the String to convertasClass
- 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
java.lang.IllegalArgumentException
- if this method is not capable of doing the transformation because of illegal
argumentspublic java.lang.String convertToString(java.lang.Object o, java.lang.Class asClass) throws java.lang.IllegalArgumentException
ObjectStringConverter
convertToString
in interface ObjectStringConverter
o
- the object to convertasClass
- the type which should be used to interpret the object, may be less specific than
the actual object's type
java.lang.IllegalArgumentException
- if this method is not capable of doing the transformation because of illegal
argumentspublic ObjectStringConverter findObjectStringConverter(java.lang.Class forClass)
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |