• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java AbstractXMLStreamWriter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: testIntAttributeAsString

import org.codehaus.jettison.AbstractXMLStreamWriter; //导入依赖的package包/类
public void testIntAttributeAsString() throws Exception {
    StringWriter strWriter = new StringWriter();
    
    Configuration c = new Configuration();
    c.setTypeConverter(new SimpleConverter());
    MappedNamespaceConvention con = new MappedNamespaceConvention(c);
    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,代码行数:20,代码来源:MappedXMLStreamWriterTest.java


示例17: testAttributesAsElements

import org.codehaus.jettison.AbstractXMLStreamWriter; //导入依赖的package包/类
public void testAttributesAsElements() throws Exception {
    StringWriter strWriter = new StringWriter();
    
    Map xtoj = new HashMap();
    xtoj.put("http://foo/", "foo");
    List atts = new ArrayList();
    atts.add(new QName("http://foo/", "att2"));
    
    Configuration c = new Configuration(xtoj, atts, null);
    
    MappedNamespaceConvention con = new MappedNamespaceConvention(c);
    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,代码行数:27,代码来源:MappedXMLStreamWriterTest.java


示例18: testTwoChildren

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


示例19: testComplexArrayOfChildren

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


示例20: testNamespacedElements

import org.codehaus.jettison.AbstractXMLStreamWriter; //导入依赖的package包/类
public void testNamespacedElements() 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("http://foo/", "root");
    
    w.writeStartElement("http://foo/", "child");
    w.writeEndElement();
    
    w.writeStartElement("http://foo/", "child");
    w.writeEndElement();
    
    w.writeEndElement();
    w.writeEndDocument();
    
    w.close();
    strWriter.close();
    
    assertEquals("{\"foo.root\":{\"foo.child\":[\"\",\"\"]}}", strWriter.toString());
}
 
开发者ID:jettison-json,项目名称:jettison,代码行数:27,代码来源:MappedXMLStreamWriterTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Configuration类代码示例发布时间:2022-05-22
下一篇:
Java ExtFile类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap