当前位置: 首页>>代码示例>>Java>>正文


Java AbstractXMLStreamWriter类代码示例

本文整理汇总了Java中org.codehaus.jettison.AbstractXMLStreamWriter的典型用法代码示例。如果您正苦于以下问题:Java AbstractXMLStreamWriter类的具体用法?Java AbstractXMLStreamWriter怎么用?Java AbstractXMLStreamWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AbstractXMLStreamWriter类属于org.codehaus.jettison包,在下文中一共展示了AbstractXMLStreamWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startNode

import org.codehaus.jettison.AbstractXMLStreamWriter; //导入依赖的package包/类
@Override
public void startNode(final String name, final Class<?> clazz) {
    final XMLStreamWriter out = getXMLStreamWriter();
    if (clazz != null && out instanceof AbstractXMLStreamWriter) {
        if (Collection.class.isAssignableFrom(clazz) || Map.class.isAssignableFrom(clazz) || clazz.isArray()) {
            final QName qname = getQNameMap().getQName(encodeNode(name));
            final String prefix = qname.getPrefix();
            final String uri = qname.getNamespaceURI();
            final String key = convention.createKey(prefix, uri, qname.getLocalPart());
            if (!((AbstractXMLStreamWriter)out).getSerializedAsArrays().contains(key)) {
                // Typo is in the API of Jettison ...
                ((AbstractXMLStreamWriter)out).seriliazeAsArray(key);
            }
        }
    }
    startNode(name);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:JettisonStaxWriter.java

示例2: testChild

import org.codehaus.jettison.AbstractXMLStreamWriter; //导入依赖的package包/类
public void testChild() throws Exception {
    StringWriter strWriter = new StringWriter();
    MappedNamespaceConvention con = new MappedNamespaceConvention();
    AbstractXMLStreamWriter w = new MappedXMLStreamWriter(con, strWriter);
    
    w.writeStartDocument();
    w.writeStartElement("root");
    w.writeStartElement("child");
    w.writeEndElement();
    w.writeEndElement();
    w.writeEndDocument();
    
    w.close();
    strWriter.close();
    
    assertEquals("{\"root\":{\"child\":\"\"}}", strWriter.toString());
}
 
开发者ID:jettison-json,项目名称:jettison,代码行数:18,代码来源:MappedXMLStreamWriterTest.java

示例3: testChildDropElement

import org.codehaus.jettison.AbstractXMLStreamWriter; //导入依赖的package包/类
public void testChildDropElement() throws Exception {
    StringWriter strWriter = new StringWriter();
    Configuration c = new Configuration();
    c.setDropRootElement(true);
    MappedNamespaceConvention con = new MappedNamespaceConvention(c);
    AbstractXMLStreamWriter w = new MappedXMLStreamWriter(con, strWriter);
    
    w.writeStartDocument();
    w.writeStartElement("root");
    w.writeStartElement("child");
    w.writeEndElement();
    w.writeEndElement();
    w.writeEndDocument();
    
    w.close();
    strWriter.close();
    
    assertEquals("{\"child\":\"\"}", strWriter.toString());
}
 
开发者ID:jettison-json,项目名称:jettison,代码行数:20,代码来源:MappedXMLStreamWriterTest.java

示例4: testChildDropElement2

import org.codehaus.jettison.AbstractXMLStreamWriter; //导入依赖的package包/类
public void testChildDropElement2() throws Exception {
    StringWriter strWriter = new StringWriter();
    Configuration c = new Configuration();
    c.setDropRootElement(true);
    MappedNamespaceConvention con = new MappedNamespaceConvention(c);
    AbstractXMLStreamWriter w = new MappedXMLStreamWriter(con, strWriter);
    
    w.writeStartDocument();
    w.writeStartElement("root");
    w.writeStartElement("root2");
    w.writeStartElement("child");
    w.writeEndElement();
    w.writeEndElement();
    w.writeEndElement();
    w.writeEndDocument();
    
    w.close();
    strWriter.close();
    
    assertEquals("{\"root2\":{\"child\":\"\"}}", strWriter.toString());
}
 
开发者ID:jettison-json,项目名称:jettison,代码行数:22,代码来源:MappedXMLStreamWriterTest.java

示例5: testChildDropElement3

import org.codehaus.jettison.AbstractXMLStreamWriter; //导入依赖的package包/类
public void testChildDropElement3() throws Exception {
    StringWriter strWriter = new StringWriter();
    Configuration c = new Configuration();
    List<String> ignoredElements = new LinkedList<String>();
    ignoredElements.add("root");
    ignoredElements.add("root2");
    c.setIgnoredElements(ignoredElements);
    MappedNamespaceConvention con = new MappedNamespaceConvention(c);
    AbstractXMLStreamWriter w = new MappedXMLStreamWriter(con, strWriter);
    
    w.writeStartDocument();
    w.writeStartElement("root");
    w.writeStartElement("root2");
    w.writeStartElement("child");
    w.writeEndElement();
    w.writeEndElement();
    w.writeEndElement();
    w.writeEndDocument();
    
    w.close();
    strWriter.close();
    
    assertEquals("{\"child\":\"\"}", strWriter.toString());
}
 
开发者ID:jettison-json,项目名称:jettison,代码行数:25,代码来源:MappedXMLStreamWriterTest.java

示例6: testChildDropElement4

import org.codehaus.jettison.AbstractXMLStreamWriter; //导入依赖的package包/类
public void testChildDropElement4() throws Exception {
    StringWriter strWriter = new StringWriter();
    Configuration c = new Configuration();
    List<String> ignoredElements = new LinkedList<String>();
    ignoredElements.add("child");
    c.setIgnoredElements(ignoredElements);
    MappedNamespaceConvention con = new MappedNamespaceConvention(c);
    AbstractXMLStreamWriter w = new MappedXMLStreamWriter(con, strWriter);
    
    w.writeStartDocument();
    w.writeStartElement("root");
    w.writeStartElement("child");
    w.writeEndElement();
    w.writeStartElement("child2");
    w.writeEndElement();
    w.writeEndElement();
    w.writeEndDocument();
    
    w.close();
    strWriter.close();
    
    assertEquals("{\"root\":{\"child2\":\"\"}}", strWriter.toString());
}
 
开发者ID:jettison-json,项目名称:jettison,代码行数:24,代码来源:MappedXMLStreamWriterTest.java

示例7: testText

import org.codehaus.jettison.AbstractXMLStreamWriter; //导入依赖的package包/类
public void testText() throws Exception {
    StringWriter strWriter = new StringWriter();
    MappedNamespaceConvention con = new MappedNamespaceConvention();
    AbstractXMLStreamWriter w = new MappedXMLStreamWriter(con, strWriter);
    
    w.writeStartDocument();
    w.writeStartElement("root");
    w.writeStartElement("child");
    
    w.writeCharacters("test");
    w.writeCharacters("test");
    w.writeCharacters("test".toCharArray(), 0, 4);
    w.writeEndElement();
    w.writeEndElement();
    w.writeEndDocument();
    
    w.close();
    strWriter.close();
    
    assertEquals("{\"root\":{\"child\":\"testtesttest\"}}", strWriter.toString());
}
 
开发者ID:jettison-json,项目名称:jettison,代码行数:22,代码来源:MappedXMLStreamWriterTest.java

示例8: testTextEscapeForwardSlash

import org.codehaus.jettison.AbstractXMLStreamWriter; //导入依赖的package包/类
public void testTextEscapeForwardSlash() throws Exception {
    StringWriter strWriter = new StringWriter();
    MappedNamespaceConvention con = new MappedNamespaceConvention();
    con.setEscapeForwardSlashAlways(true);
    AbstractXMLStreamWriter w = new MappedXMLStreamWriter(con, strWriter);
    
    w.writeStartDocument();
    w.writeStartElement("root");
    w.writeStartElement("child");
    
    w.writeCharacters("http://localhost:8080/json");
    w.writeEndElement();
    w.writeEndElement();
    w.writeEndDocument();
    
    w.close();
    strWriter.close();
    
    assertEquals("{\"root\":{\"child\":\"http:\\/\\/localhost:8080\\/json\"}}", strWriter.toString());
}
 
开发者ID:jettison-json,项目名称:jettison,代码行数:21,代码来源:MappedXMLStreamWriterTest.java

示例9: testTextForwardSlash

import org.codehaus.jettison.AbstractXMLStreamWriter; //导入依赖的package包/类
public void testTextForwardSlash() throws Exception {
    StringWriter strWriter = new StringWriter();
    MappedNamespaceConvention con = new MappedNamespaceConvention();
    AbstractXMLStreamWriter w = new MappedXMLStreamWriter(con, strWriter);
    
    w.writeStartDocument();
    w.writeStartElement("root");
    w.writeStartElement("child");
    
    w.writeCharacters("http://localhost:8080/json");
    w.writeEndElement();
    w.writeEndElement();
    w.writeEndDocument();
    
    w.close();
    strWriter.close();
    
    assertEquals("{\"root\":{\"child\":\"http://localhost:8080/json\"}}", strWriter.toString());
}
 
开发者ID:jettison-json,项目名称:jettison,代码行数:20,代码来源:MappedXMLStreamWriterTest.java

示例10: testTextForwardSlashWithLeftAngle

import org.codehaus.jettison.AbstractXMLStreamWriter; //导入依赖的package包/类
public void testTextForwardSlashWithLeftAngle() throws Exception {
    StringWriter strWriter = new StringWriter();
    MappedNamespaceConvention con = new MappedNamespaceConvention();
    AbstractXMLStreamWriter w = new MappedXMLStreamWriter(con, strWriter);
    
    w.writeStartDocument();
    w.writeStartElement("root");
    w.writeStartElement("child");
    
    w.writeCharacters("</abc>");
    w.writeEndElement();
    w.writeEndElement();
    w.writeEndDocument();
    
    w.close();
    strWriter.close();
    
    assertEquals("{\"root\":{\"child\":\"<\\/abc>\"}}", strWriter.toString());
}
 
开发者ID:jettison-json,项目名称:jettison,代码行数:20,代码来源:MappedXMLStreamWriterTest.java

示例11: testTextForwardSlashFirstChar

import org.codehaus.jettison.AbstractXMLStreamWriter; //导入依赖的package包/类
public void testTextForwardSlashFirstChar() throws Exception {
    StringWriter strWriter = new StringWriter();
    MappedNamespaceConvention con = new MappedNamespaceConvention();
    AbstractXMLStreamWriter w = new MappedXMLStreamWriter(con, strWriter);
    
    w.writeStartDocument();
    w.writeStartElement("root");
    w.writeStartElement("child");
    
    w.writeCharacters("/abc");
    w.writeEndElement();
    w.writeEndElement();
    w.writeEndDocument();
    
    w.close();
    strWriter.close();
    
    assertEquals("{\"root\":{\"child\":\"/abc\"}}", strWriter.toString());
}
 
开发者ID:jettison-json,项目名称:jettison,代码行数:20,代码来源:MappedXMLStreamWriterTest.java

示例12: testTextNullAsString

import org.codehaus.jettison.AbstractXMLStreamWriter; //导入依赖的package包/类
public void testTextNullAsString() throws Exception {
    StringWriter strWriter = new StringWriter();
    MappedNamespaceConvention con = new MappedNamespaceConvention();
    AbstractXMLStreamWriter w = new MappedXMLStreamWriter(con, strWriter);
    
    w.writeStartDocument();
    w.writeStartElement("root");
    w.writeStartElement("child");
    w.writeCharacters(null);
    w.writeEndElement();
    w.writeEndElement();
    w.writeEndDocument();
    
    w.close();
    strWriter.close();
    
    assertEquals("{\"root\":{\"child\":\"null\"}}", strWriter.toString());
}
 
开发者ID:jettison-json,项目名称:jettison,代码行数:19,代码来源:MappedXMLStreamWriterTest.java

示例13: testTextNullAsNull

import org.codehaus.jettison.AbstractXMLStreamWriter; //导入依赖的package包/类
public void testTextNullAsNull() throws Exception {
    StringWriter strWriter = new StringWriter();
    Configuration c = new Configuration();
    c.setWriteNullAsString(false);
    MappedNamespaceConvention con = new MappedNamespaceConvention(c);
    AbstractXMLStreamWriter w = new MappedXMLStreamWriter(con, strWriter);
    
    w.writeStartDocument();
    w.writeStartElement("root");
    w.writeStartElement("child");
    w.writeCharacters(null);
    w.writeEndElement();
    w.writeEndElement();
    w.writeEndDocument();
    
    w.close();
    strWriter.close();
    
    assertEquals("{\"root\":{\"child\":null}}", strWriter.toString());
}
 
开发者ID:jettison-json,项目名称:jettison,代码行数:21,代码来源:MappedXMLStreamWriterTest.java

示例14: testAttributes

import org.codehaus.jettison.AbstractXMLStreamWriter; //导入依赖的package包/类
public void testAttributes() throws Exception {
    StringWriter strWriter = new StringWriter();
    
    Map xtoj = new HashMap();
    xtoj.put("http://foo/", "foo");
    MappedNamespaceConvention con = new MappedNamespaceConvention(new Configuration(xtoj));
    AbstractXMLStreamWriter w = new MappedXMLStreamWriter(con, strWriter);
    
    w.writeStartDocument();
    w.writeStartElement("root");
    w.writeAttribute("att", "attvalue");
    w.writeAttribute("http://foo/", "att2", "attvalue");
    
    
    w.writeEndElement();
    w.writeEndDocument();
    
    w.close();
    strWriter.close();
    
    assertEquals("{\"root\":{\"@att\":\"attvalue\",\"@foo.att2\":\"attvalue\"}}", strWriter.toString());
}
 
开发者ID:jettison-json,项目名称:jettison,代码行数:23,代码来源:MappedXMLStreamWriterTest.java

示例15: testIntAttribute

import org.codehaus.jettison.AbstractXMLStreamWriter; //导入依赖的package包/类
public void testIntAttribute() throws Exception {
    StringWriter strWriter = new StringWriter();
    
    MappedNamespaceConvention con = new MappedNamespaceConvention(new Configuration());
    AbstractXMLStreamWriter w = new MappedXMLStreamWriter(con, strWriter);
    
    w.writeStartDocument();
    w.writeStartElement("root");
    w.writeAttribute("att", "123");
    w.writeEndElement();
    w.writeEndDocument();
    
    w.close();
    strWriter.close();
    
    assertEquals("{\"root\":{\"@att\":123}}", strWriter.toString());
}
 
开发者ID:jettison-json,项目名称:jettison,代码行数:18,代码来源:MappedXMLStreamWriterTest.java


注:本文中的org.codehaus.jettison.AbstractXMLStreamWriter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。