当前位置: 首页>>代码示例>>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;未经允许,请勿转载。