Package com.jcasey.jaxb.Books

Examples of com.jcasey.jaxb.Books.Book


  public static void main(String[] args) throws JAXBException, IOException {

    Books books = new Books();
   
    // create books
    Book book1 = new Book();
    book1.setIsbn("978-1617290060");
    book1.setTitle("The Well-Grounded Java Developer: Vital techniques of Java 7 and polyglot programming");
    book1.setAuthor("Benjamin J Evans");
   
    // create genre objects
    Genre java = new Genre();
    java.setType("Java");
   
    Genre scala = new Genre();
    scala.setType("Scala");
   
    book1.setGenres(new Genres()); //Books do not need to *have* a list of Genres so create a list here
   
    // link genres with genre list   
  book1.getGenres().getGenre().add(java);
  book1.getGenres().getGenre().add(scala);
 
  // add book to list of books
    books.getBook().add(book1);
   
   
    // create book2 note there are no genres in this book
    Book book2 = new Book();
    book2.setIsbn("978-3832180577");
    book2.setTitle("Java Concurrency in Practice");
    book2.setAuthor("Brian Goetz");

    // add book to list of books
    books.getBook().add(book2);
   
    // create JAXB context and instantiate marshaller
View Full Code Here

TOP

Related Classes of com.jcasey.jaxb.Books.Book

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.