- All Superinterfaces:
AutoCloseable
,Closeable
- All Known Implementing Classes:
AbstractXContentParser
,CopyingXContentParser
,FilterXContentParser
,FilterXContentParserWrapper
,FlatteningXContentParser
,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 enum
static enum
-
Method Summary
Modifier and TypeMethodDescriptionvoid
allowDuplicateKeys
(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 theirString
variants of the separated value methods.boolean
Returns aCharBuffer
holding UTF-8 bytes.double
double
doubleValue
(boolean coerce) float
float
floatValue
(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)
.boolean
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.int
intValue()
int
intValue
(boolean coerce) boolean
boolean
isClosed()
list()
long
long
longValue
(boolean coerce) map()
map
(Supplier<Map<String, T>> mapFactory, CheckedFunction<XContentParser, T, IOException> mapValueParser) Returns an instance ofMap
holding parsed map.<T> T
namedObject
(Class<T> categoryClass, String name, Object context) Parse an object by name.default String
short
short
shortValue
(boolean coerce) void
text()
char[]
int
int
-
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 ofMap
holding 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 newMap
objectsmapValueParser
- parser for parsing a single map value- Returns:
Map
object- Throws:
IOException
-
list
- Throws:
IOException
-
listOrderedMap
- Throws:
IOException
-
text
- Throws:
IOException
-
textOrNull
- Throws:
IOException
-
charBufferOrNull
- Throws:
IOException
-
charBuffer
Returns aCharBuffer
holding 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 (
true
orfalse
) 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 theirString
variants 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.
-