stream ::= STREAM-START implicit_document? explicit_document* STREAM-END implicit_document ::= block_node DOCUMENT-END explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END
9899100101102103104105106107108109110111112113114
if (target.respondsTo("read")) { reader = new StreamReader(new InputStreamReader(new IOInputStream(target))); } else { reader = new StreamReader(new StringReader(target.convertToString().asJavaString())); } Parser parser = new ParserImpl(reader); IRubyObject handler = getInstanceVariable("@handler"); Event event; while (true) { try { event = parser.getEvent(); // FIXME: Event should expose a getID, so it can be switched if (event.is(ID.StreamStart)) { invoke( context,
166167168169170171172173174175176
public IRubyObject parse(ThreadContext context, IRubyObject yaml, IRubyObject path) { Ruby runtime = context.runtime; boolean tainted = yaml.isTaint() || yaml instanceof RubyIO; try { parser = new ParserImpl(readerFor(context, yaml)); if (path.isNil() && yaml.respondsTo("path")) { path = yaml.callMethod(context, "path"); }
4950515253545556575859
return construct(new Constructor(), data); } 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); }
6667686970717273747576
} @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;
181182183184185186187188189190191
} } } 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()); }
76777879808182838485868788
} // String data = stream.toString(); List<Event> newEvents = new ArrayList<Event>(); StreamReader reader = new StreamReader(data); Parser parser = new ParserImpl(reader); while (parser.peekEvent() != null) { Event event = parser.getEvent(); newEvents.add(event); } // check assertEquals(events.size(), newEvents.size()); Iterator<Event> iter1 = events.iterator();
128129130131132133134135136137138139140
for (File file : allFiles) { try { List<Event> events = new ArrayList<Event>(); InputStream input = new FileInputStream(file); StreamReader reader = new StreamReader(new UnicodeReader(input)); Parser parser = new ParserImpl(reader); while (parser.peekEvent() != null) { Event event = parser.getEvent(); events.add(event); } input.close(); // for (Boolean flowStyle : new Boolean[] { Boolean.FALSE, Boolean.TRUE }) {
207208209210211212213214215216217218
} return writer.toString(); } private List<Event> parse(String data) { ParserImpl parser = new ParserImpl(new StreamReader(data)); List<Event> newEvents = new ArrayList<Event>(); while (parser.peekEvent() != null) { newEvents.add(parser.getEvent()); } return newEvents; }
237238239240241242243244245246247248249
101102103104105106107108109110111112113
return result; } 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; }