Package javax.xml.bind

Examples of javax.xml.bind.JAXBContext


   // @Test
   public void testUnmarshalOrdertype() throws Exception
   {
      InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(
              "order_123.xml");
      JAXBContext jaxb = JAXBContext.newInstance(Ordertype.class);
      Unmarshaller u = jaxb.createUnmarshaller();
      Ordertype order = (Ordertype) u.unmarshal(in);
      Assert.assertNotNull(order);
      Assert.assertEquals("Ryan J. McDonough", order.getPerson());
   }
View Full Code Here


         // I'm testing unknown content-length here
         GetMethod method = new GetMethod("http://localhost:8080/async-http-servlet-3.0-test/xml");
         int status = client.executeMethod(method);
         Assert.assertEquals(HttpResponseCodes.SC_OK, status);
         String result = method.getResponseBodyAsString();
         JAXBContext ctx = JAXBContext.newInstance(Customer.class);
         Customer cust = (Customer) ctx.createUnmarshaller().unmarshal(new StringReader(result));
         Assert.assertEquals("Bill Burke", cust.getName());
         method.releaseConnection();
      }

   }
View Full Code Here

      client.putXop(xop);
   }

   private String createCustomerData(String name) throws JAXBException
   {
      JAXBContext context = JAXBContext.newInstance(Customer.class);
      StringWriter writer = new StringWriter();
      context.createMarshaller().marshal(new Customer(name), writer);
      String data = writer.toString();
      return data;
   }
View Full Code Here

    public void setUp() throws Exception
    {
        super.setUp();
        random = new Random();

        JAXBContext context = JAXBContext.newInstance("org.xwiki.rest.model.jaxb");
        marshaller = context.createMarshaller();
        unmarshaller = context.createUnmarshaller();
        objectFactory = new ObjectFactory();

    }
View Full Code Here

    automatedInstallation.getComIzforgeIzpackPanelsUserInputPanelOrComIzforgeIzpackPanelsHTMLLicencePanelOrComIzforgeIzpackPanelsTargetPanel().add(comIzforgeIzpackPanelsFinishPanel);
  
   }
  
   public void writeFile(File output) throws JAXBException {
    JAXBContext context = JAXBContext.newInstance( AutomatedInstallation.class );
     Marshaller m = context.createMarshaller();
    m.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE );
    m.marshal( automatedInstallation, output );   
   }
View Full Code Here

   public boolean eof() {
    return !jsInstallationsIterator.hasNext();
   }

  public void readInstallationDefinitionFile() throws JAXBException  {
   JAXBContext context = JAXBContext.newInstance( Installations.class );
   Unmarshaller unmarshaller = context.createUnmarshaller();
   installations = (Installations) unmarshaller.unmarshal( installationsDefinitionFile );
   listOfInstallations = (ArrayList)installations.getInstallation();
   reset();
   }
View Full Code Here

   listOfInstallations = (ArrayList)installations.getInstallation();
   reset();
   }
  
   public void writeFile(File output) throws JAXBException, ParseException {
    JAXBContext context = JAXBContext.newInstance( Installations.class );

     Marshaller m = context.createMarshaller();
     m.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE );
    m.marshal( installations, output );   
   
   }
View Full Code Here

        Map<String, Object> jaxbConfig = new HashMap<String, Object>();
        JAXBRuntimeBinder annReader = new JAXBRuntimeBinder(mmgr, clr);
        //jaxbConfig.put(JAXBRIContext.DEFAULT_NAMESPACE_REMAP, "DefaultNamespace");
        jaxbConfig.put(JAXBRIContext.ANNOTATION_READER, annReader);

        JAXBContext jaxbContext = JAXBContext.newInstance(new Class[]{obj.getClass()}, jaxbConfig);
        Marshaller marshaller = jaxbContext.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
        marshaller.marshal(obj, node);
    }
View Full Code Here

        Map<String, Object> jaxbConfig = new HashMap<String, Object>();
        JAXBRuntimeBinder annReader = new JAXBRuntimeBinder(mmgr, clr);
        //jaxbConfig.put(JAXBRIContext.DEFAULT_NAMESPACE_REMAP, "DefaultNamespace");
        jaxbConfig.put(JAXBRIContext.ANNOTATION_READER, annReader);

        JAXBContext jaxbContext = JAXBContext.newInstance(new Class[]{cls}, jaxbConfig);
        return jaxbContext.createUnmarshaller().unmarshal(node);
    }
View Full Code Here

  }
 
  private boolean roundTripValidate(JaxbEventBase event, Schema s, Errors errors) {
      try {
      ValidationMonitor monitor = new ValidationMonitor();
      JAXBContext context = JAXBContext.newInstance(event.getClass().getPackage().getName());
      Marshaller marshaller = context.createMarshaller();
      marshaller.setSchema(s);
      marshaller.setEventHandler(monitor);
      Document doc = getTargetDocument();
     
      marshaller.marshal(event.getMarshallableType(), doc);
View Full Code Here

TOP

Related Classes of javax.xml.bind.JAXBContext

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.