Package org.exolab.castor.xml

Examples of org.exolab.castor.xml.Serializer


     * @throws IOException in case taht wrapping the Writer fails
    **/
    public SchemaWriter(final Writer writer)
    throws IOException {
        this();
        Serializer serializer = _schemaContext.getSerializer();

        if (serializer == null) {
            throw new IOException("Unable to obtain serailizer");
        }

        serializer.setOutputCharStream(writer);

        DocumentHandler handler = serializer.asDocumentHandler();

        if (handler == null) {
            String err = "The following serializer is not SAX capable: ";
            err += serializer.getClass().getName();
            err += "; cannot proceed.";
            throw new IOException(err);
        }

        _handler = handler;
View Full Code Here


     * To set the DocumentHandler to a Writer - which is wrapped by a serializer.
     * @param writer the Writer to use for output
     * @throws IOException in case the Writer cannot be used for DocumentHandler
     */
    public void setDocumentHandler(final Writer writer) throws IOException {
        Serializer serializer = _schemaContext.getSerializer();

        if (serializer == null) {
            String message = "Unable to obtain serailizer";
            LOG.warn(message);
            throw new IOException(message);
        }

        serializer.setOutputCharStream(writer);

        DocumentHandler handler = serializer.asDocumentHandler();

        if (handler == null) {
            String err = "The following serializer is not SAX capable: ";
            err += serializer.getClass().getName();
            err += "; cannot proceed.";
            LOG.warn(err);
            throw new IOException(err);
        }

View Full Code Here

   
    /**
     * @see org.castor.xml.InternalContext#getSerializer()
     */
    public static Serializer getSerializer(final AbstractProperties properties) {
        Serializer serializer = getSerializerFactory(
                properties.getString(XMLProperties.SERIALIZER_FACTORY)).getSerializer();
        serializer.setOutputFormat(getOutputFormat(properties));
        return serializer;
    }
View Full Code Here

    /**
     * @see org.castor.xml.InternalContext#getSerializer(java.io.OutputStream)
     */
    public DocumentHandler getSerializer(final OutputStream output) throws IOException {
        Serializer serializer;
        DocumentHandler docHandler;

        serializer = getSerializer();
        serializer.setOutputByteStream(output);
        docHandler = serializer.asDocumentHandler();
        if (docHandler == null) {
            throw new RuntimeException(Messages.format("conf.serializerNotSaxCapable", serializer
                    .getClass().getName()));
        }
        return docHandler;
    }
View Full Code Here

    /**
     * @see org.castor.xml.InternalContext#getSerializer(java.io.Writer)
     */
    public DocumentHandler getSerializer(final Writer output) throws IOException {
        Serializer serializer;
        DocumentHandler docHandler;

        serializer = getSerializer();
        serializer.setOutputCharStream(output);
        docHandler = serializer.asDocumentHandler();
        if (docHandler == null) {
            throw new RuntimeException(Messages.format("conf.serializerNotSaxCapable", serializer
                    .getClass().getName()));
        }
        return docHandler;
    }
View Full Code Here

     * representation is a xml well-formed fragment corresponding to the
     * representation of this node.
     * @return the String representation of this AnyNode.
     */
    public String toString() {
        Serializer serializer = new BackwardCompatibilityContext().getSerializer();
        if (serializer == null) {
            throw new RuntimeException("Unable to obtain serializer");
        }

        StringWriter writer = new StringWriter();

        serializer.setOutputCharStream(writer);

        try {
            AnyNode2SAX.fireEvents(this, serializer.asDocumentHandler());
        } catch (java.io.IOException ioe) {
            return privateToString();
        } catch (org.xml.sax.SAXException saxe) {
            throw new RuntimeException(saxe.getMessage());
        }
View Full Code Here

TOP

Related Classes of org.exolab.castor.xml.Serializer

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.