當前位置: 首頁>>代碼示例>>Java>>正文


Java YAMLException.getMessage方法代碼示例

本文整理匯總了Java中org.yaml.snakeyaml.error.YAMLException.getMessage方法的典型用法代碼示例。如果您正苦於以下問題:Java YAMLException.getMessage方法的具體用法?Java YAMLException.getMessage怎麽用?Java YAMLException.getMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.yaml.snakeyaml.error.YAMLException的用法示例。


在下文中一共展示了YAMLException.getMessage方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testBean2

import org.yaml.snakeyaml.error.YAMLException; //導入方法依賴的package包/類
public void testBean2() {
    IncompleteBean bean = new IncompleteBean();
    bean.setName("lunch");
    DumperOptions options = new DumperOptions();
    options.setAllowReadOnlyProperties(true);
    Yaml yaml = new Yaml(options);
    String output = yaml.dumpAsMap(bean);
    // System.out.println(output);
    assertEquals("id: 10\nname: lunch\n", output);
    //
    Yaml loader = new Yaml();
    try {
        loader.loadAs(output, IncompleteBean.class);
        fail("Setter is missing.");
    } catch (YAMLException e) {
        String message = e.getMessage();
        assertTrue(
                message,
                message.contains("Unable to find property 'id' on class: org.yaml.snakeyaml.issues.issue47.IncompleteBean"));
    }
}
 
開發者ID:bmoliveira,項目名稱:snake-yaml,代碼行數:22,代碼來源:ReadOnlyPropertiesTest.java

示例2: readYamlFile

import org.yaml.snakeyaml.error.YAMLException; //導入方法依賴的package包/類
Map<String, Object> readYamlFile(String yamlfile) throws FileNotFoundException {
    File file = new File(yamlfile);
    if (file.exists()) {
        InputStream input = new FileInputStream(file);
        Yaml yaml = new Yaml();
        Object data;
        try {
            data = yaml.load(input);
        } catch (YAMLException ye) {
            throw new PivioYamlParserException("Data in " + yamlfile + " is not valid: "+ye.getMessage());
        }
        if (data instanceof Map) {
            return makeLowerCaseKeys((Map<String, Object>) data);
        } else {
            throw new PivioYamlParserException("Data in " + yamlfile + " is not valid.");
        }
    } else {
        throw new FileNotFoundException("Could not find " + yamlfile + ".");
    }
}
 
開發者ID:pivio,項目名稱:pivio-client,代碼行數:21,代碼來源:Reader.java

示例3: buildFromYml

import org.yaml.snakeyaml.error.YAMLException; //導入方法依賴的package包/類
/**
 * Verify and create node tree by yml
 *
 * @param yml raw yml string
 * @return root node of yml
 * @throws YmlException if yml format is illegal
 */
public static Node buildFromYml(String yml, String rootName) {
    try {
        Yaml yaml = new Yaml(ROOT_YML_CONSTRUCTOR);
        RootYmlWrapper node = yaml.load(yml);

        // verify flow node
        if (Objects.isNull(node.flow)) {
            throw new YmlException("The 'flow' content must be defined");
        }

        // current version only support single flow
        if (node.flow.size() > 1) {
            throw new YmlException("Unsupported multiple flows definition");
        }

        // steps must be provided
        List<NodeWrapper> steps = node.flow.get(0).steps;
        if (Objects.isNull(steps) || steps.isEmpty()) {
            throw new YmlException("The 'step' must be defined");
        }

        node.flow.get(0).name = rootName;
        Node root = node.flow.get(0).toNode();

        buildNodeRelation(root);
        VALIDATOR.validate(root);

        return root;
    } catch (YAMLException e) {
        throw new YmlException(e.getMessage());
    }
}
 
開發者ID:FlowCI,項目名稱:flow-platform,代碼行數:40,代碼來源:NodeUtil.java


注:本文中的org.yaml.snakeyaml.error.YAMLException.getMessage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。