java - Pass XML Marshalled data into a ByteBuffer -
for current project, need write xml data bytebuffer write output xml in binary format (.dat example).
is there lib or class will, each java objects corresponding elements of xml, write value of attributes bytebuffer (or similar implementation) while respecting attributes type (int -> buffer.putint(intattribute) ...
ps: ideally, need method put size of each element sequence before values of elements
edit : here concrete example of i'd like
let's have following class defining walker_template xml element
@xmlaccessortype(xmlaccesstype.field) @xmltype(name = "", proporder = { "routestep" }) @xmlrootelement(name = "walker_template") public class walkertemplate { protected list<routestep> routestep; @xmlattribute(name = "route_id") protected string routeid; public list<routestep> getroutestep() { if (routestep == null) { routestep = new arraylist<routestep>(); } return this.routestep; }
routestep being :
@xmlaccessortype(xmlaccesstype.field) @xmltype(name = "", proporder = { "value" }) @xmlrootelement(name = "routestep") public class routestep { @xmlattribute protected integer step; @xmlattribute protected float x; @xmlattribute protected float y; @xmlattribute protected float z;
those classes defines objects marshal using jaxb write output file.
marshaller.marshal(templatestowrite, myxmlstreamwriter);
what want write data of objects in binary format.
the method should (for example) :
bytebuffer buffer = new bytebuffer.allocate(size); buffer.putint(mywalkertemplate.getrouteid()); buffer.putint(mywalkertemplate.getroutesteps().size()); (routestep step : mywalkertemplate.getroutesteps()) { buffer.putfloat(step.getx()); buffer.putfloat(step.gety()); buffer.putfloat(step.getz()); }
so, there library/class automatically object, given classes of objects of course (like marshaller using jaxbcontext).
thanks
Comments
Post a Comment