Class XContentSubParser

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, XContentParser

    public class XContentSubParser
    extends java.lang.Object
    implements 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.
    • Constructor Detail

      • XContentSubParser

        public XContentSubParser​(XContentParser parser)
    • Method Detail

      • skipChildren

        public void skipChildren()
                          throws java.io.IOException
        Specified by:
        skipChildren in interface XContentParser
        Throws:
        java.io.IOException
      • currentName

        public java.lang.String currentName()
                                     throws java.io.IOException
        Specified by:
        currentName in interface XContentParser
        Throws:
        java.io.IOException
      • map

        public java.util.Map<java.lang.String,​java.lang.Object> map()
                                                                   throws java.io.IOException
        Specified by:
        map in interface XContentParser
        Throws:
        java.io.IOException
      • mapOrdered

        public java.util.Map<java.lang.String,​java.lang.Object> mapOrdered()
                                                                          throws java.io.IOException
        Specified by:
        mapOrdered in interface XContentParser
        Throws:
        java.io.IOException
      • mapStrings

        public java.util.Map<java.lang.String,​java.lang.String> mapStrings()
                                                                          throws java.io.IOException
        Specified by:
        mapStrings in interface XContentParser
        Throws:
        java.io.IOException
      • mapStringsOrdered

        public java.util.Map<java.lang.String,​java.lang.String> mapStringsOrdered()
                                                                                 throws java.io.IOException
        Specified by:
        mapStringsOrdered in interface XContentParser
        Throws:
        java.io.IOException
      • list

        public java.util.List<java.lang.Object> list()
                                              throws java.io.IOException
        Specified by:
        list in interface XContentParser
        Throws:
        java.io.IOException
      • listOrderedMap

        public java.util.List<java.lang.Object> listOrderedMap()
                                                        throws java.io.IOException
        Specified by:
        listOrderedMap in interface XContentParser
        Throws:
        java.io.IOException
      • text

        public java.lang.String text()
                              throws java.io.IOException
        Specified by:
        text in interface XContentParser
        Throws:
        java.io.IOException
      • textOrNull

        public java.lang.String textOrNull()
                                    throws java.io.IOException
        Specified by:
        textOrNull in interface XContentParser
        Throws:
        java.io.IOException
      • charBufferOrNull

        public java.nio.CharBuffer charBufferOrNull()
                                             throws java.io.IOException
        Specified by:
        charBufferOrNull in interface XContentParser
        Throws:
        java.io.IOException
      • charBuffer

        public java.nio.CharBuffer charBuffer()
                                       throws java.io.IOException
        Description copied from interface: XContentParser
        Returns a CharBuffer holding UTF-8 bytes. This method should be used to read text only binary content should be read through XContentParser.binaryValue()
        Specified by:
        charBuffer in interface XContentParser
        Throws:
        java.io.IOException
      • objectText

        public java.lang.Object objectText()
                                    throws java.io.IOException
        Specified by:
        objectText in interface XContentParser
        Throws:
        java.io.IOException
      • objectBytes

        public java.lang.Object objectBytes()
                                     throws java.io.IOException
        Specified by:
        objectBytes in interface XContentParser
        Throws:
        java.io.IOException
      • hasTextCharacters

        public boolean hasTextCharacters()
        Description copied from interface: XContentParser
        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.
        Specified by:
        hasTextCharacters in interface XContentParser
      • textCharacters

        public char[] textCharacters()
                              throws java.io.IOException
        Specified by:
        textCharacters in interface XContentParser
        Throws:
        java.io.IOException
      • textLength

        public int textLength()
                       throws java.io.IOException
        Specified by:
        textLength in interface XContentParser
        Throws:
        java.io.IOException
      • textOffset

        public int textOffset()
                       throws java.io.IOException
        Specified by:
        textOffset in interface XContentParser
        Throws:
        java.io.IOException
      • numberValue

        public java.lang.Number numberValue()
                                     throws java.io.IOException
        Specified by:
        numberValue in interface XContentParser
        Throws:
        java.io.IOException
      • shortValue

        public short shortValue​(boolean coerce)
                         throws java.io.IOException
        Specified by:
        shortValue in interface XContentParser
        Throws:
        java.io.IOException
      • intValue

        public int intValue​(boolean coerce)
                     throws java.io.IOException
        Specified by:
        intValue in interface XContentParser
        Throws:
        java.io.IOException
      • longValue

        public long longValue​(boolean coerce)
                       throws java.io.IOException
        Specified by:
        longValue in interface XContentParser
        Throws:
        java.io.IOException
      • floatValue

        public float floatValue​(boolean coerce)
                         throws java.io.IOException
        Specified by:
        floatValue in interface XContentParser
        Throws:
        java.io.IOException
      • doubleValue

        public double doubleValue​(boolean coerce)
                           throws java.io.IOException
        Specified by:
        doubleValue in interface XContentParser
        Throws:
        java.io.IOException
      • shortValue

        public short shortValue()
                         throws java.io.IOException
        Specified by:
        shortValue in interface XContentParser
        Throws:
        java.io.IOException
      • intValue

        public int intValue()
                     throws java.io.IOException
        Specified by:
        intValue in interface XContentParser
        Throws:
        java.io.IOException
      • longValue

        public long longValue()
                       throws java.io.IOException
        Specified by:
        longValue in interface XContentParser
        Throws:
        java.io.IOException
      • floatValue

        public float floatValue()
                         throws java.io.IOException
        Specified by:
        floatValue in interface XContentParser
        Throws:
        java.io.IOException
      • doubleValue

        public double doubleValue()
                           throws java.io.IOException
        Specified by:
        doubleValue in interface XContentParser
        Throws:
        java.io.IOException
      • isBooleanValue

        public boolean isBooleanValue()
                               throws java.io.IOException
        Specified by:
        isBooleanValue in interface XContentParser
        Returns:
        true iff the current value is either boolean (true or false) or one of "false", "true".
        Throws:
        java.io.IOException
      • booleanValue

        public boolean booleanValue()
                             throws java.io.IOException
        Specified by:
        booleanValue in interface XContentParser
        Throws:
        java.io.IOException
      • isBooleanValueLenient

        public boolean isBooleanValueLenient()
                                      throws java.io.IOException
        Description copied from interface: XContentParser
        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"
        Specified by:
        isBooleanValueLenient in interface XContentParser
        Throws:
        java.io.IOException
      • booleanValueLenient

        public boolean booleanValueLenient()
                                    throws java.io.IOException
        Specified by:
        booleanValueLenient in interface XContentParser
        Throws:
        java.io.IOException
      • getTokenLocation

        public XContentLocation getTokenLocation()
        Description copied from interface: XContentParser
        Used for error reporting to highlight where syntax errors occur in content being parsed.
        Specified by:
        getTokenLocation in interface XContentParser
        Returns:
        last token's location or null if cannot be determined
      • namedObject

        public <T> T namedObject​(java.lang.Class<T> categoryClass,
                                 java.lang.String name,
                                 java.lang.Object context)
                          throws java.io.IOException
        Description copied from interface: XContentParser
        Parse an object by name.
        Specified by:
        namedObject in interface XContentParser
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException