Package org.exolab.castor.xml

Examples of org.exolab.castor.xml.Marshaller


    {
      ((ParseException)throwable).toXML(super.contentHandler);
      return;
    }
     
    Marshaller marshaller = new Marshaller(super.contentHandler);

    try
    {
      marshaller.marshal(throwable);
    }
    catch (MarshalException me)
    {
      throw new ProcessingException(me);
    }
View Full Code Here


    }

  public void storeObject(OutputStream stream, Map parameters, Object object) throws ConverterException {
        Writer writer = new OutputStreamWriter(stream);
    try {
      Marshaller marshaller = new Marshaller( writer );
      marshaller.setMapping((Mapping)this.mappings.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

  }
 
  public static final void writeXML(Object _response, HttpServletResponse _httpResponse) throws MarshalException, ValidationException, IOException, MappingException {
    _httpResponse.addHeader("Content-Type", "application/xml");
    StringWriter writer = new StringWriter();
    Marshaller marshaller = new Marshaller(writer);
    marshaller.setMapping(MAPPING);
    marshaller.marshal(_response);
    if (LOG.isDebugEnabled()) {
      LOG.debug("Writing XML [" + writer.toString() + "]");
    }
    _httpResponse.getWriter().write(writer.toString());
  }
View Full Code Here

            // tags enabling Castor XML binding; see JETSPEED-INF/castor/page-mapping.xml
            writer = new OutputStreamWriter(new FileOutputStream(f), PSML_DOCUMENT_ENCODING);
            Serializer serializer = new XMLSerializer(writer, this.format);
            final ContentHandler handler = serializer.asContentHandler();
           
            Marshaller marshaller = new Marshaller(new ContentHandler()
                {
                    private int menuDepth = 0;
                   
                    public void characters(char[] ch, int start, int length) throws SAXException
                    {
                        handler.characters(ch, start, length);
                    }

                    public void endDocument() throws SAXException
                    {
                        handler.endDocument();
                    }
                   
                    public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
                    {
                        handler.ignorableWhitespace(ch, start, length);
                    }
                   
                    public void processingInstruction(String target, String data) throws SAXException
                    {
                        handler.processingInstruction(target, data);
                    }
                   
                    public void setDocumentLocator(Locator locator)
                    {
                        handler.setDocumentLocator(locator);
                    }
                   
                    public void startDocument() throws SAXException
                    {
                        handler.startDocument();
                    }
                   
          public void endElement(String uri, String localName, String qName) throws SAXException {
                        // track menu depth
                        if (qName.equals("menu"))
                        {
                            menuDepth--;
                        }

                        // filter menu-element noded within menu definition
                        if ((menuDepth == 0) || !qName.equals("menu-element"))
                        {
                            handler.endElement(uri, localName, qName);
                        }
          }

          public void endPrefixMapping(String prefix) throws SAXException {
          }

          public void skippedEntity(String name) throws SAXException {
            handler.skippedEntity(name);
          }

          public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
                        // filter menu-element noded within menu definition
                        if ((menuDepth == 0) || !qName.equals("menu-element"))
                        {
                            handler.startElement(uri,localName, qName, atts);
                        }

                        // track menu depth
                        if (qName.equals("menu"))
                        {
                            menuDepth++;
                        }
          }

          public void startPrefixMapping(String prefix, String uri) throws SAXException {
          }
                });
            marshaller.setResolver((XMLClassDescriptorResolver) classDescriptorResolver);
           
            marshaller.setValidation(false); // results in better performance
            marshaller.marshal(document);
        }
        catch (MarshalException e)
        {
            log.error("Could not marshal the file " + f.getAbsolutePath(), e);
            throw new FailedToUpdateDocumentException(e);
View Full Code Here

    }

    public void marshal(Exchange exchange, Object body, OutputStream outputStream) throws Exception {
        Writer writer = new OutputStreamWriter(outputStream, encoding);

        Marshaller marshaller = createMarshaller(exchange);
        marshaller.setWriter(writer);
        marshaller.marshal(body);
    }
View Full Code Here

        return answer;
    }

    public Marshaller createMarshaller(Exchange exchange) throws Exception {
        // need to create new marshaller as we may have concurrent processing
        Marshaller answer = xmlContext.createMarshaller();
        answer.setValidation(isValidation());
        return answer;
    }
