本文整理了Java中com.esotericsoftware.yamlbeans.YamlReader
类的一些代码示例,展示了YamlReader
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YamlReader
类的具体详情如下:
包路径:com.esotericsoftware.yamlbeans.YamlReader
类名称:YamlReader
[英]Deserializes Java objects from YAML.
[中]从YAML反序列化Java对象。
代码示例来源:origin: FlowCI/flow-platform
/**
* Yml To Map
* @param str
* @return
*/
public static Map ymlToMap(String str) {
Map result;
try {
YamlReader yamlReader = new YamlReader(str, yamlConfig);
result = (Map) yamlReader.read();
} catch (Throwable throwable) {
throw new YmlParseException(YML_ILLEGAL_MESSAGE);
}
return result;
}
代码示例来源:origin: westnordost/StreetComplete
private CountryInfo loadCountryInfo(String countryCodeIso3166) throws IOException
{
String filename = countryCodeIso3166+".yml";
InputStream is = null;
try
{
is = assetManager.open(BASEPATH + File.separator + filename);
Reader reader = new InputStreamReader(is, "UTF-8");
YamlReader yamlReader = new YamlReader(reader);
yamlReader.getConfig().setPrivateFields(true);
CountryInfo result = yamlReader.read(CountryInfo.class);
result.countryCode = countryCodeIso3166.split("-")[0];
return result;
}
finally
{
if(is != null) try
{
is.close();
}
catch (IOException ignore) { }
}
}
代码示例来源:origin: dariober/ASCIIGenome
YamlReader reader = new YamlReader(new FileReader(yaml));
Map<String, Object> values= (HashMap<String, Object>)reader.read();
List<String> cmd = (List<String>) values.get("commands");
if(cmd != null){
this.sessions= sessions;
reader.close();
} catch (Exception e){
System.err.println("Cannot read history file '" + yaml + "'");
代码示例来源:origin: EsotericSoftware/yamlbeans
/** Reads the next YAML document and deserializes it into an object. The type of object is defined by the YAML tag. If there is
* no YAML tag, the object will be an {@link ArrayList}, {@link HashMap}, or String. */
public Object read () throws YamlException {
return read(null);
}
代码示例来源:origin: KayLerch/alexa-skills-kit-tester-java
public static AlexaClientBuilder create(final InputStream scriptInputStream) throws IOException {
final YamlReader yamlReader = new YamlReader(IOUtils.toString(scriptInputStream));
return new AlexaClientBuilder(yamlReader);
}
代码示例来源:origin: gncloud/fastcatsearch
reader = new YamlReader(new FileReader(configFile));
while (true) {
Map sdata = (Map) reader.read();
if (sdata == null) break;
sourceList.add(sdata);
} finally {
try {
reader.close();
} catch (IOException Ignore) {
代码示例来源:origin: EsotericSoftware/yamlbeans
/** Reads an object of the specified type from YAML.
* @param type The type of object to read. If null, behaves the same as {{@link #read()}. */
public <T> T read (Class<T> type) throws YamlException {
return read(type, null);
}
代码示例来源:origin: westnordost/StreetComplete
private List<String> readContributors()
{
try
{
InputStream is = getResources().openRawResource(R.raw.credits_contributors);
YamlReader reader = new YamlReader(new InputStreamReader(is));
List<String> result = new ArrayList<>((List) reader.read());
result.add(getString(R.string.credits_and_more));
return result;
} catch (YamlException e)
{
throw new RuntimeException(e);
}
}
代码示例来源:origin: audit4j/audit4j-core
/**
* {@inheritDoc}
*
* @see org.audit4j.core.ConfigProvider#readConfig(java.io.InputStream)
*
*/
@SuppressWarnings("unchecked")
@Override
public T readConfig(InputStream fileAsStream) throws ConfigurationException {
InputStreamReader streamReader = new InputStreamReader(fileAsStream);
try {
YamlReader reader = new YamlReader(streamReader);
reader.getConfig().setClassTag(clazz.getSimpleName(), clazz);
return (T) reader.read();
} catch (YamlException e) {
throw new ConfigurationException("Configuration Exception", "CONF_002", e);
}
}
代码示例来源:origin: stackoverflow.com
YamlReader reader = new YamlReader(r);
p1 = reader.read(Person.class);
reader.close();
代码示例来源:origin: com.esotericsoftware.yamlbeans/yamlbeans
/** Reads an object of the specified type from YAML.
* @param type The type of object to read. If null, behaves the same as {{@link #read()}. */
public <T> T read (Class<T> type) throws YamlException {
return read(type, null);
}
代码示例来源:origin: westnordost/StreetComplete
private List<Map.Entry<String,String>> readTranslators()
{
try
{
InputStream is = getResources().openRawResource(R.raw.credits_translations);
YamlReader reader = new YamlReader(new InputStreamReader(is));
Map yml = (Map) reader.read();
List<Map.Entry<String, String>> result = new ArrayList<>();
for (Object e : yml.entrySet())
{
result.add((Map.Entry<String, String>) e);
}
Collections.sort(result, (o1, o2) -> o1.getKey().compareTo(o2.getKey()));
return result;
} catch (YamlException e)
{
throw new RuntimeException(e);
}
}
}
代码示例来源:origin: audit4j/audit4j-core
/**
* {@inheritDoc}
*
* @see org.audit4j.core.ConfigProvider#readConfig(java.lang.String)
*
*/
@SuppressWarnings("unchecked")
@Override
public T readConfig(String filePath) throws ConfigurationException {
try {
YamlReader reader = new YamlReader(new FileReader(filePath));
reader.getConfig().setClassTag(clazz.getSimpleName(), clazz);
return (T) reader.read();
} catch (FileNotFoundException e) {
throw new ConfigurationException("Configuration Exception", "CONF_001", e);
} catch (YamlException e) {
throw new ConfigurationException("Configuration Exception", "CONF_002", e);
}
}
代码示例来源:origin: com.esotericsoftware.yamlbeans/yamlbeans
/** Reads the next YAML document and deserializes it into an object. The type of object is defined by the YAML tag. If there is
* no YAML tag, the object will be an {@link ArrayList}, {@link HashMap}, or String. */
public Object read () throws YamlException {
return read(null);
}
代码示例来源:origin: westnordost/StreetComplete
private void parseConfig(InputStream config) throws YamlException
{
abbreviations = new HashMap<>();
YamlReader reader = new YamlReader(new InputStreamReader(config));
Map map = (Map) reader.read();
for(Object o : map.entrySet())
{
Map.Entry pair2 = (Map.Entry) o;
String abbreviation = ((String)pair2.getKey()).toLowerCase(locale);
String expansion = ((String) pair2.getValue()).toLowerCase(locale);
if(abbreviation.endsWith("$"))
{
abbreviation = abbreviation.substring(0, abbreviation.length() - 1) + "\\.?$";
}
else
{
abbreviation += "\\.?";
}
if(abbreviation.startsWith("..."))
{
abbreviation = "(\\w*)" + abbreviation.substring(3);
expansion = "$1" + expansion;
}
abbreviations.put(abbreviation, expansion);
}
}
代码示例来源:origin: stackoverflow.com
YamlReader reader = new YamlReader(new FileReader(path));
reader.getConfig().setClassTag("tag:yaml.org,2002:opencv-matrix", MatStorage.class);
Map map = (Map) reader.read();
代码示例来源:origin: KayLerch/alexa-skills-kit-tester-java
AlexaClientBuilder(final YamlReader root) {
HashMap<Object, Object> yRoot = null;
try {
yRoot = (HashMap)root.read();
} catch (YamlException e) {
log.error("[ERROR] Could not read YAML script file", e);
代码示例来源:origin: stackoverflow.com
name: Nathan Sweet
age: 28
public class Contact {
public String name;
public int age;
}
YamlReader reader = new YamlReader(new FileReader("contact.yml"));
Contact contact = reader.read(Contact.class);
System.out.println(contact.age);
代码示例来源:origin: EsotericSoftware/yamlbeans
public static void main (String[] args) throws Exception {
YamlReader reader = new YamlReader(new FileReader("test/test.yml"));
System.out.println(reader.read());
}
}
代码示例来源:origin: com.esotericsoftware.yamlbeans/yamlbeans
public static void main (String[] args) throws Exception {
YamlReader reader = new YamlReader(new FileReader("test/test.yml"));
System.out.println(reader.read());
}
}
内容来源于网络,如有侵权,请联系作者删除!