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


Java AbstractXMLStreamWriter.close方法代码示例

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


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

示例1: 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

示例2: testTwoChildrenWithSameName

import org.codehaus.jettison.AbstractXMLStreamWriter; //导入方法依赖的package包/类
public void testTwoChildrenWithSameName() throws Exception {
    StringWriter strWriter = new StringWriter();
    AbstractXMLStreamWriter w = new BadgerFishXMLStreamWriter(strWriter);
    
    w.writeStartDocument();
    w.writeStartElement("alice");

    w.writeStartElement("bob");
    w.writeCharacters("charlie");
    w.writeEndElement();
    
    w.writeStartElement("bob");
    w.writeCharacters("david");
    w.writeEndElement();
    
    w.writeEndElement();
    w.writeEndDocument();
    
    w.close();
    strWriter.close();
    
    assertJSONEquals("{\"alice\":{\"bob\":[{\"$\":\"charlie\"},{\"$\":\"david\"}]}}", 
                     strWriter.toString());
}
 
开发者ID:jettison-json,项目名称:jettison,代码行数:25,代码来源:BadgerFishXMLStreamWriterTest.java

示例3: testComplexElements

import org.codehaus.jettison.AbstractXMLStreamWriter; //导入方法依赖的package包/类
public void testComplexElements() throws Exception {
    StringWriter strWriter = new StringWriter();
    MappedNamespaceConvention con = new MappedNamespaceConvention();
    AbstractXMLStreamWriter w = new MappedXMLStreamWriter(con, strWriter);
    
    w.writeStartDocument();
    w.writeStartElement("", "a", "");

    w.writeStartElement("", "o", "");
    w.writeAttribute("class", "string");
    w.writeCharacters("1");
    w.writeEndElement();
    
    w.writeEndElement();
    w.writeEndDocument();
    
    w.close();
    strWriter.close();
    
    assertEquals("{\"a\":{\"o\":{\"@class\":\"string\",\"$\":\"1\"}}}", strWriter.toString());
}
 
开发者ID:jettison-json,项目名称:jettison,代码行数:22,代码来源:MappedXMLStreamWriterTest.java

示例4: 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

示例5: 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

示例6: 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

示例7: testTwoChildren

import org.codehaus.jettison.AbstractXMLStreamWriter; //导入方法依赖的package包/类
public void testTwoChildren() throws Exception {
    StringWriter strWriter = new StringWriter();
    AbstractXMLStreamWriter w = new BadgerFishXMLStreamWriter(strWriter);
    
    w.writeStartDocument();
    w.writeStartElement("alice");

    w.writeStartElement("bob");
    w.writeCharacters("charlie");
    w.writeEndElement();
    
    w.writeStartElement("david");
    w.writeCharacters("edgar");
    w.writeEndElement();
    
    w.writeEndElement();
    w.writeEndDocument();
    
    w.close();
    strWriter.close();
    
    assertJSONEquals("{\"alice\":{\"bob\":{\"$\":\"charlie\"},"+
                     "\"david\":{\"$\":\"edgar\"}}}", strWriter.toString());
}
 
开发者ID:jettison-json,项目名称:jettison,代码行数:25,代码来源:BadgerFishXMLStreamWriterTest.java

示例8: testSingleArrayElementIgnore

import org.codehaus.jettison.AbstractXMLStreamWriter; //导入方法依赖的package包/类
public void testSingleArrayElementIgnore() throws Exception {
	StringWriter strWriter = new StringWriter();
	MappedNamespaceConvention con = new MappedNamespaceConvention();
	AbstractXMLStreamWriter w = new MappedXMLStreamWriter(con, strWriter);

	w.writeStartDocument();
	w.writeStartElement("", "array-a", "");

	w.writeStartElement("", "a", "");
	w.writeStartElement("", "n", "");
	w.writeCharacters("1");
	w.writeEndElement();
	w.writeEndElement();

	w.writeEndElement();
	w.writeEndDocument();

	w.close();
	strWriter.close();

	assertEquals("{\"array-a\":{\"a\":{\"n\":1}}}", strWriter.toString());
}
 
