java - How to improve Jaxb unmarshaller performance -



java - How to improve Jaxb unmarshaller performance -

i want marshal , unmarshal below: want unmarshal xml <keyname>value</keyname> hashmap

class a{ private string name; private list<b> list; } class b{ private map <string, string> map; }

xml:

<a> <name>name</name> <blist> <b> <key>value</key> <key>value</key> </b> </blist> </a>

i want unmarshal xml class a. using @xmlanyelement. when unmarshal @ big size xml blist.size=100000, performance not ideal. should improve performance?

this xml snippet according description:

<doc> <data> <somekey>somevalue</somekey> <otherkey>othervalue</otherkey> </data> </doc>

this class data's type:

import java.util.arraylist; import java.util.list; import javax.xml.bind.annotation.xmlaccesstype; import javax.xml.bind.annotation.xmlaccessortype; import javax.xml.bind.annotation.xmlanyelement; import javax.xml.bind.annotation.xmltype; @xmlaccessortype(xmlaccesstype.field) @xmltype(name = "mappingtype", proporder = { "any" }) public class mappingtype { @xmlanyelement(lax = true) protected list<object> any; public list<object> getany() { if (any == null) { = new arraylist<object>(); } homecoming this.any; } }

to unmarshal:

void unmarshal() throws exception { jaxbcontext jc = jaxbcontext.newinstance( bundle ); unmarshaller m = jc.createunmarshaller(); jaxbelement<?> obj = (jaxbelement<?>)m.unmarshal( new file( xmlin ) ); doctype dt = (doctype)obj.getvalue(); mappingtype mt = dt.getdata(); for( object elobj: mt.getany() ){ system.out.println( "object: " + elobj.getclass() ); } system.out.println( "done" ); }

output

object: class com.sun.org.apache.xerces.internal.dom.elementnsimpl object: class com.sun.org.apache.xerces.internal.dom.elementnsimpl done

processing dom elements you, else can expect?

java xml jaxb

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -