Java 类org.yaml.snakeyaml.composer.Composer 实例源码

项目:AndroidApktool    文件:Yaml.java   
/**
 * Parse all YAML documents in a String and produce corresponding Java
 * objects. The documents are parsed only when the iterator is invoked.
 * 
 * @param yaml
 *            YAML data to load from (BOM must not be present)
 * @return an iterator over the parsed Java objects in this String in proper
 *         sequence
 */
public Iterable<Object> loadAll(Reader yaml) {
    Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver);
    constructor.setComposer(composer);
    Iterator<Object> result = new Iterator<Object>() {
        public boolean hasNext() {
            return constructor.checkData();
        }

        public Object next() {
            return constructor.getData();
        }

        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
    return new YamlIterable(result);
}
项目:AndroidApktool    文件:Yaml.java   
/**
 * Parse all YAML documents in a stream and produce corresponding
 * representation trees.
 * 
 * @see <a href="http://yaml.org/spec/1.1/#id859333">Processing Overview</a>
 * @param yaml
 *            stream of YAML documents
 * @return parsed root Nodes for all the specified YAML documents
 */
public Iterable<Node> composeAll(Reader yaml) {
    final Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver);
    constructor.setComposer(composer);
    Iterator<Node> result = new Iterator<Node>() {
        public boolean hasNext() {
            return composer.checkNode();
        }

        public Node next() {
            return composer.getNode();
        }

        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
    return new NodeIterable(result);
}
项目:5zig-TIMV-Plugin    文件:Yaml.java   
/**
 * Parse all YAML documents in a String and produce corresponding Java
 * objects. The documents are parsed only when the iterator is invoked.
 *
 * @param yaml
 *            YAML data to load from (BOM must not be present)
 * @return an iterator over the parsed Java objects in this String in proper
 *         sequence
 */
public Iterable<Object> loadAll(Reader yaml) {
    Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver);
    constructor.setComposer(composer);
    Iterator<Object> result = new Iterator<Object>() {
        public boolean hasNext() {
            return constructor.checkData();
        }

        public Object next() {
            return constructor.getData();
        }

        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
    return new YamlIterable(result);
}
项目:5zig-TIMV-Plugin    文件:Yaml.java   
/**
 * Parse all YAML documents in a stream and produce corresponding
 * representation trees.
 *
 * @see <a href="http://yaml.org/spec/1.1/#id859333">Processing Overview</a>
 * @param yaml
 *            stream of YAML documents
 * @return parsed root Nodes for all the specified YAML documents
 */
public Iterable<Node> composeAll(Reader yaml) {
    final Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver);
    constructor.setComposer(composer);
    Iterator<Node> result = new Iterator<Node>() {
        public boolean hasNext() {
            return composer.checkNode();
        }

        public Node next() {
            return composer.getNode();
        }

        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
    return new NodeIterable(result);
}
项目:diorite-configs-java8    文件:Yaml.java   
/**
 * Parse the only YAML document in a stream as configuration object.
 *
 * @param template
 *         template of config object.
 * @param io
 *         data to load from (BOM must not be present)
 * @param <T>
 *         type of config object.
 *
 * @return parsed object
 */
@SuppressWarnings("unchecked")
@Nullable
public <T extends Config> T fromYaml(ConfigTemplate<T> template, Reader io)
{
    ClassLoader old = Thread.currentThread().getContextClassLoader();
    if (old == null)
    {
        Thread.currentThread().setContextClassLoader(template.getConfigType().getClassLoader());
    }
    try
    {
        Composer composer = new Composer(new ParserImpl(new StreamReader(io)), new ConfigTemplateResolver(template));
        this.constructor.setComposer(composer);
        return (T) this.constructor.getSingleData(template.getConfigType());
    }
    finally
    {
        if (old == null)
        {
            Thread.currentThread().setContextClassLoader(null);
        }
    }
}
项目:diorite-configs-java8    文件:Yaml.java   
@Nullable
private Object loadFromReader(StreamReader sreader, Class<?> type)
{
    ClassLoader old = Thread.currentThread().getContextClassLoader();
    if (old == null)
    {
        Thread.currentThread().setContextClassLoader(type.getClassLoader());
    }
    try
    {
        Composer composer = new Composer(new ParserImpl(sreader), this.resolver);
        this.constructor.setComposer(composer);
        return this.constructor.getSingleData(type);
    }
    finally
    {
        if (old == null)
        {
            Thread.currentThread().setContextClassLoader(null);
        }
    }
}
项目:snake-yaml    文件:Yaml.java   
/**
 * Parse all YAML documents in a String and produce corresponding Java
 * objects. The documents are parsed only when the iterator is invoked.
 * 
 * @param yaml
 *            YAML data to load from (BOM must not be present)
 * @return an iterator over the parsed Java objects in this String in proper
 *         sequence
 */
