I am serializing a class using simple-xml (http://simple.sourceforge.net/) but when i try to use @Element on a Point object i get an error, how can i transform this Point object?
+1
A:
You can create a transform like so
public class PointTransform implements Transform<Point> {
public Point read(String value) {
return fromString(value);
}
public String write(Point value) {
return toString(value);
}
// etc ...
}
Then pass in a Matcher to the Persister constructor so that it can resolve your Transform given the class. Transforms are used for primitives only, like attribute or text values. They should not be used to compose XML, as it will only get escaped when written to the resulting document. Best to use annotations like so.
@Root
public class Point {
@Attribute
private int x;
@Attribute
private int y;
public int getX() {
return x;
}
public int getY() {
return y;
}
}
ng
2009-01-13 18:20:36
I ended up just implementing my own alternative to Point.
utdiscant
2009-01-13 19:14:09