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


Java CompactWriter.flush方法代码示例

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


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

示例1: testWithValueInConvertedClass

import com.thoughtworks.xstream.io.xml.CompactWriter; //导入方法依赖的package包/类
/**
 * Tests conversion with field defined in converted class.
 */
public void testWithValueInConvertedClass() {
    converterLookup.registerConverter(new ToAttributedValueConverter(
        Software.class, mapper, reflectionProvider, converterLookup, "name"), 0);

    final Software name = new Software(null, "XStream");
    final StringWriter writer = new StringWriter();
    final CompactWriter compactWriter = new CompactWriter(writer);
    new TreeMarshaller(compactWriter, converterLookup, mapper).start(name, null);
    compactWriter.flush();
    assertEquals("<software>XStream</software>", writer.toString());

    final HierarchicalStreamReader reader = driver.createReader(new StringReader(
        writer.toString()));
    assertEquals(
        name, new TreeUnmarshaller(null, reader, converterLookup, mapper).start(null));
}
 
开发者ID:x-stream,项目名称:xstream,代码行数:20,代码来源:ToAttributedValueConverterTest.java

示例2: testWithValueInSuperclass

import com.thoughtworks.xstream.io.xml.CompactWriter; //导入方法依赖的package包/类
/**
 * Tests conversion with field defined in superclass.
 */
public void testWithValueInSuperclass() {
    converterLookup.registerConverter(new ToAttributedValueConverter(
        OpenSourceSoftware.class, mapper, reflectionProvider, converterLookup, "name",
        Software.class), 0);

    final Software software = new OpenSourceSoftware("Codehaus", "XStream", "BSD");
    final StringWriter writer = new StringWriter();
    final CompactWriter compactWriter = new CompactWriter(writer);
    new TreeMarshaller(compactWriter, converterLookup, mapper).start(software, null);
    compactWriter.flush();
    assertEquals(
        "<open-source vendor=\"Codehaus\" license=\"BSD\">XStream</open-source>",
        writer.toString());

    final HierarchicalStreamReader reader = driver.createReader(new StringReader(
        writer.toString()));
    assertEquals(
        software, new TreeUnmarshaller(null, reader, converterLookup, mapper).start(null));
}
 
开发者ID:x-stream,项目名称:xstream,代码行数:23,代码来源:ToAttributedValueConverterTest.java

示例3: testWithNullValueDeserializedAsEmptyString

import com.thoughtworks.xstream.io.xml.CompactWriter; //导入方法依赖的package包/类
/**
 * Tests conversion with null in field value.
 */
public void testWithNullValueDeserializedAsEmptyString() {
    converterLookup.registerConverter(new ToAttributedValueConverter(
        Software.class, mapper, reflectionProvider, converterLookup, "name"), 0);

    final Software software = new Software(null, null);
    final StringWriter writer = new StringWriter();
    final CompactWriter compactWriter = new CompactWriter(writer);
    new TreeMarshaller(compactWriter, converterLookup, mapper).start(software, null);
    compactWriter.flush();
    assertEquals("<software/>", writer.toString());

    final HierarchicalStreamReader reader = driver.createReader(new StringReader(
        writer.toString()));
    assertEquals(
        "",
        ((Software)new TreeUnmarshaller(null, reader, converterLookup, mapper).start(null)).name);
}
 
开发者ID:x-stream,项目名称:xstream,代码行数:21,代码来源:ToAttributedValueConverterTest.java

示例4: testWithoutValueField

import com.thoughtworks.xstream.io.xml.CompactWriter; //导入方法依赖的package包/类
/**
 * Tests conversion with null in field value.
 */
public void testWithoutValueField() {
    converterLookup.registerConverter(new ToAttributedValueConverter(
        Software.class, mapper, reflectionProvider, converterLookup, null), 0);

    final Software software = new Software("Codehaus", "XStream");
    final StringWriter writer = new StringWriter();
    final CompactWriter compactWriter = new CompactWriter(writer);
    new TreeMarshaller(compactWriter, converterLookup, mapper).start(software, null);
    compactWriter.flush();
    assertEquals("<software vendor=\"Codehaus\" name=\"XStream\"/>", writer.toString());

    final HierarchicalStreamReader reader = driver.createReader(new StringReader(
        writer.toString()));
    assertEquals(
        software, new TreeUnmarshaller(null, reader, converterLookup, mapper).start(null));
}
 
开发者ID:x-stream,项目名称:xstream,代码行数:20,代码来源:ToAttributedValueConverterTest.java

示例5: testWithComplexValueField

import com.thoughtworks.xstream.io.xml.CompactWriter; //导入方法依赖的package包/类
/**
 * Tests conversion with complex value field.
 */
public void testWithComplexValueField() {
    converterLookup.registerConverter(new ToAttributedValueConverter(
        X.class, mapper, reflectionProvider, converterLookup, "innerObj"), 0);

    final X x = new X(42);
    x.aStr = "xXx";
    x.innerObj = new Y();
    x.innerObj.yField = "inner";
    final StringWriter writer = new StringWriter();
    final CompactWriter compactWriter = new CompactWriter(writer);
    new TreeMarshaller(compactWriter, converterLookup, mapper).start(x, null);
    compactWriter.flush();
    assertEquals(
        "<x aStr=\"xXx\" anInt=\"42\"><yField>inner</yField></x>", writer.toString());

    final HierarchicalStreamReader reader = driver.createReader(new StringReader(
        writer.toString()));
    assertEquals(x, new TreeUnmarshaller(null, reader, converterLookup, mapper).start(null));
}
 
开发者ID:x-stream,项目名称:xstream,代码行数:23,代码来源:ToAttributedValueConverterTest.java


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