Interface XContentParser
-
- All Superinterfaces:
java.lang.AutoCloseable,java.io.Closeable
- All Known Implementing Classes:
AbstractXContentParser,CborXContentParser,JsonXContentParser,SmileXContentParser,XContentSubParser,YamlXContentParser
public interface XContentParser extends java.io.CloseableInterface for pull - parsingXContentseeXContentTypefor 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 Classes Modifier and Type Interface Description static classXContentParser.NumberTypestatic classXContentParser.Token
-
Method Summary
Modifier and Type Method Description byte[]binaryValue()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.booleanbooleanValue()booleanbooleanValueLenient()Deprecated.Just present for providing backwards compatibility.java.nio.CharBuffercharBuffer()Returns aCharBufferholding UTF-8 bytes.java.nio.CharBuffercharBufferOrNull()XContentTypecontentType()java.lang.StringcurrentName()XContentParser.TokencurrentToken()doubledoubleValue()doubledoubleValue(boolean coerce)floatfloatValue()floatfloatValue(boolean coerce)DeprecationHandlergetDeprecationHandler()The callback to notify when parsing encounters a deprecated field.XContentLocationgetTokenLocation()Used for error reporting to highlight where syntax errors occur in content being parsed.NamedXContentRegistrygetXContentRegistry()The registry used to resolvenamedObject(Class, String, Object).booleanhasTextCharacters()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.intintValue()intintValue(boolean coerce)booleanisBooleanValue()booleanisBooleanValueLenient()Deprecated.Just present for providing backwards compatibility.booleanisClosed()java.util.List<java.lang.Object>list()java.util.List<java.lang.Object>listOrderedMap()longlongValue()longlongValue(boolean coerce)java.util.Map<java.lang.String,java.lang.Object>map()java.util.Map<java.lang.String,java.lang.Object>mapOrdered()java.util.Map<java.lang.String,java.lang.String>mapStrings()java.util.Map<java.lang.String,java.lang.String>mapStringsOrdered()<T> TnamedObject(java.lang.Class<T> categoryClass, java.lang.String name, java.lang.Object context)Parse an object by name.XContentParser.TokennextToken()XContentParser.NumberTypenumberType()java.lang.NumbernumberValue()java.lang.ObjectobjectBytes()java.lang.ObjectobjectText()shortshortValue()shortshortValue(boolean coerce)voidskipChildren()java.lang.Stringtext()char[]textCharacters()inttextLength()inttextOffset()java.lang.StringtextOrNull()
-
-
-
Method Detail
-
contentType
XContentType contentType()
-
nextToken
XContentParser.Token nextToken() throws java.io.IOException
- Throws:
java.io.IOException
-
skipChildren
void skipChildren() throws java.io.IOException- Throws:
java.io.IOException
-
currentToken
XContentParser.Token currentToken()
-
currentName
java.lang.String currentName() throws java.io.IOException- Throws:
java.io.IOException
-
map
java.util.Map<java.lang.String,java.lang.Object> map() throws java.io.IOException- Throws:
java.io.IOException
-
mapOrdered
java.util.Map<java.lang.String,java.lang.Object> mapOrdered() throws java.io.IOException- Throws:
java.io.IOException
-
mapStrings
java.util.Map<java.lang.String,java.lang.String> mapStrings() throws java.io.IOException- Throws:
java.io.IOException
-
mapStringsOrdered
java.util.Map<java.lang.String,java.lang.String> mapStringsOrdered() throws java.io.IOException- Throws:
java.io.IOException
-
list
java.util.List<java.lang.Object> list() throws java.io.IOException- Throws:
java.io.IOException
-
listOrderedMap
java.util.List<java.lang.Object> listOrderedMap() throws java.io.IOException- Throws:
java.io.IOException
-
text
java.lang.String text() throws java.io.IOException- Throws:
java.io.IOException
-
textOrNull
java.lang.String textOrNull() throws java.io.IOException- Throws:
java.io.IOException
-
charBufferOrNull
java.nio.CharBuffer charBufferOrNull() throws java.io.IOException- Throws:
java.io.IOException
-
charBuffer
java.nio.CharBuffer charBuffer() throws java.io.IOExceptionReturns aCharBufferholding UTF-8 bytes. This method should be used to read text only binary content should be read throughbinaryValue()- Throws:
java.io.IOException
-
objectText
java.lang.Object objectText() throws java.io.IOException- Throws:
java.io.IOException
-
objectBytes
java.lang.Object objectBytes() throws java.io.IOException- Throws:
java.io.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
char[] textCharacters() throws java.io.IOException- Throws:
java.io.IOException
-
textLength
int textLength() throws java.io.IOException- Throws:
java.io.IOException
-
textOffset
int textOffset() throws java.io.IOException- Throws:
java.io.IOException
-
numberValue
java.lang.Number numberValue() throws java.io.IOException- Throws:
java.io.IOException
-
numberType
XContentParser.NumberType numberType() throws java.io.IOException
- Throws:
java.io.IOException
-
shortValue
short shortValue(boolean coerce) throws java.io.IOException- Throws:
java.io.IOException
-
intValue
int intValue(boolean coerce) throws java.io.IOException- Throws:
java.io.IOException
-
longValue
long longValue(boolean coerce) throws java.io.IOException- Throws:
java.io.IOException
-
floatValue
float floatValue(boolean coerce) throws java.io.IOException- Throws:
java.io.IOException
-
doubleValue
double doubleValue(boolean coerce) throws java.io.IOException- Throws:
java.io.IOException
-
shortValue
short shortValue() throws java.io.IOException- Throws:
java.io.IOException
-
intValue
int intValue() throws java.io.IOException- Throws:
java.io.IOException
-
longValue
long longValue() throws java.io.IOException- Throws:
java.io.IOException
-
floatValue
float floatValue() throws java.io.IOException- Throws:
java.io.IOException
-
doubleValue
double doubleValue() throws java.io.IOException- Throws:
java.io.IOException
-
isBooleanValue
boolean isBooleanValue() throws java.io.IOException- Returns:
- true iff the current value is either boolean (
trueorfalse) or one of "false", "true". - Throws:
java.io.IOException
-
booleanValue
boolean booleanValue() throws java.io.IOException- Throws:
java.io.IOException
-
isBooleanValueLenient
@Deprecated boolean isBooleanValueLenient() throws java.io.IOExceptionDeprecated.Just present for providing backwards compatibility. UseisBooleanValue()instead.returns true if the current value is boolean in nature. values that are considered booleans: - boolean value (true/false) - numeric integers (=0 is considered as false, !=0 is true) - one of the following strings: "true","false","on","off","yes","no","1","0"- Throws:
java.io.IOException
-
booleanValueLenient
@Deprecated boolean booleanValueLenient() throws java.io.IOExceptionDeprecated.Just present for providing backwards compatibility. UsebooleanValue()instead.- Throws:
java.io.IOException
-
binaryValue
byte[] binaryValue() throws java.io.IOExceptionReads 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:
java.io.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
<T> T namedObject(java.lang.Class<T> categoryClass, java.lang.String name, java.lang.Object context) throws java.io.IOExceptionParse an object by name.- Throws:
java.io.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()
-
getDeprecationHandler
DeprecationHandler getDeprecationHandler()
The callback to notify when parsing encounters a deprecated field.
-
-