Package com.drighetto.jaxb.vo

Examples of com.drighetto.jaxb.vo.Catalog


    try {
      // Create an Unmarshaller
      Unmarshaller unmarshaller = context.createUnmarshaller();

      // Unmarshall XML to Object
      Catalog catalog = (Catalog) unmarshaller.unmarshal(new File("books.xml"));

      // Display object infos to valide unmarshalling
      System.out.printf("Books count : %s\n", catalog.getBook().size());
    } catch (JAXBException e) {
      e.printStackTrace();
      Assert.fail(e.getMessage());
    }
  }
View Full Code Here


    try {
      // Create an Unmarshaller
      Unmarshaller unmarshaller = context.createUnmarshaller();

      // Unmarshall XML to Object
      Catalog catalog = (Catalog) unmarshaller.unmarshal(new File("books.xml"));

      // Display object infos to valide unmarshalling
      System.out.printf("Books description of book[0] : %s\n", catalog.getBook().get(0).getDescription());
      System.out.printf("Books description of book[1] : %s\n", catalog.getBook().get(1).getDescription());
    } catch (JAXBException e) {
      e.printStackTrace();
      Assert.fail(e.getMessage());
    }
  }
View Full Code Here

      // Create an object using ObjectFactory class generated by XJC
      // during
      // mapping generation
      ObjectFactory factory = new ObjectFactory();
      Catalog catalog = factory.createCatalog();
      Catalog.Book book = factory.createCatalogBook();
      book.setAuthor("Dominique");
      book.setDescription("Spring par la pratique");
      book.setGenre("IT");
      book.setId("bk155");
      book.setPrice(22.50f);
      book.setTitle("Spring");
      book.setAvailable(Boolean.TRUE);
      book.setPublishDate(DatatypeFactory.newInstance().newXMLGregorianCalendar((GregorianCalendar) GregorianCalendar.getInstance()));
      catalog.getBook().add(book);

      // Marshall Object to XML file
      marshaller.marshal(catalog, new File("books_sampleMarshalling.xml"));
    } catch (JAXBException e) {
      e.printStackTrace();
View Full Code Here

      // Create an object using ObjectFactory class generated by XJC
      // during
      // mapping generation
      ObjectFactory factory = new ObjectFactory();
      Catalog catalog = factory.createCatalog();
      Catalog.Book book = factory.createCatalogBook();
      book.setAuthor("Dominique");
      book.setDescription("Spring par la pratique");
      book.setGenre("IT");
      book.setId("bk155");
      book.setPrice(22.50f);
      book.setTitle("Spring");
      book.setAvailable(Boolean.TRUE);
      book.setPublishDate(DatatypeFactory.newInstance().newXMLGregorianCalendar((GregorianCalendar) GregorianCalendar.getInstance()));
      catalog.getBook().add(book);

      // Marshall Object to XML file
      marshaller.marshal(catalog, sampleFile);

      // Save "catalog" object hash code in order to check that object
      // reference are different before and after unmarshalling
      int hcBefore = catalog.hashCode();

      /* Step 2 : Unmarshall XML to Object */
      // Create an Unmarshaller
      Unmarshaller unmarshaller = context.createUnmarshaller();

      // Unmarshall XML to Object
      catalog = (Catalog) unmarshaller.unmarshal(sampleFile);

      /* Step 3 : Check behavior of the "StockAdapter" adapter */
      Assert.assertFalse((hcBefore == catalog.hashCode()));
      Assert.assertNotNull(catalog);
      Assert.assertEquals(catalog.getBook().size(), 1);
      Assert.assertNotNull(catalog.getBook().get(0));
      Assert.assertTrue(catalog.getBook().get(0).isAvailable());
    } catch (Exception e) {
      e.printStackTrace();
      Assert.fail(e.getMessage());
    }
  }
View Full Code Here

      // Create an object using ObjectFactory class generated by XJC
      // during
      // mapping generation
      ObjectFactory factory = new ObjectFactory();
      Catalog catalog = factory.createCatalog();
      Catalog.Book book = factory.createCatalogBook();
      book.setAuthor("Dominique");
      book.setDescription("Spring par la pratique");
      book.setGenre("IT");
      book.setId("bk155");
      book.setPrice(22.50f);
      book.setTitle("Spring");
      book.setAvailable(Boolean.TRUE);
      book.setPublishDate(DatatypeFactory.newInstance().newXMLGregorianCalendar((GregorianCalendar) GregorianCalendar.getInstance()));
      catalog.getBook().add(book);

      // Marshall Object to XML file
      marshaller.marshal(catalog, sampleFile);

      // Save "catalog" object hash code in order to check that object
      // reference are different before and after unmarshalling
      @SuppressWarnings("unused")
      int hcBefore = catalog.hashCode();

      /* Step 2 : Unmarshall XML to Object */
      // Create an Unmarshaller
      Unmarshaller unmarshaller = context.createUnmarshaller();
      // Set listener
View Full Code Here

TOP

Related Classes of com.drighetto.jaxb.vo.Catalog

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.