org.yaml.snakeyaml.parser.Parser Java Examples

The following examples show how to use org.yaml.snakeyaml.parser.Parser. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Yaml.java    From orion.server with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Parse a YAML stream and produce parsing events.
 * 
 * @see <a href="http://yaml.org/spec/1.1/#id859333">Processing Overview</a>
 * @param yaml
 *            YAML document(s)
 * @return parsed events
 */
public Iterable<Event> parse(Reader yaml) {
    final Parser parser = new ParserImpl(new StreamReader(yaml));
    Iterator<Event> result = new Iterator<Event>() {
        public boolean hasNext() {
            return parser.peekEvent() != null;
        }

        public Event next() {
            return parser.getEvent();
        }

        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
    return new EventIterable(result);
}
 
Example #2
Source File: Yaml.java    From snake-yaml with Apache License 2.0 6 votes vote down vote up
/**
 * Parse a YAML stream and produce parsing events.
 * 
 * @see <a href="http://yaml.org/spec/1.1/#id859333">Processing Overview</a>
 * @param yaml
 *            YAML document(s)
 * @return parsed events
 */
public Iterable<Event> parse(Reader yaml) {
    final Parser parser = new ParserImpl(new StreamReader(yaml));
    Iterator<Event> result = new Iterator<Event>() {
        public boolean hasNext() {
            return parser.peekEvent() != null;
        }

        public Event next() {
            return parser.getEvent();
        }

        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
    return new EventIterable(result);
}
 
Example #3
Source File: Yaml.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Parse a YAML stream and produce parsing events.
 *
 * @see <a href="http://yaml.org/spec/1.1/#id859333">Processing Overview</a>
 * @param yaml
 *            YAML document(s)
 * @return parsed events
 */
public Iterable<Event> parse(Reader yaml) {
    final Parser parser = new ParserImpl(new StreamReader(yaml));
    Iterator<Event> result = new Iterator<Event>() {
        public boolean hasNext() {
            return parser.peekEvent() != null;
        }

        public Event next() {
            return parser.getEvent();
        }

        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
    return new EventIterable(result);
}
 
Example #4
Source File: ConstructorMappingTest.java    From snake-yaml with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #5
Source File: ConstructorSequenceTest.java    From snake-yaml with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #6
Source File: PyImportTest.java    From snake-yaml with Apache License 2.0 5 votes vote down vote up
protected List<Event> parse(InputStream input) throws IOException {
    StreamReader reader = new StreamReader(new UnicodeReader(input));
    Parser parser = new ParserImpl(reader);
    List<Event> result = new ArrayList<Event>();
    while (parser.peekEvent() != null) {
        result.add(parser.getEvent());
    }
    input.close();
    return result;
}
 
Example #7
Source File: Composer.java    From orion.server with Eclipse Public License 1.0 4 votes vote down vote up
public Composer(Parser parser, Resolver resolver) {
    this.parser = parser;
    this.resolver = resolver;
    this.anchors = new HashMap<String, Node>();
    this.recursiveNodes = new HashSet<Node>();
}
 
Example #8
Source File: Composer.java    From snake-yaml with Apache License 2.0 4 votes vote down vote up
public Composer(Parser parser, Resolver resolver) {
    this.parser = parser;
    this.resolver = resolver;
    this.anchors = new HashMap<String, Node>();
    this.recursiveNodes = new HashSet<Node>();
}
 
Example #9
Source File: FragmentComposer.java    From snake-yaml with Apache License 2.0 4 votes vote down vote up
public FragmentComposer(Parser parser, Resolver resolver, String nodeName) {
    super(parser, resolver);
    this.nodeName = nodeName;
}
 
Example #10
Source File: YamlParserEventIterator.java    From Diorite with MIT License 4 votes vote down vote up
YamlParserEventIterator(Parser parser)
{
    this.parser = parser;
}
 
Example #11
Source File: Yaml.java    From Diorite with MIT License 3 votes vote down vote up
/**
 * Parse a YAML stream and produce parsing events.
 *
 * @param yaml
 *         YAML document(s)
 *
 * @return parsed events
 *
 * @see <a href="http://yaml.org/spec/1.1/#id859333">Processing Overview</a>
 */
public Iterable<Event> parse(Reader yaml)
{
    Parser parser = new ParserImpl(new StreamReader(yaml));
    Iterator<Event> result = new YamlParserEventIterator(parser);
    return new YamlEventIterable(result);
}