Search this API

y.util
Interface ObjectStringConverter

All Known Implementing Classes:
AbstractStringConverter, ObjectStringConversion, ReflectionStringConverter

public interface ObjectStringConverter

Interface for classes which can convert Objects to String representations and vice versa

 

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.
 

Method Detail

convertToString

java.lang.String convertToString(java.lang.Object o,
                                 java.lang.Class asClass)
                                 throws java.lang.IllegalArgumentException
This method takes an object, treats it as an object of the given class type and produces a String representation.

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
Throws:
java.lang.IllegalArgumentException - if this method is not capable of doing the transformation because of illegal arguments

convertToObject

java.lang.Object convertToObject(java.lang.String o,
                                 java.lang.Class asClass)
                                 throws java.lang.IllegalArgumentException
This method takes a String, and tries to interpret it as a String representation of the given class type, which it will then create.

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
Throws:
java.lang.IllegalArgumentException - if this method is not capable of doing the transformation because of illegal arguments

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