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


Java DumperOptions.setIndent方法代碼示例

本文整理匯總了Java中org.yaml.snakeyaml.DumperOptions.setIndent方法的典型用法代碼示例。如果您正苦於以下問題:Java DumperOptions.setIndent方法的具體用法?Java DumperOptions.setIndent怎麽用?Java DumperOptions.setIndent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.yaml.snakeyaml.DumperOptions的用法示例。


在下文中一共展示了DumperOptions.setIndent方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: newYaml

import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
public static Yaml newYaml() {
  PropertyUtils propertyUtils = new AdvancedPropertyUtils();
  propertyUtils.setSkipMissingProperties(true);

  Constructor constructor = new Constructor(Federations.class);
  TypeDescription federationDescription = new TypeDescription(Federations.class);
  federationDescription.putListPropertyType("federatedMetaStores", FederatedMetaStore.class);
  constructor.addTypeDescription(federationDescription);
  constructor.setPropertyUtils(propertyUtils);

  Representer representer = new AdvancedRepresenter();
  representer.setPropertyUtils(new FieldOrderPropertyUtils());
  representer.addClassTag(Federations.class, Tag.MAP);
  representer.addClassTag(AbstractMetaStore.class, Tag.MAP);
  representer.addClassTag(WaggleDanceConfiguration.class, Tag.MAP);
  representer.addClassTag(YamlStorageConfiguration.class, Tag.MAP);
  representer.addClassTag(GraphiteConfiguration.class, Tag.MAP);

  DumperOptions dumperOptions = new DumperOptions();
  dumperOptions.setIndent(2);
  dumperOptions.setDefaultFlowStyle(FlowStyle.BLOCK);

  return new Yaml(constructor, representer, dumperOptions);
}
 
開發者ID:HotelsDotCom,項目名稱:waggle-dance,代碼行數:25,代碼來源:YamlFactory.java

示例2: testDumperOptions

import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
public void testDumperOptions() {
    List<Integer> data = new ArrayList<Integer>();
    for (int i = 0; i < 50; i++) {
        data.add(i);
    }
    Yaml yaml = new Yaml();
    String output = yaml.dump(data);
    assertTrue(output.contains("[0, 1, 2, 3, 4, 5, 6, 7, 8"));
    //
    DumperOptions options = new DumperOptions();
    options.setWidth(50);
    options.setIndent(4);
    yaml = new Yaml(options);
    output = yaml.dump(data);
    assertTrue(output.contains("1, 2"));
}
 
開發者ID:bmoliveira,項目名稱:snake-yaml,代碼行數:17,代碼來源:DumpExampleTest.java

示例3: checkQuotes

import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
private void checkQuotes(boolean isBlock, String expectation) {
    DumperOptions options = new DumperOptions();
    options.setIndent(4);
    if (isBlock) {
        options.setDefaultFlowStyle(FlowStyle.BLOCK);
    }
    Representer representer = new Representer();

    Yaml yaml = new Yaml(new SafeConstructor(), representer, options);

    LinkedHashMap<String, Object> lvl1 = new LinkedHashMap<String, Object>();
    lvl1.put("steak:cow", "11");
    LinkedHashMap<String, Object> root = new LinkedHashMap<String, Object>();
    root.put("cows", lvl1);
    String output = yaml.dump(root);
    assertEquals(expectation + "\n", output);

    // parse the value back
    @SuppressWarnings("unchecked")
    Map<String, Object> cows = (Map<String, Object>) yaml.load(output);
    @SuppressWarnings("unchecked")
    Map<String, String> cow = (Map<String, String>) cows.get("cows");
    assertEquals("11", cow.get("steak:cow"));
}
 
開發者ID:bmoliveira,項目名稱:snake-yaml,代碼行數:25,代碼來源:SingleQuoteTest.java

示例4: addServerId

import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
public static void addServerId(String serverId) throws IOException {

        FileWriter writer = new FileWriter(ConfigurationConstants.CONFIG_FILE_NAME);

        DumperOptions options=new DumperOptions();
        options.setIndent(1);
        options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);

        Yaml yaml=new Yaml(new NullRepresenter(),options);
        String conf = yaml.dump(configuration);
        yaml.dump(conf, writer);

        //remove |- literal from the config file
        File file = new File(ConfigurationConstants.CONFIG_FILE_NAME);
        String s1 = FileUtils.readFileToString(file);
        String substring = s1.substring(1, s1.length() - 1);
        FileUtils.writeStringToFile(file,substring);
    }
 
開發者ID:rndsolutions,項目名稱:hawkcd,代碼行數:19,代碼來源:Config.java

示例5: save

