Details
- 
        Type: New Feature New Feature
- 
        Status: Closed Closed
- 
            Priority: Major Major
- 
            Resolution: Fixed
- 
            Affects Version/s: None
- 
            Fix Version/s: 1.2
- 
            Component/s: None
- 
            Labels:None
Description
 Suggested by Mark Helmstetter 
A converter that provides functionality such
that if an object has a method such as "public Object fromString(String str)".  It
seems that such a converter could be very valuable to avoid writing a special
converter for lots of relatively simple objects that require special handling that
the packaged converters don't address.
 Additional notes by Joe 
I think this is a good idea.
An interface could be introduced for this that objects can implement if they want to be handled by the converter:
package com.thoughtworks.xstream;
public interface StringSerializable {
  String toString(); // implicit from Object anyway, but in the interface for clarity
  void fromString(String string); 
}
Any objects implementing this method would also require a default constructor - similar to the contract of java.io.Externalizable.

 
                            


Joe,
I took a crack at this, let me know what you think.
I'm thinking that it's really not necessary to impose constraints that classes must implement a particular interface to take advantage of the FromStringConverter, and that they have a public default constructor. Feel free to disagree...
I've used Spring's BeanUtils as a helper here, that could potentially be factored out, but I don't see any harm in including it. I think the same can be easily applied to the BeanConverter, and this should solve the Applet security issue as well.