com.github.evgenbar:java-binary-decoder

Reflection based decoder for decoding binary stream of C-like structures

Лицензия

Лицензия

Категории

Категории

Java Языки программирования
Группа

Группа

com.github.evgenbar
Идентификатор

Идентификатор

java-binary-decoder
Последняя версия

Последняя версия

1.0.3
Дата

Дата

Тип

Тип

jar
Описание

Описание

com.github.evgenbar:java-binary-decoder
Reflection based decoder for decoding binary stream of C-like structures
Ссылка на сайт

Ссылка на сайт

https://github.com/evgenbar/java-binary-decoder
Система контроля версий

Система контроля версий

http://github.com/evgenbar/java-binary-decoder/tree/master

Скачать java-binary-decoder

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.github.evgenbar/java-binary-decoder/ -->
<dependency>
    <groupId>com.github.evgenbar</groupId>
    <artifactId>java-binary-decoder</artifactId>
    <version>1.0.3</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.evgenbar/java-binary-decoder/
implementation 'com.github.evgenbar:java-binary-decoder:1.0.3'
// https://jarcasting.com/artifacts/com.github.evgenbar/java-binary-decoder/
implementation ("com.github.evgenbar:java-binary-decoder:1.0.3")
'com.github.evgenbar:java-binary-decoder:jar:1.0.3'
<dependency org="com.github.evgenbar" name="java-binary-decoder" rev="1.0.3">
  <artifact name="java-binary-decoder" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.evgenbar', module='java-binary-decoder', version='1.0.3')
)
libraryDependencies += "com.github.evgenbar" % "java-binary-decoder" % "1.0.3"
[com.github.evgenbar/java-binary-decoder "1.0.3"]

Зависимости

compile (2)

Идентификатор библиотеки Тип Версия
com.google.guava : guava jar 18.0
org.apache.commons : commons-lang3 jar 3.0

test (2)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.11
org.hamcrest : hamcrest-all jar 1.3

Модули Проекта

Данный проект не имеет модулей.

java-binary-decoder Build Status

Simple library for decoding C++\C-like structures serialized to a binary buffer and converting them to Java classes.

Purpose

The library is intended to ease the maintenance of protocol between Java and the side that defines the binary structure.
The decoding is reflection based, thus it eliminates the need for changing the decoding code when the binary structure changes. The only thing that has to be changed is a corresponding Java class.

Features

  • Signed\Unsigned integer types
  • Hierarchical structures
  • Nested structures
  • Arrays (primitives and complex structures)
    • Arrays with constant size
    • Arrays with size determined by another structure member

How to use

Simple structure:

Given the following structure being serialized to a binary buffer:

struct mystruct 
{
	bool cBoolean;
	char cChar;
    unsigned char cByte; 
    short cShort;
    int cInt;
    long cLong;
    float cFloat;
    double cDouble;    
}

Assuming that serialization is done by the following rules: boolean is 1 byte, char is 1 byte, short is 2 bytes, int is 4 bytes, long is 8 bytes, float is 4 bytes and double is 8 bytes, the specified binary buffer consists of 29 bytes and includes all the data according to its apearance in the structure.
On the Java side the corresponding class will look like this:

@Decodable
public class MyJavaClass {
	public boolean javaBoolean;
    public char javaChar;
    public byte javaByte;
    public short javaShort;
    public int javaInt;
    public long javaLong;
    public float javaFloat;
    public double javaDouble;
}

The decoding itself:

IDataInputDecoder decoder = new BinaryDataDecoder();
try(DataInput dis = new DataInputStream(new BufferedInputStream(new ByteArrayInputStream(buffer)))){
	MyJavaClass instance = decoder.decode(MyJavaClass.class, dis);
}

Версии библиотеки

Версия
1.0.3
1.0.2
1.0.1