Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A Java version of "Construct" a python library for parsing and building of data structures (binary or textual)
Java Python
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
.externalToolBuilders Test for simple struct with BeanAdapter + some project configuration
src Fixed UBInt16 sign
.classpath Removed src paths
.project Test for simple struct with BeanAdapter + some project configuration
.pydevproject Implemented Reconfig
LICENSE Added Sirtrack Ltd. Fixed project tree
README.textile spelling
pom.xml Updated compiler plugin


Python Construct

Construct is a powerful declarative parser for binary data.

It is based on the concept of defining data structures in a declarative
manner, rather than procedural code: Simple constructs can be combined
hierarchically to form increasingly complex data structures. It’s the first
library that makes parsing fun, instead of the usual headache it is today.

Construct features bit and byte granularity, symmetrical operation (parsing
and building), component-oriented declarative design, easy debugging and
testing, an easy-to-extend subclass system, and lots of primitive
constructs to make your work easier:

  • Fields
  • Structs
  • Unions
  • Repeaters
  • Meta constructs
  • Switches
  • On-demand parsing
  • Pointers
  • And more!

Java Construct

This Java version employs some syntactic sugar (i.e. static methods) to make the syntax as close as possible to the original Construct library in Python.

See for example

    Construct struct = BitStruct("foo",
                         BitField("a", 3),

A Java Construct can parse byte arrays and produces Objects like Containers. Viceversa, it can take Objects to produce byte arrays.

public Object parse(byte[] data);
public byte[] build( Object obj);

Parsing example:

    Container c1 = Container( "a", 7, "b", false, "bar", Container( "d", 15 , "e", 1), "c",8);
    Container c2 = struct.parse( ByteArray( 0xe1, 0x1f ));
    assertEquals( c1, c2 );


Currently Java Construct supports enough Macros, Adapters and repeaters to parse and build these protocols:

Something went wrong with that request. Please try again.