Issue Details (XML | Word | Printable)

Key: XSTR-325
Type: New Feature New Feature
Status: Closed Closed
Resolution: Fixed
Assignee: Unassigned
Reporter: Paul Hammant
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
XStream

Conventional Converter

Created: 21/Jun/06 11:48 PM   Updated: 07/Jul/06 04:25 AM
Component/s: None
Affects Version/s: None
Fix Version/s: 1.2

File Attachments: 1. Java Source File ConventionalStringConverter.java (2 kB)
2. Java Source File ConventionalStringConverterTest.java (2 kB)



 Description  « Hide
ConventionalStringConverter is a converter that assumes two things about the class that is passed into its ctor ..

1) There is a single string parameter for the constructor of the class that its helping
2) toString() does something meaningful on the same class.

Like so ...

public class Foo {
private foo;
public Foo(String foo) { this.foo = foo; }
public String toString() { return foo; }
}



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Mauro Talevi added a comment - 22/Jun/06 06:26 AM
How about renaming it StringConstructableConverter?

Mauro Talevi added a comment - 22/Jun/06 06:26 AM
Or better yet SingleStringConstructableConverter?

Joerg Schaible added a comment - 22/Jun/06 07:56 AM
ToStringConverter ?

Paul Hammant added a comment - 28/Jun/06 02:46 PM
This is why I reply on brighter collaborators to name/rename things ... after committing

Paul Hammant added a comment - 28/Jun/06 09:39 PM
Of course, String itself matches the ToString ideal.

Thus ...

xStream.useAttributeFor( ... , String.class);
xStream.registerConverter(new ConventionalStringConverter(String.class));

could be replaced with ...

xStream.useAttributeFor( ... , String.class);

as long as 'useAttributeFor' performs a silent ...

xStream.registerConverter(new ConventionalStringConverter(String.class));


Mauro Talevi added a comment - 07/Jul/06 04:25 AM
Applied, using ToStringConverter as name.