Class CborDecoder


  • public class CborDecoder
    extends Object
    Decoder for the CBOR format based.
    • 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 DataItems
        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.