开发者ID:jettison-json,项目名称:jettison,代码行数:23,代码来源:MappedXMLStreamWriterTest.java

示例9: 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

示例10: testRoot

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

示例11: testPrimitiveUnenforcedInteger

import org.codehaus.jettison.AbstractXMLStreamWriter; //导入方法依赖的package包/类
/**
 * issue 61
 * @see DefaultTypeConverterEnforcedIntegerTest
 */
public void testPrimitiveUnenforcedInteger() throws Exception {
    assertFalse( DefaultConverter.ENFORCE_32BIT_INTEGER );

    StringWriter strWriter = new StringWriter();
    MappedNamespaceConvention con = new MappedNamespaceConvention();
    AbstractXMLStreamWriter w = new MappedXMLStreamWriter(con, strWriter);

    w.writeStartDocument();
    w.writeStartElement("root");


    w.writeStartElement("subchild1");
    w.writeCharacters(Long.MAX_VALUE + "");
    w.writeEndElement();

    w.writeStartElement("subchild1");
    w.writeCharacters(Long.MIN_VALUE + "");
    w.writeEndElement();


    w.writeEndElement();
    w.writeEndDocument();

    w.close();
    strWriter.close();
    String expected = "{\"root\":{\"subchild1\":[" + Long.MAX_VALUE + "," + Long.MIN_VALUE + "]}}";
    String actual = strWriter.toString();
    assertEquals(expected, actual);
}
 
开发者ID:jettison-json,项目名称:jettison,代码行数:34,代码来源:DefaultTypeConverterUnenforcedIntegerTest.java

示例12: testMap

import org.codehaus.jettison.AbstractXMLStreamWriter; //导入方法依赖的package包/类
public void testMap() throws Exception {
    StringWriter strWriter = new StringWriter();
    MappedNamespaceConvention con = new MappedNamespaceConvention();
    AbstractXMLStreamWriter w = new MappedXMLStreamWriter(con, strWriter);
    w.writeStartDocument();
    
    w.writeStartElement("map");
    	w.writeStartElement("entry");
    		w.writeStartElement("string");
    			w.writeCharacters("id");
    		w.writeEndElement();
    		w.writeStartElement("string");
    			w.writeCharacters("6");
    		w.writeEndElement();
    	w.writeEndElement();
    	w.writeStartElement("entry");
    		w.writeStartElement("string");
				w.writeCharacters("name");
			w.writeEndElement();
			w.writeStartElement("string");
				w.writeCharacters("Dejan");
			w.writeEndElement();
		w.writeEndElement();
		w.writeStartElement("entry");
    		w.writeStartElement("string");
    			w.writeCharacters("city");
    		w.writeEndElement();
    		w.writeStartElement("string");
				w.writeCharacters("Belgrade");
			w.writeEndElement();
		w.writeEndElement();
    w.writeEndElement();
    
    w.writeEndDocument();
    w.close();
    strWriter.close();
    String result = strWriter.toString();
    assertEquals(result, "{\"map\":{\"entry\":[{\"string\":[\"id\",6]},{\"string\":[\"name\",\"Dejan\"]},{\"string\":[\"city\",\"Belgrade\"]}]}}");
}
 
开发者ID:jettison-json,项目名称:jettison,代码行数:40,代码来源:MappedXMLStreamWriterTest.java

示例13: testNestedArrayOfChildrenWithComplexElements

