本文整理汇总了Java中org.yaml.snakeyaml.DumperOptions.setSplitLines方法的典型用法代码示例。如果您正苦于以下问题:Java DumperOptions.setSplitLines方法的具体用法?Java DumperOptions.setSplitLines怎么用?Java DumperOptions.setSplitLines使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.yaml.snakeyaml.DumperOptions
的用法示例。
在下文中一共展示了DumperOptions.setSplitLines方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: 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);
}
示例4: 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);
}
示例5: 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);
}
示例6: 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);
}
示例7: test
import org.yaml.snakeyaml.DumperOptions; //导入方法依赖的package包/类
@Test
public void test() throws IOException, ParseException {
String optDir=context.getDataDir()+"/test_api_locator";
TestDataSet testDataSet=new Yaml().loadAs(new FileInputStream(new File(SnowGraphContext.class.getResource("/").getPath()+"lucene-test.yml")),TestDataSet.class);
FileUtils.deleteDirectory(new File(optDir));
for (TestDataItem testDataItem:testDataSet.getItems()){
ApiLocatorResult apiLocatorResult=new ApiLocatorResult();
apiLocatorResult.setItem(testDataItem);
for (long id: ApiLocator.query(testDataItem.getQuery(),context.getApiLocatorContext(),false).getNodes()){
String sig=context.getApiLocatorContext().getId2Sig().get(id);
apiLocatorResult.add(sig);
}
String itemDir=optDir+"/"+testDataItem.getQuery().replace(" ","_")+"/";
DumperOptions options=new DumperOptions();
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
options.setSplitLines(false);
FileUtils.write(new File(itemDir+"/apiLocation.txt"),new Yaml(options).dump(apiLocatorResult));
/*
List<Graph<MiningNode, Integer>> graphs= CodePatternSearcher.run(testDataItem.getQuery(),context);
for (int i=0;i<graphs.size();i++){
Graph<MiningNode, Integer> graph=graphs.get(i);
File file=new File(itemDir+"/"+(i+1)+".txt");
FileUtils.write(file,"");
CFGUtil.printGraph(graph,new PrintStream(file));
}
*/
}
}