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

项目:diorite-configs-java8    文件:Serializer.java   
public void open() throws IOException
{
    if (this.closed == null)
    {
        this.emitter.emit(new StreamStartEvent(null, null));
        this.closed = Boolean.FALSE;
    }
    else if (Boolean.TRUE.equals(this.closed))
    {
        throw new SerializerException("serializer is closed");
    }
    else
    {
        throw new SerializerException("serializer is already opened");
    }
}
项目: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);
}
项目:Diorite    文件:Serializer.java   
public void open() throws IOException
{
    if (this.closed == null)
    {
        this.emitter.emit(new StreamStartEvent(null, null));
        this.closed = Boolean.FALSE;
    }
    else if (Boolean.TRUE.equals(this.closed))
    {
        throw new SerializerException("serializer is closed");
    }
    else
    {
        throw new SerializerException("serializer is already opened");
    }
}
项目: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));
}
项目:AndroidApktool    文件:ParserImpl.java   
public Event produce() {
    // Parse the stream start.
    StreamStartToken token = (StreamStartToken) scanner.getToken();
    Event event = new StreamStartEvent(token.getStartMark(), token.getEndMark());
    // Prepare the next state.
    state = new ParseImplicitDocumentStart();
    return event;
}
项目:AndroidApktool    文件:Serializer.java   
public void open() throws IOException {
    if (closed == null) {
        this.emitter.emit(new StreamStartEvent(null, null));
        this.closed = Boolean.FALSE;
    } else if (Boolean.TRUE.equals(closed)) {
        throw new SerializerException("serializer is closed");
    } else {
        throw new SerializerException("serializer is already opened");
    }
}
项目:AndroidApktool    文件:Emitter.java   
public void expect() throws IOException {
    if (event instanceof StreamStartEvent) {
        writeStreamStart();
        state = new ExpectFirstDocumentStart();
    } else {
        throw new EmitterException("需要 StreamStartEvent 事件, 但却得到了 " + event);
    }
}
项目:5zig-TIMV-Plugin    文件:ParserImpl.java   
public Event produce() {
    // Parse the stream start.
    StreamStartToken token = (StreamStartToken) scanner.getToken();
    Event event = new StreamStartEvent(token.getStartMark(), token.getEndMark());
    // Prepare the next state.
    state = new ParseImplicitDocumentStart();
    return event;
}
项目:5zig-TIMV-Plugin    文件:Serializer.java   
public void open() throws IOException {
    if (closed == null) {
        this.emitter.emit(new StreamStartEvent(null, null));
        this.closed = Boolean.FALSE;
    } else if (Boolean.TRUE.equals(closed)) {
        throw new SerializerException("serializer is closed");
    } else {
        throw new SerializerException("serializer is already opened");
    }
}
项目:5zig-TIMV-Plugin    文件:Emitter.java   
public void expect() throws IOException {
    if (event instanceof StreamStartEvent) {
        writeStreamStart();
        state = new ExpectFirstDocumentStart();
    } else {
        throw new EmitterException("expected StreamStartEvent, but got " + event);
    }
}
项目:diorite-configs-java8    文件:ExpectStreamStart.java   
@Override
public void expect(Emitter emitter) throws IOException
{
    if (emitter.event instanceof StreamStartEvent)
    {
        emitter.writeStreamStart();
        emitter.state = new ExpectFirstDocumentStart();
    }
    else
    {
        throw new EmitterException("expected StreamStartEvent, but got " + emitter.event);
    }
}
项目:snake-yaml    文件:ParserImpl.java   
public Event produce() {
    // Parse the stream start.
    StreamStartToken token = (StreamStartToken) scanner.getToken();
    Event event = new StreamStartEvent(token.getStartMark(), token.getEndMark());
    // Prepare the next state.
    state = new ParseImplicitDocumentStart();
    return event;
}
项目:snake-yaml    文件:Serializer.java   
public void open() throws IOException {
    if (closed == null) {
        this.emitter.emit(new StreamStartEvent(null, null));
        this.closed = Boolean.FALSE;
    } else if (Boolean.TRUE.equals(closed)) {
        throw new SerializerException("serializer is closed");
    } else {
        throw new SerializerException("serializer is already opened");
    }
}
项目:snake-yaml    文件:Emitter.java   
public void expect() throws IOException {
    if (event instanceof StreamStartEvent) {
        writeStreamStart();
        state = new ExpectFirstDocumentStart();
    } else {
        throw new EmitterException("expected StreamStartEvent, but got " + event);
    }
}
项目:snake-yaml    文件:EmitterTest.java   
public void testWriteSupplementaryUnicode() throws IOException {
    DumperOptions options = new DumperOptions();
    String burger = new String(Character.toChars(0x1f354));
    String halfBurger = "\uD83C";
    StringWriter output = new StringWriter();
    Emitter emitter = new Emitter(output, options);

    emitter.emit(new StreamStartEvent(null, null));
    emitter.emit(new DocumentStartEvent(null, null, false, null, null));
    emitter.emit(new ScalarEvent(null, null, new ImplicitTuple(true, false), burger
            + halfBurger, null, null, '"'));
    String expected = "! \"\\U0001f354\\ud83c\"";
    assertEquals(expected, output.toString());
}
项目: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    文件:ParserImpl.java   
public Event produce() {
    // Parse the stream start.
    StreamStartToken token = (StreamStartToken) scanner.getToken();
    Event event = new StreamStartEvent(token.getStartMark(), token.getEndMark());
    // Prepare the next state.
    state = new ParseImplicitDocumentStart();
    return event;
}
项目:SubServers-2    文件:Serializer.java   
public void open() throws IOException {
    if (closed == null) {
        this.emitter.emit(new StreamStartEvent(null, null));
        this.closed = Boolean.FALSE;
    } else if (Boolean.TRUE.equals(closed)) {
        throw new SerializerException("serializer is closed");
    } else {
        throw new SerializerException("serializer is already opened");
    }
}
项目:SubServers-2    文件:Emitter.java   
public void expect() throws IOException {
    if (event instanceof StreamStartEvent) {
        writeStreamStart();
        state = new ExpectFirstDocumentStart();
    } else {
        throw new EmitterException("expected StreamStartEvent, but got " + event);
    }
}
项目:Diorite    文件:ExpectStreamStart.java   
@Override
public void expect(Emitter emitter) throws IOException
{
    if (emitter.event instanceof StreamStartEvent)
    {
        emitter.writeStreamStart();
        emitter.state = new ExpectFirstDocumentStart();
    }
    else
    {
        throw new EmitterException("expected StreamStartEvent, but got " + emitter.event);
    }
}
项目:snakeyaml    文件:ParserImpl.java   
public Event produce() {
    // Parse the stream start.
    StreamStartToken token = (StreamStartToken) scanner.getToken();
    Event event = new StreamStartEvent(token.getStartMark(), token.getEndMark());
    // Prepare the next state.
    state = new ParseImplicitDocumentStart();
    return event;
}
项目:snakeyaml    文件:Serializer.java   
public void open() throws IOException {
    if (closed == null) {
        this.emitter.emit(new StreamStartEvent(null, null));
        this.closed = Boolean.FALSE;
    } else if (Boolean.TRUE.equals(closed)) {
        throw new SerializerException("serializer is closed");
    } else {
        throw new SerializerException("serializer is already opened");
    }
}
项目:snakeyaml    文件:Emitter.java   
public void expect() throws IOException {
    if (event instanceof StreamStartEvent) {
        writeStreamStart();
        state = new ExpectFirstDocumentStart();
    } else {
        throw new EmitterException("expected StreamStartEvent, but got " + event);
    }
}
项目: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    文件:EmitterTest.java   
public void testWriteSupplementaryUnicode() throws IOException {
    DumperOptions options = new DumperOptions();
    String burger = new String(Character.toChars(0x1f354));
    String halfBurger = "\uD83C";
    StringWriter output = new StringWriter();
    Emitter emitter = new Emitter(output, options);

    emitter.emit(new StreamStartEvent(null, null));
    emitter.emit(new DocumentStartEvent(null, null, false, null, null));
    emitter.emit(new ScalarEvent(null, null, new ImplicitTuple(true, false), burger
            + halfBurger, null, null, '"'));
    String expected = "! \"\\U0001f354\\ud83c\"";
    assertEquals(expected, output.toString());
}
项目: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    文件:ParserImpl.java   
public Event produce() {
    // Parse the stream start.
    StreamStartToken token = (StreamStartToken) scanner.getToken();
    Event event = new StreamStartEvent(token.getStartMark(), token.getEndMark());
    // Prepare the next state.
    state = new ParseImplicitDocumentStart();
    return event;
}
项目:TestTheTeacher    文件:Serializer.java   
public void open() throws IOException {
    if (closed == null) {
        this.emitter.emit(new StreamStartEvent(null, null));
        this.closed = Boolean.FALSE;
    } else if (Boolean.TRUE.equals(closed)) {
        throw new SerializerException("serializer is closed");
    } else {
        throw new SerializerException("serializer is already opened");
    }
}
项目:TestTheTeacher    文件:Emitter.java   
public void expect() throws IOException {
    if (event instanceof StreamStartEvent) {
        writeStreamStart();
        state = new ExpectFirstDocumentStart();
    } else {
        throw new EmitterException("expected StreamStartEvent, but got " + event);
    }
}
项目:org.openntf.domino    文件:ParserImpl.java   
@Override
public Event produce() {
    // Parse the stream start.
    StreamStartToken token = (StreamStartToken) scanner.getToken();
    Event event = new StreamStartEvent(token.getStartMark(), token.getEndMark());
    // Prepare the next state.
    state = new ParseImplicitDocumentStart();
    return event;
}
项目:org.openntf.domino    文件:Serializer.java   
public void open() throws IOException {
    if (closed == null) {
        this.emitter.emit(new StreamStartEvent(null, null));
        this.closed = Boolean.FALSE;
    } else if (Boolean.TRUE.equals(closed)) {
        throw new SerializerException("serializer is closed");
    } else {
        throw new SerializerException("serializer is already opened");
    }
}
项目:org.openntf.domino    文件:Emitter.java   
public void expect() throws IOException {
    if (event instanceof StreamStartEvent) {
        writeStreamStart();
        state = new ExpectFirstDocumentStart();
    } else {
        throw new EmitterException("expected StreamStartEvent, but got " + event);
    }
}
项目:mobi    文件:YamlConfigParser.java   
public StreamStartEvent expectStreamStart() {
    return (StreamStartEvent) expect(Event.ID.StreamStart);
}
项目:mobi    文件:YamlConfigParser.java   
public StreamStartEvent expectStreamStart() {
    return (StreamStartEvent) expect(Event.ID.StreamStart);
}