Search in sources :

Example 1 with PropertyUtils

use of org.yaml.snakeyaml.introspector.PropertyUtils in project es6draft by anba.

the class Test262Info method readYaml.

private void readYaml(String descriptor, boolean lenient) throws MalformedDataException {
    assert descriptor != null && !descriptor.isEmpty();
    Yaml yaml = null;
    if (lenient) {
        yaml = yamlQueue.poll();
    }
    if (yaml == null) {
        Constructor constructor = new Constructor(TestDescriptor.class);
        if (lenient) {
            PropertyUtils utils = new PropertyUtils();
            utils.setSkipMissingProperties(true);
            constructor.setPropertyUtils(utils);
        }
        yaml = new Yaml(constructor);
    }
    TestDescriptor desc;
    try {
        desc = yaml.loadAs(descriptor, TestDescriptor.class);
    } catch (YAMLException e) {
        throw new MalformedDataException(e.getMessage(), e);
    }
    if (lenient) {
        yamlQueue.offer(yaml);
    }
    this.description = desc.getDescription();
    this.includes = desc.getIncludes();
    this.features = desc.getFeatures();
    this.errorType = desc.getNegative();
    this.negative = desc.getNegative() != null;
    if (!desc.getFlags().isEmpty()) {
        if (!lenient) {
            for (String flag : desc.getFlags()) {
                if (!allowedFlags.contains(flag)) {
                    throw new MalformedDataException(String.format("Unknown flag '%s'", flag));
                }
            }
        }
        this.negative |= desc.getFlags().contains("negative");
        this.noStrict = desc.getFlags().contains("noStrict");
        this.onlyStrict = desc.getFlags().contains("onlyStrict");
        this.module = desc.getFlags().contains("module");
        this.raw = desc.getFlags().contains("raw");
    }
}
Also used : PropertyUtils(org.yaml.snakeyaml.introspector.PropertyUtils) Constructor(org.yaml.snakeyaml.constructor.Constructor) YAMLException(org.yaml.snakeyaml.error.YAMLException) Yaml(org.yaml.snakeyaml.Yaml)

Example 2 with PropertyUtils

use of org.yaml.snakeyaml.introspector.PropertyUtils in project Apktool by iBotPeaches.

the class MetaInfo method getYaml.

private static Yaml getYaml() {
    DumperOptions options = new DumperOptions();
    options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
    StringExRepresent representer = new StringExRepresent();
    PropertyUtils propertyUtils = representer.getPropertyUtils();
    propertyUtils.setSkipMissingProperties(true);
    return new Yaml(new StringExConstructor(), representer, options);
}
Also used : PropertyUtils(org.yaml.snakeyaml.introspector.PropertyUtils) DumperOptions(org.yaml.snakeyaml.DumperOptions) Yaml(org.yaml.snakeyaml.Yaml)

Aggregations

Yaml (org.yaml.snakeyaml.Yaml)2 PropertyUtils (org.yaml.snakeyaml.introspector.PropertyUtils)2 DumperOptions (org.yaml.snakeyaml.DumperOptions)1 Constructor (org.yaml.snakeyaml.constructor.Constructor)1 YAMLException (org.yaml.snakeyaml.error.YAMLException)1