public class JsonUnmarshallerContextImpl extends JsonUnmarshallerContext
Modifier and Type | Class and Description |
---|---|
private static class |
JsonUnmarshallerContextImpl.JsonFieldTokenPair
An immutable class used to indicate a JSON field value followed by a
subsequent JSON token.
|
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
currentField
The name of the field that is currently being parsed.
|
private java.lang.String |
currentHeader |
private com.fasterxml.jackson.core.JsonToken |
currentToken
The current JsonToken that the private JsonParser is currently pointing to.
|
private HttpResponse |
httpResponse |
private com.fasterxml.jackson.core.JsonParser |
jsonParser |
private java.lang.String |
lastParsedParentElement
This string is used to cache the parent element that was just parsed,
after it is removed from the stack.
|
private java.util.Map<java.lang.String,java.lang.String> |
metadata |
private com.fasterxml.jackson.core.JsonToken |
nextToken
A cache of the next token if it has been peeked ahead.
|
private java.util.Stack<JsonUnmarshallerContextImpl.JsonFieldTokenPair> |
stack
A stack of JsonFieldTokenPair objects that indicates the current state of the context.
|
private java.util.Map<java.lang.Class<?>,Unmarshaller<?,JsonUnmarshallerContext>> |
unmarshallerMap |
Constructor and Description |
---|
JsonUnmarshallerContextImpl(com.fasterxml.jackson.core.JsonParser jsonParser,
java.util.Map<java.lang.Class<?>,Unmarshaller<?,JsonUnmarshallerContext>> mapper,
HttpResponse httpResponse) |
Modifier and Type | Method and Description |
---|---|
int |
getCurrentDepth()
Returns the element depth of the parser's current position in the JSON
document being parsed.
|
java.lang.String |
getCurrentParentElement()
Returns the name of the JSON field that is the nearest parent of the
current context.Returns null by default.
|
com.fasterxml.jackson.core.JsonToken |
getCurrentToken()
Returns the current JsonToken that is to be parsed by the parser.
|
java.lang.String |
getHeader(java.lang.String header)
Returns the value of the header with the specified name from the
response, or null if not present.
|
HttpResponse |
getHttpResponse()
Returns the original HttpResponse constructed for this request.
|
com.fasterxml.jackson.core.JsonParser |
getJsonParser()
Returns the JsonParser used for parsing the Json document.
|
java.lang.String |
getLastParsedParentElement()
This will return the deleted string in stackString when doing update on
the stack.
|
java.util.Map<java.lang.String,java.lang.String> |
getMetadata()
Returns any metadata collected through metadata expressions while this
context was reading the JSON events from the JSON document.
|
<T> Unmarshaller<T,JsonUnmarshallerContext> |
getUnmarshaller(java.lang.Class<T> type)
Returns the JsonUnmarsheller for the specified scalar type.
|
boolean |
isInsideResponseHeader()
Returns true if the
JsonUnmarshallerContext is involved in
parsing response headers. |
boolean |
isStartOfDocument()
Returns true if parsing of the Json document is yet to start.
|
com.fasterxml.jackson.core.JsonToken |
nextToken()
Returns the next JsonToken from the JsonParser.
|
com.fasterxml.jackson.core.JsonToken |
peek()
Returns the JsonToken which is to be parsed next.
|
private java.lang.String |
readCurrentJsonTokenValue() |
java.lang.String |
readText()
Returns the text of the current token, or throws an exception if the
current token does not contain text (ex: '{', '}', etc.).
|
void |
setCurrentHeader(java.lang.String currentHeader)
Sets the name of the response header that is to be read next.
|
boolean |
testExpression(java.lang.String expression)
Tests the specified expression (a JSON field name) against the current
position in the JSON document being parsed.
|
boolean |
testExpression(java.lang.String expression,
int stackDepth)
Tests the specified expression (a JSON field name) against the current
position in the JSON document being parsed, and restricts the expression
to matching at the specified stack depth.
|
java.lang.String |
toString() |
private void |
updateContext() |
registerMetadataExpression
private com.fasterxml.jackson.core.JsonToken currentToken
private com.fasterxml.jackson.core.JsonToken nextToken
private final com.fasterxml.jackson.core.JsonParser jsonParser
private java.lang.String currentHeader
private final java.util.Stack<JsonUnmarshallerContextImpl.JsonFieldTokenPair> stack
private java.lang.String currentField
private java.lang.String lastParsedParentElement
private java.util.Map<java.lang.String,java.lang.String> metadata
private final HttpResponse httpResponse
private final java.util.Map<java.lang.Class<?>,Unmarshaller<?,JsonUnmarshallerContext>> unmarshallerMap
public JsonUnmarshallerContextImpl(com.fasterxml.jackson.core.JsonParser jsonParser, java.util.Map<java.lang.Class<?>,Unmarshaller<?,JsonUnmarshallerContext>> mapper, HttpResponse httpResponse)
public java.lang.String getHeader(java.lang.String header)
JsonUnmarshallerContext
getHeader
in class JsonUnmarshallerContext
header
- The name of the header to lookup.public HttpResponse getHttpResponse()
JsonUnmarshallerContext
getHttpResponse
in class JsonUnmarshallerContext
public int getCurrentDepth()
JsonUnmarshallerContext
getCurrentDepth
in class JsonUnmarshallerContext
public java.lang.String readText() throws java.io.IOException
JsonUnmarshallerContext
readText
in class JsonUnmarshallerContext
java.io.IOException
private java.lang.String readCurrentJsonTokenValue() throws java.io.IOException
java.io.IOException
public boolean isInsideResponseHeader()
JsonUnmarshallerContext
JsonUnmarshallerContext
is involved in
parsing response headers. Else returns false. Returns true by default.isInsideResponseHeader
in class JsonUnmarshallerContext
public boolean isStartOfDocument()
JsonUnmarshallerContext
isStartOfDocument
in class JsonUnmarshallerContext
public boolean testExpression(java.lang.String expression)
JsonUnmarshallerContext
testExpression
in class JsonUnmarshallerContext
expression
- The field name to test.public java.lang.String getCurrentParentElement()
JsonUnmarshallerContext
getCurrentParentElement
in class JsonUnmarshallerContext
public boolean testExpression(java.lang.String expression, int stackDepth)
JsonUnmarshallerContext
testExpression
in class JsonUnmarshallerContext
expression
- The field name to test.stackDepth
- The depth in the stack representing where the expression must
start matching in order for this method to return true.public com.fasterxml.jackson.core.JsonToken nextToken() throws java.io.IOException
JsonUnmarshallerContext
nextToken
in class JsonUnmarshallerContext
java.io.IOException
public com.fasterxml.jackson.core.JsonToken peek() throws java.io.IOException
JsonUnmarshallerContext
peek
in class JsonUnmarshallerContext
java.io.IOException
public com.fasterxml.jackson.core.JsonParser getJsonParser()
JsonUnmarshallerContext
getJsonParser
in class JsonUnmarshallerContext
public java.util.Map<java.lang.String,java.lang.String> getMetadata()
JsonUnmarshallerContext
getMetadata
in class JsonUnmarshallerContext
public void setCurrentHeader(java.lang.String currentHeader)
JsonUnmarshallerContext
setCurrentHeader
in class JsonUnmarshallerContext
public <T> Unmarshaller<T,JsonUnmarshallerContext> getUnmarshaller(java.lang.Class<T> type)
JsonUnmarshallerContext
getUnmarshaller
in class JsonUnmarshallerContext
public com.fasterxml.jackson.core.JsonToken getCurrentToken()
JsonUnmarshallerContext
getCurrentToken
in class JsonUnmarshallerContext
private void updateContext() throws java.io.IOException
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getLastParsedParentElement()
JsonUnmarshallerContext
getLastParsedParentElement
in class JsonUnmarshallerContext