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