public Iterable<Object> loadAll(Reader yaml) {
    Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver);
    constructor.setComposer(composer);
    Iterator<Object> result = new Iterator<Object>() {
        public boolean hasNext() {
            return constructor.checkData();
        }

        public Object next() {
            return constructor.getData();
        }

        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
    return new YamlIterable(result);
}
项目:snake-yaml    文件:Yaml.java   
/**
 * Parse all YAML documents in a stream and produce corresponding
 * representation trees.
 * 
 * @see <a href="http://yaml.org/spec/1.1/#id859333">Processing Overview</a>
 * @param yaml
 *            stream of YAML documents
 * @return parsed root Nodes for all the specified YAML documents
 */
public Iterable<Node> composeAll(Reader yaml) {
    final Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver);
    constructor.setComposer(composer);
    Iterator<Node> result = new Iterator<Node>() {
        public boolean hasNext() {
            return composer.checkNode();
        }

        public Node next() {
            return composer.getNode();
        }

        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
    return new NodeIterable(result);
}
项目:snake-yaml    文件:PyStructureTest.java   
@Override
public Iterable<Object> loadAll(Reader yaml) {
    StreamReader reader = new StreamReader(yaml);
    StringBuilder buffer = new StringBuilder();
    while (reader.peek() != '\0') {
        buffer.append(reader.peek());
        reader.forward();
    }
    CanonicalParser parser = new CanonicalParser(buffer.toString());
    Composer composer = new Composer(parser, resolver);
    this.constructor.setComposer(composer);
    Iterator<Object> result = new Iterator<Object>() {
        public boolean hasNext() {
            return constructor.checkData();
        }

        public Object next() {
            return constructor.getData();
        }

        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
    return new YamlIterable(result);
}
项目:snake-yaml    文件:CanonicalLoader.java   
@Override
public Object load(Reader yaml) {
    try {
        int ch = yaml.read();
        StringBuilder buffer = new StringBuilder();
        while (ch != -1) {
            buffer.append((char) ch);
            ch = yaml.read();
        }
        Composer composer = new Composer(new CanonicalParser(buffer.toString()), resolver);
        constructor.setComposer(composer);
        return constructor.getSingleData(Object.class);
    } catch (IOException e) {
        throw new YAMLException(e);
    }
}
项目:SubServers-2    文件:Yaml.java   
/**
 * Parse all YAML documents in a String and produce corresponding Java
 * objects. The documents are parsed only when the iterator is invoked.
 *
 * @param yaml
 *            YAML data to load from (BOM must not be present)
 * @return an iterator over the parsed Java objects in this String in proper
 *         sequence
 */
public Iterable<Object> loadAll(Reader yaml) {
    Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver);
    constructor.setComposer(composer);
    Iterator<Object> result = new Iterator<Object>() {
        public boolean hasNext() {
            return constructor.checkData();
        }

        public Object next() {
            return constructor.getData();
        }

        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
    return new YamlIterable(result);
}
项目:SubServers-2    文件:Yaml.java   
/**
 * Parse all YAML documents in a stream and produce corresponding
 * representation trees.
 *
 * @see <a href="http://yaml.org/spec/1.1/#id859333">Processing Overview</a>
 * @param yaml
 *            stream of YAML documents
 * @return parsed root Nodes for all the specified YAML documents
 */
public Iterable<Node> composeAll(Reader yaml) {
    final Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver);
    constructor.setComposer(composer);
    Iterator<Node> result = new Iterator<Node>() {
        public boolean hasNext() {
            return composer.checkNode();
        }

        public Node next() {
            return composer.getNode();
        }

        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
    return new NodeIterable(result);
}
项目:FastAsyncWorldedit    文件:Yaml.java   
/**
 * Parse all YAML documents in a String and produce corresponding Java
 * objects. The documents are parsed only when the iterator is invoked.
 *
 * @param yaml
 *            YAML data to load from (BOM must not be present)
 * @return an iterator over the parsed Java objects in this String in proper
 *         sequence
 */
public Iterable<Object> loadAll(Reader yaml) {
    Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver);
    constructor.setComposer(composer);
    Iterator<Object> result = new Iterator<Object>() {
        public boolean hasNext() {
            return constructor.checkData();
        }

        public Object next() {
            return constructor.getData();
        }

        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
    return new YamlIterable(result);
}
项目:FastAsyncWorldedit    文件:Yaml.java   
/**
 * Parse all YAML documents in a stream and produce corresponding
 * representation trees.
 *
 * @see <a href="http://yaml.org/spec/1.1/#id859333">Processing Overview</a>
 * @param yaml
 *            stream of YAML documents
 * @return parsed root Nodes for all the specified YAML documents
 */
public Iterable<Node> composeAll(Reader yaml) {
    final Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver);
    constructor.setComposer(composer);
    Iterator<Node> result = new Iterator<Node>() {
        public boolean hasNext() {
            return composer.checkNode();
        }

        public Node next() {
            return composer.getNode();
        }

        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
    return new NodeIterable(result);
}
项目:snakeyaml    文件:Yaml.java   
/**
 * Parse all YAML documents in a String and produce corresponding Java
 * objects. The documents are parsed only when the iterator is invoked.
 * 
 * @param yaml
 *            YAML data to load from (BOM must not be present)
 * @return an iterator over the parsed Java objects in this String in proper
 *         sequence
 */
public Iterable<Object> loadAll(Reader yaml) {
    Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver);
    constructor.setComposer(composer);
    Iterator<Object> result = new Iterator<Object>() {
        public boolean hasNext() {
            return constructor.checkData();
        }

        public Object next() {
            return constructor.getData();
        }

        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
    return new YamlIterable(result);
}
项目:snakeyaml    文件:Yaml.java   
/**
 * Parse all YAML documents in a stream and produce corresponding
 * representation trees.
 * 
 * @see <a href="http://yaml.org/spec/1.1/#id859333">Processing Overview</a>
 * @param yaml
 *            stream of YAML documents
 * @return parsed root Nodes for all the specified YAML documents
 */
public Iterable<Node> composeAll(Reader yaml) {
    final Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver);
    constructor.setComposer(composer);
    Iterator<Node> result = new Iterator<Node>() {
        public boolean hasNext() {
            return composer.checkNode();
        }

        public Node next() {
            return composer.getNode();
        }

        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
    return new NodeIterable(result);
}
项目:snakeyaml    文件:PyStructureTest.java   
private List<Node> compose_all(InputStream file) {
    Composer composer = new Composer(new ParserImpl(new StreamReader(new UnicodeReader(file))),
            new Resolver());
    List<Node> documents = new ArrayList<Node>();
    while (composer.checkNode()) {
        documents.add(composer.getNode());
    }
    return documents;
}
项目:snakeyaml    文件:PyStructureTest.java   
@Override
public Iterable<Object> loadAll(Reader yaml) {
    StreamReader reader = new StreamReader(yaml);
    StringBuilder buffer = new StringBuilder();
    while (reader.peek() != '\0') {
        buffer.append(reader.peek());
        reader.forward();
    }
    CanonicalParser parser = new CanonicalParser(buffer.toString());
    Composer composer = new Composer(parser, resolver);
    this.constructor.setComposer(composer);
    Iterator<Object> result = new Iterator<Object>() {
        public boolean hasNext() {
            return constructor.checkData();
        }

        public Object next() {
            return constructor.getData();
        }

        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
    return new YamlIterable(result);
}
项目:snakeyaml    文件:CanonicalLoader.java   
@Override
public Object load(Reader yaml) {
    try {
        int ch = yaml.read();
        StringBuilder buffer = new StringBuilder();
        while (ch != -1) {
            buffer.append((char) ch);
            ch = yaml.read();
        }
        Composer composer = new Composer(new CanonicalParser(buffer.toString()), resolver);
        constructor.setComposer(composer);
        return constructor.getSingleData(Object.class);
    } catch (IOException e) {
        throw new YAMLException(e);
    }
}
项目:TestTheTeacher    文件:Yaml.java   
/**
 * Parse all YAML documents in a String and produce corresponding Java
 * objects. The documents are parsed only when the iterator is invoked.
 * 
 * @param yaml
 *            YAML data to load from (BOM must not be present)
 * @return an iterator over the parsed Java objects in this String in proper
 *         sequence
 */
public Iterable<Object> loadAll(Reader yaml) {
    Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver);
    constructor.setComposer(composer);
    Iterator<Object> result = new Iterator<Object>() {
        public boolean hasNext() {
            return constructor.checkData();
        }

        public Object next() {
            return constructor.getData();
        }

        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
    return new YamlIterable(result);
}
项目:TestTheTeacher    文件:Yaml.java   
/**
 * Parse all YAML documents in a stream and produce corresponding
 * representation trees.
 * 
 * @see <a href="http://yaml.org/spec/1.1/#id859333">Processing Overview</a>
 * @param yaml
 *            stream of YAML documents
 * @return parsed root Nodes for all the specified YAML documents
 */
public Iterable<Node> composeAll(Reader yaml) {
    final Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver);
    constructor.setComposer(composer);
    Iterator<Node> result = new Iterator<Node>() {
        public boolean hasNext() {
            return composer.checkNode();
        }

        public Node next() {
            return composer.getNode();
        }

        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
    return new NodeIterable(result);
}
项目:kurgan    文件:YamlUtils.java   
public Iterable<Node> composeAll(StreamReader yaml) {
    final Composer composer = new Composer(new ParserImpl(yaml), resolver);
    constructor.setComposer(composer);
    final Iterator<Node> result = new Iterator<Node>() {
        public boolean hasNext() {
            return composer.checkNode();
        }

        public Node next() {
            return composer.getNode();
        }

        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
    return new Iterable<Node>() {
        public Iterator<Node> iterator() {
            return result;
        }
    };
}
项目:org.openntf.domino    文件:Yaml.java   
/**
 * Parse all YAML documents in a String and produce corresponding Java objects. The documents are parsed only when the iterator is
 * invoked.
 * 
 * @param yaml
 *            YAML data to load from (BOM must not be present)
 * @return an iterator over the parsed Java objects in this String in proper sequence
 */
public Iterable<Object> loadAll(final Reader yaml) {
    Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver);
    constructor.setComposer(composer);
    Iterator<Object> result = new Iterator<Object>() {
        @Override
        public boolean hasNext() {
            return constructor.checkData();
        }

        @Override
        public Object next() {
            return constructor.getData();
        }

        @Override
        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
    return new YamlIterable(result);
}
项目:org.openntf.domino    文件:Yaml.java   
/**
 * Parse all YAML documents in a stream and produce corresponding representation trees.
 * 
 * @see <a href="http://yaml.org/spec/1.1/#id859333">Processing Overview</a>
 * @param yaml
 *            stream of YAML documents
 * @return parsed root Nodes for all the specified YAML documents
 */
public Iterable<Node> composeAll(final Reader yaml) {
    final Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver);
    constructor.setComposer(composer);
    Iterator<Node> result = new Iterator<Node>() {
        @Override
        public boolean hasNext() {
            return composer.checkNode();
        }

        @Override
        public Node next() {
            return composer.getNode();
        }

        @Override
        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
    return new NodeIterable(result);
}
项目:snake-yaml    文件:FragmentComposerTest.java   
public void testFragment() {
    String document = "foo:  blargle\n"
            + "developer:  { name: \"Bjarne Stroustrup\", language: \"C++\"}\n"
            + "gee:  [ \"whiz\", \"bang\"]\n";//

    StreamReader reader = new StreamReader(document);
    Composer composer = new FragmentComposer(new ParserImpl(reader), new Resolver(),
            "developer");
    Constructor constructor = new Constructor();
    constructor.setComposer(composer);
    DeveloperBean developer = (DeveloperBean) constructor.getSingleData(DeveloperBean.class);
    assertEquals("Bjarne Stroustrup", developer.name);
    assertEquals("C++", developer.language);
}
项目:snake-yaml    文件:ConstructorMappingTest.java   
private Object construct(Constructor constructor, String data) {
    StreamReader reader = new StreamReader(data);
    Parser parser = new ParserImpl(reader);
    Resolver resolver = new Resolver();
    Composer composer = new Composer(parser, resolver);
    constructor.setComposer(composer);
    return constructor.getSingleData(Object.class);
}
项目:snake-yaml    文件:ConstructorSequenceTest.java   
@SuppressWarnings("unchecked")
private List<Object> construct(Constructor constructor, String data) {
    StreamReader reader = new StreamReader(data);
    Parser parser = new ParserImpl(reader);
    Resolver resolver = new Resolver();
    Composer composer = new Composer(parser, resolver);
    constructor.setComposer(composer);
    List<Object> result = (List<Object>) constructor.getSingleData(Object.class);
    return result;
}
项目:snake-yaml    文件:CanonicalLoader.java   
public Iterable<Object> loadAll(Reader yaml) {
    try {
        int ch = yaml.read();
        StringBuilder buffer = new StringBuilder();
        while (ch != -1) {
            buffer.append((char) ch);
            ch = yaml.read();
        }
        Composer composer = new Composer(new CanonicalParser(buffer.toString()), resolver);
        this.constructor.setComposer(composer);
        Iterator<Object> result = new Iterator<Object>() {
            public boolean hasNext() {
                return constructor.checkData();
            }

            public Object next() {
                return constructor.getData();
            }

            public void remove() {
                throw new UnsupportedOperationException();
            }
        };
        return new YamlIterable(result);
    } catch (IOException e) {
        throw new YAMLException(e);
    }
}
项目:snakeyaml    文件:FragmentComposerTest.java   
public void testFragment() {
    String document = "foo:  blargle\n"
            + "developer:  { name: \"Bjarne Stroustrup\", language: \"C++\"}\n"
            + "gee:  [ \"whiz\", \"bang\"]\n";//

    StreamReader reader = new StreamReader(document);
    Composer composer = new FragmentComposer(new ParserImpl(reader), new Resolver(),
            "developer");
    Constructor constructor = new Constructor();
    constructor.setComposer(composer);
    DeveloperBean developer = (DeveloperBean) constructor.getSingleData(DeveloperBean.class);
    assertEquals("Bjarne Stroustrup", developer.name);
    assertEquals("C++", developer.language);
}
项目:snakeyaml    文件:ConstructorMappingTest.java   
private Object construct(Constructor constructor, String data) {
    StreamReader reader = new StreamReader(data);
    Parser parser = new ParserImpl(reader);
    Resolver resolver = new Resolver();
    Composer composer = new Composer(parser, resolver);
    constructor.setComposer(composer);
    return constructor.getSingleData(Object.class);
}
项目:snakeyaml    文件:ConstructorSequenceTest.java   
@SuppressWarnings("unchecked")
private List<Object> construct(Constructor constructor, String data) {
    StreamReader reader = new StreamReader(data);
    Parser parser = new ParserImpl(reader);
    Resolver resolver = new Resolver();
    Composer composer = new Composer(parser, resolver);
    constructor.setComposer(composer);
    List<Object> result = (List<Object>) constructor.getSingleData(Object.class);
    return result;
}
项目:snakeyaml    文件:CanonicalLoader.java   
public Iterable<Object> loadAll(Reader yaml) {
    try {
        int ch = yaml.read();
        StringBuilder buffer = new StringBuilder();
        while (ch != -1) {
            buffer.append((char) ch);
            ch = yaml.read();
        }
        Composer composer = new Composer(new CanonicalParser(buffer.toString()), resolver);
        this.constructor.setComposer(composer);
        Iterator<Object> result = new Iterator<Object>() {
            public boolean hasNext() {
                return constructor.checkData();
            }

            public Object next() {
                return constructor.getData();
            }

            public void remove() {
                throw new UnsupportedOperationException();
            }
        };
        return new YamlIterable(result);
    } catch (IOException e) {
        throw new YAMLException(e);
    }
}
项目:AndroidApktool    文件:Yaml.java   
private Object loadFromReader(StreamReader sreader, Class<?> type) {
    Composer composer = new Composer(new ParserImpl(sreader), resolver);
    constructor.setComposer(composer);
    return constructor.getSingleData(type);
}
项目:AndroidApktool    文件:BaseConstructor.java   
public void setComposer(Composer composer) {
    this.composer = composer;
}
项目:5zig-TIMV-Plugin    文件:Yaml.java   
private Object loadFromReader(StreamReader sreader, Class<?> type) {
    Composer composer = new Composer(new ParserImpl(sreader), resolver);
    constructor.setComposer(composer);
    return constructor.getSingleData(type);
}
项目:5zig-TIMV-Plugin    文件:BaseConstructor.java   
public void setComposer(Composer composer) {
    this.composer = composer;
}
项目:diorite-configs-java8    文件:YamlComposerNodeIterator.java   
YamlComposerNodeIterator(Composer composer)
{
    this.composer = composer;
}
项目:snake-yaml    文件:Yaml.java   
private Object loadFromReader(StreamReader sreader, Class<?> type) {
    Composer composer = new Composer(new ParserImpl(sreader), resolver);
    constructor.setComposer(composer);
    return constructor.getSingleData(type);
}
项目:snake-yaml    文件:BaseConstructor.java   
public void setComposer(Composer composer) {
    this.composer = composer;
}
项目:snake-yaml    文件:PyStructureTest.java   
private List<Node> compose_all(InputStream file) {
    Composer composer = new Composer(new ParserImpl(new StreamReader(new UnicodeReader(file))),
            new Resolver());
    List<Node> documents = new ArrayList<Node>();
    while (composer.checkNode()) {
        documents.add(composer.getNode());
    }
    return documents;
}