com.fasterxml.jackson.core.json.JsonReadContext Java Examples

The following examples show how to use com.fasterxml.jackson.core.json.JsonReadContext. 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: NonBlockingJsonParserBase.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
protected final JsonToken _closeArrayScope() throws IOException
{
    if (!_parsingContext.inArray()) {
        _reportMismatchedEndMarker(']', '}');
    }
    JsonReadContext ctxt = _parsingContext.getParent();
    _parsingContext = ctxt;
    int st;
    if (ctxt.inObject()) {
        st = MAJOR_OBJECT_FIELD_NEXT;
    } else if (ctxt.inArray()) {
        st = MAJOR_ARRAY_ELEMENT_NEXT;
    } else {
        st = MAJOR_ROOT;
    }
    _majorState = st;
    _majorStateAfterValue = st;
    return (_currToken = JsonToken.END_ARRAY);
}
 
Example #2
Source File: NonBlockingJsonParserBase.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
protected final JsonToken _closeObjectScope() throws IOException
{
    if (!_parsingContext.inObject()) {
        _reportMismatchedEndMarker('}', ']');
    }
    JsonReadContext ctxt = _parsingContext.getParent();
    _parsingContext = ctxt;
    int st;
    if (ctxt.inObject()) {
        st = MAJOR_OBJECT_FIELD_NEXT;
    } else if (ctxt.inArray()) {
        st = MAJOR_ARRAY_ELEMENT_NEXT;
    } else {
        st = MAJOR_ROOT;
    }
    _majorState = st;
    _majorStateAfterValue = st;
    return (_currToken = JsonToken.END_OBJECT);
}
 
Example #3
Source File: TokenBufferReadContext.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
protected TokenBufferReadContext(JsonStreamContext base, Object srcRef) {
    super(base);
    _parent = base.getParent();
    _currentName = base.getCurrentName();
    _currentValue = base.getCurrentValue();
    if (base instanceof JsonReadContext) {
        JsonReadContext rc = (JsonReadContext) base;
        _startLocation = rc.getStartLocation(srcRef);
    } else {
        _startLocation = JsonLocation.NA;
    }
}
 
Example #4
Source File: ParserBase.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
protected ParserBase(IOContext ctxt, int features) {
    super(features);
    _ioContext = ctxt;
    _textBuffer = ctxt.constructTextBuffer();
    DupDetector dups = Feature.STRICT_DUPLICATE_DETECTION.enabledIn(features)
            ? DupDetector.rootDetector(this) : null;
    _parsingContext = JsonReadContext.createRootContext(dups);
}
 
Example #5
Source File: ParserBase.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Method that can be called to get the name associated with
 * the current event.
 */
@Override public String getCurrentName() throws IOException {
    // [JACKSON-395]: start markers require information from parent
    if (_currToken == JsonToken.START_OBJECT || _currToken == JsonToken.START_ARRAY) {
        JsonReadContext parent = _parsingContext.getParent();
        if (parent != null) {
            return parent.getCurrentName();
        }
    }
    return _parsingContext.getCurrentName();
}
 
Example #6
Source File: ParserBase.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override public void overrideCurrentName(String name) {
    // Simple, but need to look for START_OBJECT/ARRAY's "off-by-one" thing:
    JsonReadContext ctxt = _parsingContext;
    if (_currToken == JsonToken.START_OBJECT || _currToken == JsonToken.START_ARRAY) {
        ctxt = ctxt.getParent();
    }
    /* 24-Sep-2013, tatu: Unfortunate, but since we did not expose exceptions,
     *   need to wrap this here
     */
    try {
        ctxt.setCurrentName(name);
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
}
 
Example #7
Source File: ParserBase.java    From openbd-core with GNU General Public License v3.0 5 votes vote down vote up
protected ParserBase(IOContext ctxt, int features) {
    super(features);
    _ioContext = ctxt;
    _textBuffer = ctxt.constructTextBuffer();
    DupDetector dups = Feature.STRICT_DUPLICATE_DETECTION.enabledIn(features)
            ? DupDetector.rootDetector(this) : null;
    _parsingContext = JsonReadContext.createRootContext(dups);
}
 
Example #8
Source File: ParserBase.java    From openbd-core with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Method that can be called to get the name associated with
 * the current event.
 */
@Override public String getCurrentName() throws IOException {
    // [JACKSON-395]: start markers require information from parent
    if (_currToken == JsonToken.START_OBJECT || _currToken == JsonToken.START_ARRAY) {
        JsonReadContext parent = _parsingContext.getParent();
        return parent.getCurrentName();
    }
    return _parsingContext.getCurrentName();
}
 
Example #9
Source File: ParserBase.java    From openbd-core with GNU General Public License v3.0 5 votes vote down vote up
@Override public void overrideCurrentName(String name) {
    // Simple, but need to look for START_OBJECT/ARRAY's "off-by-one" thing:
    JsonReadContext ctxt = _parsingContext;
    if (_currToken == JsonToken.START_OBJECT || _currToken == JsonToken.START_ARRAY) {
        ctxt = ctxt.getParent();
    }
    /* 24-Sep-2013, tatu: Unfortunate, but since we did not expose exceptions,
     *   need to wrap this here
     */
    try {
        ctxt.setCurrentName(name);
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
}
 
Example #10
Source File: MessagePackParser.java    From jackson-dataformat-msgpack with Apache License 2.0 5 votes vote down vote up
@Override public String getCurrentName() throws IOException {
    if (_currToken == JsonToken.START_OBJECT || _currToken == JsonToken.START_ARRAY) {
        JsonReadContext parent = parsingContext.getParent();
        return parent.getCurrentName();
    }
    return parsingContext.getCurrentName();
}
 
Example #11
Source File: ParserBase.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
protected void _reportMismatchedEndMarker(int actCh, char expCh) throws JsonParseException {
    JsonReadContext ctxt = getParsingContext();
    _reportError(String.format(
            "Unexpected close marker '%s': expected '%c' (for %s starting at %s)",
            (char) actCh, expCh, ctxt.typeDesc(), ctxt.getStartLocation(_getSourceReference())));
}
 
Example #12
Source File: ParserBase.java    From lams with GNU General Public License v2.0 votes vote down vote up
@Override public JsonReadContext getParsingContext() { return _parsingContext; } 
Example #13
Source File: ParserBase.java    From openbd-core with GNU General Public License v3.0 votes vote down vote up
@Override public JsonReadContext getParsingContext() { return _parsingContext; }