Package javax.xml.bind

Examples of javax.xml.bind.JAXBContext.createUnmarshaller()


  @SuppressWarnings("unchecked")
  public static Object buildFromString(String source, String thePackage) throws JAXBException, IOException {
    Object obj = null;
    JAXBContext jc = JAXBContext.newInstance(thePackage);
    Unmarshaller unmarshaller = jc.createUnmarshaller();
    obj = ((JAXBElement)unmarshaller.unmarshal(new StringReader(source)));
    return obj;
  }
   
  public static void outputEntity(Object obj, String thePackage) throws JAXBException {
View Full Code Here


  @SuppressWarnings("unchecked")
  public static Object unmarshallFromInputStream(InputStream inputStream, String thePackage) throws JAXBException {
    Object obj = null;
    if (inputStream != null) {
      JAXBContext jc = JAXBContexts.get(thePackage);
      Unmarshaller unmarshaller = jc.createUnmarshaller();
      obj = ((JAXBElement)unmarshaller.unmarshal(inputStream)).getValue();
    }
    else
      logger.error("A null input stream was provided");
View Full Code Here

  }
 
  @SuppressWarnings("unchecked")
  public static Object unmarshallFromElement(Element element, String thePackage) throws JAXBException {
    JAXBContext jc = JAXBContexts.get(thePackage);
    Unmarshaller unmarshaller = jc.createUnmarshaller();
    Object obj = ((JAXBElement) unmarshaller.unmarshal(element)).getValue();
    return obj;
  }
 
}
View Full Code Here

   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

         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

        super.setUp();
        random = new Random();

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

    }

    public void setPort(int port)
View Full Code Here

    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

        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);
    }

    public JAXBRuntimeBinder(MetaDataManager metaDataMgr, ClassLoaderResolver clr)
    {
        this.metaDataMgr = metaDataMgr;
View Full Code Here

    List<SoapEventMap> events = new ArrayList<SoapEventMap>();

    try {
      JAXBContext jcontext = JAXBContext.newInstance(this.eventPkg);

      Unmarshaller unmarshaller = jcontext.createUnmarshaller();

      if (this.elements != null) {
        for (Element element : this.elements) {
          if (element != null) {
            SoapEventMap event = new SoapEventMap();
View Full Code Here

  static public Object unmarshall(String path, String pkg, ClassLoader loader)
      throws Exception {
    LOGGER.debug("Unmarshalling " + path + " in package " + pkg); //$NON-NLS-1$ //$NON-NLS-2$
    JAXBContext jc = JAXBContext.newInstance(pkg, loader);
    Unmarshaller u = jc.createUnmarshaller();
    InputStream istream = ClassLoader.getSystemResourceAsStream(path);

    return u.unmarshal(istream);
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.