Package javax.xml.bind

Examples of javax.xml.bind.Unmarshaller.unmarshal()


  @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 {
    JAXBContext jc = JAXBContext.newInstance(thePackage);
View Full Code Here


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

    return obj;
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

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

   // @Test
View Full Code Here

  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();
   }
  
   public void writeFile(File output) throws JAXBException, ParseException {
View Full Code Here

      final OServerConfiguration obj;

      if (file != null) {
        if (file.exists())
          obj = rootClass.cast(unmarshaller.unmarshal(file));
        else
          return rootClass.getConstructor(OServerConfigurationLoaderXml.class, String.class).newInstance(this, file);
        obj.location = file.getAbsolutePath();
      } else {
        obj = rootClass.cast(unmarshaller.unmarshal(new StringReader(configurationText)));
View Full Code Here

          obj = rootClass.cast(unmarshaller.unmarshal(file));
        else
          return rootClass.getConstructor(OServerConfigurationLoaderXml.class, String.class).newInstance(this, file);
        obj.location = file.getAbsolutePath();
      } else {
        obj = rootClass.cast(unmarshaller.unmarshal(new StringReader(configurationText)));
        obj.location = "memory";
      }

      // AUTO CONFIGURE SYSTEM CONFIGURATION
      OGlobalConfiguration config;
View Full Code Here

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

  static public OutputStream marshall(Object obj, String pkg,
      ClassLoader loader) throws Exception {
    LOGGER.debug("Marshalling " + obj + " in package " + pkg); //$NON-NLS-1$ //$NON-NLS-2$
View Full Code Here

        _context = JAXBContext.newInstance("com.caucho.soap.wsdl:" +
                                           "com.caucho.xml.schema");
      }

      Unmarshaller unmarshaller = _context.createUnmarshaller();
      return (WSDLDefinitions) unmarshaller.unmarshal(is);
    }
    catch (JAXBException e) {
      throw e;
    }
    catch (Exception e) {
View Full Code Here

  public Object getPayload(JAXBContext context)
    throws WebServiceException
  {
    try {
      Unmarshaller unmarshaller = context.createUnmarshaller();
      return unmarshaller.unmarshal(_source);
    }
    catch (Exception e) {
      throw new WebServiceException(e);
    }
  }
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.