2 * Copyright (C) 2009 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.cdm
.jaxb
;
13 import java
.util
.concurrent
.ConcurrentHashMap
;
15 import javax
.xml
.bind
.annotation
.adapters
.XmlAdapter
;
17 import eu
.etaxonomy
.cdm
.model
.common
.IIdentifiableEntity
;
20 * @author a.babadshanjan
23 public class NamespacesAdapter
extends XmlAdapter
<NamespacesElement
, Map
<String
,Class
<?
extends IIdentifiableEntity
>>> {
26 public NamespacesElement
marshal(Map
<String
,Class
<?
extends IIdentifiableEntity
>> value
)
29 NamespacesElement namespacesElement
= new NamespacesElement();
31 for(String s
: value
.keySet()) {
32 Namespace namespace
= new Namespace();
33 namespace
.setNSpace(s
);
34 namespace
.setClazz(value
.get(s
));
35 namespacesElement
.getNamespace().add(namespace
);
37 return namespacesElement
;
41 public Map
<String
,Class
<?
extends IIdentifiableEntity
>> unmarshal(NamespacesElement value
)
44 Map
<String
, Class
<?
extends IIdentifiableEntity
>> map
= new ConcurrentHashMap
<String
, Class
<?
extends IIdentifiableEntity
>>();
46 for(Namespace n
: value
.getNamespace()) {
47 map
.put(n
.getNSpace(),n
.getClazz());