Java 类org.yaml.snakeyaml.events.StreamEndEvent 实例源码

项目:AndroidApktool    文件:Emitter.java   
private boolean needEvents(int count) {
    int level = 0;
    Iterator<Event> iter = events.iterator();
    iter.next();
    while (iter.hasNext()) {
        Event event = iter.next();
        if (event instanceof DocumentStartEvent || event instanceof CollectionStartEvent) {
            level++;
        } else if (event instanceof DocumentEndEvent || event instanceof CollectionEndEvent) {
            level--;
        } else if (event instanceof StreamEndEvent) {
            level = -1;
        }
        if (level < 0) {
            return false;
        }
    }
    return events.size() < count + 1;
}
项目:5zig-TIMV-Plugin    文件:Emitter.java   
private boolean needEvents(int count) {
    int level = 0;
    Iterator<Event> iter = events.iterator();
    iter.next();
    while (iter.hasNext()) {
        Event event = iter.next();
        if (event instanceof DocumentStartEvent || event instanceof CollectionStartEvent) {
            level++;
        } else if (event instanceof DocumentEndEvent || event instanceof CollectionEndEvent) {
            level--;
        } else if (event instanceof StreamEndEvent) {
            level = -1;
        }
        if (level < 0) {
            return false;
        }
    }
    return events.size() < count + 1;
}
项目:snake-yaml    文件:Emitter.java   
private boolean needEvents(int count) {
    int level = 0;
    Iterator<Event> iter = events.iterator();
    iter.next();
    while (iter.hasNext()) {
        Event event = iter.next();
        if (event instanceof DocumentStartEvent || event instanceof CollectionStartEvent) {
            level++;
        } else if (event instanceof DocumentEndEvent || event instanceof CollectionEndEvent) {
            level--;
        } else if (event instanceof StreamEndEvent) {
            level = -1;
        }
        if (level < 0) {
            return false;
        }
    }
    return events.size() < count + 1;
}
项目:snake-yaml    文件:ParserImplTest.java   
public void testGetEvent() {
    String data = "string: abcd";
    StreamReader reader = new StreamReader(data);
    Parser parser = new ParserImpl(reader);
    Mark dummyMark = new Mark("dummy", 0, 0, 0, "", 0);
    LinkedList<Event> etalonEvents = new LinkedList<Event>();
    etalonEvents.add(new StreamStartEvent(dummyMark, dummyMark));
    etalonEvents.add(new DocumentStartEvent(dummyMark, dummyMark, false, null, null));
    etalonEvents.add(new MappingStartEvent(null, null, true, dummyMark, dummyMark,
            Boolean.FALSE));
    etalonEvents.add(new ScalarEvent(null, null, new ImplicitTuple(true, false), "string",
            dummyMark, dummyMark, (char) 0));
    etalonEvents.add(new ScalarEvent(null, null, new ImplicitTuple(true, false), "abcd",
            dummyMark, dummyMark, (char) 0));
    etalonEvents.add(new MappingEndEvent(dummyMark, dummyMark));
    etalonEvents.add(new DocumentEndEvent(dummyMark, dummyMark, false));
    etalonEvents.add(new StreamEndEvent(dummyMark, dummyMark));
    check(etalonEvents, parser);
}
项目:snake-yaml    文件:ParserImplTest.java   
public void testGetEvent2() {
    String data = "american:\n  - Boston Red Sox";
    StreamReader reader = new StreamReader(data);
    Parser parser = new ParserImpl(reader);
    Mark dummyMark = new Mark("dummy", 0, 0, 0, "", 0);
    LinkedList<Event> etalonEvents = new LinkedList<Event>();
    etalonEvents.add(new StreamStartEvent(dummyMark, dummyMark));
    etalonEvents.add(new DocumentStartEvent(dummyMark, dummyMark, false, null, null));
    etalonEvents
            .add(new MappingStartEvent(null, null, true, dummyMark, dummyMark, Boolean.TRUE));
    etalonEvents.add(new ScalarEvent(null, null, new ImplicitTuple(true, false), "american",
            dummyMark, dummyMark, (char) 0));
    etalonEvents.add(new SequenceStartEvent(null, null, true, dummyMark, dummyMark,
            Boolean.FALSE));
    etalonEvents.add(new ScalarEvent(null, null, new ImplicitTuple(true, false),
            "Boston Red Sox", dummyMark, dummyMark, (char) 0));
    etalonEvents.add(new SequenceEndEvent(dummyMark, dummyMark));
    etalonEvents.add(new MappingEndEvent(dummyMark, dummyMark));
    etalonEvents.add(new DocumentEndEvent(dummyMark, dummyMark, false));
    etalonEvents.add(new StreamEndEvent(dummyMark, dummyMark));
    check(etalonEvents, parser);
}
项目:SubServers-2    文件:Emitter.java   
private boolean needEvents(int count) {
    int level = 0;
    Iterator<Event> iter = events.iterator();
    iter.next();
    while (iter.hasNext()) {
        Event event = iter.next();
        if (event instanceof DocumentStartEvent || event instanceof CollectionStartEvent) {
            level++;
        } else if (event instanceof DocumentEndEvent || event instanceof CollectionEndEvent) {
            level--;
        } else if (event instanceof StreamEndEvent) {
            level = -1;
        }
        if (level < 0) {
            return false;
        }
    }
    return events.size() < count + 1;
}
项目:snakeyaml    文件:Emitter.java   
private boolean needEvents(int count) {
    int level = 0;
    Iterator<Event> iter = events.iterator();
    iter.next();
    while (iter.hasNext()) {
        Event event = iter.next();
        if (event instanceof DocumentStartEvent || event instanceof CollectionStartEvent) {
            level++;
        } else if (event instanceof DocumentEndEvent || event instanceof CollectionEndEvent) {
            level--;
        } else if (event instanceof StreamEndEvent) {
            level = -1;
        }
        if (level < 0) {
            return false;
        }
    }
    return events.size() < count + 1;
}
项目:snakeyaml    文件:ParserImplTest.java   
public void testGetEvent() {
    String data = "string: abcd";
    StreamReader reader = new StreamReader(data);
    Parser parser = new ParserImpl(reader);
    Mark dummyMark = new Mark("dummy", 0, 0, 0, "", 0);
    LinkedList<Event> etalonEvents = new LinkedList<Event>();
    etalonEvents.add(new StreamStartEvent(dummyMark, dummyMark));
    etalonEvents.add(new DocumentStartEvent(dummyMark, dummyMark, false, null, null));
    etalonEvents.add(new MappingStartEvent(null, null, true, dummyMark, dummyMark,
            Boolean.FALSE));
    etalonEvents.add(new ScalarEvent(null, null, new ImplicitTuple(true, false), "string",
            dummyMark, dummyMark, (char) 0));
    etalonEvents.add(new ScalarEvent(null, null, new ImplicitTuple(true, false), "abcd",
            dummyMark, dummyMark, (char) 0));
    etalonEvents.add(new MappingEndEvent(dummyMark, dummyMark));
    etalonEvents.add(new DocumentEndEvent(dummyMark, dummyMark, false));
    etalonEvents.add(new StreamEndEvent(dummyMark, dummyMark));
    while (parser.checkEvent(null)) {
        Event event = parser.getEvent();
        if (etalonEvents.isEmpty()) {
            fail("unexpected event: " + event);
        }
        assertEquals(etalonEvents.removeFirst(), event);
    }
    assertFalse("Must contain no more events: " + parser.getEvent(), parser.checkEvent(null));
}
项目:TestTheTeacher    文件:Emitter.java   
private boolean needEvents(int count) {
    int level = 0;
    Iterator<Event> iter = events.iterator();
    iter.next();
    while (iter.hasNext()) {
        Event event = iter.next();
        if (event instanceof DocumentStartEvent || event instanceof CollectionStartEvent) {
            level++;
        } else if (event instanceof DocumentEndEvent || event instanceof CollectionEndEvent) {
            level--;
        } else if (event instanceof StreamEndEvent) {
            level = -1;
        }
        if (level < 0) {
            return false;
        }
    }
    return events.size() < count + 1;
}
项目:org.openntf.domino    文件:Emitter.java   
private boolean needEvents(int count) {
    int level = 0;
    Iterator<Event> iter = events.iterator();
    iter.next();
    while (iter.hasNext()) {
        Event event = iter.next();
        if (event instanceof DocumentStartEvent || event instanceof CollectionStartEvent) {
            level++;
        } else if (event instanceof DocumentEndEvent || event instanceof CollectionEndEvent) {
            level--;
        } else if (event instanceof StreamEndEvent) {
            level = -1;
        }
        if (level < 0) {
            return false;
        }
    }
    return events.size() < count + 1;
}
项目:AndroidApktool    文件:Serializer.java   
public void close() throws IOException {
    if (closed == null) {
        throw new SerializerException("serializer is not opened");
    } else if (!Boolean.TRUE.equals(closed)) {
        this.emitter.emit(new StreamEndEvent(null, null));
        this.closed = Boolean.TRUE;
    }
}
项目:5zig-TIMV-Plugin    文件:Serializer.java   
public void close() throws IOException {
    if (closed == null) {
        throw new SerializerException("serializer is not opened");
    } else if (!Boolean.TRUE.equals(closed)) {
        this.emitter.emit(new StreamEndEvent(null, null));
        this.closed = Boolean.TRUE;
    }
}
项目:diorite-configs-java8    文件:Emitter.java   
private boolean needEvents(int count)
{
    int level = 0;
    Iterator<Event> iter = this.events.iterator();
    iter.next();
    while (iter.hasNext())
    {
        Event event = iter.next();
        if ((event instanceof DocumentStartEvent) || (event instanceof CollectionStartEvent))
        {
            level++;
        }
        else if ((event instanceof DocumentEndEvent) || (event instanceof CollectionEndEvent))
        {
            level--;
        }
        else if (event instanceof StreamEndEvent)
        {
            level = - 1;
        }
        if (level < 0)
        {
            return false;
        }
    }
    return this.events.size() < (count + 1);
}
项目:diorite-configs-java8    文件:Serializer.java   
public void close() throws IOException
{
    if (this.closed == null)
    {
        throw new SerializerException("serializer is not opened");
    }
    else if (! Boolean.TRUE.equals(this.closed))
    {
        this.emitter.emit(new StreamEndEvent(null, null));
        this.closed = Boolean.TRUE;
    }
}
项目:snake-yaml    文件:Serializer.java   
public void close() throws IOException {
    if (closed == null) {
        throw new SerializerException("serializer is not opened");
    } else if (!Boolean.TRUE.equals(closed)) {
        this.emitter.emit(new StreamEndEvent(null, null));
        this.closed = Boolean.TRUE;
    }
}
项目:snake-yaml    文件:CanonicalParser.java   
private void parseStream() {
    scanner.getToken(Token.ID.StreamStart);
    events.add(new StreamStartEvent(null, null));
    while (!scanner.checkToken(Token.ID.StreamEnd)) {
        if (scanner.checkToken(Token.ID.Directive, Token.ID.DocumentStart)) {
            parseDocument();
        } else {
            throw new CanonicalException("document is expected, got " + scanner.tokens.get(0));
        }
    }
    scanner.getToken(Token.ID.StreamEnd);
    events.add(new StreamEndEvent(null, null));
}
项目:SubServers-2    文件:Serializer.java   
public void close() throws IOException {
    if (closed == null) {
        throw new SerializerException("serializer is not opened");
    } else if (!Boolean.TRUE.equals(closed)) {
        this.emitter.emit(new StreamEndEvent(null, null));
        this.closed = Boolean.TRUE;
    }
}
项目:Diorite    文件:Emitter.java   
private boolean needEvents(int count)
{
    int level = 0;
    Iterator<Event> iter = this.events.iterator();
    iter.next();
    while (iter.hasNext())
    {
        Event event = iter.next();
        if ((event instanceof DocumentStartEvent) || (event instanceof CollectionStartEvent))
        {
            level++;
        }
        else if ((event instanceof DocumentEndEvent) || (event instanceof CollectionEndEvent))
        {
            level--;
        }
        else if (event instanceof StreamEndEvent)
        {
            level = - 1;
        }
        if (level < 0)
        {
            return false;
        }
    }
    return this.events.size() < (count + 1);
}
项目:Diorite    文件:Serializer.java   
public void close() throws IOException
{
    if (this.closed == null)
    {
        throw new SerializerException("serializer is not opened");
    }
    else if (! Boolean.TRUE.equals(this.closed))
    {
        this.emitter.emit(new StreamEndEvent(null, null));
        this.closed = Boolean.TRUE;
    }
}
项目:snakeyaml    文件:Serializer.java   
public void close() throws IOException {
    if (closed == null) {
        throw new SerializerException("serializer is not opened");
    } else if (!Boolean.TRUE.equals(closed)) {
        this.emitter.emit(new StreamEndEvent(null, null));
        this.closed = Boolean.TRUE;
    }
}
项目:snakeyaml    文件:YamlParseTest.java   
public void testParse() {
    Yaml yaml = new Yaml();
    Event e = null;
    int counter = 0;
    for (Event event : yaml.parse(new StringReader("abc: 56"))) {
        if (e == null) {
            assertTrue(event instanceof StreamStartEvent);
        }
        e = event;
        counter++;
    }
    assertTrue(e instanceof StreamEndEvent);
    assertEquals(8, counter);
}
项目:snakeyaml    文件:YamlParseTest.java   
public void testParseManyDocuments() {
    Yaml yaml = new Yaml();
    Event e = null;
    int counter = 0;
    for (Event event : yaml.parse(new StringReader("abc: 56\n---\n4\n---\nqwe\n"))) {
        if (e == null) {
            assertTrue(event instanceof StreamStartEvent);
        }
        e = event;
        counter++;
    }
    assertTrue(e instanceof StreamEndEvent);
    assertEquals(14, counter);
}
项目:snakeyaml    文件:ParserImplTest.java   
public void testGetEvent2() {
    String data = "american:\n  - Boston Red Sox";
    StreamReader reader = new StreamReader(data);
    Parser parser = new ParserImpl(reader);
    Mark dummyMark = new Mark("dummy", 0, 0, 0, "", 0);
    LinkedList<Event> etalonEvents = new LinkedList<Event>();
    etalonEvents.add(new StreamStartEvent(dummyMark, dummyMark));
    etalonEvents.add(new DocumentStartEvent(dummyMark, dummyMark, false, null, null));
    etalonEvents
            .add(new MappingStartEvent(null, null, true, dummyMark, dummyMark, Boolean.TRUE));
    etalonEvents.add(new ScalarEvent(null, null, new ImplicitTuple(true, false), "american",
            dummyMark, dummyMark, (char) 0));
    etalonEvents.add(new SequenceStartEvent(null, null, true, dummyMark, dummyMark,
            Boolean.FALSE));
    etalonEvents.add(new ScalarEvent(null, null, new ImplicitTuple(true, false),
            "Boston Red Sox", dummyMark, dummyMark, (char) 0));
    etalonEvents.add(new SequenceEndEvent(dummyMark, dummyMark));
    etalonEvents.add(new MappingEndEvent(dummyMark, dummyMark));
    etalonEvents.add(new DocumentEndEvent(dummyMark, dummyMark, false));
    etalonEvents.add(new StreamEndEvent(dummyMark, dummyMark));
    while (parser.checkEvent(null)) {
        Event event = parser.getEvent();
        if (etalonEvents.isEmpty()) {
            fail("unexpected event: " + event);
        }
        assertEquals(etalonEvents.removeFirst(), event);
    }
    assertFalse("Must contain no more events: " + parser.getEvent(), parser.checkEvent(null));
}
项目:snakeyaml    文件:CanonicalParser.java   
private void parseStream() {
    scanner.getToken(Token.ID.StreamStart);
    events.add(new StreamStartEvent(null, null));
    while (!scanner.checkToken(Token.ID.StreamEnd)) {
        if (scanner.checkToken(Token.ID.Directive, Token.ID.DocumentStart)) {
            parseDocument();
        } else {
            throw new CanonicalException("document is expected, got " + scanner.tokens.get(0));
        }
    }
    scanner.getToken(Token.ID.StreamEnd);
    events.add(new StreamEndEvent(null, null));
}
项目:TestTheTeacher    文件:Serializer.java   
public void close() throws IOException {
    if (closed == null) {
        throw new SerializerException("serializer is not opened");
    } else if (!Boolean.TRUE.equals(closed)) {
        this.emitter.emit(new StreamEndEvent(null, null));
        this.closed = Boolean.TRUE;
    }
}
项目:org.openntf.domino    文件:Serializer.java   
public void close() throws IOException {
    if (closed == null) {
        throw new SerializerException("serializer is not opened");
    } else if (!Boolean.TRUE.equals(closed)) {
        this.emitter.emit(new StreamEndEvent(null, null));
        this.closed = Boolean.TRUE;
    }
}
项目:AndroidApktool    文件:Emitter.java   
public void expect() throws IOException {
    if (event instanceof DocumentStartEvent) {
        DocumentStartEvent ev = (DocumentStartEvent) event;
        if ((ev.getVersion() != null || ev.getTags() != null) && openEnded) {
            writeIndicator("...", true, false, false);
            writeIndent();
        }
        if (ev.getVersion() != null) {
            String versionText = prepareVersion(ev.getVersion());
            writeVersionDirective(versionText);
        }
        tagPrefixes = new LinkedHashMap<String, String>(DEFAULT_TAG_PREFIXES);
        if (ev.getTags() != null) {
            Set<String> handles = new TreeSet<String>(ev.getTags().keySet());
            for (String handle : handles) {
                String prefix = ev.getTags().get(handle);
                tagPrefixes.put(prefix, handle);
                String handleText = prepareTagHandle(handle);
                String prefixText = prepareTagPrefix(prefix);
                writeTagDirective(handleText, prefixText);
            }
        }
        boolean implicit = first && !ev.getExplicit() && !canonical
                && ev.getVersion() == null
                && (ev.getTags() == null || ev.getTags().isEmpty())
                && !checkEmptyDocument();
        if (!implicit) {
            writeIndent();
            writeIndicator("---", true, false, false);
            if (canonical) {
                writeIndent();
            }
        }
        state = new ExpectDocumentRoot();
    } else if (event instanceof StreamEndEvent) {
        // TODO fix 313 PyYAML changeset
        // if (openEnded) {
        // writeIndicator("...", true, false, false);
        // writeIndent();
        // }
        writeStreamEnd();
        state = new ExpectNothing();
    } else {
        throw new EmitterException("需要 DocumentStartEvent 事件, 但却得到了 " + event);
    }
}
项目:5zig-TIMV-Plugin    文件:Emitter.java   
public void expect() throws IOException {
    if (event instanceof DocumentStartEvent) {
        DocumentStartEvent ev = (DocumentStartEvent) event;
        if ((ev.getVersion() != null || ev.getTags() != null) && openEnded) {
            writeIndicator("...", true, false, false);
            writeIndent();
        }
        if (ev.getVersion() != null) {
            String versionText = prepareVersion(ev.getVersion());
            writeVersionDirective(versionText);
        }
        tagPrefixes = new LinkedHashMap<String, String>(DEFAULT_TAG_PREFIXES);
        if (ev.getTags() != null) {
            Set<String> handles = new TreeSet<String>(ev.getTags().keySet());
            for (String handle : handles) {
                String prefix = ev.getTags().get(handle);
                tagPrefixes.put(prefix, handle);
                String handleText = prepareTagHandle(handle);
                String prefixText = prepareTagPrefix(prefix);
                writeTagDirective(handleText, prefixText);
            }
        }
        boolean implicit = first && !ev.getExplicit() && !canonical
                && ev.getVersion() == null
                && (ev.getTags() == null || ev.getTags().isEmpty())
                && !checkEmptyDocument();
        if (!implicit) {
            writeIndent();
            writeIndicator("---", true, false, false);
            if (canonical) {
                writeIndent();
            }
        }
        state = new ExpectDocumentRoot();
    } else if (event instanceof StreamEndEvent) {
        // TODO fix 313 PyYAML changeset
        // if (openEnded) {
        // writeIndicator("...", true, false, false);
        // writeIndent();
        // }
        writeStreamEnd();
        state = new ExpectNothing();
    } else {
        throw new EmitterException("expected DocumentStartEvent, but got " + event);
    }
}
项目:diorite-configs-java8    文件:ExpectDocumentStart.java   
public static void expect(Emitter emitter, boolean first) throws IOException
{
    if (emitter.event instanceof DocumentStartEvent)
    {
        DocumentStartEvent ev = (DocumentStartEvent) emitter.event;
        if (((ev.getVersion() != null) || (ev.getTags() != null)) && emitter.openEnded)
        {
            emitter.writeIndicator("...", true, false, false);
            emitter.writeIndent();
        }
        if (ev.getVersion() != null)
        {
            String versionText = emitter.prepareVersion(ev.getVersion());
            emitter.writeVersionDirective(versionText);
        }
        emitter.tagPrefixes = new LinkedHashMap<>(Emitter.DEFAULT_TAG_PREFIXES);
        if (ev.getTags() != null)
        {
            Set<String> handles = new TreeSet<>(ev.getTags().keySet());
            for (String handle : handles)
            {
                String prefix = ev.getTags().get(handle);
                emitter.tagPrefixes.put(prefix, handle);
                String handleText = emitter.prepareTagHandle(handle);
                String prefixText = emitter.prepareTagPrefix(prefix);
                emitter.writeTagDirective(handleText, prefixText);
            }
        }
        boolean implicit =
                first && ! ev.getExplicit() && ! emitter.canonical && (ev.getVersion() == null) && ((ev.getTags() == null) || ev.getTags().isEmpty()) &&
                ! emitter.checkEmptyDocument();
        if (! implicit)
        {
            emitter.writeIndent();
            emitter.writeIndicator("---", true, false, false);
            if (emitter.canonical)
            {
                emitter.writeIndent();
            }
        }
        emitter.state = new ExpectDocumentRoot();
    }
    else if (emitter.event instanceof StreamEndEvent)
    {
        // TODO fix 313 PyYAML changeset
        // if (openEnded) {
        // writeIndicator("...", true, false, false);
        // writeIndent();
        // }
        emitter.writeStreamEnd();
        emitter.state = new ExpectNothing();
    }
    else
    {
        throw new EmitterException("expected DocumentStartEvent, but got " + emitter.event);
    }
}
项目:snake-yaml    文件:Emitter.java   
public void expect() throws IOException {
    if (event instanceof DocumentStartEvent) {
        DocumentStartEvent ev = (DocumentStartEvent) event;
        if ((ev.getVersion() != null || ev.getTags() != null) && openEnded) {
            writeIndicator("...", true, false, false);
            writeIndent();
        }
        if (ev.getVersion() != null) {
            String versionText = prepareVersion(ev.getVersion());
            writeVersionDirective(versionText);
        }
        tagPrefixes = new LinkedHashMap<String, String>(DEFAULT_TAG_PREFIXES);
        if (ev.getTags() != null) {
            Set<String> handles = new TreeSet<String>(ev.getTags().keySet());
            for (String handle : handles) {
                String prefix = ev.getTags().get(handle);
                tagPrefixes.put(prefix, handle);
                String handleText = prepareTagHandle(handle);
                String prefixText = prepareTagPrefix(prefix);
                writeTagDirective(handleText, prefixText);
            }
        }
        boolean implicit = first && !ev.getExplicit() && !canonical
                && ev.getVersion() == null
                && (ev.getTags() == null || ev.getTags().isEmpty())
                && !checkEmptyDocument();
        if (!implicit) {
            writeIndent();
            writeIndicator("---", true, false, false);
            if (canonical) {
                writeIndent();
            }
        }
        state = new ExpectDocumentRoot();
    } else if (event instanceof StreamEndEvent) {
        // TODO fix 313 PyYAML changeset
        // if (openEnded) {
        // writeIndicator("...", true, false, false);
        // writeIndent();
        // }
        writeStreamEnd();
        state = new ExpectNothing();
    } else {
        throw new EmitterException("expected DocumentStartEvent, but got " + event);
    }
}
项目:SubServers-2    文件:Emitter.java   
public void expect() throws IOException {
    if (event instanceof DocumentStartEvent) {
        DocumentStartEvent ev = (DocumentStartEvent) event;
        if ((ev.getVersion() != null || ev.getTags() != null) && openEnded) {
            writeIndicator("...", true, false, false);
            writeIndent();
        }
        if (ev.getVersion() != null) {
            String versionText = prepareVersion(ev.getVersion());
            writeVersionDirective(versionText);
        }
        tagPrefixes = new LinkedHashMap<String, String>(DEFAULT_TAG_PREFIXES);
        if (ev.getTags() != null) {
            Set<String> handles = new TreeSet<String>(ev.getTags().keySet());
            for (String handle : handles) {
                String prefix = ev.getTags().get(handle);
                tagPrefixes.put(prefix, handle);
                String handleText = prepareTagHandle(handle);
                String prefixText = prepareTagPrefix(prefix);
                writeTagDirective(handleText, prefixText);
            }
        }
        boolean implicit = first && !ev.getExplicit() && !canonical
                && ev.getVersion() == null
                && (ev.getTags() == null || ev.getTags().isEmpty())
                && !checkEmptyDocument();
        if (!implicit) {
            writeIndent();
            writeIndicator("---", true, false, false);
            if (canonical) {
                writeIndent();
            }
        }
        state = new ExpectDocumentRoot();
    } else if (event instanceof StreamEndEvent) {
        // TODO fix 313 PyYAML changeset
        // if (openEnded) {
        // writeIndicator("...", true, false, false);
        // writeIndent();
        // }
        writeStreamEnd();
        state = new ExpectNothing();
    } else {
        throw new EmitterException("expected DocumentStartEvent, but got " + event);
    }
}
项目:mobi    文件:YamlConfigParser.java   
public StreamEndEvent expectStreamEnd() {
    return (StreamEndEvent) expect(Event.ID.StreamEnd);
}
项目:Diorite    文件:ExpectDocumentStart.java   
public static void expect(Emitter emitter, boolean first) throws IOException
{
    if (emitter.event instanceof DocumentStartEvent)
    {
        DocumentStartEvent ev = (DocumentStartEvent) emitter.event;
        if (((ev.getVersion() != null) || (ev.getTags() != null)) && emitter.openEnded)
        {
            emitter.writeIndicator("...", true, false, false);
            emitter.writeIndent();
        }
        if (ev.getVersion() != null)
        {
            String versionText = emitter.prepareVersion(ev.getVersion());
            emitter.writeVersionDirective(versionText);
        }
        emitter.tagPrefixes = new LinkedHashMap<>(Emitter.DEFAULT_TAG_PREFIXES);
        if (ev.getTags() != null)
        {
            Set<String> handles = new TreeSet<>(ev.getTags().keySet());
            for (String handle : handles)
            {
                String prefix = ev.getTags().get(handle);
                emitter.tagPrefixes.put(prefix, handle);
                String handleText = emitter.prepareTagHandle(handle);
                String prefixText = emitter.prepareTagPrefix(prefix);
                emitter.writeTagDirective(handleText, prefixText);
            }
        }
        boolean implicit =
                first && ! ev.getExplicit() && ! emitter.canonical && (ev.getVersion() == null) && ((ev.getTags() == null) || ev.getTags().isEmpty()) &&
                ! emitter.checkEmptyDocument();
        if (! implicit)
        {
            emitter.writeIndent();
            emitter.writeIndicator("---", true, false, false);
            if (emitter.canonical)
            {
                emitter.writeIndent();
            }
        }
        emitter.state = new ExpectDocumentRoot();
    }
    else if (emitter.event instanceof StreamEndEvent)
    {
        // TODO fix 313 PyYAML changeset
        // if (openEnded) {
        // writeIndicator("...", true, false, false);
        // writeIndent();
        // }
        emitter.writeStreamEnd();
        emitter.state = new ExpectNothing();
    }
    else
    {
        throw new EmitterException("expected DocumentStartEvent, but got " + emitter.event);
    }
}
项目:snakeyaml    文件:Emitter.java   
public void expect() throws IOException {
    if (event instanceof DocumentStartEvent) {
        DocumentStartEvent ev = (DocumentStartEvent) event;
        if ((ev.getVersion() != null || ev.getTags() != null) && openEnded) {
            writeIndicator("...", true, false, false);
            writeIndent();
        }
        if (ev.getVersion() != null) {
            String versionText = prepareVersion(ev.getVersion());
            writeVersionDirective(versionText);
        }
        tagPrefixes = new LinkedHashMap<String, String>(DEFAULT_TAG_PREFIXES);
        if (ev.getTags() != null) {
            Set<String> handles = new TreeSet<String>(ev.getTags().keySet());
            for (String handle : handles) {
                String prefix = ev.getTags().get(handle);
                tagPrefixes.put(prefix, handle);
                String handleText = prepareTagHandle(handle);
                String prefixText = prepareTagPrefix(prefix);
                writeTagDirective(handleText, prefixText);
            }
        }
        boolean implicit = first && !ev.getExplicit() && !canonical
                && ev.getVersion() == null
                && (ev.getTags() == null || ev.getTags().isEmpty())
                && !checkEmptyDocument();
        if (!implicit) {
            writeIndent();
            writeIndicator("---", true, false, false);
            if (canonical) {
                writeIndent();
            }
        }
        state = new ExpectDocumentRoot();
    } else if (event instanceof StreamEndEvent) {
        // TODO fix 313 PyYAML changeset
        // if (openEnded) {
        // writeIndicator("...", true, false, false);
        // writeIndent();
        // }
        writeStreamEnd();
        state = new ExpectNothing();
    } else {
        throw new EmitterException("expected DocumentStartEvent, but got " + event);
    }
}
项目:TestTheTeacher    文件:Emitter.java   
public void expect() throws IOException {
    if (event instanceof DocumentStartEvent) {
        DocumentStartEvent ev = (DocumentStartEvent) event;
        if ((ev.getVersion() != null || ev.getTags() != null) && openEnded) {
            writeIndicator("...", true, false, false);
            writeIndent();
        }
        if (ev.getVersion() != null) {
            String versionText = prepareVersion(ev.getVersion());
            writeVersionDirective(versionText);
        }
        tagPrefixes = new LinkedHashMap<String, String>(DEFAULT_TAG_PREFIXES);
        if (ev.getTags() != null) {
            Set<String> handles = new TreeSet<String>(ev.getTags().keySet());
            for (String handle : handles) {
                String prefix = ev.getTags().get(handle);
                tagPrefixes.put(prefix, handle);
                String handleText = prepareTagHandle(handle);
                String prefixText = prepareTagPrefix(prefix);
                writeTagDirective(handleText, prefixText);
            }
        }
        boolean implicit = first && !ev.getExplicit() && !canonical
                && ev.getVersion() == null
                && (ev.getTags() == null || ev.getTags().isEmpty())
                && !checkEmptyDocument();
        if (!implicit) {
            writeIndent();
            writeIndicator("---", true, false, false);
            if (canonical) {
                writeIndent();
            }
        }
        state = new ExpectDocumentRoot();
    } else if (event instanceof StreamEndEvent) {
        // TODO fix 313 PyYAML changeset
        // if (openEnded) {
        // writeIndicator("...", true, false, false);
        // writeIndent();
        // }
        writeStreamEnd();
        state = new ExpectNothing();
    } else {
        throw new EmitterException("expected DocumentStartEvent, but got " + event);
    }
}
项目:mobi    文件:YamlConfigParser.java   
public StreamEndEvent expectStreamEnd() {
    return (StreamEndEvent) expect(Event.ID.StreamEnd);
}
项目:org.openntf.domino    文件:Emitter.java   
public void expect() throws IOException {
    if (event instanceof DocumentStartEvent) {
        DocumentStartEvent ev = (DocumentStartEvent) event;
        if ((ev.getVersion() != null || ev.getTags() != null) && openEnded) {
            writeIndicator("...", true, false, false);
            writeIndent();
        }
        if (ev.getVersion() != null) {
            String versionText = prepareVersion(ev.getVersion());
            writeVersionDirective(versionText);
        }
        tagPrefixes = new LinkedHashMap<String, String>(DEFAULT_TAG_PREFIXES);
        if (ev.getTags() != null) {
            Set<String> handles = new TreeSet<String>(ev.getTags().keySet());
            for (String handle : handles) {
                String prefix = ev.getTags().get(handle);
                tagPrefixes.put(prefix, handle);
                String handleText = prepareTagHandle(handle);
                String prefixText = prepareTagPrefix(prefix);
                writeTagDirective(handleText, prefixText);
            }
        }
        boolean implicit = first && !ev.getExplicit() && !canonical
                && ev.getVersion() == null
                && (ev.getTags() == null || ev.getTags().isEmpty())
                && !checkEmptyDocument();
        if (!implicit) {
            writeIndent();
            writeIndicator("---", true, false, false);
            if (canonical) {
                writeIndent();
            }
        }
        state = new ExpectDocumentRoot();
    } else if (event instanceof StreamEndEvent) {
        // TODO fix 313 PyYAML changeset
        // if (openEnded) {
        // writeIndicator("...", true, false, false);
        // writeIndent();
        // }
        writeStreamEnd();
        state = new ExpectNothing();
    } else {
        throw new EmitterException("expected DocumentStartEvent, but got " + event);
    }
}