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


Java DumperOptions.setWidth方法代码示例

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


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

示例1: testDumperOptions

import org.yaml.snakeyaml.DumperOptions; //导入方法依赖的package包/类
public void testDumperOptions() {
    List<Integer> data = new ArrayList<Integer>();
    for (int i = 0; i < 50; i++) {
        data.add(i);
    }
    Yaml yaml = new Yaml();
    String output = yaml.dump(data);
    assertTrue(output.contains("[0, 1, 2, 3, 4, 5, 6, 7, 8"));
    //
    DumperOptions options = new DumperOptions();
    options.setWidth(50);
    options.setIndent(4);
    yaml = new Yaml(options);
    output = yaml.dump(data);
    assertTrue(output.contains("1, 2"));
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:17,代码来源:DumpExampleTest.java

示例2: testMatteBorder

import org.yaml.snakeyaml.DumperOptions; //导入方法依赖的package包/类
public void testMatteBorder() {
    DumperOptions options = new DumperOptions();
    options.setWidth(400);
    Yaml yaml = new Yaml(new ImmutablesRepresenter(), options);
    Insets insets = new Insets(10, 20, 30, 40);
    Color color = new Color(100, 150, 200);
    MatteBorder border = BorderFactory.createMatteBorder(insets.top, insets.left,
            insets.bottom, insets.right, color);
    String dump = yaml.dump(border);
    assertEquals(
            "!!javax.swing.border.MatteBorder [!!java.awt.Insets [10, 20, 30, 40], !!java.awt.Color [100, 150, 200, 255]]\n",
            dump);
    Object loaded = yaml.load(dump);
    assertTrue(loaded instanceof MatteBorder);
    MatteBorder loadedBorder = (MatteBorder) loaded;
    assertEquals(insets, loadedBorder.getBorderInsets());
    assertEquals(color, loadedBorder.getMatteColor());
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:19,代码来源:MoreImmutablesTest.java

示例3: testSplitLineExpectFirstFlowSequenceItem

import org.yaml.snakeyaml.DumperOptions; //导入方法依赖的package包/类
public void testSplitLineExpectFirstFlowSequenceItem() {

        DumperOptions options = new DumperOptions();
        options.setDefaultScalarStyle(DumperOptions.ScalarStyle.DOUBLE_QUOTED);
        options.setDefaultFlowStyle(DumperOptions.FlowStyle.FLOW);
        options.setWidth(8);
        Yaml yaml;
        String output;
        Map<String, Object> map = new TreeMap<String, Object>();
        map.put("12345", Arrays.asList("1111111111"));

        // Split lines enabled (default)
        yaml = new Yaml(options);
        output = yaml.dump(map);
        assertEquals("{\"12345\": [\n    \"1111111111\"]}\n", output);

        // Split lines disabled
        options.setSplitLines(false);
        assertFalse(options.getSplitLines());
        yaml = new Yaml(options);
        output = yaml.dump(map);
        assertEquals("{\"12345\": [\"1111111111\"]}\n", output);
    }
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:24,代码来源:EmitterTest.java

示例4: testSplitLineExpectFlowSequenceItem

import org.yaml.snakeyaml.DumperOptions; //导入方法依赖的package包/类
public void testSplitLineExpectFlowSequenceItem() {

        DumperOptions options = new DumperOptions();
        options.setDefaultScalarStyle(DumperOptions.ScalarStyle.DOUBLE_QUOTED);
        options.setDefaultFlowStyle(DumperOptions.FlowStyle.FLOW);
        options.setWidth(8);
        Yaml yaml;
        String output;

        // Split lines enabled (default)
        yaml = new Yaml(options);
        output = yaml.dump(Arrays.asList("1111111111", "2222222222"));
        assertEquals("[\"1111111111\",\n  \"2222222222\"]\n", output);
        output = yaml.dump(Arrays.asList("1", "2"));
        assertEquals("[\"1\", \"2\"]\n", output);

        // Split lines disabled
        options.setSplitLines(false);
        assertFalse(options.getSplitLines());
        yaml = new Yaml(options);
        output = yaml.dump(Arrays.asList("1111111111", "2222222222"));
        assertEquals("[\"1111111111\", \"2222222222\"]\n", output);
        output = yaml.dump(Arrays.asList("1", "2"));
        assertEquals("[\"1\", \"2\"]\n", output);
    }
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:26,代码来源:EmitterTest.java

示例5: getYaml

import org.yaml.snakeyaml.DumperOptions; //导入方法依赖的package包/类
private static Yaml getYaml() {
  Representer representer = new TapeRepresenter();
  representer.addClassTag(YamlTape.class, YamlTape.TAPE_TAG);
  Constructor constructor = new TapeConstructor();
  constructor.addTypeDescription(new TypeDescription(YamlTape.class, YamlTape.TAPE_TAG));
  DumperOptions dumperOptions = new DumperOptions();
  dumperOptions.setDefaultFlowStyle(BLOCK);
  dumperOptions.setWidth(256);
  Yaml yaml = new Yaml(constructor, representer, dumperOptions);
  yaml.setBeanAccess(BeanAccess.FIELD);
  return yaml;
}
 
开发者ID:airbnb,项目名称:okreplay,代码行数:13,代码来源:YamlTapeLoader.java

示例6: testDoubleQuotedStyle

import org.yaml.snakeyaml.DumperOptions; //导入方法依赖的package包/类
public void testDoubleQuotedStyle() {
    DumperOptions options = new DumperOptions();
    options.setDefaultScalarStyle(ScalarStyle.DOUBLE_QUOTED);
    options.setWidth(20);
    options.setIndent(4);
    Yaml yaml = new Yaml(options);
    String etalon = "12345678901234567890\n\n123  456";
    String output = yaml.dump(etalon);
    // System.out.println(output);
    assertEquals("\"12345678901234567890\\n\\\n    \\n123  456\"\n", output);
    String parsed = (String) yaml.load(output);
    assertEquals(etalon, parsed);
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:14,代码来源:LineBreakDooubleQuotedTest.java

示例7: testDoubleQuotedStyleNoLineSplit

import org.yaml.snakeyaml.DumperOptions; //导入方法依赖的package包/类
public void testDoubleQuotedStyleNoLineSplit() {
    DumperOptions options = new DumperOptions();
    options.setDefaultScalarStyle(ScalarStyle.DOUBLE_QUOTED);
    options.setWidth(20);
    options.setSplitLines(false);
    options.setIndent(4);
    Yaml yaml = new Yaml(options);
    String etalon = "12345678901234567890\n\n123  456";
    String output = yaml.dump(etalon);
    // System.out.println(output);
    assertEquals("\"12345678901234567890\\n\\n123  456\"\n", output);
    String parsed = (String) yaml.load(output);
    assertEquals(etalon, parsed);
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:15,代码来源:LineBreakDooubleQuotedTest.java

示例8: testNoFoldedScalar

import org.yaml.snakeyaml.DumperOptions; //导入方法依赖的package包/类
public void testNoFoldedScalar() {
    DumperOptions options = new DumperOptions();
    options.setWidth(30);
    Yaml yaml = new Yaml(options);
    String output = yaml.dump(getData());
    // System.out.println(output);
    String etalon = Util.getLocalResource("representer/scalar-style1.yaml");
    assertEquals(etalon, output);
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:10,代码来源:FlexibleScalarStyleTest.java

示例9: testCustomScalarStyle

import org.yaml.snakeyaml.DumperOptions; //导入方法依赖的package包/类
public void testCustomScalarStyle() {
    DumperOptions options = new DumperOptions();
    options.setWidth(30);
    Yaml yaml = new Yaml(new MyRepresenter(), options);
    String output = yaml.dump(getData());
    // System.out.println(output);
    String etalon = Util.getLocalResource("representer/scalar-style2.yaml");
    assertEquals(etalon, output);
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:10,代码来源:FlexibleScalarStyleTest.java

示例10: testCustomScalarStyleNoSplitLines

import org.yaml.snakeyaml.DumperOptions; //导入方法依赖的package包/类
public void testCustomScalarStyleNoSplitLines() {
    DumperOptions options = new DumperOptions();
    options.setWidth(30);
    options.setSplitLines(false);
    Yaml yaml = new Yaml(new MyRepresenter(), options);
    String output = yaml.dump(getData());
    // System.out.println(output);
    String etalon = Util.getLocalResource("representer/scalar-style3.yaml");
    assertEquals(etalon, output);
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:11,代码来源:FlexibleScalarStyleTest.java

示例11: testJavaStackTraceWithNoSpecialCharacters

import org.yaml.snakeyaml.DumperOptions; //导入方法依赖的package包/类
public void testJavaStackTraceWithNoSpecialCharacters() {
    DumperOptions options = new DumperOptions();
    options.setWidth(50);
    Yaml yaml = new Yaml(options);
    String input = Util.getLocalResource("representer/stacktrace2.txt");
    assertEquals(-1, input.indexOf(':'));
    assertEquals(-1, input.indexOf('\t'));
    String result = yaml.dump(input);
    // System.out.println(result);
    assertEquals(result, yaml.dump(yaml.load(result)));
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:12,代码来源:DumpStackTraceTest.java

示例12: testSplitLineExpectFirstFlowMappingKey

import org.yaml.snakeyaml.DumperOptions; //导入方法依赖的package包/类
public void testSplitLineExpectFirstFlowMappingKey() {
    DumperOptions options = new DumperOptions();
    options.setDefaultScalarStyle(DumperOptions.ScalarStyle.DOUBLE_QUOTED);
    options.setDefaultFlowStyle(DumperOptions.FlowStyle.FLOW);
    options.setWidth(16);
    Yaml yaml;
    String output;
    Map<String, String> nonSplitMap = new TreeMap<String, String>();
    nonSplitMap.put("3", "4");
    Map<String, Map<String, String>> nonSplitContainerMap = new TreeMap<String, Map<String, String>>();
    nonSplitContainerMap.put("1 2", nonSplitMap);
    Map<String, String> splitMap = new TreeMap<String, String>();
    splitMap.put("3333333333", "4444444444");
    Map<String, Map<String, String>> splitContainerMap = new TreeMap<String, Map<String, String>>();
    splitContainerMap.put("1111111111 2222222222", splitMap);

    // Split lines enabled (default)
    yaml = new Yaml(options);
    output = yaml.dump(splitContainerMap);
    assertEquals("{\"1111111111 2222222222\": {\n    \"3333333333\": \"4444444444\"}}\n", output);
    output = yaml.dump(nonSplitContainerMap);
    assertEquals("{\"1 2\": {\"3\": \"4\"}}\n", output);

    // Split lines disabled
    options.setSplitLines(false);
    assertFalse(options.getSplitLines());
    yaml = new Yaml(options);
    output = yaml.dump(splitContainerMap);
    assertEquals("{\"1111111111 2222222222\": {\"3333333333\": \"4444444444\"}}\n", output);
    output = yaml.dump(nonSplitContainerMap);
    assertEquals("{\"1 2\": {\"3\": \"4\"}}\n", output);
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:33,代码来源:EmitterTest.java

示例13: testSplitLineExpectFlowMappingKey

import org.yaml.snakeyaml.DumperOptions; //导入方法依赖的package包/类
public void testSplitLineExpectFlowMappingKey() {
    DumperOptions options = new DumperOptions();
    options.setDefaultScalarStyle(DumperOptions.ScalarStyle.DOUBLE_QUOTED);
    options.setDefaultFlowStyle(DumperOptions.FlowStyle.FLOW);
    options.setWidth(16);
    Yaml yaml;
    String output;
    Map<String, String> nonSplitMap = new TreeMap<String, String>();
    nonSplitMap.put("1", "2");
    nonSplitMap.put("3", "4");
    Map<String, String> splitMap = new TreeMap<String, String>();
    splitMap.put("1111111111", "2222222222");
    splitMap.put("3333333333", "4444444444");

    // Split lines enabled (default)
    yaml = new Yaml(options);
    output = yaml.dump(splitMap);
    assertEquals("{\"1111111111\": \"2222222222\",\n  \"3333333333\": \"4444444444\"}\n", output);
    output = yaml.dump(nonSplitMap);
    assertEquals("{\"1\": \"2\", \"3\": \"4\"}\n", output);

    // Split lines disabled
    options.setSplitLines(false);
    assertFalse(options.getSplitLines());
    yaml = new Yaml(options);
    output = yaml.dump(splitMap);
    assertEquals("{\"1111111111\": \"2222222222\", \"3333333333\": \"4444444444\"}\n", output);
    output = yaml.dump(nonSplitMap);
    assertEquals("{\"1\": \"2\", \"3\": \"4\"}\n", output);
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:31,代码来源:EmitterTest.java

示例14: toString

import org.yaml.snakeyaml.DumperOptions; //导入方法依赖的package包/类
public synchronized String toString() {
	DumperOptions options = new DumperOptions();
	options.setWidth(50);
	options.setIndent(4);
	options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
	Yaml yaml = new Yaml(options);

	return yaml.dump(map);
}
 
开发者ID:gncloud,项目名称:fastcatsearch3,代码行数:10,代码来源:OldSettings.java


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