MCPcopy Index your code
hub / github.com/c-rack/cbor-java

github.com/c-rack/cbor-java @v0.8

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.8 ↗ · + Follow
724 symbols 2,421 edges 187 files 96 documented · 13%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

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.

Extension points exported contracts — how you extend this code

DataItemListener (Interface)
Callback interface for a streaming CborDecoder. [1 implementers]
src/main/java/co/nstant/in/cbor/DataItemListener.java

Core symbols most depended-on inside this repo

add
called by 157
src/main/java/co/nstant/in/cbor/model/Array.java
assertTrue
called by 72
src/main/java/co/nstant/in/cbor/model/DataItem.java
write
called by 71
src/main/java/co/nstant/in/cbor/encoder/AbstractEncoder.java
encode
called by 67
src/main/java/co/nstant/in/cbor/CborEncoder.java
end
called by 64
src/main/java/co/nstant/in/cbor/builder/MapBuilder.java
build
called by 62
src/main/java/co/nstant/in/cbor/CborBuilder.java
decode
called by 61
src/main/java/co/nstant/in/cbor/CborDecoder.java
get
called by 55
src/main/java/co/nstant/in/cbor/model/Map.java

Shape

Method 530
Class 189
Enum 4
Interface 1

Languages

Java100%

Modules by API surface

src/main/java/co/nstant/in/cbor/CborDecoder.java20 symbols
src/test/java/co/nstant/in/cbor/decoder/AbstractDecoderTest.java16 symbols
src/test/java/co/nstant/in/cbor/decoder/CborDecoderTest.java14 symbols
src/main/java/co/nstant/in/cbor/CborBuilder.java13 symbols
src/test/java/co/nstant/in/cbor/model/DataItemTest.java12 symbols
src/test/java/co/nstant/in/cbor/builder/AbstractBuilderTest.java11 symbols
src/test/java/co/nstant/in/cbor/model/MajorTypeTest.java10 symbols
src/main/java/co/nstant/in/cbor/model/Map.java10 symbols
src/main/java/co/nstant/in/cbor/model/DataItem.java10 symbols
src/test/java/co/nstant/in/cbor/encoder/SpecialEncoderTest.java9 symbols
src/test/java/co/nstant/in/cbor/encoder/AbstractEncoderTest.java9 symbols
src/main/java/co/nstant/in/cbor/builder/AbstractBuilder.java9 symbols

For agents

$ claude mcp add cbor-java \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact