Package com.fasterxml.jackson.dataformat.xml.ser

Examples of com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator


    @Override
    public ToXmlGenerator createJsonGenerator(OutputStream out, JsonEncoding enc)
        throws IOException
    {
        // false -> we won't manage the stream unless explicitly directed to
        return new ToXmlGenerator(_createContext(out, false),
                _generatorFeatures, _xmlGeneratorFeatures,
                _objectCodec, _createXmlWriter(out));
    }
View Full Code Here


    @Override
    public ToXmlGenerator createJsonGenerator(Writer out)
        throws IOException
    {
        return new ToXmlGenerator(_createContext(out, false),
                _generatorFeatures, _xmlGeneratorFeatures,
                _objectCodec, _createXmlWriter(out));
    }
View Full Code Here

    {
        OutputStream out = new FileOutputStream(f);
        // true -> yes, we have to manage the stream since we created it
        IOContext ctxt = _createContext(out, true);
        ctxt.setEncoding(enc);
        return new ToXmlGenerator(ctxt, _generatorFeatures, _xmlGeneratorFeatures,
                _objectCodec, _createXmlWriter(out));
    }
View Full Code Here

     * a time.
     *
     * @since 2.4
     */
    public void writeValue(XMLStreamWriter w0, Object value) throws IOException {
        @SuppressWarnings("resource")
        ToXmlGenerator g = getFactory().createGenerator(w0);
        super.writeValue(g, value);
        /* NOTE: above call should do flush(); and we should NOT close here.
         * Finally, 'g' has no buffers to release.
         */
 
View Full Code Here

   
    @Override
    public ToXmlGenerator createGenerator(OutputStream out, JsonEncoding enc) throws IOException
    {
        // false -> we won't manage the stream unless explicitly directed to
        return new ToXmlGenerator(_createContext(out, false),
                _generatorFeatures, _xmlGeneratorFeatures,
                _objectCodec, _createXmlWriter(out));
    }
View Full Code Here

    }
   
    @Override
    public ToXmlGenerator createGenerator(Writer out) throws IOException
    {
        return new ToXmlGenerator(_createContext(out, false),
                _generatorFeatures, _xmlGeneratorFeatures,
                _objectCodec, _createXmlWriter(out));
    }
View Full Code Here

    {
        OutputStream out = new FileOutputStream(f);
        // true -> yes, we have to manage the stream since we created it
        IOContext ctxt = _createContext(out, true);
        ctxt.setEncoding(enc);
        return new ToXmlGenerator(ctxt, _generatorFeatures, _xmlGeneratorFeatures,
                _objectCodec, _createXmlWriter(out));
    }
View Full Code Here

            sw = _initializeXmlWriter(sw);
        } catch (XMLStreamException e) {
            return StaxUtil.throwXmlAsIOException(e);
        }
        IOContext ctxt = _createContext(sw, false);
        return new ToXmlGenerator(ctxt, _generatorFeatures, _xmlGeneratorFeatures,
                _objectCodec, sw);
    }
View Full Code Here

    @SuppressWarnings("resource")
    protected String _writeXml(XmlFactory f, boolean useBytes) throws IOException
    {
        if (useBytes) {
            ByteArrayOutputStream bytes = new ByteArrayOutputStream();
            ToXmlGenerator jg = f.createGenerator(bytes);
            _write(f, jg);
            return bytes.toString("UTF-8");
        }
        StringWriter sw = new StringWriter();
        ToXmlGenerator jg = f.createGenerator(sw);
        _write(f, jg);
        return sw.toString();
    }
View Full Code Here

    public void testIssue54() throws Exception
    {
        XmlMapper xmlMapper = new XmlMapper();
        xmlMapper.enable(ToXmlGenerator.Feature.WRITE_XML_DECLARATION);
        StringWriter sw = new StringWriter();
        ToXmlGenerator generator = (ToXmlGenerator) xmlMapper.getFactory().createGenerator(sw);
        generator.initGenerator();

        generator.setNextName(new QName("items"));
        generator.writeStartObject();
        ArrayList<Value> values = new ArrayList<Value>();
        values.add(new Value(13));
        values.add(new Value(456));
        for (Value value : values) {
            generator.writeFieldName("foo");
            generator.setNextName(new QName("item"));
            generator.writeObject(value);
        }
        generator.writeEndObject();
        generator.close();
       
        String xml = sw.toString();
       
        // Remove XML declaration
        assertTrue(xml.startsWith("<?xml version"));
View Full Code Here

TOP

Related Classes of com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator

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.