Package org.exolab.castor.xml

Examples of org.exolab.castor.xml.Marshaller


    }

  public void storeObject(OutputStream stream, Map parameters, Object object) throws ConverterException {
        Writer writer = new OutputStreamWriter(stream);
    try {
      Marshaller marshaller = new Marshaller( writer );
      Mapping mapping = new Mapping();
      marshaller.setMapping((Mapping)this.mappings.get(parameters.get(parameters.get("profiletype"))));
      marshaller.marshal(object);
      writer.close();
    } catch (MappingException e) {
      throw new ConverterException("can't create Unmarshaller", e);
    } catch (Exception e) {
      throw new ConverterException(e.getMessage(), e);
View Full Code Here


  {
    try
    {
      StringWriter stringWriter = new StringWriter();

      Marshaller marshaller = new Marshaller(stringWriter);
      marshaller.setMapping(mapping);
      marshaller.setEncoding("ISO-8859-15");
      marshaller.marshal(object);
      stringWriter.close();

      return stringWriter.getBuffer().toString();
    }
    catch (CastorException e)
View Full Code Here

    File fileOut = new File(directory, "temp.xml");
    FileUtils.forceMkdir(directory);
    fileOut.createNewFile();
    FileWriter writer = new FileWriter(fileOut);

    Marshaller marshaller = new Marshaller(writer);
    marshaller.marshal(request);
  }
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

        public void saveHistory() {
            // write back the history to file
            try{
                FileWriter writer = new FileWriter("queryhistory.xml");
                Marshaller marshaller = new Marshaller(writer);
                marshaller.setMapping(mapping);
                marshaller.marshal(qhistory);
            } catch(Exception e) {
                e.printStackTrace();
            }
        }
View Full Code Here

     * @param writer, the Writer to serialize the mapping to
    **/
    public void write( Writer writer )
        throws MappingException
    {
        Marshaller  marshal;
        MappingRoot mapping;
        Enumeration enumeration;

        try {
            mapping = new MappingRoot();
            mapping.setDescription( "Castor generated mapping file" );
            enumeration = _mappings.elements();
            while ( enumeration.hasMoreElements() )
                mapping.addClassMapping( (ClassMapping) enumeration.nextElement() );
            marshal = new Marshaller( writer );
            marshal.setNamespaceMapping(null, "http://castor.exolab.org/");
            marshal.setNamespaceMapping("cst", "http://castor.exolab.org/");
            marshal.marshal( mapping );
        } catch ( Exception except ) {
            throw new MappingException( except );
        }
    } //-- write
View Full Code Here

    // see http://jira.codehaus.org/browse/CASTOR-2220
    // Fixed in v1.2. We are using castor-xml-1.3
    DateFieldHandler.setDefaultTimeZone(UTC);

    try {
      Marshaller m = new Marshaller(new BufferedWriter(out));
      m.marshal(gpx);
    } catch (Exception ex) {
      IOException ioex = new IOException("Error writing GPX.");
      ioex.initCause(ex);
      throw ioex;
    } finally {
View Full Code Here

                          Object value,
                          SerializationContext context)
            throws IOException {
        try {
            AxisContentHandler hand = new AxisContentHandler(context);
            Marshaller marshaller = new Marshaller(hand);

            // 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);
            String localPart = name.getLocalPart();
            int arrayDims = localPart.indexOf('[');
            if (arrayDims != -1) {
                localPart = localPart.substring(0, arrayDims);
            }
            marshaller.setRootElement(localPart);
            // Marshall the Castor object into the stream (sink)
            marshaller.marshal(value);
        } catch (MarshalException me) {
            log.error(Messages.getMessage("castorMarshalException00"), me);
            throw new IOException(Messages.getMessage(
                    "castorMarshalException00")
                    + me.getLocalizedMessage());
View Full Code Here

           filename = servletContext.getRealPath(filename);
       
        FileWriter writer = new FileWriter(filename);
       
        try {
            Marshaller marshaller = new Marshaller(writer);

            marshaller.setMapping(this.mapping);

            registry.preStore(null);

            marshaller.marshal(registry);

            registry.postStore(null);
        }
        catch (org.exolab.castor.mapping.MappingException e)
        {
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.