Package org.yaml.snakeyaml.constructor

Examples of org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlPairs


            if(resources.size() > 1) {
                throw new RuntimeException("Found multiple " + name + " resources. You're probably bundling the Storm jars with your topology jar. "
                  + resources);
            }
            URL resource = resources.iterator().next();
            Yaml yaml = new Yaml(new SafeConstructor());
            Map ret = null;
            InputStream input = resource.openStream();
            try {
                ret = (Map) yaml.load(new InputStreamReader(input));
            } finally {
View Full Code Here


        options.setIndent(4);
        options.setDefaultFlowStyle(format.getStyle());
        Representer representer = new FancyRepresenter();
        representer.setDefaultFlowStyle(format.getStyle());

        yaml = new Yaml(new SafeConstructor(), representer, options);

        this.file = file;
    }
View Full Code Here

  public OS parseOS(String agentString) {
    return osParser.parse(agentString);
  }

  private void initialize(InputStream regexYaml) {
    Yaml yaml = new Yaml(new SafeConstructor());
    @SuppressWarnings("unchecked")
    Map<String,List<Map<String,String>>> regexConfig = (Map<String,List<Map<String,String>>>) yaml.load(regexYaml);

    List<Map<String,String>> uaParserConfigs = regexConfig.get("user_agent_parsers");
    if (uaParserConfigs == null) {
View Full Code Here

            if(resources.size() > 1) {
                throw new RuntimeException("Found multiple " + name + " resources. You're probably bundling the Storm jars with your topology jar. "
                  + resources);
            }
            URL resource = resources.iterator().next();
            Yaml yaml = new Yaml(new SafeConstructor());
            Map ret = null;
            InputStream input = resource.openStream();
            try {
                ret = (Map) yaml.load(new InputStreamReader(input));
            } finally {
View Full Code Here

    DumperOptions options = new DumperOptions();

    options.setIndent(4);
    options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);

    yaml = new Yaml(new SafeConstructor(), new EmptyNullRepresenter(), options);

    this.file = file;
  }
View Full Code Here

    this.file = file;

    // make config files look nicer
    DumperOptions options = new DumperOptions();
    options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
    yaml = new Yaml(new SafeConstructor(), rep, options);

  }
View Full Code Here

    DumperOptions options = new DumperOptions();

    options.setIndent(4);
    options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);

    yaml = new Yaml(new SafeConstructor(), new Representer(), options);

    this.file = file;
  }
View Full Code Here

public class SafeConstructorExampleTest extends TestCase {
    @SuppressWarnings("unchecked")
    public void testConstruct() {
        String doc = "- 5\n- Person\n- true";
        Yaml yaml = new Yaml(new SafeConstructor());
        List<Object> list = (List<Object>) yaml.load(doc);
        assertEquals(3, list.size());
        assertEquals(new Integer(5), list.get(0));
        assertEquals("Person", list.get(1));
        assertEquals(Boolean.TRUE, list.get(2));
View Full Code Here

        assertEquals(Boolean.TRUE, list.get(2));
    }

    public void testSafeConstruct() {
        String doc = "- 5\n- !org.yaml.snakeyaml.constructor.Person\n  firstName: Andrey\n  age: 99\n- true";
        Yaml yaml = new Yaml(new SafeConstructor());
        try {
            yaml.load(doc);
            fail("Custom Java classes should not be created.");
        } catch (Exception e) {
            assertEquals(
View Full Code Here

    @SuppressWarnings({ "unchecked", "rawtypes" })
    public void testDictSafeConstructor() {
        Map value = new TreeMap();
        value.put("abc", "www");
        value.put("qwerty", value);
        Yaml yaml = new Yaml(new SafeConstructor());
        String output1 = yaml.dump(value);
        assertEquals("&id001\nabc: www\nqwerty: *id001\n", output1);
        Map value2 = (Map) yaml.load(output1);
        assertEquals(2, value2.size());
        assertEquals("www", value2.get("abc"));
View Full Code Here

TOP

Related Classes of org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlPairs

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.