Search this API

y.util
Class ReflectionStringConverter

java.lang.Object
  extended by y.util.AbstractStringConverter
      extended by y.util.ReflectionStringConverter
All Implemented Interfaces:
ObjectStringConverter

public class ReflectionStringConverter
extends AbstractStringConverter

A simple implementation of an ObjectStringConverter, which uses reflection to construct an object from a String representation and the toString() method to construct the String representation from an object.

 

Field Summary
 
Fields inherited from class y.util.AbstractStringConverter
forClass
 
Constructor Summary
ReflectionStringConverter(java.lang.Class forClass)
          Creates a new instance of ReflectionSerializer for the given class type
ReflectionStringConverter(java.lang.Class forClass, java.lang.Class nativeType)
          Creates a new instance of ReflectionSerializer for native types
 
Method Summary
protected  java.lang.Object convertToObject(java.lang.String o)
          This method must be implemented by subclasses. o will never be the null String
protected  java.lang.String convertToString(java.lang.Object o)
          This method must be implemented by subclasses. o will never be the null object.
 
Methods inherited from class y.util.AbstractStringConverter
convertToObject, convertToString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReflectionStringConverter

public ReflectionStringConverter(java.lang.Class forClass)
Creates a new instance of ReflectionSerializer for the given class type


ReflectionStringConverter

public ReflectionStringConverter(java.lang.Class forClass,
                                 java.lang.Class nativeType)
Creates a new instance of ReflectionSerializer for native types

Method Detail

convertToObject

protected java.lang.Object convertToObject(java.lang.String o)
                                    throws java.lang.IllegalArgumentException
Description copied from class: AbstractStringConverter
This method must be implemented by subclasses. o will never be the null String

Specified by:
convertToObject in class AbstractStringConverter
Parameters:
o - the string representation
Returns:
the created object
Throws:
java.lang.IllegalArgumentException - if the method was unable to do the transformation

convertToString

protected java.lang.String convertToString(java.lang.Object o)
                                    throws java.lang.IllegalArgumentException
Description copied from class: AbstractStringConverter
This method must be implemented by subclasses. o will never be the null object.

Specified by:
convertToString in class AbstractStringConverter
Parameters:
o - the object
Returns:
the String representation
Throws:
java.lang.IllegalArgumentException - if the method was unable to do the transformation

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