Class XContentSubParser
java.lang.Object
org.elasticsearch.common.xcontent.XContentSubParser
- All Implemented Interfaces:
Closeable,AutoCloseable,XContentParser
Wrapper for a XContentParser that makes a single object/array look like a complete document.
The wrapper prevents the parsing logic to consume tokens outside of the wrapped object as well
as skipping to the end of the object in case of a parsing error. The wrapper is intended to be
used for parsing objects that should be ignored if they are malformed.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.XContentParser
XContentParser.NumberType, XContentParser.Token -
Constructor Summary
Constructors -
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.voidclose()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 resolveXContentParser.namedObject(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, org.elasticsearch.core.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.shortshortshortValue(boolean coerce)voidtext()char[]intint
-
Constructor Details
-
XContentSubParser
-
-
Method Details
-
contentType
- Specified by:
contentTypein interfaceXContentParser
-
allowDuplicateKeys
public void allowDuplicateKeys(boolean allowDuplicateKeys)- Specified by:
allowDuplicateKeysin interfaceXContentParser
-
nextToken
- Specified by:
nextTokenin interfaceXContentParser- Throws:
IOException
-
skipChildren
- Specified by:
skipChildrenin interfaceXContentParser- Throws:
IOException
-
currentToken
- Specified by:
currentTokenin interfaceXContentParser
-
currentName
- Specified by:
currentNamein interfaceXContentParser- Throws:
IOException
-
map
- Specified by:
mapin interfaceXContentParser- Throws:
IOException
-
mapOrdered
- Specified by:
mapOrderedin interfaceXContentParser- Throws:
IOException
-
mapStrings
- Specified by:
mapStringsin interfaceXContentParser- Throws:
IOException
-
map
public <T> Map<String,T> map(Supplier<Map<String,T>> mapFactory, org.elasticsearch.core.CheckedFunction<XContentParser,T,IOException> mapValueParser) throws IOExceptionDescription copied from interface:XContentParserReturns an instance ofMapholding parsed map. Serves as a replacement for the "map", "mapOrdered" and "mapStrings" methods above.- Specified by:
mapin interfaceXContentParser- Type Parameters:
T- map value type- Parameters:
mapFactory- factory for creating newMapobjectsmapValueParser- parser for parsing a single map value- Returns:
Mapobject- Throws:
IOException
-
list
- Specified by:
listin interfaceXContentParser- Throws:
IOException
-
listOrderedMap
- Specified by:
listOrderedMapin interfaceXContentParser- Throws:
IOException
-
text
- Specified by:
textin interfaceXContentParser- Throws:
IOException
-
textOrNull
- Specified by:
textOrNullin interfaceXContentParser- Throws:
IOException
-
charBufferOrNull
- Specified by:
charBufferOrNullin interfaceXContentParser- Throws:
IOException
-
charBuffer
Description copied from interface:XContentParserReturns aCharBufferholding UTF-8 bytes. This method should be used to read text only binary content should be read throughXContentParser.binaryValue()- Specified by:
charBufferin interfaceXContentParser- Throws:
IOException
-
objectText
- Specified by:
objectTextin interfaceXContentParser- Throws:
IOException
-
objectBytes
- Specified by:
objectBytesin interfaceXContentParser- Throws:
IOException
-
hasTextCharacters
public boolean hasTextCharacters()Description copied from interface:XContentParserMethod 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.- Specified by:
hasTextCharactersin interfaceXContentParser
-
textCharacters
- Specified by:
textCharactersin interfaceXContentParser- Throws:
IOException
-
textLength
- Specified by:
textLengthin interfaceXContentParser- Throws:
IOException
-
textOffset
- Specified by:
textOffsetin interfaceXContentParser- Throws:
IOException
-
numberValue
- Specified by:
numberValuein interfaceXContentParser- Throws:
IOException
-
numberType
- Specified by:
numberTypein interfaceXContentParser- Throws:
IOException
-
shortValue
- Specified by:
shortValuein interfaceXContentParser- Throws:
IOException
-
intValue
- Specified by:
intValuein interfaceXContentParser- Throws:
IOException
-
longValue
- Specified by:
longValuein interfaceXContentParser- Throws:
IOException
-
floatValue
- Specified by:
floatValuein interfaceXContentParser- Throws:
IOException
-
doubleValue
- Specified by:
doubleValuein interfaceXContentParser- Throws:
IOException
-
shortValue
- Specified by:
shortValuein interfaceXContentParser- Throws:
IOException
-
intValue
- Specified by:
intValuein interfaceXContentParser- Throws:
IOException
-
longValue
- Specified by:
longValuein interfaceXContentParser- Throws:
IOException
-
floatValue
- Specified by:
floatValuein interfaceXContentParser- Throws:
IOException
-
doubleValue
- Specified by:
doubleValuein interfaceXContentParser- Throws:
IOException
-
isBooleanValue
- Specified by:
isBooleanValuein interfaceXContentParser- Returns:
- true iff the current value is either boolean (
trueorfalse) or one of "false", "true". - Throws:
IOException
-
booleanValue
- Specified by:
booleanValuein interfaceXContentParser- Throws:
IOException
-
binaryValue
Description copied from interface:XContentParserReads 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:- Specified by:
binaryValuein interfaceXContentParser- Throws:
IOException
-
getTokenLocation
Description copied from interface:XContentParserUsed for error reporting to highlight where syntax errors occur in content being parsed.- Specified by:
getTokenLocationin interfaceXContentParser- Returns:
- last token's location or null if cannot be determined
-
namedObject
Description copied from interface:XContentParserParse an object by name.- Specified by:
namedObjectin interfaceXContentParser- Throws:
IOException
-
getXContentRegistry
Description copied from interface:XContentParserThe registry used to resolveXContentParser.namedObject(Class, String, Object). Use this when building a sub-parser from this parser.- Specified by:
getXContentRegistryin interfaceXContentParser
-
isClosed
public boolean isClosed()- Specified by:
isClosedin interfaceXContentParser
-
getDeprecationHandler
Description copied from interface:XContentParserThe callback to notify when parsing encounters a deprecated field.- Specified by:
getDeprecationHandlerin interfaceXContentParser
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-