import org.codehaus.jettison.AbstractXMLStreamWriter; //导入方法依赖的package包/类
public void testNestedArrayOfChildrenWithComplexElements() throws Exception {
     StringWriter strWriter = new StringWriter();
     MappedNamespaceConvention con = new MappedNamespaceConvention();
     AbstractXMLStreamWriter w = new MappedXMLStreamWriter(con, strWriter);
     
     w.writeStartDocument();
     w.writeStartElement("root");
     
     	w.writeStartElement("subchild1");
     
     		w.writeStartElement("subchild2");
     			w.writeCharacters("first sub2");
     		w.writeEndElement();
     		
     	w.writeEndElement();
     	
     	w.writeStartElement("subchild1");
 			w.writeCharacters("text");
 		w.writeEndElement();
 		
     	w.writeStartElement("subchild1");
	   w.writeCharacters("text1");
   w.writeEndElement();

w.writeStartElement("outer");
	w.writeCharacters("test");
w.writeEndElement();
     
     w.writeEndElement();
     w.writeEndDocument();
     
     w.close();
     strWriter.close();
     
     assertEquals(strWriter.toString(), "{\"root\":{\"subchild1\":[{\"subchild2\":\"first sub2\"},\"text\",\"text1\"],\"outer\":\"test\"}}");
 }
 
开发者ID:jettison-json,项目名称:jettison,代码行数:37,代码来源:MappedXMLStreamWriterTest.java

示例14: testMultipleChildrenAgain

import org.codehaus.jettison.AbstractXMLStreamWriter; //导入方法依赖的package包/类
public void testMultipleChildrenAgain() throws Exception {
    StringWriter strWriter = new StringWriter();
    AbstractXMLStreamWriter xsw = new BadgerFishXMLStreamWriter(strWriter);
    
    xsw.writeStartDocument();
    xsw.writeStartElement("Ratings");

    xsw.writeStartElement("Rating");
    xsw.writeAttribute("id", "100");
    xsw.writeAttribute("value", "3");
    xsw.writeEndElement();

    xsw.writeStartElement("Rating");
    xsw.writeAttribute("id", "200");
    xsw.writeAttribute("value", "4");
    xsw.writeEndElement();

    xsw.writeStartElement("Rating");
    xsw.writeAttribute("id", "300");
    xsw.writeAttribute("value", "5");
    xsw.writeEndElement();

    xsw.writeEndElement();
    xsw.writeEndDocument ();
    xsw.flush();

    xsw.close();
    strWriter.close();
    System.out.println(strWriter.toString());
    
    assertJSONEquals("{\"Ratings\":{\"Rating\":[" +
                    "{\"@id\":\"100\",\"@value\":\"3\"}," +
                    "{\"@id\":\"200\",\"@value\":\"4\"}," +
                    "{\"@id\":\"300\",\"@value\":\"5\"}" +
                    "]}}", 
                     strWriter.toString());
}
 
开发者ID:jettison-json,项目名称:jettison,代码行数:38,代码来源:BadgerFishXMLStreamWriterTest.java

示例15: testIssue18Enh

import org.codehaus.jettison.AbstractXMLStreamWriter; //导入方法依赖的package包/类
public void testIssue18Enh() throws Exception {
    StringWriter strWriter = new StringWriter();
    MappedNamespaceConvention con = new MappedNamespaceConvention();
    AbstractXMLStreamWriter w = new MappedXMLStreamWriter(con, strWriter);
    
    w.writeStartDocument();
    w.writeStartElement("", "a", "");

    w.writeStartElement("", "vals", "");
    
    w.writeStartElement("", "string", "");
    w.writeCharacters("1");
    w.writeEndElement();
    
    w.writeStartElement("", "string", "");
    w.writeCharacters("2");
    w.writeEndElement();
    
    w.writeStartElement("", "string", "");
    w.writeCharacters("3");
    w.writeEndElement();
    
    w.writeEndElement();
    
    w.writeStartElement("", "n", "");
    w.writeCharacters("5");
    w.writeEndElement();
    
    w.writeEndElement();
    w.writeEndDocument();
    
    w.close();
    strWriter.close();

    assertEquals("{\"a\":{\"vals\":{\"string\":[1,2,3]},\"n\":5}}", strWriter.toString());
}
 
开发者ID:jettison-json,项目名称:jettison,代码行数:37,代码来源:MappedXMLStreamWriterTest.java


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