Hi Manfred,
This sort of adapter approach is something I'd like to work into the
JiBX 2.0 binding handling. It's not as efficient as a customer
marshaller/unmarshaller, but much easier to write.
- Dennis
Lichtmannegger, Manfred wrote:
as my data structures are full of maps (id -> complex object),
I have looked for a way to present jibx the maps as collections
by introducing some helper classes
a very simple example would be
public class NameValueMap extends HashMap<String, String> {
// default constructor to satisfy jibx
public NameValueMap() { }
public boolean add(NameValuePair argNameValuePair) {
put(argNameValuePair.myKey,argNameValuePair.myValue);
return true;
}
public Iterator<NameValuePair> iterator() {
return new NameValueIterator(this);
}
}
public class NameValueIterator implements
Iterator<NameValuePair> {
Iterator<Map.Entry<String,String>> myIterator=null;
NameValueIterator(NameValueMap argMap) {
myIterator=argMap.entrySet().iterator();
}
public boolean hasNext() {
return myIterator.hasNext();
}
public NameValuePair next() {
return new NameValuePair(myIterator.next());
}
public void remove() {
myIterator.remove();
}
}
public class NameValuePair {
// private default constructor to satisfy jibx
private NameValuePair() { }
NameValuePair(Map.Entry<String,String> curr) {
myKey=curr.getKey();
myValue=curr.getValue();
}
public String myKey=null;
public String myValue=null;
}
manfred
<_mailto:[EMAIL PROTECTED]> Tel +49 89 636-76854
Siemens AG mobile +49 178 7700153
COM MN MS RD SE 2 Fax +49 89 636-75037
St.-Martin-Str. 76, D-81541 München Mch M 34/493
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users