本文整理匯總了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());
}
示例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());
}
示例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());
}
示例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"));
}
示例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));
}