本文整理匯總了Java中org.yaml.snakeyaml.DumperOptions.setPrettyFlow方法的典型用法代碼示例。如果您正苦於以下問題:Java DumperOptions.setPrettyFlow方法的具體用法?Java DumperOptions.setPrettyFlow怎麽用?Java DumperOptions.setPrettyFlow使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.yaml.snakeyaml.DumperOptions
的用法示例。
在下文中一共展示了DumperOptions.setPrettyFlow方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: convert
import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
private YamlConversionResult convert(Map<String, Collection<String>> properties) {
if (properties.isEmpty()) {
return YamlConversionResult.EMPTY;
}
YamlBuilder root = new YamlBuilder(mode, keyspaceList, status, YamlPath.EMPTY);
for (Entry<String, Collection<String>> e : properties.entrySet()) {
for (String v : e.getValue()) {
root.addProperty(YamlPath.fromProperty(e.getKey()), v);
}
}
Object object = root.build();
DumperOptions options = new DumperOptions();
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
options.setPrettyFlow(true);
Yaml yaml = new Yaml(options);
String output = yaml.dump(object);
return new YamlConversionResult(status, output);
}
示例2: testStyle2Pretty
import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
public void testStyle2Pretty() {
List<Integer> list = new ArrayList<Integer>();
list.add(new Integer(1));
list.add(new Integer(1));
Map<String, Object> map = new LinkedHashMap<String, Object>();
map.put("age", 5);
map.put("name", "Ubuntu");
map.put("list", list);
DumperOptions options = new DumperOptions();
options.setDefaultScalarStyle(DumperOptions.ScalarStyle.SINGLE_QUOTED);
options.setDefaultFlowStyle(DumperOptions.FlowStyle.FLOW);
options.setPrettyFlow(true);
Yaml yaml = new Yaml(options);
String output = yaml.dump(map);
assertEquals(
"{\n 'age': !!int '5',\n 'name': 'Ubuntu',\n 'list': [\n !!int '1',\n !!int '1']\n \n}\n",
output);
}
示例3: configYamlFormat
import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
private static void configYamlFormat(final ToolBelt belt, final AppConfig config) {
DumperOptions dumperOptions = new DumperOptions();
dumperOptions.setDefaultFlowStyle(
"BLOCK".equalsIgnoreCase(config.getString("RD_YAML_FLOW", "BLOCK")) ?
DumperOptions.FlowStyle.BLOCK :
DumperOptions.FlowStyle.FLOW
);
dumperOptions.setPrettyFlow(config.getBool("RD_YAML_PRETTY", true));
Representer representer = new Representer();
representer.addClassTag(JobItem.class, Tag.MAP);
representer.addClassTag(ScheduledJobItem.class, Tag.MAP);
representer.addClassTag(DateInfo.class, Tag.MAP);
representer.addClassTag(Execution.class, Tag.MAP);
belt.formatter(new YamlFormatter(representer, dumperOptions));
belt.channels().infoEnabled(false);
belt.channels().warningEnabled(false);
belt.channels().errorEnabled(false);
}
示例4: toString
import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
@Override
public String toString() {
Map<String,Object> data = new LinkedHashMap<String,Object>() {{
if (asset != null) {
put(ASSET, asset);
}
put(MAIN_CLASS, mainClass);
put(HOLLOW, hollow);
put(PROPERTIES, properties);
put(MODULES, bootstrapModules);
put(BOOTSTRAP_ARTIFACTS, bootstrapArtifacts);
put(BUNDLE_DEPENDENCIES, bundleDependencies);
put(DEPENDENCIES, dependencies);
}};
DumperOptions options = new DumperOptions();
options.setPrettyFlow(true);
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
Yaml yaml = new Yaml(options);
return yaml.dump(data);
}
示例5: ManifestCommands
import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
@Autowired
public ManifestCommands(SkipperClient skipperClient) {
this.skipperClient = skipperClient;
DumperOptions dumperOptions = new DumperOptions();
dumperOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
dumperOptions.setPrettyFlow(true);
this.yaml = new Yaml(dumperOptions);
}
示例6: sanitizeYml
import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
/**
* Redacts the values stored for keys that contain the following: password,
* secret, key, token, *credentials.*.
* @param yml String containing a yaml.
* @return redacted yaml String.
*/
public static String sanitizeYml(String yml) {
String result = "";
try {
DumperOptions options = new DumperOptions();
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
options.setPrettyFlow(true);
Yaml yaml = new Yaml(options);
Iterator<Object> iter = yaml.loadAll(yml).iterator();
while (iter.hasNext()) {
Object o = iter.next();
if (o instanceof LinkedHashMap) {
iterateLinkedHashMap((LinkedHashMap<String, Object>) o);
}
result += yaml.dump(o);
}
}
catch (Throwable throwable) {
logger.error("Unable to redact data from Manifest debug entry", throwable);
}
if (result == null || result.length() == 0) {
result = yml;
}
return result;
}
示例7: testYamlMerge
import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
@Test
public void testYamlMerge() throws IOException {
DumperOptions dumperOptions = new DumperOptions();
dumperOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
dumperOptions.setPrettyFlow(true);
Yaml yaml = new Yaml(dumperOptions);
Resource resource = new ClassPathResource("/org/springframework/cloud/skipper/server/service/ticktock-1.0.0");
Package pkg = this.packageReader.read(resource.getFile());
ConfigValues configValues = new ConfigValues();
Map<String, Object> configValuesMap = new TreeMap<>();
Map<String, Object> logMap = new TreeMap<>();
logMap.put("appVersion", "1.2.1.RELEASE");
configValuesMap.put("log", logMap);
configValuesMap.put("hello", "universe");
String configYaml = yaml.dump(configValuesMap);
configValues.setRaw(configYaml);
Map<String, Object> mergedMap = ConfigValueUtils.mergeConfigValues(pkg, configValues);
String mergedYaml = yaml.dump(mergedMap);
String expectedYaml = StreamUtils.copyToString(
TestResourceUtils.qualifiedResource(getClass(), "merged.yaml").getInputStream(),
Charset.defaultCharset());
assertThat(mergedYaml).isEqualTo(expectedYaml);
}
示例8: createSimplePackage
import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
private Package createSimplePackage() throws IOException {
Package pkg = new Package();
// Add package metadata
PackageMetadata packageMetadata = new PackageMetadata();
packageMetadata.setName("myapp");
packageMetadata.setVersion("1.0.0");
packageMetadata.setMaintainer("bob");
pkg.setMetadata(packageMetadata);
// Add ConfigValues
Map<String, String> map = new HashMap<>();
map.put("foo", "bar");
map.put("fiz", "faz");
DumperOptions dumperOptions = new DumperOptions();
dumperOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
dumperOptions.setPrettyFlow(true);
Yaml yaml = new Yaml(dumperOptions);
ConfigValues configValues = new ConfigValues();
configValues.setRaw(yaml.dump(map));
pkg.setConfigValues(configValues);
// Add template
Resource resource = new ClassPathResource("/org/springframework/cloud/skipper/io/generic-template.yml");
String genericTempateData = StreamUtils.copyToString(resource.getInputStream(), Charset.defaultCharset());
Template template = new Template();
template.setData(genericTempateData);
template.setName(resource.getURL().toString());
List<Template> templateList = new ArrayList<>();
templateList.add(template);
pkg.setTemplates(templateList);
return pkg;
}
示例9: 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;
}
示例10: writeTo
import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
void writeTo(Path filePath) {
DumperOptions options = new DumperOptions();
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
options.setPrettyFlow(true);
Yaml yaml = new Yaml(options);
try {
FileWriter writer = new FileWriter(filePath.toString());
yaml.dump(properties, writer);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例11: getYaml
import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
public static Yaml getYaml() {
final DumperOptions options = new DumperOptions();
options.setDefaultFlowStyle(DumperOptions.FlowStyle.FLOW);
options.setPrettyFlow(true);
SkipNullRepresenter representer = new SkipNullRepresenter();
representer.addClassTag(TestDefAction.class, Tag.MAP);
return new Yaml(representer, options);
}
示例12: testNoChildrenPretty
import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
public void testNoChildrenPretty() {
Human father = new Human();
father.setName("Father");
father.setBirthday(new Date(1000000000));
father.setBirthPlace("Leningrad");
father.setBankAccountOwner(father);
Human mother = new Human();
mother.setName("Mother");
mother.setBirthday(new Date(100000000000L));
mother.setBirthPlace("Saint-Petersburg");
father.setPartner(mother);
mother.setPartner(father);
mother.setBankAccountOwner(father);
DumperOptions options = new DumperOptions();
options.setPrettyFlow(true);
options.setDefaultFlowStyle(FlowStyle.FLOW);
Yaml yaml = new Yaml(options);
String output = yaml.dump(father);
String etalon = Util.getLocalResource("recursive/no-children-1-pretty.yaml");
assertEquals(etalon, output);
//
Human father2 = (Human) yaml.load(output);
assertNotNull(father2);
assertEquals("Father", father2.getName());
assertEquals("Mother", father2.getPartner().getName());
assertEquals("Father", father2.getBankAccountOwner().getName());
assertSame(father2, father2.getBankAccountOwner());
}
示例13: testStringsPretty
import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
public void testStringsPretty() {
A a = new A();
a.setNames(new String[] { "aaa", "bbb", "ccc" });
DumperOptions options = new DumperOptions();
options.setPrettyFlow(true);
Yaml yaml = new Yaml(options);
String output = yaml.dump(a);
assertEquals(
"!!org.yaml.snakeyaml.javabeans.StringArrayTest$A\nnames: [\n aaa,\n bbb,\n ccc]\n",
output);
A b = (A) yaml.load(output);
assertTrue(Arrays.equals(a.getNames(), b.getNames()));
}
示例14: testWritePlainPretty
import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
public void testWritePlainPretty() {
DumperOptions options = new DumperOptions();
options.setDefaultScalarStyle(ScalarStyle.PLAIN);
options.setPrettyFlow(true);
String folded = "0123456789 0123456789\n0123456789 0123456789";
Map<String, String> map = new LinkedHashMap<String, String>();
map.put("aaa", folded);
map.put("bbb", "\nbla-bla");
Yaml yaml = new Yaml(options);
String output = yaml.dump(map);
String etalon = "aaa: |-\n 0123456789 0123456789\n 0123456789 0123456789\nbbb: |2-\n\n bla-bla\n";
assertEquals(etalon, output);
}
示例15: assertToString
import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
private void assertToString(String message, YamlMap map) {
DumperOptions prettyFlowBlockOptions = new DumperOptions();
prettyFlowBlockOptions.setDefaultFlowStyle(FlowStyle.BLOCK);
prettyFlowBlockOptions.setPrettyFlow(true);
prettyFlowBlockOptions.setLineBreak(LineBreak.getPlatformLineBreak());
assertAsString(message, map, new Yaml(prettyFlowBlockOptions).dump(map.getRawData()).replace("|-", "|"));
}
開發者ID:Enterprise-Content-Management,項目名稱:infoarchive-sip-sdk,代碼行數:8,代碼來源:WhenWorkingWithYamlInAGenericYetTypeSafeManner.java