gpt4 book ai didi

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

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

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

YamlReader.<init>介绍

暂无

代码示例

代码示例来源: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

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: 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: 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: 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: 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: io.cloudslang.tools/cs-content-packager-sources

public String getGav() {
    final YamlReader yamlReader = new YamlReader(new StringReader(slangSource.getContent()));
    try {
      final Optional<Object> gavOpt = simpleYPath(yamlReader.read(),
          "operation.java_action.gav", ".");

      final Object gav = gavOpt.orElseGet(() -> {
        throw new RuntimeException("GAV not found in Slang file.");
      });

      return gav.toString();
    } catch (YamlException e) {
      throw new RuntimeException("Failed to parse the Slang file.");
    }
  }
}

代码示例来源: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: sonar-perl/sonar-perl

@SuppressWarnings("unchecked")
private void readMetaYaml(TestHarnessReport.TestHarnessReportBuilder builder, ArchiveInputStream archive) throws YamlException {
  BufferedReader br = new BufferedReader(new InputStreamReader(archive));
  YamlReader reader = new YamlReader(br);
  Map<String, Object> object = (Map<String, Object>) reader.read(Map.class);
  builder.startTime(getFromMap(object, "start_time"));
  builder.endTime(getFromMap(object, "stop_time"));
  for (Map<String, Object> fileAttr : (List<Map<String, Object>>) object.get("file_attributes")) {
    builder.addTest(
        new Test((String) fileAttr.get("description"), new BigDecimal((String) fileAttr.get("start_time")),
            new BigDecimal((String) fileAttr.get("end_time"))));
  }
}

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

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