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

项目:AndroidApktool    文件:Emitter.java   
public void expect() throws IOException {
    if (event instanceof SequenceEndEvent) {
        indent = indents.pop();
        flowLevel--;
        if (canonical) {
            writeIndicator(",", false, false, false);
            writeIndent();
        }
        writeIndicator("]", false, false, false);
        if (prettyFlow) {
            writeIndent();
        }
        state = states.pop();
    } else {
        writeIndicator(",", false, false, false);
        if (canonical || (column > bestWidth && splitLines) || prettyFlow) {
            writeIndent();
        }
        states.push(new ExpectFlowSequenceItem());
        expectNode(false, false, false);
    }
}
项目:5zig-TIMV-Plugin    文件:Emitter.java   
public void expect() throws IOException {
    if (event instanceof SequenceEndEvent) {
        indent = indents.pop();
        flowLevel--;
        if (canonical) {
            writeIndicator(",", false, false, false);
            writeIndent();
        }
        writeIndicator("]", false, false, false);
        if (prettyFlow) {
            writeIndent();
        }
        state = states.pop();
    } else {
        writeIndicator(",", false, false, false);
        if (canonical || (column > bestWidth && splitLines) || prettyFlow) {
            writeIndent();
        }
        states.push(new ExpectFlowSequenceItem());
        expectNode(false, false, false);
    }
}
项目:diorite-configs-java8    文件:ExpectBlockSequenceItem.java   
public static void expect(Emitter emitter, boolean first) throws IOException
{
    if (! first && (emitter.event instanceof SequenceEndEvent))
    {
        emitter.indent = emitter.indents.pop();
        emitter.state = emitter.states.pop();
    }
    else
    {
        emitter.writeIndent();
        emitter.writeWhitespace(emitter.indicatorIndent);
        emitter.writeIndicator("-", true, false, true);
        emitter.states.push(new ExpectBlockSequenceItem(false));
        emitter.expectNode(false, false, false);
    }
}
项目:diorite-configs-java8    文件:ExpectFirstFlowSequenceItem.java   
@Override
public void expect(Emitter emitter) throws IOException
{
    if (emitter.event instanceof SequenceEndEvent)
    {
        emitter.indent = emitter.indents.pop();
        emitter.flowLevel--;
        emitter.writeIndicator("]", false, false, false);
        emitter.state = emitter.states.pop();
    }
    else
    {
        if (emitter.canonical || ((emitter.column > emitter.bestWidth) && emitter.splitLines) || emitter.prettyFlow)
        {
            emitter.writeIndent();
        }
        emitter.states.push(new ExpectFlowSequenceItem());
        emitter.expectNode(false, false, false);
    }
}
项目:snake-yaml    文件:Emitter.java   
public void expect() throws IOException {
    if (event instanceof SequenceEndEvent) {
        indent = indents.pop();
        flowLevel--;
        if (canonical) {
            writeIndicator(",", false, false, false);
            writeIndent();
        }
        writeIndicator("]", false, false, false);
        if (prettyFlow) {
            writeIndent();
        }
        state = states.pop();
    } else {
        writeIndicator(",", false, false, false);
        if (canonical || (column > bestWidth && splitLines) || prettyFlow) {
            writeIndent();
        }
        states.push(new ExpectFlowSequenceItem());
        expectNode(false, false, false);
    }
}
项目: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   
public void expect() throws IOException {
    if (event instanceof SequenceEndEvent) {
        indent = indents.pop();
        flowLevel--;
        if (canonical) {
            writeIndicator(",", false, false, false);
            writeIndent();
        }
        writeIndicator("]", false, false, false);
        if (prettyFlow) {
            writeIndent();
        }
        state = states.pop();
    } else {
        writeIndicator(",", false, false, false);
        if (canonical || (column > bestWidth && splitLines) || prettyFlow) {
            writeIndent();
        }
        states.push(new ExpectFlowSequenceItem());
        expectNode(false, false, false);
    }
}
项目:Diorite    文件:ExpectBlockSequenceItem.java   
public static void expect(Emitter emitter, boolean first) throws IOException
{
    if (! first && (emitter.event instanceof SequenceEndEvent))
    {
        emitter.indent = emitter.indents.pop();
        emitter.state = emitter.states.pop();
    }
    else
    {
        emitter.writeIndent();
        emitter.writeWhitespace(emitter.indicatorIndent);
        emitter.writeIndicator("-", true, false, true);
        emitter.states.push(new ExpectBlockSequenceItem(false));
        emitter.expectNode(false, false, false);
    }
}
项目:Diorite    文件:ExpectFirstFlowSequenceItem.java   
@Override
public void expect(Emitter emitter) throws IOException
{
    if (emitter.event instanceof SequenceEndEvent)
    {
        emitter.indent = emitter.indents.pop();
        emitter.flowLevel--;
        emitter.writeIndicator("]", false, false, false);
        emitter.state = emitter.states.pop();
    }
    else
    {
        if (emitter.canonical || ((emitter.column > emitter.bestWidth) && emitter.splitLines) || emitter.prettyFlow)
        {
            emitter.writeIndent();
        }
        emitter.states.push(new ExpectFlowSequenceItem());
        emitter.expectNode(false, false, false);
    }
}
项目:snakeyaml    文件:Emitter.java   
public void expect() throws IOException {
    if (event instanceof SequenceEndEvent) {
        indent = indents.pop();
        flowLevel--;
        if (canonical) {
            writeIndicator(",", false, false, false);
            writeIndent();
        }
        writeIndicator("]", false, false, false);
        if (prettyFlow) {
            writeIndent();
        }
        state = states.pop();
    } else {
        writeIndicator(",", false, false, false);
        if (canonical || (column > bestWidth && splitLines) || prettyFlow) {
            writeIndent();
        }
        states.push(new ExpectFlowSequenceItem());
        expectNode(false, false, false);
    }
}
项目:TestTheTeacher    文件:Emitter.java   
public void expect() throws IOException {
    if (event instanceof SequenceEndEvent) {
        indent = indents.pop();
        flowLevel--;
        if (canonical) {
            writeIndicator(",", false, false, false);
            writeIndent();
        }
        writeIndicator("]", false, false, false);
        if (prettyFlow) {
            writeIndent();
        }
        state = states.pop();
    } else {
        writeIndicator(",", false, false, false);
        if (canonical || column > bestWidth || prettyFlow) {
            writeIndent();
        }
        states.push(new ExpectFlowSequenceItem());
        expectNode(false, false, false);
    }
}
项目:org.openntf.domino    文件:Emitter.java   
public void expect() throws IOException {
    if (event instanceof SequenceEndEvent) {
        indent = indents.pop();
        flowLevel--;
        if (canonical) {
            writeIndicator(",", false, false, false);
            writeIndent();
        }
        writeIndicator("]", false, false, false);
        if (prettyFlow) {
            writeIndent();
        }
        state = states.pop();
    } else {
        writeIndicator(",", false, false, false);
        if (canonical || column > bestWidth || prettyFlow) {
            writeIndent();
        }
        states.push(new ExpectFlowSequenceItem());
        expectNode(false, false, false);
    }
}
项目:AndroidApktool    文件:Emitter.java   
public void expect() throws IOException {
    if (event instanceof SequenceEndEvent) {
        indent = indents.pop();
        flowLevel--;
        writeIndicator("]", false, false, false);
        state = states.pop();
    } else {
        if (canonical || (column > bestWidth && splitLines) || prettyFlow) {
            writeIndent();
        }
        states.push(new ExpectFlowSequenceItem());
        expectNode(false, false, false);
    }
}
项目:AndroidApktool    文件:Emitter.java   
public void expect() throws IOException {
    if (!this.first && event instanceof SequenceEndEvent) {
        indent = indents.pop();
        state = states.pop();
    } else {
        writeIndent();
        writeWhitespace(indicatorIndent);
        writeIndicator("-", true, false, true);
        states.push(new ExpectBlockSequenceItem(false));
        expectNode(false, false, false);
    }
}
项目:5zig-TIMV-Plugin    文件:Emitter.java   
public void expect() throws IOException {
    if (event instanceof SequenceEndEvent) {
        indent = indents.pop();
        flowLevel--;
        writeIndicator("]", false, false, false);
        state = states.pop();
    } else {
        if (canonical || (column > bestWidth && splitLines) || prettyFlow) {
            writeIndent();
        }
        states.push(new ExpectFlowSequenceItem());
        expectNode(false, false, false);
    }
}
项目:5zig-TIMV-Plugin    文件:Emitter.java   
public void expect() throws IOException {
    if (!this.first && event instanceof SequenceEndEvent) {
        indent = indents.pop();
        state = states.pop();
    } else {
        writeIndent();
        writeWhitespace(indicatorIndent);
        writeIndicator("-", true, false, true);
        states.push(new ExpectBlockSequenceItem(false));
        expectNode(false, false, false);
    }
}
项目:diorite-configs-java8    文件:ExpectFlowSequenceItem.java   
@Override
public void expect(Emitter emitter) throws IOException
{
    if (emitter.event instanceof SequenceEndEvent)
    {
        emitter.indent = emitter.indents.pop();
        emitter.flowLevel--;
        if (emitter.canonical)
        {
            emitter.writeIndicator(",", false, false, false);
            emitter.writeIndent();
        }
        emitter.writeIndicator("]", false, false, false);
        if (emitter.prettyFlow)
        {
            emitter.writeIndent();
        }
        emitter.state = emitter.states.pop();
    }
    else
    {
        emitter.writeIndicator(",", false, false, false);
        if (emitter.canonical || ((emitter.column > emitter.bestWidth) && emitter.splitLines) || emitter.prettyFlow)
        {
            emitter.writeIndent();
        }
        emitter.states.push(new ExpectFlowSequenceItem());
        emitter.expectNode(false, false, false);
    }
}
项目:snake-yaml    文件:Emitter.java   
public void expect() throws IOException {
    if (event instanceof SequenceEndEvent) {
        indent = indents.pop();
        flowLevel--;
        writeIndicator("]", false, false, false);
        state = states.pop();
    } else {
        if (canonical || (column > bestWidth && splitLines) || prettyFlow) {
            writeIndent();
        }
        states.push(new ExpectFlowSequenceItem());
        expectNode(false, false, false);
    }
}
项目:snake-yaml    文件:Emitter.java   
public void expect() throws IOException {
    if (!this.first && event instanceof SequenceEndEvent) {
        indent = indents.pop();
        state = states.pop();
    } else {
        writeIndent();
        writeWhitespace(indicatorIndent);
        writeIndicator("-", true, false, true);
        states.push(new ExpectBlockSequenceItem(false));
        expectNode(false, false, false);
    }
}
项目:snake-yaml    文件:CanonicalParser.java   
private void parseSequence() {
    scanner.getToken(Token.ID.FlowSequenceStart);
    if (!scanner.checkToken(Token.ID.FlowSequenceEnd)) {
        parseNode();
        while (!scanner.checkToken(Token.ID.FlowSequenceEnd)) {
            scanner.getToken(Token.ID.FlowEntry);
            if (!scanner.checkToken(Token.ID.FlowSequenceEnd)) {
                parseNode();
            }
        }
    }
    scanner.getToken(Token.ID.FlowSequenceEnd);
    events.add(new SequenceEndEvent(null, null));
}
项目:SubServers-2    文件:Emitter.java   
public void expect() throws IOException {
    if (event instanceof SequenceEndEvent) {
        indent = indents.pop();
        flowLevel--;
        writeIndicator("]", false, false, false);
        state = states.pop();
    } else {
        if (canonical || (column > bestWidth && splitLines) || prettyFlow) {
            writeIndent();
        }
        states.push(new ExpectFlowSequenceItem());
        expectNode(false, false, false);
    }
}
项目:SubServers-2    文件:Emitter.java   
public void expect() throws IOException {
    if (!this.first && event instanceof SequenceEndEvent) {
        indent = indents.pop();
        state = states.pop();
    } else {
        writeIndent();
        writeWhitespace(indicatorIndent);
        writeIndicator("-", true, false, true);
        states.push(new ExpectBlockSequenceItem(false));
        expectNode(false, false, false);
    }
}
项目:Diorite    文件:ExpectFlowSequenceItem.java   
@Override
public void expect(Emitter emitter) throws IOException
{
    if (emitter.event instanceof SequenceEndEvent)
    {
        emitter.indent = emitter.indents.pop();
        emitter.flowLevel--;
        if (emitter.canonical)
        {
            emitter.writeIndicator(",", false, false, false);
            emitter.writeIndent();
        }
        emitter.writeIndicator("]", false, false, false);
        if (emitter.prettyFlow)
        {
            emitter.writeIndent();
        }
        emitter.state = emitter.states.pop();
    }
    else
    {
        emitter.writeIndicator(",", false, false, false);
        if (emitter.canonical || ((emitter.column > emitter.bestWidth) && emitter.splitLines) || emitter.prettyFlow)
        {
            emitter.writeIndent();
        }
        emitter.states.push(new ExpectFlowSequenceItem());
        emitter.expectNode(false, false, false);
    }
}
项目:snakeyaml    文件:Emitter.java   
public void expect() throws IOException {
    if (event instanceof SequenceEndEvent) {
        indent = indents.pop();
        flowLevel--;
        writeIndicator("]", false, false, false);
        state = states.pop();
    } else {
        if (canonical || (column > bestWidth && splitLines) || prettyFlow) {
            writeIndent();
        }
        states.push(new ExpectFlowSequenceItem());
        expectNode(false, false, false);
    }
}
项目:snakeyaml    文件:Emitter.java   
public void expect() throws IOException {
    if (!this.first && event instanceof SequenceEndEvent) {
        indent = indents.pop();
        state = states.pop();
    } else {
        writeIndent();
        writeIndicator("-", true, false, true);
        states.push(new ExpectBlockSequenceItem(false));
        expectNode(false, false, false);
    }
}
项目: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 parseSequence() {
    scanner.getToken(Token.ID.FlowSequenceStart);
    if (!scanner.checkToken(Token.ID.FlowSequenceEnd)) {
        parseNode();
        while (!scanner.checkToken(Token.ID.FlowSequenceEnd)) {
            scanner.getToken(Token.ID.FlowEntry);
            if (!scanner.checkToken(Token.ID.FlowSequenceEnd)) {
                parseNode();
            }
        }
    }
    scanner.getToken(Token.ID.FlowSequenceEnd);
    events.add(new SequenceEndEvent(null, null));
}
项目:TestTheTeacher    文件:Emitter.java   
public void expect() throws IOException {
    if (event instanceof SequenceEndEvent) {
        indent = indents.pop();
        flowLevel--;
        writeIndicator("]", false, false, false);
        state = states.pop();
    } else {
        if (canonical || column > bestWidth || prettyFlow) {
            writeIndent();
        }
        states.push(new ExpectFlowSequenceItem());
        expectNode(false, false, false);
    }
}
项目:TestTheTeacher    文件:Emitter.java   
public void expect() throws IOException {
    if (!this.first && event instanceof SequenceEndEvent) {
        indent = indents.pop();
        state = states.pop();
    } else {
        writeIndent();
        writeIndicator("-", true, false, true);
        states.push(new ExpectBlockSequenceItem(false));
        expectNode(false, false, false);
    }
}
项目:org.openntf.domino    文件:Emitter.java   
public void expect() throws IOException {
    if (event instanceof SequenceEndEvent) {
        indent = indents.pop();
        flowLevel--;
        writeIndicator("]", false, false, false);
        state = states.pop();
    } else {
        if (canonical || column > bestWidth || prettyFlow) {
            writeIndent();
        }
        states.push(new ExpectFlowSequenceItem());
        expectNode(false, false, false);
    }
}
项目:org.openntf.domino    文件:Emitter.java   
public void expect() throws IOException {
    if (!this.first && event instanceof SequenceEndEvent) {
        indent = indents.pop();
        state = states.pop();
    } else {
        writeIndent();
        writeIndicator("-", true, false, true);
        states.push(new ExpectBlockSequenceItem(false));
        expectNode(false, false, false);
    }
}
项目:AndroidApktool    文件:Serializer.java   
private void serializeNode(Node node, Node parent) throws IOException {
    if (node.getNodeId() == NodeId.anchor) {
        node = ((AnchorNode) node).getRealNode();
    }
    String tAlias = this.anchors.get(node);
    if (this.serializedNodes.contains(node)) {
        this.emitter.emit(new AliasEvent(tAlias, null, null));
    } else {
        this.serializedNodes.add(node);
        switch (node.getNodeId()) {
        case scalar:
            ScalarNode scalarNode = (ScalarNode) node;
            Tag detectedTag = this.resolver.resolve(NodeId.scalar, scalarNode.getValue(), true);
            Tag defaultTag = this.resolver.resolve(NodeId.scalar, scalarNode.getValue(), false);
            ImplicitTuple tuple = new ImplicitTuple(node.getTag().equals(detectedTag), node
                    .getTag().equals(defaultTag));
            ScalarEvent event = new ScalarEvent(tAlias, node.getTag().getValue(), tuple,
                    scalarNode.getValue(), null, null, scalarNode.getStyle());
            this.emitter.emit(event);
            break;
        case sequence:
            SequenceNode seqNode = (SequenceNode) node;
            boolean implicitS = node.getTag().equals(this.resolver.resolve(NodeId.sequence,
                    null, true));
            this.emitter.emit(new SequenceStartEvent(tAlias, node.getTag().getValue(),
                    implicitS, null, null, seqNode.getFlowStyle()));
            List<Node> list = seqNode.getValue();
            for (Node item : list) {
                serializeNode(item, node);
            }
            this.emitter.emit(new SequenceEndEvent(null, null));
            break;
        default:// instance of MappingNode
            Tag implicitTag = this.resolver.resolve(NodeId.mapping, null, true);
            boolean implicitM = node.getTag().equals(implicitTag);
            this.emitter.emit(new MappingStartEvent(tAlias, node.getTag().getValue(),
                    implicitM, null, null, ((CollectionNode) node).getFlowStyle()));
            MappingNode mnode = (MappingNode) node;
            List<NodeTuple> map = mnode.getValue();
            for (NodeTuple row : map) {
                Node key = row.getKeyNode();
                Node value = row.getValueNode();
                serializeNode(key, mnode);
                serializeNode(value, mnode);
            }
            this.emitter.emit(new MappingEndEvent(null, null));
        }
    }
}
项目:AndroidApktool    文件:Emitter.java   
private boolean checkEmptySequence() {
    return event instanceof SequenceStartEvent && !events.isEmpty() && events.peek() instanceof SequenceEndEvent;
}
项目:5zig-TIMV-Plugin    文件:Serializer.java   
private void serializeNode(Node node, Node parent) throws IOException {
    if (node.getNodeId() == NodeId.anchor) {
        node = ((AnchorNode) node).getRealNode();
    }
    String tAlias = this.anchors.get(node);
    if (this.serializedNodes.contains(node)) {
        this.emitter.emit(new AliasEvent(tAlias, null, null));
    } else {
        this.serializedNodes.add(node);
        switch (node.getNodeId()) {
        case scalar:
            ScalarNode scalarNode = (ScalarNode) node;
            Tag detectedTag = this.resolver.resolve(NodeId.scalar, scalarNode.getValue(), true);
            Tag defaultTag = this.resolver.resolve(NodeId.scalar, scalarNode.getValue(), false);
            ImplicitTuple tuple = new ImplicitTuple(node.getTag().equals(detectedTag), node
                    .getTag().equals(defaultTag));
            ScalarEvent event = new ScalarEvent(tAlias, node.getTag().getValue(), tuple,
                    scalarNode.getValue(), null, null, scalarNode.getStyle());
            this.emitter.emit(event);
            break;
        case sequence:
            SequenceNode seqNode = (SequenceNode) node;
            boolean implicitS = node.getTag().equals(this.resolver.resolve(NodeId.sequence,
                    null, true));
            this.emitter.emit(new SequenceStartEvent(tAlias, node.getTag().getValue(),
                    implicitS, null, null, seqNode.getFlowStyle()));
            List<Node> list = seqNode.getValue();
            for (Node item : list) {
                serializeNode(item, node);
            }
            this.emitter.emit(new SequenceEndEvent(null, null));
            break;
        default:// instance of MappingNode
            Tag implicitTag = this.resolver.resolve(NodeId.mapping, null, true);
            boolean implicitM = node.getTag().equals(implicitTag);
            this.emitter.emit(new MappingStartEvent(tAlias, node.getTag().getValue(),
                    implicitM, null, null, ((CollectionNode) node).getFlowStyle()));
            MappingNode mnode = (MappingNode) node;
            List<NodeTuple> map = mnode.getValue();
            for (NodeTuple row : map) {
                Node key = row.getKeyNode();
                Node value = row.getValueNode();
                serializeNode(key, mnode);
                serializeNode(value, mnode);
            }
            this.emitter.emit(new MappingEndEvent(null, null));
        }
    }
}
项目:5zig-TIMV-Plugin    文件:Emitter.java   
private boolean checkEmptySequence() {
    return event instanceof SequenceStartEvent && !events.isEmpty() && events.peek() instanceof SequenceEndEvent;
}
项目:diorite-configs-java8    文件:Emitter.java   
private boolean checkEmptySequence()
{
    return (this.event instanceof SequenceStartEvent) && ! this.events.isEmpty() && (this.events.peek() instanceof SequenceEndEvent);
}
项目:diorite-configs-java8    文件:Serializer.java   
private void serializeNode(Node node, @Nullable Node parent, LinkedList<String> commentPath, boolean mappingScalar) throws IOException
{
    if (node.getNodeId() == NodeId.anchor)
    {
        node = ((AnchorNode) node).getRealNode();
    }
    String tAlias = this.anchors.get(node);
    if (this.serializedNodes.contains(node))
    {
        this.emitter.emit(new AliasEvent(tAlias, null, null));
    }
    else
    {
        this.serializedNodes.add(node);
        switch (node.getNodeId())
        {
            case scalar:
                ScalarNode scalarNode = (ScalarNode) node;
                Tag detectedTag = this.resolver.resolve(NodeId.scalar, scalarNode.getValue(), true);
                Tag defaultTag = this.resolver.resolve(NodeId.scalar, scalarNode.getValue(), false);
                String[] pathNodes = commentPath.toArray(new String[commentPath.size()]);
                String comment;
                if (this.checkCommentsSet(pathNodes))
                {
                    comment = this.comments.getComment(pathNodes);
                }
                else
                {
                    comment = null;
                }
                ImplicitTuple tuple = new ImplicitTupleExtension(node.getTag().equals(detectedTag), node.getTag().equals(defaultTag), comment);
                ScalarEvent event = new ScalarEvent(tAlias, node.getTag().getValue(), tuple, scalarNode.getValue(), null, null, scalarNode.getStyle());
                this.emitter.emit(event);
                break;
            case sequence:
                SequenceNode seqNode = (SequenceNode) node;
                boolean implicitS = node.getTag().equals(this.resolver.resolve(NodeId.sequence, null, true));
                this.emitter.emit(new SequenceStartEvent(tAlias, node.getTag().getValue(), implicitS, null, null, seqNode.getFlowStyle()));
                List<Node> list = seqNode.getValue();
                for (Node item : list)
                {
                    this.serializeNode(item, node, commentPath, false);
                }
                this.emitter.emit(new SequenceEndEvent(null, null));
                break;
            default:// instance of MappingNode
                Tag implicitTag = this.resolver.resolve(NodeId.mapping, null, true);
                boolean implicitM = node.getTag().equals(implicitTag);
                this.emitter.emit(new MappingStartEvent(tAlias, node.getTag().getValue(), implicitM, null, null, ((CollectionNode) node).getFlowStyle()));
                MappingNode mnode = (MappingNode) node;
                List<NodeTuple> map = mnode.getValue();
                for (NodeTuple row : map)
                {
                    Node key = row.getKeyNode();
                    Node value = row.getValueNode();
                    if (key instanceof ScalarNode)
                    {
                        commentPath.add(((ScalarNode) key).getValue());
                    }
                    this.serializeNode(key, mnode, commentPath, true);
                    this.serializeNode(value, mnode, commentPath, false);
                    if (key instanceof ScalarNode)
                    {
                        commentPath.removeLast();
                    }
                }
                this.emitter.emit(new MappingEndEvent(null, null));
        }
    }
}
项目:snake-yaml    文件:Serializer.java   
private void serializeNode(Node node, Node parent) throws IOException {
    if (node.getNodeId() == NodeId.anchor) {
        node = ((AnchorNode) node).getRealNode();
    }
    String tAlias = this.anchors.get(node);
    if (this.serializedNodes.contains(node)) {
        this.emitter.emit(new AliasEvent(tAlias, null, null));
    } else {
        this.serializedNodes.add(node);
        switch (node.getNodeId()) {
        case scalar:
            ScalarNode scalarNode = (ScalarNode) node;
            Tag detectedTag = this.resolver.resolve(NodeId.scalar, scalarNode.getValue(), true);
            Tag defaultTag = this.resolver.resolve(NodeId.scalar, scalarNode.getValue(), false);
            ImplicitTuple tuple = new ImplicitTuple(node.getTag().equals(detectedTag), node
                    .getTag().equals(defaultTag));
            ScalarEvent event = new ScalarEvent(tAlias, node.getTag().getValue(), tuple,
                    scalarNode.getValue(), null, null, scalarNode.getStyle());
            this.emitter.emit(event);
            break;
        case sequence:
            SequenceNode seqNode = (SequenceNode) node;
            boolean implicitS = node.getTag().equals(this.resolver.resolve(NodeId.sequence,
                    null, true));
            this.emitter.emit(new SequenceStartEvent(tAlias, node.getTag().getValue(),
                    implicitS, null, null, seqNode.getFlowStyle()));
            List<Node> list = seqNode.getValue();
            for (Node item : list) {
                serializeNode(item, node);
            }
            this.emitter.emit(new SequenceEndEvent(null, null));
            break;
        default:// instance of MappingNode
            Tag implicitTag = this.resolver.resolve(NodeId.mapping, null, true);
            boolean implicitM = node.getTag().equals(implicitTag);
            this.emitter.emit(new MappingStartEvent(tAlias, node.getTag().getValue(),
                    implicitM, null, null, ((CollectionNode) node).getFlowStyle()));
            MappingNode mnode = (MappingNode) node;
            List<NodeTuple> map = mnode.getValue();
            for (NodeTuple row : map) {
                Node key = row.getKeyNode();
                Node value = row.getValueNode();
                serializeNode(key, mnode);
                serializeNode(value, mnode);
            }
            this.emitter.emit(new MappingEndEvent(null, null));
        }
    }
}
项目:snake-yaml    文件:Emitter.java   
private boolean checkEmptySequence() {
    return event instanceof SequenceStartEvent && !events.isEmpty() && events.peek() instanceof SequenceEndEvent;
}
项目:SubServers-2    文件:Serializer.java   
private void serializeNode(Node node, Node parent) throws IOException {
    if (node.getNodeId() == NodeId.anchor) {
        node = ((AnchorNode) node).getRealNode();
    }
    String tAlias = this.anchors.get(node);
    if (this.serializedNodes.contains(node)) {
        this.emitter.emit(new AliasEvent(tAlias, null, null));
    } else {
        this.serializedNodes.add(node);
        switch (node.getNodeId()) {
        case scalar:
            ScalarNode scalarNode = (ScalarNode) node;
            Tag detectedTag = this.resolver.resolve(NodeId.scalar, scalarNode.getValue(), true);
            Tag defaultTag = this.resolver.resolve(NodeId.scalar, scalarNode.getValue(), false);
            ImplicitTuple tuple = new ImplicitTuple(node.getTag().equals(detectedTag), node
                    .getTag().equals(defaultTag));
            ScalarEvent event = new ScalarEvent(tAlias, node.getTag().getValue(), tuple,
                    scalarNode.getValue(), null, null, scalarNode.getStyle());
            this.emitter.emit(event);
            break;
        case sequence:
            SequenceNode seqNode = (SequenceNode) node;
            boolean implicitS = node.getTag().equals(this.resolver.resolve(NodeId.sequence,
                    null, true));
            this.emitter.emit(new SequenceStartEvent(tAlias, node.getTag().getValue(),
                    implicitS, null, null, seqNode.getFlowStyle()));
            List<Node> list = seqNode.getValue();
            for (Node item : list) {
                serializeNode(item, node);
            }
            this.emitter.emit(new SequenceEndEvent(null, null));
            break;
        default:// instance of MappingNode
            Tag implicitTag = this.resolver.resolve(NodeId.mapping, null, true);
            boolean implicitM = node.getTag().equals(implicitTag);
            this.emitter.emit(new MappingStartEvent(tAlias, node.getTag().getValue(),
                    implicitM, null, null, ((CollectionNode) node).getFlowStyle()));
            MappingNode mnode = (MappingNode) node;
            List<NodeTuple> map = mnode.getValue();
            for (NodeTuple row : map) {
                Node key = row.getKeyNode();
                Node value = row.getValueNode();
                serializeNode(key, mnode);
                serializeNode(value, mnode);
            }
            this.emitter.emit(new MappingEndEvent(null, null));
        }
    }
}