Examples of BadgerFishXMLStreamWriter


Examples of org.codehaus.jettison.badgerfish.BadgerFishXMLStreamWriter

                         strWriter.toString());
    }

    public void testDefaultNamespace() throws Exception {
        StringWriter strWriter = new StringWriter();
        BadgerFishXMLStreamWriter w = new BadgerFishXMLStreamWriter(strWriter);
       
        w.writeStartDocument();
        w.writeStartElement("alice");
       
        w.writeDefaultNamespace("http://some-namespace");
        w.writeCharacters("bob");
       
        w.writeEndElement();
        w.writeEndDocument();
       
        w.close();
        strWriter.close();
       
        assertJSONEquals("{\"alice\":{\"@xmlns\":{\"$\":\"http:\\/\\/some-namespace\"},\"$\":\"bob\"}}",
                         strWriter.toString());
    }
View Full Code Here

Examples of org.codehaus.jettison.badgerfish.BadgerFishXMLStreamWriter

                         strWriter.toString());
    }
   
    public void testPrefixedNamespace() throws Exception {
        StringWriter strWriter = new StringWriter();
        BadgerFishXMLStreamWriter w = new BadgerFishXMLStreamWriter(strWriter);
       
        w.writeStartDocument();
        w.writeStartElement("alice");
       
        w.writeDefaultNamespace("http://some-namespace");
        w.writeNamespace("charlie", "http://some-other-namespace");
       
        assertEquals("http://some-other-namespace", w.getNamespaceContext().getNamespaceURI("charlie"));
        assertEquals("charlie", w.getNamespaceContext().getPrefix("http://some-other-namespace"));
       
        w.writeCharacters("bob");
       
        w.writeEndElement();
        w.writeEndDocument();
       
        w.close();
        strWriter.close();
       
        assertJSONEquals("{ \"alice\": { \"@xmlns\": { \"$\" : \"http:\\/\\/some-namespace\", \"charlie\" : \"http:\\/\\/some-other-namespace\" }, \"$\" : \"bob\" } }",
                         strWriter.toString());
       
View Full Code Here

Examples of org.codehaus.jettison.badgerfish.BadgerFishXMLStreamWriter

   

   
    public void testPrefixedElements() throws Exception {
        StringWriter strWriter = new StringWriter();
        BadgerFishXMLStreamWriter w = new BadgerFishXMLStreamWriter(strWriter);
       
        w.writeStartDocument();
        w.writeStartElement("alice");
       
        w.writeDefaultNamespace("http://some-namespace");
        w.writeNamespace("charlie", "http://some-other-namespace");
       
        w.writeStartElement("bob");
        w.writeCharacters("david");
        w.writeEndElement();
       

        w.writeStartElement("charlie", "edgar", "http://some-other-namespace");
        w.writeCharacters("frank");
        w.writeEndElement();
       
        w.writeEndElement();
        w.writeEndDocument();
       
        w.close();
        strWriter.close();
        assertJSONEquals(
            "{ \"alice\" : { " +
              "\"@xmlns\" : { " +
                "\"$\" : \"http:\\/\\/some-namespace\"," +
View Full Code Here

Examples of org.codehaus.jettison.badgerfish.BadgerFishXMLStreamWriter

    public static XMLStreamWriter createWriter(final Writer writer,
                                               final JettisonConfig config) throws IOException {
        switch (config.getNotation()) {
            case BADGERFISH:
                return new BadgerFishXMLStreamWriter(writer);
            case MAPPED_JETTISON:
                Configuration jmConfig;
                if (null == config.getXml2JsonNs()) {
                    jmConfig = new Configuration();
                } else {
View Full Code Here

Examples of org.codehaus.jettison.badgerfish.BadgerFishXMLStreamWriter

    }

    public Object transform(XMLStreamReader source, TransformationContext context) {
        try {
            StringWriter writer = new StringWriter();
            XMLStreamWriter jsonWriter = new BadgerFishXMLStreamWriter(writer);
            staxHelper.save(source, jsonWriter);
            source.close();
            Class type = null;
            if (context != null && context.getTargetDataType() != null) {
                type = context.getTargetDataType().getPhysical();
View Full Code Here

Examples of org.codehaus.jettison.badgerfish.BadgerFishXMLStreamWriter

public class JSONBadgerfishMessageFormatter extends JSONMessageFormatter {

    //returns the writer for the badgerfish format
    protected XMLStreamWriter getJSONWriter(OutputStream outStream) {
        return new BadgerFishXMLStreamWriter(new OutputStreamWriter(outStream));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.