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

Java ScalarStyle类代码示例

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

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



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

示例1: testEmitQuoted

import org.yaml.snakeyaml.DumperOptions.ScalarStyle; //导入依赖的package包/类
/**
 * http://pyyaml.org/ticket/196
 */
public void testEmitQuoted() {
    List<String> list = new ArrayList<String>(3);
    list.add("This is an 'example'.");
    list.add("This is an \"example\".");
    list.add("123");
    String output = dump(list);
    assertEquals("[This is an 'example'., This is an \"example\"., '123']\n", output);
    // single quoted
    DumperOptions options = new DumperOptions();
    options.setDefaultScalarStyle(ScalarStyle.SINGLE_QUOTED);
    Yaml yaml = new Yaml(options);
    String output2 = yaml.dump(list);
    // System.out.println(output2);
    assertEquals("- 'This is an ''example''.'\n- 'This is an \"example\".'\n- '123'\n", output2);
    // double quoted
    DumperOptions options2 = new DumperOptions();
    options2.setDefaultScalarStyle(ScalarStyle.DOUBLE_QUOTED);
    yaml = new Yaml(options2);
    String output3 = yaml.dump(list);
    // System.out.println(output2);
    assertEquals("- \"This is an 'example'.\"\n- \"This is an \\\"example\\\".\"\n- \"123\"\n",
            output3);
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:27,代码来源:StrTagTest.java


示例2: testSplitLineExpectFirstFlowSequenceItem

import org.yaml.snakeyaml.DumperOptions.ScalarStyle; //导入依赖的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


示例3: testSplitLineExpectFlowSequenceItem

import org.yaml.snakeyaml.DumperOptions.ScalarStyle; //导入依赖的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


示例4: testDoubleQuotedStyle

import org.yaml.snakeyaml.DumperOptions.ScalarStyle; //导入依赖的package包/类
public void testDoubleQuotedStyle() {
    DumperOptions options = new DumperOptions();
    options.setDefaultScalarStyle(ScalarStyle.DOUBLE_QUOTED);
    Yaml yaml = new Yaml(options);
    String output = yaml.dump("í");
    // System.out.println(output);
    assertEquals("\"í\"\n", output);
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:9,代码来源:UnicodeStyleTest.java


示例5: testDoubleQuotedStyle

import org.yaml.snakeyaml.DumperOptions.ScalarStyle; //导入依赖的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


示例6: testDoubleQuotedStyleNoLineSplit

import org.yaml.snakeyaml.DumperOptions.ScalarStyle; //导入依赖的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


示例7: testLong

import org.yaml.snakeyaml.DumperOptions.ScalarStyle; //导入依赖的package包/类
public void testLong() {
    DumperOptions options = new DumperOptions();
    options.setDefaultScalarStyle(ScalarStyle.FOLDED);
    Yaml yaml = new Yaml(options);
    String result = yaml
            .dump("qqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqq "
                    + "qqqqqqqqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqq "
                    + "qqqqqqqqqqqqqqqqqqqqqqqqq 111111111111111111111111\n "
                    + "qqqqqqqqqqqqqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqqqqq\n");
    // System.out.println(result);
    assertTrue(result.startsWith(">\n"));
    assertEquals(
            ">\n  qqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqq\n  qqqqqqqqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqqq 111111111111111111111111\n   qqqqqqqqqqqqqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqqqqq\n",
            result);
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:16,代码来源:FlexibleScalarStyleTest.java


示例8: testExample_2_15

import org.yaml.snakeyaml.DumperOptions.ScalarStyle; //导入依赖的package包/类
public void testExample_2_15() {
    String etalon = "Sammy Sosa completed another fine season with great stats.\n\n  63 Home Runs\n  0.288 Batting Average\n\nWhat a year!\n";
    InputStream input = YamlDocument.class.getClassLoader().getResourceAsStream(
            YamlDocument.ROOT + "example2_15.yaml");
    DumperOptions options = new DumperOptions();
    options.setDefaultScalarStyle(ScalarStyle.FOLDED);
    Yaml yaml = new Yaml(options);
    String data = (String) yaml.load(input);
    assertEquals(etalon, data);
    //
    String dumped = yaml.dump(data);
    String etalonDumped = Util.getLocalResource("specification/example2_15_dumped.yaml");
    assertEquals(etalonDumped, dumped);
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:15,代码来源:Chapter2_3Test.java


示例9: testWriteFolded

import org.yaml.snakeyaml.DumperOptions.ScalarStyle; //导入依赖的package包/类
public void testWriteFolded() {
    DumperOptions options = new DumperOptions();
    options.setDefaultScalarStyle(ScalarStyle.FOLDED);
    String folded = "0123456789 0123456789\n0123456789 0123456789";
    Map<String, String> map = new LinkedHashMap<String, String>();
    map.put("aaa", folded);
    map.put("bbb", "\nbla-bla\n");
    Yaml yaml = new Yaml(options);
    String output = yaml.dump(map);
    String etalon = "\"aaa\": >-\n  0123456789 0123456789\n\n  0123456789 0123456789\n\"bbb\": >2\n\n  bla-bla\n";
    assertEquals(etalon, output);
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:13,代码来源:EmitterTest.java


示例10: testWriteLiteral

import org.yaml.snakeyaml.DumperOptions.ScalarStyle; //导入依赖的package包/类
public void testWriteLiteral() {
    DumperOptions options = new DumperOptions();
    options.setDefaultScalarStyle(ScalarStyle.LITERAL);
    String folded = "0123456789 0123456789 0123456789 0123456789";
    Map<String, String> map = new LinkedHashMap<String, String>();
    map.put("aaa", folded);
    map.put("bbb", "\nbla-bla\n");
    Yaml yaml = new Yaml(options);
    String output = yaml.dump(map);
    String etalon = "\"aaa\": |-\n  0123456789 0123456789 0123456789 0123456789\n\"bbb\": |2\n\n  bla-bla\n";
    assertEquals(etalon, output);
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:13,代码来源:EmitterTest.java


示例11: testWritePlain

import org.yaml.snakeyaml.DumperOptions.ScalarStyle; //导入依赖的package包/类
public void testWritePlain() {
    DumperOptions options = new DumperOptions();
    options.setDefaultScalarStyle(ScalarStyle.PLAIN);
    String folded = "0123456789 0123456789\n0123456789 0123456789";
    Map<String, String> map = new LinkedHashMap<String, String>();
    map.put("aaa", folded);
    map.put("bbb", "\nbla-bla");
    Yaml yaml = new Yaml(options);
    String output = yaml.dump(map);
    String etalon = "aaa: |-\n  0123456789 0123456789\n  0123456789 0123456789\nbbb: |2-\n\n  bla-bla\n";
    assertEquals(etalon, output);
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:13,代码来源:EmitterTest.java


示例12: testWritePlainPretty

import org.yaml.snakeyaml.DumperOptions.ScalarStyle; //导入依赖的package包/类
public void testWritePlainPretty() {
    DumperOptions options = new DumperOptions();
    options.setDefaultScalarStyle(ScalarStyle.PLAIN);
    options.setPrettyFlow(true);

    String folded = "0123456789 0123456789\n0123456789 0123456789";
    Map<String, String> map = new LinkedHashMap<String, String>();
    map.put("aaa", folded);
    map.put("bbb", "\nbla-bla");

    Yaml yaml = new Yaml(options);
    String output = yaml.dump(map);
    String etalon = "aaa: |-\n  0123456789 0123456789\n  0123456789 0123456789\nbbb: |2-\n\n  bla-bla\n";
    assertEquals(etalon, output);
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:16,代码来源:EmitterTest.java


示例13: testWriteSingleQuoted

import org.yaml.snakeyaml.DumperOptions.ScalarStyle; //导入依赖的package包/类
public void testWriteSingleQuoted() {
    DumperOptions options = new DumperOptions();
    options.setDefaultScalarStyle(ScalarStyle.SINGLE_QUOTED);
    String folded = "0123456789 0123456789\n0123456789 0123456789";
    Map<String, String> map = new LinkedHashMap<String, String>();
    map.put("aaa", folded);
    map.put("bbb", "\nbla-bla");
    Yaml yaml = new Yaml(options);
    String output = yaml.dump(map);
    String etalon = "'aaa': '0123456789 0123456789\n\n  0123456789 0123456789'\n'bbb': '\n\n  bla-bla'\n";
    assertEquals(etalon, output);
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:13,代码来源:EmitterTest.java


示例14: testWriteDoubleQuoted

import org.yaml.snakeyaml.DumperOptions.ScalarStyle; //导入依赖的package包/类
public void testWriteDoubleQuoted() {
    DumperOptions options = new DumperOptions();
    options.setDefaultScalarStyle(ScalarStyle.DOUBLE_QUOTED);
    String folded = "0123456789 0123456789\n0123456789 0123456789";
    Map<String, String> map = new LinkedHashMap<String, String>();
    map.put("aaa", folded);
    map.put("bbb", "\nbla-bla");
    Yaml yaml = new Yaml(options);
    String output = yaml.dump(map);
    String etalon = "\"aaa\": \"0123456789 0123456789\\n0123456789 0123456789\"\n\"bbb\": \"\\nbla-bla\"\n";
    assertEquals(etalon, output);
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:13,代码来源:EmitterTest.java


示例15: testSplitLineExpectFirstFlowMappingKey

import org.yaml.snakeyaml.DumperOptions.ScalarStyle; //导入依赖的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


示例16: testSplitLineExpectFlowMappingKey

import org.yaml.snakeyaml.DumperOptions.ScalarStyle; //导入依赖的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


示例17: processScalar

import org.yaml.snakeyaml.DumperOptions.ScalarStyle; //导入依赖的package包/类
@SuppressWarnings("deprecation")
private void processScalar() throws IOException {
    ScalarEvent ev = (ScalarEvent) event;
    if (analysis == null) {
        analysis = analyzeScalar(ev.getValue());
    }
    if (style == null) {
        style = chooseScalarStyle();
    }
    // TODO the next line should be removed
    style = options.calculateScalarStyle(analysis, ScalarStyle.createStyle(style)).getChar();
    boolean split = !simpleKeyContext;
    if (style == null) {
        writePlain(analysis.scalar, split);
    } else {
        switch (style) {
        case '"':
            writeDoubleQuoted(analysis.scalar, split);
            break;
        case '\'':
            writeSingleQuoted(analysis.scalar, split);
            break;
        case '>':
            writeFolded(analysis.scalar);
            break;
        case '|':
            writeLiteral(analysis.scalar);
            break;
        default:
            throw new YAMLException("Unexpected style: " + style);
        }
    }
    analysis = null;
    style = null;
}
 
开发者ID:timvisee,项目名称:TestTheTeacher,代码行数:36,代码来源:Emitter.java


示例18: setDefaultScalarStyle

import org.yaml.snakeyaml.DumperOptions.ScalarStyle; //导入依赖的package包/类
public void setDefaultScalarStyle(ScalarStyle defaultStyle) {
    this.defaultScalarStyle = defaultStyle.getChar();
}
 
开发者ID:imkiva,项目名称:AndroidApktool,代码行数:4,代码来源:BaseRepresenter.java


示例19: createYaml

import org.yaml.snakeyaml.DumperOptions.ScalarStyle; //导入依赖的package包/类
private Yaml createYaml() {
    DumperOptions options = new DumperOptions();
    options.setAllowUnicode(false);
    options.setDefaultScalarStyle(ScalarStyle.DOUBLE_QUOTED);
    return new Yaml(options);
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:7,代码来源:PrintableUnicodeTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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