• Home
Name Date Size #Lines LOC

..--

src/03-May-2024-8,1556,001

.gitignoreD03-May-202452 76

.travis.ymlD03-May-2024512 1914

Android.bpD03-May-20241.1 KiB4337

LICENSED03-May-202411.1 KiB203169

METADATAD03-May-2024393 1917

README.mdD03-May-20243.1 KiB9971

pom.xmlD03-May-20247.5 KiB261259

README.md

1cbor-java
2=========
3
4A Java 7 implementation of [RFC 7049](http://tools.ietf.org/html/rfc7049): Concise Binary Object Representation ([CBOR](http://cbor.io/))
5
6
7[![Build Status](https://travis-ci.org/c-rack/cbor-java.svg?branch=master)](https://travis-ci.org/c-rack/cbor-java)
8[![Coverage Status](https://coveralls.io/repos/c-rack/cbor-java/badge.svg?branch=master&service=github)](https://coveralls.io/github/c-rack/cbor-java?branch=master)
9[![Coverity Scan Build Status](https://scan.coverity.com/projects/1218/badge.svg)](https://scan.coverity.com/projects/1218)
10[![Dependency Status](https://www.versioneye.com/user/projects/555e2fb6634daa30fb000ea0/badge.svg?style=flat)](https://www.versioneye.com/user/projects/555e2fb6634daa30fb000ea0)
11
12
13## Features
14
15* Encodes and decodes **all examples** described in RFC 7049
16* Provides a **fluent interface builder** for CBOR messages
17* Supports semantic tags
18* Supports 64-bit integer values
19* Passes all [CPD](http://c-rack.github.io/cbor-java/cpd.html), [PMD](http://c-rack.github.io/cbor-java/pmd.html) and [FindBugs](http://c-rack.github.io/cbor-java/findbugs.html) tests
20
21## Documentation
22
23* [Documentation](http://c-rack.github.io/cbor-java/)
24* [JavaDoc](http://c-rack.github.io/cbor-java/apidocs/index.html)
25
26## Maven Dependency
27
28Add this to the dependencies section of your pom.xml file:
29
30```xml
31<dependency>
32    <groupId>co.nstant.in</groupId>
33    <artifactId>cbor</artifactId>
34    <version>0.8</version>
35</dependency>
36```
37
38## Usage
39
40### Encoding Example
41
42```java
43ByteArrayOutputStream baos = new ByteArrayOutputStream();
44new CborEncoder(baos).encode(new CborBuilder()
45    .add("text")                // add string
46    .add(1234)                  // add integer
47    .add(new byte[] { 0x10 })   // add byte array
48    .addArray()                 // add array
49        .add(1)
50        .add("text")
51        .end()
52    .build());
53byte[] encodedBytes = baos.toByteArray();
54```
55
56### Decoding Example
57
58```java
59ByteArrayInputStream bais = new ByteArrayInputStream(encodedBytes);
60List<DataItem> dataItems = new CborDecoder(bais).decode();
61for(DataItem dataItem : dataItems) {
62    // process data item
63}
64```
65
66### Streaming Decoding Example
67
68```java
69ByteArrayInputStream bais = new ByteArrayInputStream(encodedBytes);
70new CborDecoder(bais).decode(new DataItemListener() {
71
72    @Override
73    public void onDataItem(DataItem dataItem) {
74        // process data item
75    }
76
77});
78```
79
80## Contribution Process
81
82This project uses the [C4 process](https://rfc.zeromq.org/spec:42/C4/) for all code changes.
83
84## License
85
86    Copyright 2013-2017 Constantin Rack
87
88    Licensed under the Apache License, Version 2.0 (the "License");
89    you may not use this file except in compliance with the License.
90    You may obtain a copy of the License at
91
92        http://www.apache.org/licenses/LICENSE-2.0
93
94    Unless required by applicable law or agreed to in writing, software
95    distributed under the License is distributed on an "AS IS" BASIS,
96    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
97    See the License for the specific language governing permissions and
98    limitations under the License.
99