Package co.nstant.in.cbor

## Class CborDecoder

- java.lang.Object
- - co.nstant.in.cbor.CborDecoder

-     public class CborDecoder
      extends Object

  Decoder for the CBOR format based.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `CborDecoder​(InputStream inputStream)` | Initialize a new decoder which reads the binary encoded data from an `OutputStream`.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `List<DataItem>` | `decode()` | Decode the `InputStream` to a list of `DataItem`s.
    `static List<DataItem>` | `decode​(byte[] bytes)` | Convenience method to decode a byte array directly.
    `void` | `decode​(DataItemListener dataItemListener)` | Streaming decoding of an input stream.
    `DataItem` | `decodeNext()` | Decodes exactly one DataItem from the input stream.
    `boolean` | `isAutoDecodeInfinitiveArrays()` |
    `boolean` | `isAutoDecodeInfinitiveByteStrings()` |
    `boolean` | `isAutoDecodeInfinitiveMaps()` |
    `boolean` | `isAutoDecodeInfinitiveUnicodeStrings()` |
    `boolean` | `isAutoDecodeLanguageTaggedStrings()` |
    `boolean` | `isAutoDecodeRationalNumbers()` |
    `boolean` | `isRejectDuplicateKeys()` |
    `void` | `setAutoDecodeInfinitiveArrays​(boolean autoDecodeInfinitiveArrays)` |
    `void` | `setAutoDecodeInfinitiveByteStrings​(boolean autoDecodeInfinitiveByteStrings)` |
    `void` | `setAutoDecodeInfinitiveMaps​(boolean autoDecodeInfinitiveMaps)` |
    `void` | `setAutoDecodeInfinitiveUnicodeStrings​(boolean autoDecodeInfinitiveUnicodeStrings)` |
    `void` | `setAutoDecodeLanguageTaggedStrings​(boolean autoDecodeLanguageTaggedStrings)` |
    `void` | `setAutoDecodeRationalNumbers​(boolean autoDecodeRationalNumbers)` |
    `void` | `setMaxPreallocationSize​(int maxSize)` | Sets the given amount of bytes as maximum preallocation limit for arrays in all decoders.
    `void` | `setRejectDuplicateKeys​(boolean rejectDuplicateKeys)` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### CborDecoder

          public CborDecoder​(InputStream inputStream)

      Initialize a new decoder which reads the binary encoded data from an `OutputStream`.
      Parameters:
        `inputStream` - the `OutputStream` to read the data from

  - ### Method Detail

    - #### decode

          public static List<DataItem> decode​(byte[] bytes)
                                       throws CborException

      Convenience method to decode a byte array directly.
      Parameters:
        `bytes` - the CBOR encoded data
      Returns:
        a list of `DataItem`s
      Throws:
        `CborException` - if decoding failed

    - #### decode

          public List<DataItem> decode()
                                throws CborException

      Decode the `InputStream` to a list of `DataItem`s.
      Returns:
        the list of `DataItem`s
      Throws:
        `CborException` - if decoding failed

    - #### decode

          public void decode​(DataItemListener dataItemListener)
                      throws CborException

      Streaming decoding of an input stream. On each decoded DataItem, the callback listener is invoked.
      Parameters:
        `dataItemListener` - the callback listener
      Throws:
        `CborException` - if decoding failed

    - #### decodeNext

          public DataItem decodeNext()
                              throws CborException

      Decodes exactly one DataItem from the input stream.
      Returns:
        a `DataItem` or null if end of stream has reached.
      Throws:
        `CborException` - if decoding failed

    - #### isAutoDecodeInfinitiveArrays

          public boolean isAutoDecodeInfinitiveArrays()

    - #### setAutoDecodeInfinitiveArrays

          public void setAutoDecodeInfinitiveArrays​(boolean autoDecodeInfinitiveArrays)

    - #### isAutoDecodeInfinitiveMaps

          public boolean isAutoDecodeInfinitiveMaps()

    - #### setAutoDecodeInfinitiveMaps

          public void setAutoDecodeInfinitiveMaps​(boolean autoDecodeInfinitiveMaps)

    - #### isAutoDecodeInfinitiveByteStrings

          public boolean isAutoDecodeInfinitiveByteStrings()

    - #### setAutoDecodeInfinitiveByteStrings

          public void setAutoDecodeInfinitiveByteStrings​(boolean autoDecodeInfinitiveByteStrings)

    - #### isAutoDecodeInfinitiveUnicodeStrings

          public boolean isAutoDecodeInfinitiveUnicodeStrings()

    - #### setAutoDecodeInfinitiveUnicodeStrings

          public void setAutoDecodeInfinitiveUnicodeStrings​(boolean autoDecodeInfinitiveUnicodeStrings)

    - #### isAutoDecodeRationalNumbers

          public boolean isAutoDecodeRationalNumbers()

    - #### setAutoDecodeRationalNumbers

          public void setAutoDecodeRationalNumbers​(boolean autoDecodeRationalNumbers)

    - #### isAutoDecodeLanguageTaggedStrings

          public boolean isAutoDecodeLanguageTaggedStrings()

    - #### setAutoDecodeLanguageTaggedStrings

          public void setAutoDecodeLanguageTaggedStrings​(boolean autoDecodeLanguageTaggedStrings)

    - #### isRejectDuplicateKeys

          public boolean isRejectDuplicateKeys()

    - #### setRejectDuplicateKeys

          public void setRejectDuplicateKeys​(boolean rejectDuplicateKeys)

    - #### setMaxPreallocationSize

          public void setMaxPreallocationSize​(int maxSize)

      Sets the given amount of bytes as maximum preallocation limit for arrays in all decoders. This prevents OutOfMemory exceptions on malicious CBOR with forged fixed length items. Note that items may exceed the given size when the decoded data actually contains much data. This may be limited by using a limiting stream.
      Parameters:
        `maxSize` - Maximum number of bytes to preallocate in array-based items. Set to 0 to disable.