org.yaml.snakeyaml.events.NodeEvent Java Examples

The following examples show how to use org.yaml.snakeyaml.events.NodeEvent. 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: Emitter.java    From orion.server with Eclipse Public License 1.0 5 votes vote down vote up
private void expectAlias() throws IOException {
    if (((NodeEvent) event).getAnchor() == null) {
        throw new EmitterException("anchor is not specified for alias");
    }
    processAnchor("*");
    state = states.pop();
}
 
Example #2
Source File: Emitter.java    From orion.server with Eclipse Public License 1.0 5 votes vote down vote up
private boolean checkSimpleKey() {
    int length = 0;
    if (event instanceof NodeEvent && ((NodeEvent) event).getAnchor() != null) {
        if (preparedAnchor == null) {
            preparedAnchor = prepareAnchor(((NodeEvent) event).getAnchor());
        }
        length += preparedAnchor.length();
    }
    String tag = null;
    if (event instanceof ScalarEvent) {
        tag = ((ScalarEvent) event).getTag();
    } else if (event instanceof CollectionStartEvent) {
        tag = ((CollectionStartEvent) event).getTag();
    }
    if (tag != null) {
        if (preparedTag == null) {
            preparedTag = prepareTag(tag);
        }
        length += preparedTag.length();
    }
    if (event instanceof ScalarEvent) {
        if (analysis == null) {
            analysis = analyzeScalar(((ScalarEvent) event).getValue());
        }
        length += analysis.scalar.length();
    }
    return (length < 128 && (event instanceof AliasEvent
            || (event instanceof ScalarEvent && !analysis.empty && !analysis.multiline)
            || checkEmptySequence() || checkEmptyMapping()));
}
 
Example #3
Source File: Emitter.java    From orion.server with Eclipse Public License 1.0 5 votes vote down vote up
private void processAnchor(String indicator) throws IOException {
    NodeEvent ev = (NodeEvent) event;
    if (ev.getAnchor() == null) {
        preparedAnchor = null;
        return;
    }
    if (preparedAnchor == null) {
        preparedAnchor = prepareAnchor(ev.getAnchor());
    }
    writeIndicator(indicator + preparedAnchor, true, false, false);
    preparedAnchor = null;
}
 
Example #4
Source File: Emitter.java    From snake-yaml with Apache License 2.0 5 votes vote down vote up
private void expectAlias() throws IOException {
    if (((NodeEvent) event).getAnchor() == null) {
        throw new EmitterException("anchor is not specified for alias");
    }
    processAnchor("*");
    state = states.pop();
}
 
Example #5
Source File: Emitter.java    From snake-yaml with Apache License 2.0 5 votes vote down vote up
private boolean checkSimpleKey() {
    int length = 0;
    if (event instanceof NodeEvent && ((NodeEvent) event).getAnchor() != null) {
        if (preparedAnchor == null) {
            preparedAnchor = prepareAnchor(((NodeEvent) event).getAnchor());
        }
        length += preparedAnchor.length();
    }
    String tag = null;
    if (event instanceof ScalarEvent) {
        tag = ((ScalarEvent) event).getTag();
    } else if (event instanceof CollectionStartEvent) {
        tag = ((CollectionStartEvent) event).getTag();
    }
    if (tag != null) {
        if (preparedTag == null) {
            preparedTag = prepareTag(tag);
        }
        length += preparedTag.length();
    }
    if (event instanceof ScalarEvent) {
        if (analysis == null) {
            analysis = analyzeScalar(((ScalarEvent) event).getValue());
        }
        length += analysis.scalar.length();
    }
    return length < 128 && (event instanceof AliasEvent
            || (event instanceof ScalarEvent && !analysis.empty && !analysis.multiline)
            || checkEmptySequence() || checkEmptyMapping());
}
 
Example #6
Source File: Emitter.java    From snake-yaml with Apache License 2.0 5 votes vote down vote up
private void processAnchor(String indicator) throws IOException {
    NodeEvent ev = (NodeEvent) event;
    if (ev.getAnchor() == null) {
        preparedAnchor = null;
        return;
    }
    if (preparedAnchor == null) {
        preparedAnchor = prepareAnchor(ev.getAnchor());
    }
    writeIndicator(indicator + preparedAnchor, true, false, false);
    preparedAnchor = null;
}
 
Example #7
Source File: Emitter.java    From Diorite with MIT License 5 votes vote down vote up
boolean checkSimpleKey()
{
    int length = 0;
    if ((this.event instanceof NodeEvent) && (((NodeEvent) this.event).getAnchor() != null))
    {
        if (this.preparedAnchor == null)
        {
            this.preparedAnchor = prepareAnchor(((NodeEvent) this.event).getAnchor());
        }
        length += this.preparedAnchor.length();
    }
    String tag = null;
    if (this.event instanceof ScalarEvent)
    {
        tag = ((ScalarEvent) this.event).getTag();
    }
    else if (this.event instanceof CollectionStartEvent)
    {
        tag = ((CollectionStartEvent) this.event).getTag();
    }
    if (tag != null)
    {
        if (this.preparedTag == null)
        {
            this.preparedTag = this.prepareTag(tag);
        }
        length += this.preparedTag.length();
    }
    if (this.event instanceof ScalarEvent)
    {
        if (this.analysis == null)
        {
            this.analysis = this.analyzeScalar(((ScalarEvent) this.event).getValue());
        }
        length += this.analysis.scalar.length();
    }
    return (length < SMALL_LENGTH) && ((this.event instanceof AliasEvent) ||
                                       ((this.event instanceof ScalarEvent) && ! ((this.analysis == null) || this.analysis.empty) &&
                                        ! this.analysis.multiline) || this.checkEmptySequence() || this.checkEmptyMapping());
}