Package org.exolab.castor.xml

Examples of org.exolab.castor.xml.Marshaller


    if (f1.exists()) {
      Mapping mapping = new Mapping();
      try {
  mapping.loadMapping(mappingfile);
  Writer writer = new FileWriter(filename);
  Marshaller marshaller = new Marshaller(writer);
  marshaller.setMapping(mapping);
  marshaller.marshal(this);
  writer.close();
 
  log.info("written to XML");
      } catch (Exception e) {
  log.error(e.getMessage());
View Full Code Here


     * @see de.netseeker.ejoe.adapter.SerializeAdapter#write(java.lang.Object, java.io.OutputStream)
     */
    public void write( Object obj, OutputStream out ) throws Exception
    {
        Writer writer = new OutputStreamWriter( out, EJConstants.EJOE_DEFAULT_CHARSET );
        Marshaller marshaller = new Marshaller( writer );
        try
        {
            if ( _mapping != null )
            {
                marshaller.setMapping( _mapping );
            }
            // marshaller.setResolver(_cdr);
            marshaller.setValidation( false );
            marshaller.setSuppressXSIType( false );
            marshaller.setUseXSITypeAtRoot( true );
            marshaller.setMarshalExtendedType( true );
            marshaller.setResolver( _cdr );
            marshaller.marshal( obj );
        }
        finally
        {
            IOUtil.closeQuiet( writer );
        }
View Full Code Here

      writer.println( "Query result: " + results.next() );
    }
    writer.println( "Commit transaction" );
    db.commit();

    Marshaller     marshaller;

    marshaller = new Marshaller( writer );
    marshaller.setMapping( _mapping );

    db.begin();
    marshaller.marshal( db.load( Product.class, new Integer( 4 ) ) );
    computerOql = db.getOQLQuery( "SELECT c FROM myapp.Computer c" );
    results = computerOql.execute();
    while( results.hasMore() )
      marshaller.marshal( results.next() );
    db.commit();

    db.close();
  }
View Full Code Here

   
    try
    {
      mis = JRLoader.getLocationInputStream(MAPPING_FILE);

      Marshaller marshaller = new Marshaller(writer);

      Mapping mapping = new Mapping();
      mapping.loadMapping(
        new InputSource(mis)
        );
      marshaller.setMapping(mapping);

      marshaller.marshal(settings);
    }
    catch (IOException e)
    {
      throw new JRRuntimeException(e);
    }
View Full Code Here

        }
    }

    private void insertBean (String name, Object bean, String map) {
        try {
            Marshaller marshaller = new Marshaller(new IncludeXMLConsumer(super.contentHandler));
            try {
                Mapping mapping = null;
                if (map != null) {
                    mapping = loadMapping(map);
                } else {
                    mapping = defaultMapping;
                }
                marshaller.setMapping(mapping);
            } catch (Exception e) {
                getLogger().warn("Unable to load mapping " + map, e);
            }

            if (bean instanceof Collection) {
                Iterator i = ((Collection)bean).iterator();
                while (i.hasNext()) {
                    marshaller.marshal(i.next());
                }
            } else {
                marshaller.marshal(bean);
            }
        } catch (Exception e) {
            getLogger().warn("Failed to marshal bean " + name, e);
        }
    }
View Full Code Here

        try {

            writer = new StringWriter();

            // Create a Castor Marshaller initialized with the output stream
            Marshaller marshaller =new Marshaller(writer);

            // Don't include the DOCTYPE, otherwise an exception occurs due to
            //2 DOCTYPE defined in the document. The XML fragment is included in
            //an XML document containing already a DOCTYPE
            marshaller.setMarshalAsDocument(false);

            // Marshall the Castor object into the stream (sink)
            marshaller.marshal(value);

            context.writeString(writer.toString());
        } catch (MarshalException me) {
            log.error(Messages.getMessage("castorMarshalException00"), me);
            throw new IOException(Messages.getMessage("castorMarshalException00")
View Full Code Here

                 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN",
                 "http://java.sun.com/dtd/web-app_2_3.dtd");

            FileWriter writer = new FileWriter("newWeb.xml");
            XMLSerializer serializer = new XMLSerializer(writer, of);
        Marshaller marsh = new Marshaller(serializer.asDocumentHandler());
        marsh.setDebug(debug);
        marsh.setMapping(mapping);
        marsh.marshal(config);

    }
View Full Code Here

        OutputStreamWriter writer =
            new OutputStreamWriter(getOutputStream());
        XMLSerializer serializer = new XMLSerializer(writer, of);

        try {
            Marshaller marshaller =
                new Marshaller(serializer.asDocumentHandler());
            marshaller.setMapping(getCastorMapping());
            marshaller.marshal(object);
        } catch(IOException io) {
            throw io;
        } catch (Exception e) {
            throw new IOException(e.getMessage());
        }
View Full Code Here

        OutputStreamWriter writer =
            new OutputStreamWriter(out);

        try {
            Marshaller marshaller =
                new Marshaller(new DefaultHandler()); //serializer.asDocumentHandler());
            marshaller.setMapping(getCastorMapping());
            marshaller.marshal(object);
        } catch(IOException io) {
            throw io;
        } catch (Exception e) {
            throw new IOException(e.getMessage());
        }
View Full Code Here

      String filename = PlutoAdminContext.getInstance().getPlutoHome() + "/" + CONFIG_FILE;
      logDebug(METHOD_NAME, "Registry file to save: " + filename);

        FileWriter writer = new FileWriter(filename);

        Marshaller marshaller = new Marshaller(writer);

        marshaller.setMapping(this.mapping);

        marshaller.marshal(apps);
    }
View Full Code Here

TOP

Related Classes of org.exolab.castor.xml.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.