本文整理汇总了Java中com.esotericsoftware.yamlbeans.YamlException类的典型用法代码示例。如果您正苦于以下问题:Java YamlException类的具体用法?Java YamlException怎么用?Java YamlException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
YamlException类属于com.esotericsoftware.yamlbeans包,在下文中一共展示了YamlException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readYamlFile
import com.esotericsoftware.yamlbeans.YamlException; //导入依赖的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.YamlException; //导入依赖的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: loadConfig
import com.esotericsoftware.yamlbeans.YamlException; //导入依赖的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);
}
}
}
示例4: readMetaYaml
import com.esotericsoftware.yamlbeans.YamlException; //导入依赖的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"))));
}
}
示例5: getLocatorMap
import com.esotericsoftware.yamlbeans.YamlException; //导入依赖的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;
}
示例6: getYamlPageUrl
import com.esotericsoftware.yamlbeans.YamlException; //导入依赖的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;
}
示例7: loadFromFile
import com.esotericsoftware.yamlbeans.YamlException; //导入依赖的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();
}
}
示例8: getLocalHomeServerUrl
import com.esotericsoftware.yamlbeans.YamlException; //导入依赖的package包/类
/**
* Return custom home server URL.</br>
* If fromLocal = true, return URL with 'localhost'.
* @param fromLocal
* @return
*/
public static String getLocalHomeServerUrl(Boolean fromLocal, Boolean useConfigFile){
String address = null,port = null;
try {
address = getLocalHomeServerAddress(useConfigFile);
port=ReadConfigFile.getInstance().getConfMap().get("homeserver_port");
} catch (FileNotFoundException | YamlException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(fromLocal){
return new StringBuilder("https://localhost:").append(port).toString();
}else{
return new StringBuilder("https://").append(address).append(":").append(port).toString();
}
}
示例9: logUser
import com.esotericsoftware.yamlbeans.YamlException; //导入依赖的package包/类
/**
* Simple login without doing any verifications.
* @param usernameOrEmail
* @param password
* TODO: works need to be done here because if the password is null, the login won't happen.
* @throws InterruptedException
*/
public void logUser(String usernameOrEmail, String phoneNumber,String password, Boolean forceDefaultHs) throws InterruptedException{
try {
if("true".equals(ReadConfigFile.getInstance().getConfMap().get("homeserverlocal"))&& false==forceDefaultHs){
logUserWithCustomHomeServer(usernameOrEmail, phoneNumber,password,MatrixUtilities.getLocalHomeServerUrl(false, false),Constant.DEFAULT_IDENTITY_SERVER_URL);
}else{
logUserWithDefaultHomeServer(usernameOrEmail, phoneNumber,password);
}
} catch (FileNotFoundException | YamlException | InterruptedException e) {
e.printStackTrace();
}
//wait until login page isn't displayed to see if 'Riot would like to send you notifications' alert is displayed.
waitUntilDisplayed(driver, "AuthenticationVCView", false, 60);
if(isPresentTryAndCatch(alertBox)){
System.out.println("Hit OK button on alert permission about notification");
dialogOkButton.click();
waitUntilDisplayed(driver, "XCUIElementTypeActivityIndicator", false, 30);
if(isPresentTryAndCatch(alertBox)){
System.out.println("Hit Yes button on alert permission about sending crash informations");
dialogYesButton.click();
}
}
}
示例10: AlexaClientBuilder
import com.esotericsoftware.yamlbeans.YamlException; //导入依赖的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."));
}
示例11: readContributors
import com.esotericsoftware.yamlbeans.YamlException; //导入依赖的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);
}
}
示例12: parseConfig
import com.esotericsoftware.yamlbeans.YamlException; //导入依赖的package包/类
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);
}
}
示例13: convert
import com.esotericsoftware.yamlbeans.YamlException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static DesiredCapabilities convert(Path yamlFile) throws YamlException {
Preconditions.checkNotNull(yamlFile);
Preconditions.checkArgument(Files.exists(yamlFile));
try {
YamlReader yamlReader = new YamlReader(new FileReader(yamlFile.toFile()));
Map<String, String> properties = (Map<String, String>) yamlReader.read();
if (properties == null || properties.isEmpty()) {
throw new IllegalArgumentException(String.format("File %s is empty", yamlFile));
}
if (!properties.containsKey(CAPABILITIES)) {
throw new IllegalArgumentException(String.format("File %s should have property capabilities, got %s", yamlFile, properties));
}
DesiredCapabilities capabilities = Capabilities.valueOf(properties.remove(CAPABILITIES).toUpperCase()).getCapabilities();
properties.entrySet()
.stream()
.forEach(pair -> capabilities.setCapability(pair.getKey(), pair.getValue()));
if (properties.containsKey(CHROME_EXTENSION)) {
ChromeOptions options = new ChromeOptions();
options.addExtensions(new File(properties.get(CHROME_EXTENSION)));
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
}
return capabilities;
} catch (FileNotFoundException e) {
// This should never happen
throw new IllegalStateException(e);
}
}
示例14: parseFromText
import com.esotericsoftware.yamlbeans.YamlException; //导入依赖的package包/类
public static ExperimentConfiguration parseFromText(String text) {
YamlReader reader = new YamlReader(new StringReader(text));
ExperimentConfigurationSerializer.configure(reader.getConfig());
try {
return reader.read(ExperimentConfiguration.class);
} catch (YamlException e) {
throw new RuntimeException(e);
}
}
示例15: Start
import com.esotericsoftware.yamlbeans.YamlException; //导入依赖的package包/类
private Start(){
//Gets the path to the YAML file inside the resource directory.
final String yamlFilePath = ResourceLoader.getResourcePath(getClass(), "CloudEnvironment1.yml");
try {
//Loads the YAML file containing 1 or more simulation scenarios.
final YamlCloudScenarioReader reader = new YamlCloudScenarioReader(yamlFilePath);
//Gets the list or parsed scenarios.
final List<YamlCloudScenario> simulationScenarios = reader.getScenarios();
//For each existing scenario, creates and runs it in CloudSim Plus, printing results.
for (YamlCloudScenario scenario : simulationScenarios) {
new CloudSimulation(scenario).run();
}
} catch (FileNotFoundException | YamlException e) {
System.err.println("Error when trying to load the simulation scenario from the YAML file: "+e.getMessage());
}
}