當前位置: 首頁>>代碼示例>>Java>>正文


Java DumperOptions.setSplitLines方法代碼示例

本文整理匯總了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);
    }
 
開發者ID:bmoliveira,項目名稱:snake-yaml,代碼行數:24,代碼來源:EmitterTest.java

示例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);
    }
 
開發者ID:bmoliveira,項目名稱:snake-yaml,代碼行數:26,代碼來源:EmitterTest.java

示例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);
}
 
開發者ID:bmoliveira,項目名稱:snake-yaml,代碼行數:15,代碼來源:LineBreakDooubleQuotedTest.java

示例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);
}
 
開發者ID:bmoliveira,項目名稱:snake-yaml,代碼行數:11,代碼來源:FlexibleScalarStyleTest.java

示例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);
}
 
開發者ID:bmoliveira,項目名稱:snake-yaml,代碼行數:33,代碼來源:EmitterTest.java

示例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);
}
 
開發者ID:bmoliveira,項目名稱:snake-yaml,代碼行數:31,代碼來源:EmitterTest.java

示例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));
        }
        */
    }

}
 
開發者ID:linzeqipku,項目名稱:SnowGraph,代碼行數:34,代碼來源:TestApiLocator.java


注:本文中的org.yaml.snakeyaml.DumperOptions.setSplitLines方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。