Project

General

Profile

Download (1.47 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2009 EDIT
3
* European Distributed Institute of Taxonomy 
4
* http://www.e-taxonomy.eu
5
* 
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.
8
*/
9

    
10
package eu.etaxonomy.cdm.jaxb;
11

    
12
import java.util.Map;
13
import java.util.concurrent.ConcurrentHashMap;
14

    
15
import javax.xml.bind.annotation.adapters.XmlAdapter;
16

    
17
import eu.etaxonomy.cdm.model.common.IIdentifiableEntity;
18

    
19
/**
20
 * @author a.babadshanjan
21
 * @version 1.0
22
 */
23
public class NamespacesAdapter extends XmlAdapter<NamespacesElement, Map<String,Class<? extends IIdentifiableEntity>>> {
24

    
25
	@Override
26
	public NamespacesElement marshal(Map<String,Class<? extends IIdentifiableEntity>> value)
27
			throws Exception {
28
		
29
		NamespacesElement namespacesElement = new NamespacesElement();
30
		
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);
36
		}
37
		return namespacesElement;
38
	}
39

    
40
    @Override
41
	public Map<String,Class<? extends IIdentifiableEntity>> unmarshal(NamespacesElement value)
42
			throws Exception {
43
		
44
        Map<String, Class<? extends IIdentifiableEntity>> map = new ConcurrentHashMap<String, Class<? extends IIdentifiableEntity>>();
45
		
46
		for(Namespace n : value.getNamespace()) {
47
			map.put(n.getNSpace(),n.getClazz());
48
		}
49
		return map;
50
	}
51
}
(12-12/16)