public final class XContentParserUtils
extends java.lang.Object
XContentParser.Token
from XContentParser
while checking for their types and throw ParsingException
if needed.Modifier and Type | Method and Description |
---|---|
static void |
ensureExpectedToken(XContentParser.Token expected,
XContentParser.Token actual,
java.util.function.Supplier<XContentLocation> location)
Makes sure that provided token is of the expected type
|
static void |
ensureFieldName(XContentParser parser,
XContentParser.Token token,
java.lang.String fieldName)
Makes sure that current token is of type
XContentParser.Token.FIELD_NAME and the the field name is equal to the provided one |
static java.lang.Object |
parseStoredFieldsValue(XContentParser parser)
Parse the current token depending on its token type.
|
static void |
throwUnknownField(java.lang.String field,
XContentLocation location) |
static void |
throwUnknownToken(XContentParser.Token token,
XContentLocation location) |
public static void ensureFieldName(XContentParser parser, XContentParser.Token token, java.lang.String fieldName) throws java.io.IOException
XContentParser.Token.FIELD_NAME
and the the field name is equal to the provided oneParsingException
- if the token is not of type XContentParser.Token.FIELD_NAME
or is not equal to the given field namejava.io.IOException
public static void throwUnknownField(java.lang.String field, XContentLocation location)
ParsingException
- with a "unknown field found" reasonpublic static void throwUnknownToken(XContentParser.Token token, XContentLocation location)
ParsingException
- with a "unknown token found" reasonpublic static void ensureExpectedToken(XContentParser.Token expected, XContentParser.Token actual, java.util.function.Supplier<XContentLocation> location)
ParsingException
- if the token is not equal to the expected typepublic static java.lang.Object parseStoredFieldsValue(XContentParser parser) throws java.io.IOException
ParsingException
- if the token none of the allowed valuesjava.io.IOException