Class CBORDecoder

java.lang.Object
com.authlete.cbor.CBORDecoder

public class CBORDecoder extends Object
A decoder that receives CBOR tokens (CBORToken) from the CBOR tokenizer (CBORTokenizer) and constructs CBOR data items (CBORItem).
See Also:
  • Constructor Details

    • CBORDecoder

      public CBORDecoder(byte[] input)
      A constructor with a byte array that holds CBOR data items.

      This constructor is an alias of CBORDecoder(input, null).

      Parameters:
      input - A byte array that holds CBOR data items.
    • CBORDecoder

      public CBORDecoder(byte[] input, CBORDecoderOptions options)
      A constructor with a byte array that holds CBOR data items and options to control the behavior of this decoder.

      This constructor is an alias of CBORDecoder(new ByteArrayInputStream(input), options).

      Parameters:
      input - A byte array that holds CBOR data items.
      options - Options to control the behavior of this decoder.
    • CBORDecoder

      public CBORDecoder(byte[] input, int offset, int length)
      A constructor with a byte array that holds CBOR data items.

      This constructor is an alias of CBORDecoder(input, offset, length, null).

      Parameters:
      input - A byte array that holds CBOR data items.
      offset - The offset in the byte array of the first byte to read.
      length - The maximum number of bytes to read from the byte array.
    • CBORDecoder

      public CBORDecoder(byte[] input, int offset, int length, CBORDecoderOptions options)
      A constructor with a byte array that holds CBOR data items and options to control the behavior of this decoder.

      This constructor is an alias of CBORDecoder(new ByteArrayInputStream(input, offset, length), options).

      Parameters:
      input - A byte array that holds CBOR data items.
      offset - The offset in the byte array of the first byte to read.
      length - The maximum number of bytes to read from the byte array.
      options - Options to control the behavior of this decoder.
    • CBORDecoder

      public CBORDecoder(InputStream inputStream)
      A constructor with an input stream to read CBOR data items from.

      This constructor is an alias of CBORDecoder(inputStream, null).

      Parameters:
      inputStream - An input stream to read CBOR data items from.
    • CBORDecoder

      public CBORDecoder(InputStream inputStream, CBORDecoderOptions options)
      A constructor with an input stream to read CBOR data items from and options to control the behavior of this decoder.
      Parameters:
      inputStream - An input stream to read CBOR data items from.
      options - Options to control the behavior of this decoder. If null is given, an instance of CBORDefaultDecoderOptions is created and used.
  • Method Details

    • getOptions

      public CBORDecoderOptions getOptions()
      Get the options for this decoder.
      Returns:
      The options for this decoder.
    • next

      public CBORItem next() throws IOException
      Get the next CBOR data item from the input stream.
      Returns:
      A CBOR data item. When no more CBOR data item is available, null is returned.
      Throws:
      IOException
    • all

      public List<CBORItem> all() throws IOException
      Read all the CBOR data items from the input stream.
      Returns:
      A list of CBOR data items read from the input stream.
      Throws:
      IOException
      Since:
      1.1