
| Key: |
XSTR-211
|
| Type: |
New Feature
|
| Status: |
Closed
|
| Resolution: |
Fixed
|
| Priority: |
Major
|
| Assignee: |
Unassigned
|
| Reporter: |
Joe Walnes
|
| Votes: |
1
|
| Watchers: |
0
|
|
If you were logged in you would be able to see more operations.
|
|
|
XStream
Created: 03/Apr/05 06:36 AM
Updated: 07/Aug/06 09:27 PM
|
|
| Component/s: |
None
|
| Affects Version/s: |
None
|
| Fix Version/s: |
1.2
|
|
|
--- 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.
|
|
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.
|
Show » |
|
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.