- All Superinterfaces:
AutoCloseable,Closeable
- All Known Implementing Classes:
AbstractXContentParser,FilterXContentParser,FilterXContentParserWrapper,MapXContentParser,XContentSubParser
Interface for pull - parsing
XContent see XContentType for supported types.
To obtain an instance of this class use the following pattern:
XContentType xContentType = XContentType.JSON;
XContentParser parser = xContentType.xContent().createParser(
NamedXContentRegistry.EMPTY, ParserField."{\"key\" : \"value\"}");
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumstatic enum -
Method Summary
Modifier and TypeMethodDescriptionvoidallowDuplicateKeys(boolean allowDuplicateKeys) byte[]Reads a plain binary value that was written via one of the following methods:XContentBuilder.field(String, byte[], int, int)}XContentBuilder.field(String, byte[])} as well as via theirStringvariants of the separated value methods.booleanReturns aCharBufferholding UTF-8 bytes.doubledoubledoubleValue(boolean coerce) floatfloatfloatValue(boolean coerce) The callback to notify when parsing encounters a deprecated field.Used for error reporting to highlight where syntax errors occur in content being parsed.The registry used to resolvenamedObject(Class, String, Object).booleanMethod that can be used to determine whether calling of textCharacters() would be the most efficient way to access textual content for the event parser currently points to.intintValue()intintValue(boolean coerce) booleanbooleanisClosed()list()longlonglongValue(boolean coerce) map()map(Supplier<Map<String, T>> mapFactory, CheckedFunction<XContentParser, T, IOException> mapValueParser) Returns an instance ofMapholding parsed map.<T> TnamedObject(Class<T> categoryClass, String name, Object context) Parse an object by name.default StringshortshortshortValue(boolean coerce) voidtext()char[]intint
-
Method Details
-
contentType
XContentType contentType() -
allowDuplicateKeys
void allowDuplicateKeys(boolean allowDuplicateKeys) -
nextToken
- Throws:
IOException
-
nextFieldName
- Throws:
IOException
-
skipChildren
- Throws:
IOException
-
currentToken
XContentParser.Token currentToken() -
currentName
- Throws:
IOException
-
map
- Throws:
IOException
-
mapOrdered
- Throws:
IOException
-
mapStrings
- Throws:
IOException
-
map
<T> Map<String,T> map(Supplier<Map<String, T>> mapFactory, CheckedFunction<XContentParser, throws IOExceptionT, IOException> mapValueParser) Returns an instance ofMapholding parsed map. Serves as a replacement for the "map", "mapOrdered" and "mapStrings" methods above.- Type Parameters:
T- map value type- Parameters:
mapFactory- factory for creating newMapobjectsmapValueParser- parser for parsing a single map value- Returns:
Mapobject- Throws:
IOException
-
list
- Throws:
IOException
-
listOrderedMap
- Throws:
IOException
-
text
- Throws:
IOException
-
textOrNull
- Throws:
IOException
-
charBufferOrNull
- Throws:
IOException
-
charBuffer
Returns aCharBufferholding UTF-8 bytes. This method should be used to read text only binary content should be read throughbinaryValue()- Throws:
IOException
-
objectText
- Throws:
IOException
-
objectBytes
- Throws:
IOException
-
hasTextCharacters
boolean hasTextCharacters()Method that can be used to determine whether calling of textCharacters() would be the most efficient way to access textual content for the event parser currently points to. Default implementation simply returns false since only actual implementation class has knowledge of its internal buffering state. This method shouldn't be used to check if the token contains text or not. -
textCharacters
- Throws:
IOException
-
textLength
- Throws:
IOException
-
textOffset
- Throws:
IOException
-
numberValue
- Throws:
IOException
-
numberType
- Throws:
IOException
-
shortValue
- Throws:
IOException
-
intValue
- Throws:
IOException
-
longValue
- Throws:
IOException
-
floatValue
- Throws:
IOException
-
doubleValue
- Throws:
IOException
-
shortValue
- Throws:
IOException
-
intValue
- Throws:
IOException
-
longValue
- Throws:
IOException
-
floatValue
- Throws:
IOException
-
doubleValue
- Throws:
IOException
-
isBooleanValue
- Returns:
- true iff the current value is either boolean (
trueorfalse) or one of "false", "true". - Throws:
IOException
-
booleanValue
- Throws:
IOException
-
binaryValue
Reads a plain binary value that was written via one of the following methods: as well as via theirStringvariants of the separated value methods. Note: Do not use this method to read values written with: these methods write UTF-8 encoded strings and must be read through:text()()}textOrNull()()}textCharacters()()}}
- Throws:
IOException
-
getTokenLocation
XContentLocation getTokenLocation()Used for error reporting to highlight where syntax errors occur in content being parsed.- Returns:
- last token's location or null if cannot be determined
-
namedObject
Parse an object by name.- Throws:
IOException
-
getXContentRegistry
NamedXContentRegistry getXContentRegistry()The registry used to resolvenamedObject(Class, String, Object). Use this when building a sub-parser from this parser. -
isClosed
boolean isClosed() -
getRestApiVersion
RestApiVersion getRestApiVersion() -
getDeprecationHandler
DeprecationHandler getDeprecationHandler()The callback to notify when parsing encounters a deprecated field.
-