Package javax.xml.bind

Examples of javax.xml.bind.Marshaller


      juddiUsers.getUser().add(new User("bozo",cryptor.encrypt("clown")));
      juddiUsers.getUser().add(new User("sviens",cryptor.encrypt("password")));
     
      StringWriter writer = new StringWriter();
      JAXBContext context = JAXBContext.newInstance(juddiUsers.getClass());
      Marshaller marshaller = context.createMarshaller();
      marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
      marshaller.marshal(juddiUsers, writer);
      logger.info("\n" +  writer.toString());
    } catch (Exception e) {
      logger.error(e.getMessage(),e);
      Assert.fail("unexpected");
    }
View Full Code Here


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

        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

      // SYNTAX ERROR? PRINT AN EXAMPLE
      OLogManager.instance().error(this, "Invalid syntax. Below an example of how it should be:", e);

      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

 
  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);
      //dumpDocument(doc, "c:/doc.xml");
     
      /*Unmarshaller unmarshaller = context.createUnmarshaller();
      unmarshaller.setSchema(s);
      unmarshaller.setEventHandler(monitor);
View Full Code Here

    if ((obj != null) && obj instanceof Element) {
      result = (Element) obj;
    } else if (obj != null) {
      try {
        JAXBContext jcontext = JAXBContext.newInstance(this.eventPkg);
        Marshaller marshaller = jcontext.createMarshaller();

        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) {
        throw new TranslationException("Unable to marshall response", e); //$NON-NLS-1$
      } catch (Exception e) {
View Full Code Here

        String evtName = this.getEventName();
        this.setEventName(null);
        try {
      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

  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$
    JAXBContext jc = JAXBContext.newInstance(pkg, loader);
    Marshaller m = jc.createMarshaller();
    OutputStream ostream = new ByteArrayOutputStream();

    m.marshal(obj, ostream);

    return ostream;
  }
View Full Code Here

TOP

Related Classes of javax.xml.bind.Marshaller

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.