import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
public void save() throws IOException {
    FileWriter writer = new FileWriter(getConfigFile());
    DumperOptions options = new DumperOptions();
    options.setDefaultFlowStyle(FlowStyle.AUTO);
    options.setIndent(4);
    Representer representer = new Representer();
    representer.getPropertyUtils().setBeanAccess(BeanAccess.DEFAULT);
    new Yaml(options).dump(this, writer);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:10,代碼來源:ObjectMapConfiguration.java

示例6: getDumperOptions

import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
protected DumperOptions getDumperOptions() {
    DumperOptions options = new DumperOptions();
    options.setDefaultFlowStyle(DumperOptions.FlowStyle.FLOW);
    options.setPrettyFlow(true);
    options.setIndent(2);
    return options;
}
 
開發者ID:limberest,項目名稱:limberest,代碼行數:8,代碼來源:YamlLoader.java

示例7: toYaml

import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
private String toYaml(Object obj) {
	DumperOptions options = new DumperOptions();
	options.setAllowReadOnlyProperties(true);
	options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
	options.setIndent(4);
	return new Yaml(options).dump(obj);
}
 
開發者ID:xusida,項目名稱:yaml-format,代碼行數:8,代碼來源:FormatYamlAction.java

示例8: testDoubleQuotedStyle

import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的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

示例9: 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

示例10: testWriteIndicatorIndent

import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
public void testWriteIndicatorIndent() {
    DumperOptions options = new DumperOptions();
    options.setIndent(5);
    options.setIndicatorIndent(2);
    options.setDefaultFlowStyle(FlowStyle.BLOCK);
    List<?> topLevel = Arrays.asList(Collections.singletonMap("k1", "v1"), Collections.singletonMap("k2", "v2"));
    Map<String, ?> map = Collections.singletonMap("aaa", topLevel);
    Yaml yaml = new Yaml(options);
    String output = yaml.dump(map);
    String etalon = "aaa:\n  -  k1: v1\n  -  k2: v2\n";
    assertEquals(etalon, output);
}
 
開發者ID:bmoliveira,項目名稱:snake-yaml,代碼行數:13,代碼來源:EmitterTest.java

示例11: initialValue

import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
@Override
protected Yaml initialValue() {
    DumperOptions options = new DumperOptions();
    options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
    options.setPrettyFlow(false);
    options.setIndent(2);
    return new Yaml(new YamlConstructor(), new Representer(), options);
}
 
開發者ID:MylesIsCool,項目名稱:ViaVersion,代碼行數:9,代碼來源:Config.java

示例12: setupDumper

import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
private static void setupDumper() {
	options = new DumperOptions();
	representer = new Representer();

	options.setIndent(2);
	options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
	options.setAllowUnicode(Charset.defaultCharset().name().contains("UTF"));
	representer.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
}
 
開發者ID:hhaslam11,項目名稱:Text-Fighter,代碼行數:10,代碼來源:Saves.java

示例13: toString

import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
public synchronized String toString() {
	DumperOptions options = new DumperOptions();
	options.setWidth(50);
	options.setIndent(4);
	options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
	Yaml yaml = new Yaml(options);

	return yaml.dump(map);
}
 
開發者ID:gncloud,項目名稱:fastcatsearch3,代碼行數:10,代碼來源:OldSettings.java

示例14: serializeObject

import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
public static String serializeObject(Object obj) {
    DumperOptions options = new DumperOptions();
    options.setAllowReadOnlyProperties(false);
    options.setIndent(4);
    Yaml yaml = new Yaml(new OptimizationRepresenter(), options);

    return yaml.dump(obj);
}
 
開發者ID:openea,項目名稱:eva2,代碼行數:9,代碼來源:BeanSerializer.java

示例15: start

import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
public boolean start(List<AbstractModule> modules) {
    try {
        String moduleLog = "Using the following modules: ";
        moduleLog += "\n--------------------";
        for (AbstractModule module : modules) {
            if (!module.getClass().getName().startsWith("com.eden.orchid.OrchidModule")) {
                moduleLog += "\n * " + module.getClass().getName();
            }
        }
        moduleLog += "\n--------------------";
        Clog.i(moduleLog);

        injector = Guice.createInjector(modules);

        DumperOptions options = new DumperOptions();
        options.setIndent(4);
        options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);

        Yaml yaml = new Yaml(options);

        String flagLog = "Flag values: ";
        flagLog += "\n--------------------\n";
        flagLog += yaml.dump(OrchidFlags.getInstance().getData().toMap());
        flagLog += "--------------------";
        Clog.d(flagLog);

        context = injector.getInstance(OrchidContext.class);
        Clog.i("Running Orchid version {}, site version {} in {} environment", context.getOrchidVersion(), context.getVersion(), context.getEnvironment());
        context.start();
        context.finish();
        return true;
    }
    catch (Exception e) {
        Clog.e("Something went wrong running Orchid: {}", e, e.getMessage());
        e.printStackTrace();
        return false;
    }
}
 
開發者ID:JavaEden,項目名稱:Orchid,代碼行數:39,代碼來源:Orchid.java


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