|
|
||
Scott Schram's BlogSeptember 2005 ArchivesEclipseCon 2006 Adopts Transparent Call for ParticipationPosted by scottschram on September 30, 2005 at 09:53 AM | Permalink | Comments (0)EclipseCon scheduled for March 20-23, 2006 has adopted an open and transparent call for participation policy. All submissions are being handled via a modified Bugzilla system known as Eclipsezilla. "Anyone in the community (including you) is welcome to review the submissions, ask for more information, provide comments and critiques, and even vote on which ones you'd like to see at the conference - just as anyone in (the) community is invited and encouraged to do for Eclipse bugs and features via Bugzilla." It's going to be interesting to watch this process work. The XStream library offers clean, easy XML serialization of POJOs.Posted by scottschram on September 15, 2005 at 12:49 PM | Permalink | Comments (9)XStream serializes and restores very clean, readable XML from POJOs, like this:
public class Publisher {
private String publisherID;
private String name;
// getters and setters...
}
Becomes:
Using two lines of code (although you can customize lots of things if needed.) XStream xstream = new XStream(); String xml = xstream.toXML(obj); If you don't want it to include the fully qualified class name: <com.choralmusic.db.Publisher> Add one line: xstream.alias("Publisher", Publisher.class);
Collections look great, for example, this ArrayList of Listing objects:
<listings>
<Listing>
<pageRef>church_christmas</pageRef>
<includeCover>false</includeCover>
</Listing>
<Listing>
<pageRef>school_winter</pageRef>
<includeCover>false</includeCover>
</Listing>
</listings>
Restoring the object is two lines (with optional aliases):
XStream xstream = new XStream();
// If you don't have fully qualified names, add one or more aliases:
xstream.alias("CatalogItem", CatalogItem.class);
catalogItems = (ArrayList
The XML suitable for editing by hand for configuration or if persisted to a file. It would be very easy to manipulate via XSLT or XQUERY. It makes a nice readable toString() for debugging. License: BSD derived, commercial friendly. Dependencies: none (!), XML Pull Parser optional to improve performance. Limitations When using the Sun 1.4 (and 1.5) JVM, XStream can reinstantiate classes that do not have a default constructor. (Cool rule-breaking magic.) Other JVMs require a default constructor. Check out XStream and the two minute tutorial. XStream has worked very well for me. Thanks to Malcolm Davis for pointing out this terrific library. | ||
|
|