Package javax.xml.bind

Examples of javax.xml.bind.Marshaller.marshal()


      try {
        context = JAXBContext.newInstance(rootClass);
        Marshaller marshaller = context.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
        Object example = rootClass.getConstructor(OServerConfigurationLoaderXml.class).newInstance(this);
        marshaller.marshal(example, System.out);
      } catch (Exception ex) {
      }

      throw new IOException(e);
    }
View Full Code Here


  public void save(final OServerConfiguration iRootObject) throws IOException {
    try {
      context = JAXBContext.newInstance(rootClass);
      Marshaller marshaller = context.createMarshaller();
      marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
      marshaller.marshal(iRootObject, new FileWriter(file));
    } catch (JAXBException e) {
      throw new IOException(e);
    }
  }
View Full Code Here

      Marshaller marshaller = context.createMarshaller();
      marshaller.setSchema(s);
      marshaller.setEventHandler(monitor);
      Document doc = getTargetDocument();
     
      marshaller.marshal(event.getMarshallableType(), doc);
      //dumpDocument(doc, "c:/doc.xml");
     
      /*Unmarshaller unmarshaller = context.createUnmarshaller();
      unmarshaller.setSchema(s);
      unmarshaller.setEventHandler(monitor);
View Full Code Here

        Document doc = getTargetDocument();
       
        if (obj instanceof JaxbEventBase) {
          JaxbEventBase jeb = (JaxbEventBase)obj;
          marshaller.marshal(jeb.getMarshallableType(), doc);
        } else {
          marshaller.marshal(obj, doc);
        }
        result = doc.getDocumentElement();
      } catch (JAXBException e) {
View Full Code Here

       
        if (obj instanceof JaxbEventBase) {
          JaxbEventBase jeb = (JaxbEventBase)obj;
          marshaller.marshal(jeb.getMarshallableType(), doc);
        } else {
          marshaller.marshal(obj, doc);
        }
        result = doc.getDocumentElement();
      } catch (JAXBException e) {
        throw new TranslationException("Unable to marshall response", e); //$NON-NLS-1$
      } catch (Exception e) {
View Full Code Here

      ValidationMonitor monitor = new ValidationMonitor();
      JAXBContext context = JAXBContext.newInstance(this.getClass().getPackage().getName());
      Marshaller marshaller = context.createMarshaller();
      marshaller.setSchema(this.validatingSchema);
      marshaller.setEventHandler(monitor);
      marshaller.marshal(getMarshallableType(), getTargetDocument());
     
      monitor.populate(errors);
      result = errors.isEmpty();
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

    LOGGER.debug("Marshalling " + obj + " in package " + pkg); //$NON-NLS-1$ //$NON-NLS-2$
    JAXBContext jc = JAXBContext.newInstance(pkg, loader);
    Marshaller m = jc.createMarshaller();
    OutputStream ostream = new ByteArrayOutputStream();

    m.marshal(obj, ostream);

    return ostream;
  }
 
  static public Document marshall(Object obj, String pkg, Document targetDoc, ClassLoader loader) throws Exception {
View Full Code Here

 
  static public Document marshall(Object obj, String pkg, Document targetDoc, ClassLoader loader) throws Exception {
    JAXBContext jc = JAXBContext.newInstance(pkg, loader);
    Marshaller m = jc.createMarshaller();

    m.marshal(obj, targetDoc);

    return targetDoc;
  }

  static public InputStream getInputStreamFor(String path, Class<?> clazz) {
View Full Code Here

  {
    try {
      ByteArrayOutputStream baos = new ByteArrayOutputStream();

      Marshaller marshaller = context.createMarshaller();
      marshaller.marshal(payload, baos);

      ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
      _source = new StreamSource(bais);
    }
    catch (Exception e) {
View Full Code Here

        lateArrival.setCutOff(new Frequency("4", Frequency.TimeUnit.hours));
        feed.setLateArrival(lateArrival);

        StringWriter stringWriter = new StringWriter();
        Marshaller marshaller = EntityType.FEED.getMarshaller();
        marshaller.marshal(feed, stringWriter);
        System.out.println(stringWriter.toString());
        parser.parseAndValidate(stringWriter.toString());
    }

    @DataProvider(name = "invalidTableUris")
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.