下面列出了怎么用com.fasterxml.jackson.core.json.JsonReadContext的API类实例代码及写法,或者点击链接到github查看源代码。
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);
}
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);
}
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;
}
}
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);
}
/**
* 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();
}
@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);
}
}
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);
}
/**
* 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();
}
@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);
}
}
@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();
}
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())));
}
@Override public JsonReadContext getParsingContext() { return _parsingContext; }
@Override public JsonReadContext getParsingContext() { return _parsingContext; }