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


Java DumperOptions.setExplicitStart方法代码示例

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


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

示例1: testEmitNoTags

import org.yaml.snakeyaml.DumperOptions; //导入方法依赖的package包/类
public void testEmitNoTags() {
    TestObject result = parseObject(Util.getLocalResource("ruby/ruby1.yaml"));
    DumperOptions options = new DumperOptions();
    options.setExplicitStart(true);
    Yaml yaml2 = new Yaml(options);
    String output = yaml2.dumpAsMap(result);
    assertFalse("No tags expected.", output.contains("Sub1"));
    // System.out.println(output);
    // parse back. Without tags it shall still work
    Yaml beanLoader = new Yaml();
    TestObject result2 = beanLoader.loadAs(output, TestObject.class);
    assertEquals(0, result2.getSub1().getAtt2());
    assertEquals("MyString", result2.getSub2().getAtt1());
    assertEquals(1, result2.getSub2().getAtt2().size());
    assertEquals(12345, result2.getSub2().getAtt3());
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:17,代码来源:RubyTest.java

示例2: testEmitWithTags

import org.yaml.snakeyaml.DumperOptions; //导入方法依赖的package包/类
public void testEmitWithTags() {
    TestObject result = parseObject(Util.getLocalResource("ruby/ruby1.yaml"));
    DumperOptions options = new DumperOptions();
    options.setExplicitStart(true);
    Representer repr = new Representer();
    repr.addClassTag(TestObject.class, new Tag("!ruby/object:Test::Module::Object"));
    repr.addClassTag(Sub1.class, new Tag("!ruby/object:Test::Module::Sub1"));
    repr.addClassTag(Sub2.class, new Tag("!ruby/object:Test::Module::Sub2"));
    Yaml yaml2 = new Yaml(repr, options);
    String output = yaml2.dump(result);
    // System.out.println(output);
    assertTrue("Tags must be present.",
            output.startsWith("--- !ruby/object:Test::Module::Object"));
    assertTrue("Tags must be present: " + output,
            output.contains("!ruby/object:Test::Module::Sub1"));
    assertTrue("Tags must be present.", output.contains("!ruby/object:Test::Module::Sub2"));
    // parse back.
    TestObject result2 = parseObject(output);
    assertEquals(0, result2.getSub1().getAtt2());
    assertEquals("MyString", result2.getSub2().getAtt1());
    assertEquals(1, result2.getSub2().getAtt2().size());
    assertEquals(12345, result2.getSub2().getAtt3());
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:24,代码来源:RubyTest.java

示例3: testEmitWithTags2WithoutTagForParentJavabean

import org.yaml.snakeyaml.DumperOptions; //导入方法依赖的package包/类
public void testEmitWithTags2WithoutTagForParentJavabean() {
    TestObject result = parseObject(Util.getLocalResource("ruby/ruby1.yaml"));
    DumperOptions options = new DumperOptions();
    options.setExplicitStart(true);
    Representer repr = new Representer();
    repr.addClassTag(Sub1.class, new Tag("!ruby/object:Test::Module::Sub1"));
    repr.addClassTag(Sub2.class, new Tag("!ruby/object:Test::Module::Sub2"));
    Yaml yaml2 = new Yaml(repr, options);
    String output = yaml2.dump(result);
    // System.out.println(output);
    assertTrue("Tags must be present.",
            output.startsWith("--- !!org.yaml.snakeyaml.ruby.TestObject"));
    assertTrue("Tags must be present: " + output,
            output.contains("!ruby/object:Test::Module::Sub1"));
    assertTrue("Tags must be present.", output.contains("!ruby/object:Test::Module::Sub2"));
    // parse back.
    TestObject result2 = parseObject(output);
    assertEquals(0, result2.getSub1().getAtt2());
    assertEquals("MyString", result2.getSub2().getAtt1());
    assertEquals(1, result2.getSub2().getAtt2().size());
    assertEquals(12345, result2.getSub2().getAtt3());
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:23,代码来源:RubyTest.java

示例4: testDumpMany

import org.yaml.snakeyaml.DumperOptions; //导入方法依赖的package包/类
public void testDumpMany() {
    List<Integer> docs = new ArrayList<Integer>();
    for (int i = 1; i < 4; i++) {
        docs.add(i);
    }
    DumperOptions options = new DumperOptions();
    options.setExplicitStart(true);
    Yaml yaml = new Yaml(options);
    String result = yaml.dumpAll(docs.iterator());
    assertNotNull(result);
    assertTrue(result.contains("--- 2"));
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:13,代码来源:DumpExampleTest.java

示例5: executeArguments

import org.yaml.snakeyaml.DumperOptions; //导入方法依赖的package包/类
/**
 * This method takes a set of command line arguments and tries to construct
 * OptimizationParameters and StatisticsParameters from it. It will use defaults if
 * not otherwise configured.
 *
 * @param args Command line arguments
 */
private static void executeArguments(String[] args) {
    InterfaceOptimizationParameters parameters = OptimizationBuilder.parseOptimizerArguments(args);
    InterfaceStatisticsParameters statisticsParameters = OptimizationBuilder.parseStatisticsArguments(args);

    InterfaceTerminator terminator = parameters.getTerminator();
    InterfaceOptimizer optimizer = parameters.getOptimizer();
    InterfaceOptimizationProblem problem = parameters.getProblem();

    LinkedHashMap<String, Object> optimizationLog = new LinkedHashMap<>();
    // Meta parameters
    optimizationLog.put("populationSize", parameters.getOptimizer().getPopulation().getTargetSize());
    optimizationLog.put("numberOfRuns", statisticsParameters.getMultiRuns());
    optimizationLog.put("seed", parameters.getRandomSeed());
    optimizationLog.put("problem", parameters.getProblem());

    CommandLineStatistics yamlStatistics = new CommandLineStatistics(statisticsParameters);

    /**
     * Runs optimization
     */
    Processor optimizationProcessor = new Processor(yamlStatistics, parameters);
    optimizationProcessor.setSaveParams(false);
    optimizationProcessor.startOptimization();
    optimizationProcessor.runOptimizationOnce();

    /**
     * Get run statistics
     */
    optimizationLog.put("runs", yamlStatistics.getRuns());

    /**
     * Yaml configuration
     */
    DumperOptions options = new DumperOptions();
    options.setExplicitStart(true);
    options.setExplicitEnd(true);
    Yaml yaml = new Yaml();

    System.out.println(yaml.dump(optimizationLog));
}
 
开发者ID:openea,项目名称:eva2,代码行数:48,代码来源:Main.java


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