Converting a Point Object Using Simple-xml

I serialize the class using simple-xml ( http://simple.sourceforge.net/ ), but when I try to use @Element for a Point object, I get an error, how can I convert this Point object?

+3
source share
2 answers

You can create such a transformation

public class PointTransform implements Transform<Point> {

  public Point read(String value) {
     return fromString(value);
  }

  public String write(Point value)  {
     return toString(value);
  }

  // etc ...
}

Matcher Persister, , . , . XML, . .

@Root
public class Point {

  @Attribute
  private int x;

  @Attribute
  private int y;

  public int getX() {
     return x;
  }

  public int getY() {
     return y;
  }
}
+1

All Articles