- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.apache.brooklyn.util.yaml.Yamls.getTextOfYamlAtPath()
方法的一些代码示例,展示了Yamls.getTextOfYamlAtPath()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Yamls.getTextOfYamlAtPath()
方法的具体详情如下:
包路径:org.apache.brooklyn.util.yaml.Yamls
类名称:Yamls
方法名:getTextOfYamlAtPath
[英]Given a path, where each segment consists of a string (key) or number (element in list), this will find the YAML text for that element
If not found this will return a YamlExtract where YamlExtract#isMatch() is false and YamlExtract#getError() is set.
[中]给定一个路径,其中每个段由字符串(键)或数字(列表中的元素)组成,这将找到该元素的YAML文本
如果未找到,将返回一个YamlExtract,其中YamlExtract#isMatch()为false,并且设置了YamlExtract#getError()。
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
@Test
public void testReplace() {
Assert.assertEquals(Yamls.getTextOfYamlAtPath("x: a\n bc", "x").getFullYamlTextWithExtractReplaced("\nc: 1\nd: 2"),
"x: \n c: 1\n d: 2");
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
@Test
public void testExtractMapWithOddWhitespace() {
Assert.assertEquals(Yamls.getTextOfYamlAtPath("x: a\n bc", "x").getMatchedYamlText(),
"a\n bc");
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
@Test
public void testExtractMapIgnoringPreviousComments() {
String sample = "a: 1 # one\n"
+ "b: 2 # two";
Assert.assertEquals(Yamls.getTextOfYamlAtPath(sample, "b").getMatchedYamlText(),
"2 # two");
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
@Test
public void testExtractNoOOBE() {
// this might log a warning, as item not found, but won't throw
YamlExtract r1 = Yamls.getTextOfYamlAtPath(
"items:\n- id: sample2\n itemType: location\n item:\n type: jclouds:aws-ec2\n brooklyn.config:\n key2: value2\n\n",
"item");
// won't throw
r1.getMatchedYamlTextOrWarn();
// will throw
try {
r1.getMatchedYamlText();
Assert.fail();
} catch (UserFacingException e) {
// expected, it should give a vaguely explanatory exception and no trace
}
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
catalogMetadata = MutableMap.copyOf(catalogMetadata);
collectCatalogItemsFromItemMetadataBlock(Yamls.getTextOfYamlAtPath(yaml, "brooklyn.catalog").getMatchedYamlTextOrWarn(),
containingBundle, catalogMetadata, resultLegacyFormat, resultNewFormat, requireValidation, parentMeta, 0, force);
Map<String,?> rootItem = MutableMap.of("item", itemDef);
String rootItemYaml = yaml;
YamlExtract yamlExtract = Yamls.getTextOfYamlAtPath(rootItemYaml, "brooklyn.catalog");
String match = yamlExtract.withOriginalIndentation(true).withKeyIncluded(true).getMatchedYamlTextOrWarn();
if (match!=null) {
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
" - b\n";
Assert.assertEquals(Yamls.getTextOfYamlAtPath(sample, 0).getMatchedYamlText(), "a");
Assert.assertEquals(Yamls.getTextOfYamlAtPath(sample, 1, "b").getMatchedYamlText(), "2");
Assert.assertEquals(Yamls.getTextOfYamlAtPath(sample, 3, 0).getMatchedYamlText(),
"a"
Assert.assertEquals(Yamls.getTextOfYamlAtPath(sample, 2).getMatchedYamlText(), "c1:\n 1\nc2:\n 2\n");
Assert.assertEquals(Yamls.getTextOfYamlAtPath(sample, 2).withOriginalIndentation(true).getMatchedYamlText(), " c1:\n 1\n c2:\n 2\n");
Assert.assertEquals(Yamls.getTextOfYamlAtPath(sample, 3, 0).withOriginalIndentation(true).getMatchedYamlText(),
" a"
Assert.assertEquals(Yamls.getTextOfYamlAtPath(sample, 3, 1).getMatchedYamlText(), "# for b\nb\n");
Assert.assertEquals(Yamls.getTextOfYamlAtPath(sample, 3, 1).withPrecedingCommentsIncluded(false).getMatchedYamlText(), "b\n");
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
Assert.assertEquals(Yamls.getTextOfYamlAtPath(sample, "k1").withKeyIncluded(true).getMatchedYamlText(),
sample.substring(0, sample.indexOf("k2")));
Assert.assertEquals(Yamls.getTextOfYamlAtPath(sample, "k3").withKeyIncluded(true).getMatchedYamlText(),
sample.substring(sample.indexOf("k3")));
Assert.assertEquals(Yamls.getTextOfYamlAtPath(sample, "k2", "k21").getMatchedYamlText(),
"# comment\nv21");
Assert.assertEquals(Yamls.getTextOfYamlAtPath(sample, "k2", "k21").getMatchedYamlText(),
"# comment\nv21");
Assert.assertEquals(Yamls.getTextOfYamlAtPath(sample, "k2", "k21").withKeyIncluded(true).getMatchedYamlText(),
"# comment\nk21: v21");
Assert.assertEquals(Yamls.getTextOfYamlAtPath(sample, "k2", "k21").withKeyIncluded(true).withPrecedingCommentsIncluded(false).getMatchedYamlText(),
"k21: v21");
Assert.assertEquals(Yamls.getTextOfYamlAtPath(sample, "k2", "k21").withPrecedingCommentsIncluded(false).getMatchedYamlText(),
"v21");
Assert.assertEquals(Yamls.getTextOfYamlAtPath(sample, "k2", "k21").withOriginalIndentation(true).getMatchedYamlText(),
" # comment\n v21");
Assert.assertEquals(Yamls.getTextOfYamlAtPath(sample, "k2", "k21").withKeyIncluded(true).withOriginalIndentation(true).getMatchedYamlText(),
" # comment\n k21: v21");
Assert.assertEquals(Yamls.getTextOfYamlAtPath(sample, "k2", "k21").withKeyIncluded(true).withPrecedingCommentsIncluded(false).withOriginalIndentation(true).getMatchedYamlText(),
" k21: v21");
Assert.assertEquals(Yamls.getTextOfYamlAtPath(sample, "k2", "k21").withPrecedingCommentsIncluded(false).withOriginalIndentation(true).getMatchedYamlText(),
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
} else {
Map<?,?> i = checkType(ii, "entry in items list", Map.class);
collectCatalogItemsFromItemMetadataBlock(Yamls.getTextOfYamlAtPath(sourceYaml, "items", count).getMatchedYamlTextOrWarn(),
containingBundle, i, resultLegacyFormat, resultNewFormat, requireValidation, catalogMetadata, depth+1, force);
String itemYaml = Yamls.getTextOfYamlAtPath(sourceYaml, "item").getMatchedYamlTextOrWarn();
if (itemYaml!=null) sourceYaml = itemYaml;
else sourceYaml = new Yaml().dump(item);
本文整理了Java中org.apache.brooklyn.util.yaml.Yamls.getTextOfYamlAtPath()方法的一些代码示例,展示了Yamls.getTextOfYamlA
我是一名优秀的程序员,十分优秀!