View Full Code Here

            // tags enabling Castor XML binding; see JETSPEED-INF/castor/page-mapping.xml
            writer = new OutputStreamWriter(new FileOutputStream(f), PSML_DOCUMENT_ENCODING);
            Serializer serializer = new XMLSerializer(writer, this.format);
            final ContentHandler handler = serializer.asContentHandler();
           
            Marshaller marshaller = new Marshaller(new ContentHandler()
                {
                    private int menuDepth = 0;
                   
                    public void characters(char[] ch, int start, int length) throws SAXException
                    {
                        handler.characters(ch, start, length);
                    }

                    public void endDocument() throws SAXException
                    {
                        handler.endDocument();
                    }
                   
                    public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
                    {
                        handler.ignorableWhitespace(ch, start, length);
                    }
                   
                    public void processingInstruction(String target, String data) throws SAXException
                    {
                        handler.processingInstruction(target, data);
                    }
                   
                    public void setDocumentLocator(Locator locator)
                    {
                        handler.setDocumentLocator(locator);
                    }
                   
                    public void startDocument() throws SAXException
                    {
                        handler.startDocument();
                    }
                   
          public void endElement(String uri, String localName, String qName) throws SAXException {
                        // track menu depth
                        if (qName.equals("menu"))
                        {
                            menuDepth--;
                        }

                        // filter menu-element noded within menu definition
                        if ((menuDepth == 0) || !qName.equals("menu-element"))
                        {
                            handler.endElement(uri, localName, qName);
                        }
          }

          public void endPrefixMapping(String prefix) throws SAXException {
          }

          public void skippedEntity(String name) throws SAXException {
            handler.skippedEntity(name);
          }

          public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
                        // filter menu-element noded within menu definition
                        if ((menuDepth == 0) || !qName.equals("menu-element"))
                        {
                            handler.startElement(uri,localName, qName, atts);
                        }

                        // track menu depth
                        if (qName.equals("menu"))
                        {
                            menuDepth++;
                        }
          }

          public void startPrefixMapping(String prefix, String uri) throws SAXException {
          }
                });
            marshaller.setResolver((XMLClassDescriptorResolver) classDescriptorResolver);
           
            marshaller.setValidation(false); // results in better performance
            marshaller.marshal(document);
        }
        catch (MarshalException e)
        {
            log.error("Could not marshal the file " + f.getAbsolutePath(), e);
            throw new FailedToUpdateDocumentException(e);
View Full Code Here

                new FileWriter(webAppsDir + webModule +
                                               System.getProperty("file.separator") + "WEB-INF"+
                                               System.getProperty("file.separator") + "web.xml");
            XMLSerializer serializer = new XMLSerializer(writer, of);
            try {
            Marshaller marshaller =
                new Marshaller(serializer.asDocumentHandler());
            marshaller.setMapping(mappingWebXml);
            marshaller.marshal(webApp);
            } catch (Exception e) {
                writer.close();
                e.printStackTrace(System.out);
                throw new Exception();
            }
View Full Code Here

        if (!f.isAbsolute())
           filename = servletContext.getRealPath(filename);
       
        FileWriter writer = new FileWriter(filename);
       
        Marshaller marshaller = new Marshaller(writer);
       
        marshaller.setMapping(this.mapping);
       
        marshaller.marshal(registry);
    }
View Full Code Here

            // tags enabling Castor XML binding; see JETSPEED-INF/castor/page-mapping.xml
            writer = new OutputStreamWriter(new FileOutputStream(f), PSML_DOCUMENT_ENCODING);
            XMLWriter xmlWriter = new XMLWriter(writer, this.format);
            final ContentHandler handler = xmlWriter;
           
            Marshaller marshaller = new Marshaller(new ContentHandler()
                {
                    private int menuDepth = 0;
                   
                    public void characters(char[] ch, int start, int length) throws SAXException
                    {
                        handler.characters(ch, start, length);
                    }

                    public void endDocument() throws SAXException
                    {
                        handler.endDocument();
                    }
                   
                    public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
                    {
                        handler.ignorableWhitespace(ch, start, length);
                    }
                   
                    public void processingInstruction(String target, String data) throws SAXException
                    {
                        handler.processingInstruction(target, data);
                    }
                   
                    public void setDocumentLocator(Locator locator)
                    {
                        handler.setDocumentLocator(locator);
                    }
                   
                    public void startDocument() throws SAXException
                    {
                        handler.startDocument();
                    }
                   
          public void endElement(String uri, String localName, String qName) throws SAXException {
                        // track menu depth
                        if (qName.equals("menu"))
                        {
                            menuDepth--;
                        }

                        // filter menu-element noded within menu definition
                        if ((menuDepth == 0) || !qName.equals("menu-element"))
                        {
                            handler.endElement(uri, localName, qName);
                        }
          }

          public void endPrefixMapping(String prefix) throws SAXException {
          }

          public void skippedEntity(String name) throws SAXException {
            handler.skippedEntity(name);
          }

          public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
                        // filter menu-element noded within menu definition
                        if ((menuDepth == 0) || !qName.equals("menu-element"))
                        {
                            handler.startElement(uri,localName, qName, atts);
                        }

                        // track menu depth
                        if (qName.equals("menu"))
                        {
                            menuDepth++;
                        }
          }

          public void startPrefixMapping(String prefix, String uri) throws SAXException {
          }
                });
            marshaller.setResolver((XMLClassDescriptorResolver) classDescriptorResolver);
           
            marshaller.setValidation(false); // results in better performance
            marshaller.marshal(document);
        }
        catch (MarshalException e)
        {
            log.error("Could not marshal the file " + absolutePath, e);
            throw new FailedToUpdateDocumentException(e);
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.