本文整理汇总了Java中com.esotericsoftware.yamlbeans.YamlReader类的典型用法代码示例。如果您正苦于以下问题:Java YamlReader类的具体用法?Java YamlReader怎么用?Java YamlReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
YamlReader类属于com.esotericsoftware.yamlbeans包,在下文中一共展示了YamlReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readYamlFile
import com.esotericsoftware.yamlbeans.YamlReader; //导入依赖的package包/类
/**
* Reads the YAML file containing the data to creat Cloud Computing simulation scenarios.
*
* @return a List of simulation scenarios specified inside the YAML file.
* @throws FileNotFoundException when the YAML file is not found.
* @throws YamlException when there is any error parsing the YAML file.
*/
private List<YamlCloudScenario> readYamlFile() throws FileNotFoundException, YamlException {
final List<YamlCloudScenario> scenarios = new ArrayList<YamlCloudScenario>();
final YamlReader reader = createYamlReader();
YamlCloudScenario scenario;
while ((scenario = reader.read(YamlCloudScenario.class)) != null) {
scenarios.add(scenario);
}
return scenarios;
}
示例2: readConfig
import com.esotericsoftware.yamlbeans.YamlReader; //导入依赖的package包/类
/**
* {@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);
}
}
示例3: execute
import com.esotericsoftware.yamlbeans.YamlReader; //导入依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
// IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
try {
YamlReader reader = new YamlReader(new FileReader(
"C:/Users/schallit/workspace-tosca/plugins/org.eclipse.cmf.occi.tosca.parser/tosca-types/normative-types.yml"));
Map<String, ?> normativeTypesMap = (Map<String, ?>) reader.read();
readYamlFile(normativeTypesMap);
executeMapping();
ExtensionsManager.save();
ExtensionsManager.createExtendedTosca();
Map<String, ?> customTypesMap = concatCustomAndAddedTypes();
readYamlFile(customTypesMap);
ExtensionsManager.save();
} catch (Exception e) {
throw new RuntimeException(e);
}
return null;
}
示例4: readCustomAndAddedTypesInGivenDirectory
import com.esotericsoftware.yamlbeans.YamlReader; //导入依赖的package包/类
private static void readCustomAndAddedTypesInGivenDirectory(String directoryPath,
Map nodes, Map capabilities, Map relationships, Map policies) throws Exception {
File[] yamlFiles = new File(directoryPath).listFiles();
for (File path : yamlFiles) {
YamlReader reader = new YamlReader(new FileReader(path));
Map<String, ?> map = (Map<String, ?>) reader.read();
if (map.containsKey("node_types")) {
nodes.putAll((Map) map.get("node_types"));
}
if (map.containsKey("capability_types")) {
capabilities.putAll((Map) map.get("capability_types"));
}
if (map.containsKey("relationship_types")) {
relationships.putAll((Map) map.get("relationship_types"));
}
if (map.containsKey("policy_types")) {
policies.putAll((Map) map.get("policy_types"));
}
reader.close();
}
}
示例5: readYamlFile
import com.esotericsoftware.yamlbeans.YamlReader; //导入依赖的package包/类
private static void readYamlFile(String path) {
try {
YamlReader reader = new YamlReader(new FileReader(path));
System.out.println(path);
Map<String, ?> yamlFileAsMap = (Map<String, ?>) reader.read();
ConfigManager.createConfiguration(path);
Configuration configuration = ConfigManager.currentConfiguration;
Map<String, ?> topology_template = (Map<String, ?>) yamlFileAsMap.get("topology_template");
if (topology_template.get("inputs") != null && topology_template.get("inputs") instanceof Map) {
InputsReader.read(ConfigManager.convertPathToConfigName(path),
(Map<String, ?>) topology_template.get("inputs"));
}
if (topology_template.get("description") != null) {
configuration.setDescription((String) topology_template.get("description"));
}
readNodeTemplate(configuration, (Map<String, ?>) topology_template.get("node_templates"));
createApplication(configuration);
ConfigManager.save();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例6: unmarshal
import com.esotericsoftware.yamlbeans.YamlReader; //导入依赖的package包/类
/**
* {@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();
}
示例7: loadConfig
import com.esotericsoftware.yamlbeans.YamlReader; //导入依赖的package包/类
/**
* Loads the configuration from the specified filename.
*
* @throws FileNotFoundException
*/
public void loadConfig() throws FileNotFoundException {
File config = new File(filename);
if (!config.exists()) {
throw new FileNotFoundException();
} else {
try {
YamlReader reader = new YamlReader(new FileReader(filename));
Object object = reader.read();
Map data = (Map) object;
this.map = data;
} catch (YamlException ex) {
System.out.println("Unable to read config: " + filename);
System.exit(1);
}
}
}
示例8: loadConfig
import com.esotericsoftware.yamlbeans.YamlReader; //导入依赖的package包/类
public static ReportFieldConfig loadConfig(String content) {
try {
YamlReader reader = new YamlReader(content);
Object object = reader.read();
return JSON.parseObject(JSON.toJSONString(object), ReportFieldConfig.class);
} catch (Exception e) {
throw new RuntimeException("load config failed:" + content, e);
}
}
示例9: retrieveConfig
import com.esotericsoftware.yamlbeans.YamlReader; //导入依赖的package包/类
/**
* This method parses the provided configFile into its equivalent command-line args
*
* @param configFile containing config args
* @return Array of args
*/
protected Config retrieveConfig(final File configFile) {
if (!configFile.exists()) {
printHelp("Configuration file does not exist: " + configFile);
}
logger.debug("Loading configuration file: {}", configFile);
try {
final YamlReader reader = new YamlReader(new FileReader(configFile));
@SuppressWarnings("unchecked")
final Map<String, String> configVars = (HashMap<String, String>) reader.read();
return configFromFile(configVars);
} catch (final IOException | java.text.ParseException e) {
throw new RuntimeException("Unable to read configuration file due to: " + e.getMessage(), e);
}
}
示例10: readMetaYaml
import com.esotericsoftware.yamlbeans.YamlReader; //导入依赖的package包/类
@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"))));
}
}
示例11: getLocatorMap
import com.esotericsoftware.yamlbeans.YamlReader; //导入依赖的package包/类
/**
*
* @param path 对象库文件地址
* @param pageName pageName 页面名字
* @return 返回locator 哈希表 locatorName:locator
*/
public HashMap<String,Locator> getLocatorMap(String path,String pageName) throws FileNotFoundException, YamlException {
HashMap<String,Locator> locatorHashMap=new HashMap<>();
YamlReader yamlReader=new YamlReader(new FileReader(path));
Object yamlObject=yamlReader.read();
Map yamlMap=(Map) yamlObject;
ArrayList<HashMap<String,Object>> pages=(ArrayList<HashMap<String,Object>>)yamlMap.get("pages");
for (int i=0;i<pages.size();i++)//遍历Page节点
{
HashMap<String,Object> pageNode=pages.get(i);//获取page节点
HashMap<String,Object> pageElement=(HashMap<String,Object>)pageNode.get("page");
if (pageElement.get("pageName").toString().equalsIgnoreCase(pageName))//判断是否需要获取的Page节点
{
// System.out.println(pageElement.get("desc"));
List<HashMap<String,Object>> locators=(List<HashMap<String,Object>>)pageElement.get("locators");//获取locators列表
for (int j=0;j<locators.size();j++)//遍历locators列表
{
HashMap<String,Object> locatorNode=locators.get(j);
Locator locator=new Locator();
locator.setType(getByType(locatorNode.get("type").toString()));
locator.setValue(locatorNode.get("value").toString());
locator.setTimout(Integer.parseInt(locatorNode.get("timeout").toString()));
locator.setLocatorName(locatorNode.get("name").toString());
locatorHashMap.put(locatorNode.get("name").toString(),locator);
}
}else {continue;}
// System.out.println(pageObjet);
}
// System.out.println(locatorHashMap.get("登录").getLocalorName());
return locatorHashMap;
}
示例12: getYamlPageUrl
import com.esotericsoftware.yamlbeans.YamlReader; //导入依赖的package包/类
public String getYamlPageUrl(String path,String pageName) throws FileNotFoundException, YamlException {
Map<String,Locator> locatorHashMap=new HashMap<>();
YamlReader yamlReader=new YamlReader(new FileReader(path));
Object yamlObject=yamlReader.read();
Map yamlMap=(Map) yamlObject;
ArrayList<HashMap<String,Object>> pages=(ArrayList<HashMap<String,Object>>)yamlMap.get("pages");
String url="";
for (int i=0;i<pages.size();i++)//遍历Page节点
{
HashMap<String,Object> pageNode=pages.get(i);//获取page节点
HashMap<String,Object> pageElement=(HashMap<String,Object>)pageNode.get("page");
if (pageElement.get("pageName").toString().equalsIgnoreCase(pageName))//判断是否需要获取的Page节点
{
// System.out.println(pageElement.get("desc"));
url=pageElement.get("value").toString();
}else {continue;}
// System.out.println(pageObjet);
}
System.out.println(url);
return url;
}
示例13: loadFromFile
import com.esotericsoftware.yamlbeans.YamlReader; //导入依赖的package包/类
public static RefPanelList loadFromFile(String filename)
throws YamlException, FileNotFoundException {
if (new File(filename).exists()) {
YamlReader reader = new YamlReader(new FileReader(filename));
reader.getConfig().setPropertyElementType(RefPanelList.class,
"panels", RefPanel.class);
reader.getConfig().setClassTag(
"genepi.minicloudmac.hadoop.util.RefPanelList",
RefPanelList.class);
RefPanelList result = reader.read(RefPanelList.class);
return result;
} else {
return new RefPanelList();
}
}
示例14: AlexaClientBuilder
import com.esotericsoftware.yamlbeans.YamlReader; //导入依赖的package包/类
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);
}
final HashMap yConfig = Optional.ofNullable(yRoot.get("configuration")).filter(o -> o instanceof HashMap).map(o -> (HashMap)o).orElseThrow(() -> new RuntimeException("configuration node is missing or empty."));
final HashMap yEndpoint = Optional.ofNullable(yConfig.get("endpoint")).filter(o -> o instanceof HashMap).map(o -> (HashMap)o).orElseThrow(() -> new RuntimeException("endpoint node is missing or empty."));
this.endpoint = AlexaEndpointFactory.createEndpoint(yEndpoint);
this.applicationId = Optional.ofNullable(yEndpoint.get("skillId")).filter(o -> o instanceof String).map(Object::toString).orElse(System.getenv("skillId"));
this.locale = Locale.forLanguageTag(Optional.ofNullable(yEndpoint.get("locale")).filter(o -> o instanceof String).map(Object::toString).orElse("en-US"));
this.apiEndpoint = Optional.ofNullable(yEndpoint.get("region")).filter(o -> o instanceof String).map(o -> AlexaClient.API_ENDPOINT.valueOf(o.toString())).orElse(AlexaClient.API_ENDPOINT.NA);
this.debugFlagSessionAttributeName = Optional.ofNullable(yConfig.get("debugFlagSessionAttributeName")).filter(o -> o instanceof String).map(Object::toString).orElse(null);
Optional.ofNullable(yConfig.get("device")).filter(o -> o instanceof HashMap).map(o -> (HashMap)o).ifPresent(yDevice -> {
this.deviceId = Optional.ofNullable(yDevice.get("id")).map(Object::toString).orElse(System.getenv("skillDeviceId"));
Optional.ofNullable(yDevice.get("supportedInterfaces")).filter(o -> o instanceof ArrayList).map(o -> (ArrayList)o).ifPresent(yInterfaces -> {
yInterfaces.forEach(yInterface -> {
final String interfaceName = yInterface.toString();
if ("Display".equals(interfaceName)) {
withSupportedInterface(DisplayInterface.builder().build());
}
if ("AudioPlayer".equals(interfaceName)) {
withSupportedInterface(AudioPlayerInterface.builder().build());
}
});
});
});
Optional.ofNullable(yConfig.get("user")).filter(o -> o instanceof HashMap).map(o -> (HashMap)o).ifPresent(yUser -> {
this.uid = Optional.ofNullable(yUser.get("id")).map(Object::toString).orElse(System.getenv("skillUserId"));
this.accessToken = Optional.ofNullable(yUser.get("accessToken")).map(Object::toString).orElse(System.getenv("skillAccessToken"));
});
yLaunch = Optional.ofNullable(yRoot.get("Launch")).orElseThrow(() -> new RuntimeException("There's no 'Launch'-node provided in the YAML script. Create a top-level node named 'Launch' as it is the entry point for the conversation you'd like to simulate."));
}
示例15: readContributors
import com.esotericsoftware.yamlbeans.YamlReader; //导入依赖的package包/类
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);
}
}