E
Edmond wong
Hi,
I wrote the code to convert Java bean (using recursion and reflection)
to a string, and the string is:
ie. String text = MyUtil.toText(book);
text={book:Book={{name:java.lang.String="My
Book"}{author:Author={{name:java.lang.String="Edmond
Wong"}{email:java.lang.String="(e-mail address removed)"}{address:java.lang.String="333
S. Hope
St"}}}{price:double=49.99}{chapters:java.util.Vector={{chapter:Chapter={{no:int=1}{name:java.lang.String="Act
I"}}}{chapter:Chapter={{no:int=2}{name:java.lang.String="Act
II"}}}{chapter:Chapter={{no:int=3}{name:java.lang.String="Act III"}}}}}}}
However, I am having a hard time using recursion to parse the string
back to the Java beans. Any ideas?
The Java Beans have the followingstructure:
public class Book implements java.io.Serializable{
private String name;
private Author author;
private double price;
private Vector chapters;
// Setters and Getters
}
public abstract class AbstractAuthor implements java.io.Serializable {
private String address;
// Setters and Getters
}
public class Author extends AbstractAuthor {
private String name;
private String email;
// Setters and Getters
}
public class Chapter implements java.io.Serializable {
int no;
String name;
// Setters and Getters
}
Thanks,
Edmond
I wrote the code to convert Java bean (using recursion and reflection)
to a string, and the string is:
ie. String text = MyUtil.toText(book);
text={book:Book={{name:java.lang.String="My
Book"}{author:Author={{name:java.lang.String="Edmond
Wong"}{email:java.lang.String="(e-mail address removed)"}{address:java.lang.String="333
S. Hope
St"}}}{price:double=49.99}{chapters:java.util.Vector={{chapter:Chapter={{no:int=1}{name:java.lang.String="Act
I"}}}{chapter:Chapter={{no:int=2}{name:java.lang.String="Act
II"}}}{chapter:Chapter={{no:int=3}{name:java.lang.String="Act III"}}}}}}}
However, I am having a hard time using recursion to parse the string
back to the Java beans. Any ideas?
The Java Beans have the followingstructure:
public class Book implements java.io.Serializable{
private String name;
private Author author;
private double price;
private Vector chapters;
// Setters and Getters
}
public abstract class AbstractAuthor implements java.io.Serializable {
private String address;
// Setters and Getters
}
public class Author extends AbstractAuthor {
private String name;
private String email;
// Setters and Getters
}
public class Chapter implements java.io.Serializable {
int no;
String name;
// Setters and Getters
}
Thanks,
Edmond