Search in sources :

Example 1 with BaseConstructor

use of org.yaml.snakeyaml.constructor.BaseConstructor in project spring-boot by spring-projects.

the class OriginTrackedYamlLoader method createYaml.

@Override
protected Yaml createYaml() {
    BaseConstructor constructor = new OriginTrackingConstructor();
    Representer representer = new Representer();
    DumperOptions dumperOptions = new DumperOptions();
    LimitedResolver resolver = new LimitedResolver();
    return new Yaml(constructor, representer, dumperOptions, resolver);
}
Also used : BaseConstructor(org.yaml.snakeyaml.constructor.BaseConstructor) Representer(org.yaml.snakeyaml.representer.Representer) DumperOptions(org.yaml.snakeyaml.DumperOptions) Yaml(org.yaml.snakeyaml.Yaml)

Example 2 with BaseConstructor

use of org.yaml.snakeyaml.constructor.BaseConstructor in project camel by apache.

the class SnakeYAMLDataFormat method defaultConstructor.

// ***************************
// Defaults
// ***************************
private BaseConstructor defaultConstructor(CamelContext context) {
    ClassLoader yamlClassLoader = this.classLoader;
    Collection<TypeFilter> yamlTypeFilters = this.typeFilters;
    if (yamlClassLoader == null && useApplicationContextClassLoader) {
        yamlClassLoader = context.getApplicationContextClassLoader();
    }
    if (allowAnyType) {
        yamlTypeFilters = Collections.singletonList(TypeFilters.allowAll());
    }
    BaseConstructor yamlConstructor;
    if (yamlTypeFilters != null) {
        yamlConstructor = yamlClassLoader != null ? typeFilterConstructor(yamlClassLoader, yamlTypeFilters) : typeFilterConstructor(yamlTypeFilters);
    } else {
        yamlConstructor = new SafeConstructor();
    }
    if (typeDescriptions != null && yamlConstructor instanceof Constructor) {
        for (TypeDescription typeDescription : typeDescriptions) {
            ((Constructor) yamlConstructor).addTypeDescription(typeDescription);
        }
    }
    return yamlConstructor;
}
Also used : BaseConstructor(org.yaml.snakeyaml.constructor.BaseConstructor) BaseConstructor(org.yaml.snakeyaml.constructor.BaseConstructor) SafeConstructor(org.yaml.snakeyaml.constructor.SafeConstructor) CustomClassLoaderConstructor(org.yaml.snakeyaml.constructor.CustomClassLoaderConstructor) Constructor(org.yaml.snakeyaml.constructor.Constructor) SafeConstructor(org.yaml.snakeyaml.constructor.SafeConstructor) TypeDescription(org.yaml.snakeyaml.TypeDescription)

Aggregations

BaseConstructor (org.yaml.snakeyaml.constructor.BaseConstructor)2 DumperOptions (org.yaml.snakeyaml.DumperOptions)1 TypeDescription (org.yaml.snakeyaml.TypeDescription)1 Yaml (org.yaml.snakeyaml.Yaml)1 Constructor (org.yaml.snakeyaml.constructor.Constructor)1 CustomClassLoaderConstructor (org.yaml.snakeyaml.constructor.CustomClassLoaderConstructor)1 SafeConstructor (org.yaml.snakeyaml.constructor.SafeConstructor)1 Representer (org.yaml.snakeyaml.representer.Representer)1