本文整理了Java中leap.lang.yaml.YAML
类的一些代码示例,展示了YAML
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YAML
类的具体详情如下:
包路径:leap.lang.yaml.YAML
类名称:YAML
暂无
代码示例来源:origin: org.leapframework/leap-lang
/**
* Parse the yaml content to {@link YamlValue}.
*/
public static YamlValue parse(Reader reader) throws YamlException {
return YamlValue.of(decode(reader));
}
代码示例来源:origin: org.leapframework/leap-core
@Override
public boolean readProperties(AppPropertyContext context, Resource resource) {
String filename = resource.getFilename();
if(Strings.endsWithIgnoreCase(filename, ".yaml") || Strings.endsWithIgnoreCase(filename,".yml")) {
String content = resource.getContent();
if(Strings.isEmpty(content)) {
return true;
}
Map<String, Object> map = YAML.parse(content).asMap();
if(map.isEmpty()) {
return true;
}
Map<String, String> props = Maps.toProperties(map);
props.forEach((key, value) -> putProperty(context, resource, key, value));
return true;
}
return false;
}
代码示例来源:origin: org.leapframework/leap-lang
/**
* Parse the yaml content to {@link YamlValue}.
*/
public static YamlValue parse(String string) throws YamlException {
return YamlValue.of(decode(string));
}
代码示例来源:origin: org.leapframework/jmms-plugins-swagger-doc
public SwaggerDoc(String dir) {
this.dir = leap.lang.path.Paths.suffixWithSlash(dir);
Map map = null;
File swaggerFile = Paths.get(dir).resolve("./swagger.json").toFile();
if(swaggerFile.exists()) {
map = JSON.decodeMap(IO.readString(swaggerFile, Charsets.UTF_8));
}else {
swaggerFile = Paths.get(dir).resolve("./swagger.yaml").toFile();
if(swaggerFile.exists()) {
map = YAML.decode(Resources.createFileResource(swaggerFile).getContent());
}
}
if(null != map) {
this.swagger = JsonObject.of(map);
}
}
代码示例来源:origin: org.leapframework/leap-webapi
@Override
public ApiMetadataBuilder read(Reader reader) throws IOException {
String content = IO.readString(reader).trim();
Map<String,Object> swagger;
if(content.startsWith("{")) {
swagger = JSON.decode(content);
}else{
swagger = YAML.decode(content);
}
ApiMetadataBuilder m = new ApiMetadataBuilder();
readSwagger(swagger, m);
return m;
}
代码示例来源:origin: org.leapframework/leap-core
protected void readMessages(MessageContext context, Resource resource) {
try {
String localeName = Locales.extractFromFilename(resource.getFilename());
Locale locale = Strings.isEmpty(localeName) ? null : Locales.forName(localeName);
Map<String, String> props;
try (Reader reader = resource.getInputStreamReader(charset)) {
Map map = YAML.decode(reader);
if (null == map || map.isEmpty()) {
return;
}
props = Maps.toProperties(map);
}
for (String key : props.keySet()) {
readMessage(context, resource, locale, props, (String) key);
}
} catch (Exception e) {
throw new AppConfigException("Error reading messages from properties resource [" +
resource.getURLString() + "], " + e.getMessage(), e);
}
}
内容来源于网络,如有侵权,请联系作者删除!