Class AbstractXContentParser
java.lang.Object
org.elasticsearch.common.xcontent.support.AbstractXContentParser
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,XContentParser
- Direct Known Subclasses:
JsonXContentParser,MapXContentParser
public abstract class AbstractXContentParser extends java.lang.Object implements XContentParser
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.XContentParser
XContentParser.NumberType, XContentParser.Token -
Field Summary
Fields Modifier and Type Field Description static booleanDEFAULT_NUMBER_COERCE_POLICY -
Constructor Summary
Constructors Constructor Description AbstractXContentParser(NamedXContentRegistry xContentRegistry, DeprecationHandler deprecationHandler) -
Method Summary
Modifier and Type Method Description booleanbooleanValue()java.nio.CharBuffercharBufferOrNull()protected abstract booleandoBooleanValue()protected abstract doubledoDoubleValue()protected abstract floatdoFloatValue()protected abstract intdoIntValue()protected abstract longdoLongValue()protected abstract shortdoShortValue()doubledoubleValue()doubledoubleValue(boolean coerce)floatfloatValue()floatfloatValue(boolean coerce)DeprecationHandlergetDeprecationHandler()The callback to notify when parsing encounters a deprecated field.NamedXContentRegistrygetXContentRegistry()The registry used to resolveXContentParser.namedObject(Class, String, Object).intintValue()intintValue(boolean coerce)booleanisBooleanValue()abstract 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()<T> java.util.Map<java.lang.String,T>map(java.util.function.Supplier<java.util.Map<java.lang.String,T>> mapFactory, org.elasticsearch.common.CheckedFunction<XContentParser,T,java.io.IOException> mapValueParser)Returns an instance ofMapholding parsed map.java.util.Map<java.lang.String,java.lang.Object>mapOrdered()java.util.Map<java.lang.String,java.lang.String>mapStrings()<T> TnamedObject(java.lang.Class<T> categoryClass, java.lang.String name, java.lang.Object context)Parse an object by name.static java.lang.ObjectreadValue(XContentParser parser, java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.Object>> mapFactory)shortshortValue()shortshortValue(boolean coerce)java.lang.StringtextOrNull()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.io.Closeable
closeMethods inherited from interface org.elasticsearch.common.xcontent.XContentParser
binaryValue, charBuffer, contentType, currentName, currentToken, getTokenLocation, hasTextCharacters, nextToken, numberType, numberValue, objectBytes, objectText, skipChildren, text, textCharacters, textLength, textOffset
-
Field Details
-
DEFAULT_NUMBER_COERCE_POLICY
public static final boolean DEFAULT_NUMBER_COERCE_POLICY- See Also:
- Constant Field Values
-
-
Constructor Details
-
AbstractXContentParser
public AbstractXContentParser(NamedXContentRegistry xContentRegistry, DeprecationHandler deprecationHandler)
-
-
Method Details
-
isBooleanValue
public boolean isBooleanValue() throws java.io.IOException- Specified by:
isBooleanValuein interfaceXContentParser- Returns:
- true iff the current value is either boolean (
trueorfalse) or one of "false", "true". - Throws:
java.io.IOException
-
booleanValue
public boolean booleanValue() throws java.io.IOException- Specified by:
booleanValuein interfaceXContentParser- Throws:
java.io.IOException
-
doBooleanValue
protected abstract boolean doBooleanValue() throws java.io.IOException- Throws:
java.io.IOException
-
shortValue
public short shortValue() throws java.io.IOException- Specified by:
shortValuein interfaceXContentParser- Throws:
java.io.IOException
-
shortValue
public short shortValue(boolean coerce) throws java.io.IOException- Specified by:
shortValuein interfaceXContentParser- Throws:
java.io.IOException
-
doShortValue
protected abstract short doShortValue() throws java.io.IOException- Throws:
java.io.IOException
-
intValue
public int intValue() throws java.io.IOException- Specified by:
intValuein interfaceXContentParser- Throws:
java.io.IOException
-
intValue
public int intValue(boolean coerce) throws java.io.IOException- Specified by:
intValuein interfaceXContentParser- Throws:
java.io.IOException
-
doIntValue
protected abstract int doIntValue() throws java.io.IOException- Throws:
java.io.IOException
-
longValue
public long longValue() throws java.io.IOException- Specified by:
longValuein interfaceXContentParser- Throws:
java.io.IOException
-
longValue
public long longValue(boolean coerce) throws java.io.IOException- Specified by:
longValuein interfaceXContentParser- Throws:
java.io.IOException
-
doLongValue
protected abstract long doLongValue() throws java.io.IOException- Throws:
java.io.IOException
-
floatValue
public float floatValue() throws java.io.IOException- Specified by:
floatValuein interfaceXContentParser- Throws:
java.io.IOException
-
floatValue
public float floatValue(boolean coerce) throws java.io.IOException- Specified by:
floatValuein interfaceXContentParser- Throws:
java.io.IOException
-
doFloatValue
protected abstract float doFloatValue() throws java.io.IOException- Throws:
java.io.IOException
-
doubleValue
public double doubleValue() throws java.io.IOException- Specified by:
doubleValuein interfaceXContentParser- Throws:
java.io.IOException
-
doubleValue
public double doubleValue(boolean coerce) throws java.io.IOException- Specified by:
doubleValuein interfaceXContentParser- Throws:
java.io.IOException
-
doDoubleValue
protected abstract double doDoubleValue() throws java.io.IOException- Throws:
java.io.IOException
-
textOrNull
public final java.lang.String textOrNull() throws java.io.IOException- Specified by:
textOrNullin interfaceXContentParser- Throws:
java.io.IOException
-
charBufferOrNull
public java.nio.CharBuffer charBufferOrNull() throws java.io.IOException- Specified by:
charBufferOrNullin interfaceXContentParser- Throws:
java.io.IOException
-
map
public java.util.Map<java.lang.String,java.lang.Object> map() throws java.io.IOException- Specified by:
mapin interfaceXContentParser- Throws:
java.io.IOException
-
mapOrdered
public java.util.Map<java.lang.String,java.lang.Object> mapOrdered() throws java.io.IOException- Specified by:
mapOrderedin interfaceXContentParser- Throws:
java.io.IOException
-
mapStrings
public java.util.Map<java.lang.String,java.lang.String> mapStrings() throws java.io.IOException- Specified by:
mapStringsin interfaceXContentParser- Throws:
java.io.IOException
-
map
public <T> java.util.Map<java.lang.String,T> map(java.util.function.Supplier<java.util.Map<java.lang.String,T>> mapFactory, org.elasticsearch.common.CheckedFunction<XContentParser,T,java.io.IOException> mapValueParser) throws java.io.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:
java.io.IOException
-
list
public java.util.List<java.lang.Object> list() throws java.io.IOException- Specified by:
listin interfaceXContentParser- Throws:
java.io.IOException
-
listOrderedMap
public java.util.List<java.lang.Object> listOrderedMap() throws java.io.IOException- Specified by:
listOrderedMapin interfaceXContentParser- Throws:
java.io.IOException
-
readValue
public static java.lang.Object readValue(XContentParser parser, java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.Object>> mapFactory) throws java.io.IOException- Throws:
java.io.IOException
-
namedObject
public <T> T namedObject(java.lang.Class<T> categoryClass, java.lang.String name, java.lang.Object context) throws java.io.IOExceptionDescription copied from interface:XContentParserParse an object by name.- Specified by:
namedObjectin interfaceXContentParser- Throws:
java.io.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 abstract 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
-