Inactive

Project Summary

  Analyzed 3 days ago based on code collected 3 days ago.

What is Javastructjavastruct is a library for using java objects as C or C++ structs.

What is it used for?For details please refer to Wiki page

This library could be useful for java applications communicating with embedded devices or other C, C++ applications. It could also be used as a simple but space efficent serialization method.

Primitives, arrays, C Strings and Nested classes are supported. Big Endian and Little Endian byte orders are also supported. javastruct can also handle fields whose length is defined in other fields, using ArrayLengthMarker annotation. Please refer to examples and documentation in wiki section.

How to use JavaStructClasses should be marked as StructClass annotation and fields must be annotated to be used as struct fields.

Look at the test classes to learn usage in detail. A Simple Example:

@StructClass
public class Foo{
@StructField(order = 0)
public byte b;
@StructField(order = 1)
public int i;
}

try{
// Pack the class as a byte buffer
Foo f = new Foo();
f.b = (byte)1;
f.i = 1;
byte[] b = JavaStruct.pack(f);

// Unpack it into an object
Foo f2 = new Foo();
JavaStruct.unpack(f2, b);
}
catch(StructException e){
}
PeformanceFor simple classes , JavaStruct is faster than Java serialization, For complex and nested objects, generally same performance as Java serialization. Naturally JavaStruct produces 2-3 times smaller output.

Future WorkBetter naming and unified Façade class Detailed documentation ByteBuffer based struct serialization (Currently it is stream based) Better performance More unit tests Data alignment support Bitfields Unions. Requirements- Any Os with Java 5 or upper JVM

Similar ProjectsJean-Marie Dautelle's Javolution also has an excellent struct implementation. Javolution structs uses special classes for representing fields, JavaStruct has a different approach and uses POJO's and Java 5 annotations.

Share

In a Nutshell, javastruct...

 

Activity

30 Day Summary Apr 18 2013 — May 18 2013

12 Month Summary May 18 2012 — May 18 2013

Community

Ratings

Be the first to rate this project
 
Click to add your rating
 
Review this Project!
 
 
 

Creative Commons License Copyright © 2013 Black Duck Software, Inc. and its contributors, Some Rights Reserved. Unless otherwise marked, this work is licensed under a Creative Commons Attribution 3.0 Unported License . Ohloh ® and the Ohloh logo are trademarks of Black Duck Software, Inc. in the United States and/or other jurisdictions. All other trademarks are the property of their respective holders.