本文整理了Java中org.jvyaml.YAML.load()
方法的一些代码示例,展示了YAML.load()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YAML.load()
方法的具体详情如下:
包路径:org.jvyaml.YAML
类名称:YAML
方法名:load
暂无
代码示例来源:origin: com.backtype/dfs-datastores
public static PailSpec parseFromStream(InputStream is) {
Map format = (Map) YAML.load(new InputStreamReader(is));
return parseFromMap(format);
}
代码示例来源:origin: LiveRamp/jack
private static Map<String, Object> fetchInfoMap(String configName, ReaderProvider... readers) {
for (ReaderProvider reader : readers) {
try {
Optional<Reader> readerOptional = reader.get();
if (readerOptional.isPresent()) {
return (Map<String, Object>)YAML.load(readerOptional.get());
}
} catch (Exception e) {
//move to next reader
}
}
LOG.error("no yaml found for config: " + configName);
return Maps.newHashMap();
}
代码示例来源:origin: com.yahoo.bullet/bullet-core
/**
* Reads a YAML file containing mappings and returns them as a {@link Map}.
*
* @param yamlFile The String name of the YAML resource file in classpath or the path to a YAML file containing the mappings.
* @return A {@link Map} of String names to Objects of the mappings in the YAML file.
*/
protected Map<String, Object> readYAML(String yamlFile) {
if (yamlFile == null || yamlFile.isEmpty()) {
return new HashMap<>();
}
log.info("Loading configuration file: {}", yamlFile);
try {
InputStream is = this.getClass().getResourceAsStream("/" + yamlFile);
Reader reader = (is != null ? new InputStreamReader(is) : new FileReader(yamlFile));
return (Map<String, Object>) YAML.load(reader);
} catch (IOException ioe) {
log.error("Error loading configuration", ioe);
return new HashMap<>();
}
}
代码示例来源:origin: com.kenai.swingjavabuilderext/javabuilder-core
@SuppressWarnings("unchecked")
private static void handleAdditionalControlConstraintLine(LayoutConstraints co, String line) {
Map<String,String> constraints = (Map<String,String>)YAML.load(line);
for(String name : constraints.keySet()) {
List<Object> list = BuilderUtils.convertToList(constraints.get(name));
String value = BuilderUtils.convertListToString(list, ',', line.length());
co.getAdditionalControlConstraints().put(name, value);
}
}
代码示例来源:origin: com.backtype/dfs-datastores
public void readFields(DataInput di) throws IOException {
PailSpec spec = parseFromMap((Map<String, Object>)YAML.load(WritableUtils.readString(di)));
this.name = spec.name;
this.args = spec.args;
}
}
代码示例来源:origin: net.avcompris.commons/avc-commons-lang
/**
* load a YAML file into a {@link Yamled} object.
*
* @param yamlFile
* the YAML input file
* @return the loaded {@link Yamled} object.
*/
@Nullable
public static Yamled loadYAML(final File yamlFile) throws IOException {
nonNullArgument(yamlFile, "yamlFile");
final Object yaml;
final InputStream is = openInputStream(yamlFile);
try {
final Reader reader = new InputStreamReader(is, UTF_8);
try {
yaml = YAML.load(reader);
} catch (final ParserException e) {
throw new RuntimeException("Could not parse YAML file: "
+ yamlFile.getCanonicalPath(), e);
} catch (final ScannerException e) {
throw new RuntimeException("Error while parsing YAML File: "
+ yamlFile.getCanonicalPath(), e);
}
} finally {
is.close();
}
return YamledImpl.wrapToYamled(yaml);
}
代码示例来源:origin: com.kenai.swingjavabuilderext/javabuilder-core
Object value = YAML.load(temp.toString());
current.put(pair[0],value);
代码示例来源:origin: net.avcompris.commons/avc-commons-lang
/**
* load a YAML {@link String} into a {@link YAML} object.
*
* @param text
* the YAML input content
* @return the loaded {@link Yamled} object.
*/
@Nullable
public static Yamled loadYAML(final String text) throws IOException {
nonNullArgument(text, "text");
final Object yaml;
final Reader reader = new StringReader(text);
try {
yaml = YAML.load(reader);
} catch (final ScannerException e) {
throw new RuntimeException("Error while parsing YAML text", e);
}
return YamledImpl.wrapToYamled(yaml);
}
代码示例来源:origin: net.avcompris.commons/avc-commons-lang
yaml = YAML.load(reader);
代码示例来源:origin: com.kenai.swingjavabuilderext/javabuilder-core
Object document = YAML.load(bld.toString());
executeBuild(document, config, process);
return process.getBuildResult();
代码示例来源:origin: com.kenai.swingjavabuilderext/javabuilder-core
/**
* Builds assuming the root object has already been instantiated
* (e.g. for loading from within the constructor of an object and creating
* it dynamically at that time)
* @param caller The caller
* @return Build result
* @throws IOException
* @throws BuildException
*/
public static BuildResult buildFromString(BuilderConfig config,Object caller, String yamlContent, ResourceBundle...resourceBundles) {
if (caller == null) {
throw new NullPointerException("Caller cannot be null or empty");
}
BuilderUtils.validateYamlContent(yamlContent);
BuildProcess result = new BuildProcess(config, caller, resourceBundles);
Object document = YAML.load(yamlContent);
executeBuild(document, config, result);
return result.getBuildResult();
}
内容来源于网络,如有侵权,请联系作者删除!