Skip to content
/ cbor-java Public
forked from c-rack/cbor-java

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

License

Notifications You must be signed in to change notification settings

itiu/cbor-java

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.5</version>
</dependency>

Usage

Encoding Example

ByteArrayOutputStream baos = new ByteArrayOutputStream();
CborEncoder encoder = new CborEncoder(baos);
encoder.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);
CborDecoder decoder = new CborDecoder(bais);
List<DataItem> dataItems = decoder.decode();
for(DataItem dataItem : dataItems) {
    // process data item
}

Streaming Decoding Example

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

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

});

Contribution Process

This project uses the C4.1 process for all code changes.

"Everyone, without distinction or discrimination, SHALL have an equal right to become a Contributor under the terms of this contract."

tl;dr

  1. Check for open issues or open a new issue to start a discussion around a feature idea or a bug
  2. Fork the cbor-java repository on Github to start making your changes
  3. Write a test which shows that the bug was fixed or that the feature works as expected
  4. Send a pull request
  5. Your pull request is merged and you are added to the list of contributors

License

Copyright 2013-2015 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.

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%