Bug: 146355411

Clone this repo:
  1. 00c4a38 [LSC] Add LOCAL_LICENSE_KINDS to external/cbor-java am: 86e50693d2 am: 4338ccf80f am: 9fbf4dec33 by Bob Badour · 12 months ago android-s-v2-preview-1 android12--mainline-release android12-dev android12-qpr1-d-release android12-qpr1-d-s1-release android12-qpr1-d-s2-release android12-qpr1-d-s3-release android12-qpr1-release master android-12.0.0_r16 android-12.0.0_r18 android-12.0.0_r19 android-12.0.0_r20 android-12.0.0_r21 android-12.0.0_r26 android-12.0.0_r27 android-mainline-12.0.0_r4 android-s-v2-beta-2 android-s-v2-preview-2
  2. 9fbf4de [LSC] Add LOCAL_LICENSE_KINDS to external/cbor-java am: 86e50693d2 am: 4338ccf80f by Bob Badour · 12 months ago
  3. 4338ccf [LSC] Add LOCAL_LICENSE_KINDS to external/cbor-java am: 86e50693d2 by Bob Badour · 12 months ago android-s-beta-4 android-s-beta-5 android-s-beta-1 android-s-beta-2 android-s-beta-3
  4. 86e5069 [LSC] Add LOCAL_LICENSE_KINDS to external/cbor-java by Bob Badour · 12 months ago android-s-preview-1
  5. 6fe119c [automerger skipped] DO NOT MERGE - Empty merge qt-qpr1-dev-plus-aosp into stag-aosp-master am: 3d7fde33f9 -s ours am: b9fa2d4216 am: 035e7b349e am: 8f62076b7b -s ours by Xin Li · 1 year, 10 months ago

cbor-java

A Java 7 implementation of RFC 7049: Concise Binary Object Representation (CBOR)

Build Status Coverage Status Coverity Scan Build Status Dependency Status

Features

  • Encodes and decodes all examples described in RFC 7049
  • Provides a fluent interface builder for CBOR messages
  • Supports semantic tags
  • Supports 64-bit integer values
  • Passes all CPD, PMD and FindBugs tests

Documentation

Maven Dependency

Add this to the dependencies section of your pom.xml file:

<dependency>
    <groupId>co.nstant.in</groupId>
    <artifactId>cbor</artifactId>
    <version>0.8</version>
</dependency>

Usage

Encoding Example

ByteArrayOutputStream baos = new ByteArrayOutputStream();
new CborEncoder(baos).encode(new CborBuilder()
    .add("text")                // add string
    .add(1234)                  // add integer
    .add(new byte[] { 0x10 })   // add byte array
    .addArray()                 // add array
        .add(1)
        .add("text")
        .end()
    .build());
byte[] encodedBytes = baos.toByteArray();

Decoding Example

ByteArrayInputStream bais = new ByteArrayInputStream(encodedBytes);
List<DataItem> dataItems = new CborDecoder(bais).decode();
for(DataItem dataItem : dataItems) {
    // process data item
}

Streaming Decoding Example

ByteArrayInputStream bais = new ByteArrayInputStream(encodedBytes);
new CborDecoder(bais).decode(new DataItemListener() {

    @Override
    public void onDataItem(DataItem dataItem) {
        // process data item
    }

});

Contribution Process

This project uses the C4 process for all code changes.

License

Copyright 2013-2017 Constantin Rack

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.