gpt4 book ai didi

com.esotericsoftware.yamlbeans.YamlReader.read()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-16 19:24:40 28 4
gpt4 key购买 nike

本文整理了Java中com.esotericsoftware.yamlbeans.YamlReader.read()方法的一些代码示例,展示了YamlReader.read()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YamlReader.read()方法的具体详情如下:
包路径:com.esotericsoftware.yamlbeans.YamlReader
类名称:YamlReader
方法名:read

YamlReader.read介绍

[英]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 ArrayList, HashMap, or String.
[中]读取下一个YAML文档并将其反序列化为对象。对象的类型由YAML标记定义。如果没有YAML标记,对象将是ArrayList、HashMap或字符串。

代码示例

代码示例来源: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: 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: 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: 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: 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: 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: 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: 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: 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());
  }
}

代码示例来源:origin: stackoverflow.com

YamlReader reader = new YamlReader(new FileReader("contact.yml"));
Object object = reader.read();
System.out.println(object);
Map map = (Map)object;
System.out.println(map.get("address"));

代码示例来源:origin: com.github.havardh/javaflow

public TypeMap(String filename) {
 try (FileReader fileReader = new FileReader(filename)) {
  YamlReader yamlReader = new YamlReader(fileReader);
  map = (Map<String, String>)yamlReader.read();
 } catch (FileNotFoundException e) {
  map = emptyMap();
 } catch (IOException e) {
  throw new ExitException(ErrorCode.COULD_NOT_PARSE_TYPE_MAP, e);
 }
}

代码示例来源:origin: com.sap.cloud.lm.sl/cloudfoundry-client-lib

protected TargetInfos getTokensFromFile() {
  final File tokensFile = getTokensFile();
  try {
    YamlReader reader = new YamlReader(new FileReader(tokensFile));
    return reader.read(TargetInfos.class);
  } catch (FileNotFoundException fnfe) {
    return new TargetInfos();
  } catch (IOException e) {
    throw new RuntimeException("An error occurred reading the tokens file at " + tokensFile.getPath() + ":" + e.getMessage(), e);
  }
}

代码示例来源:origin: org.cloudfoundry/cloudfoundry-client-lib

protected TargetInfos getTokensFromFile() {
  final File tokensFile = getTokensFile();
  try {
    YamlReader reader = new YamlReader(new FileReader(tokensFile));
    return reader.read(TargetInfos.class);
  } catch (FileNotFoundException fnfe) {
    return new TargetInfos();
  } catch (IOException e) {
    throw new RuntimeException("An error occurred reading the tokens file at " +
        tokensFile.getPath() + ":" + e.getMessage(), e);
  }
}

代码示例来源:origin: io.cloudslang.tools/cs-content-packager-sources

public String getFullName() {
  try {
    final YamlReader yamlReader = new YamlReader(new StringReader(slangSource.getContent()));
    final Optional<Object> namespace = simpleYPath(yamlReader.read(), "namespace", ".");
    if (namespace.isPresent()) {
      return format("%s.%s", namespace.get().toString(), getBaseName(slangSource.getName()));
    }
  } catch (YamlException exception) {
    log.error("Failed to parse SL file.", exception);
  }
  return slangSource.getName();
}

代码示例来源:origin: io.cloudslang.tools/cs-content-packager-sources

public boolean isJavaOperation() {
  final YamlReader yamlReader = new YamlReader(new StringReader(slangSource.getContent()));
  try {
    final Optional<Object> gavOpt = simpleYPath(yamlReader.read(),
        "operation.java_action.gav", ".");
    return gavOpt.isPresent();
  } catch (YamlException e) {
    return false;
  }
}

代码示例来源:origin: mbechler/marshalsec

/**
 * {@inheritDoc}
 *
 * @see marshalsec.MarshallerBase#unmarshal(java.lang.Object)
 */
@Override
public Object unmarshal ( String data ) throws Exception {
  YamlConfig yc = new YamlConfig();
  YamlReader r = new YamlReader(data, yc);
  return r.read();
}

代码示例来源:origin: org.lorislab.hugoup/hugoup

public static <T> T readFile(String file, Class<T> clazz) throws Exception {
  YamlConfig yamlConfig = new YamlConfig();
  yamlConfig.readConfig.setClassTags(false);
  YamlReader reader = new YamlReader(new FileReader(file));
  return reader.read(clazz);        
}

代码示例来源:origin: tomzo/gocd-yaml-config-plugin

public static Object readYamlObject(String path) throws IOException {
  YamlConfig config = new YamlConfig();
  config.setAllowDuplicates(false);
  YamlReader reader = new YamlReader(TestUtils.createReader(path), config);
  return reader.read();
}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com