Web host 4 life - Java & XML, 2nd Edition about it just
Java & XML, 2nd Edition about it just yet. You can compile the type files, as well as the other Castor-generated sources, with this simple command: javac -d . javaxml2/castor/*.java javaxml2/castor/types/*.java At this point, you have classes that are ready to use. I won’t show you the source for these files here, because it’s quite long (and you can look at it yourself). I’ve listed the key methods for the Catalog class, though, so you’ll get an idea of what to expect: package javaxml2.castor; public class Catalog { // Add a new Item public void addItem( ); // Get the items as an Enumeration public Enumeration enumerateItem( ); // Get all items public Item[] getItem( ); // Get number of items public getItemCount( ); } Notice that you can add items, as well as move through the items available. The names of two of these methods, enumerateItem( ) and getItem( ) , are a bit odd, so watch out for those. I did not expect getItem( ) to return an array, and looked for getItems( ) or getItemList( ) first, myself. Once you’ve got these generated classes, though, you’re ready to use them in your application. 15.2.3 Marshalling and Unmarshalling After you’ve compiled the classes Castor generates, add them to your classpath. You can then use them in your own applications. Example 15-3 shows a basic HTML form that allows a user to enter information about a new item. Example 15-3. HTML form for adding items
Add New Item