Project

General

Profile

1
package eu.dnetlib.domain.enabling;
2

    
3
import java.util.ArrayList;
4
import java.util.List;
5
import java.util.Map;
6
import java.util.TreeMap;
7

    
8
import eu.dnetlib.domain.DriverResource;
9

    
10
/**
11
 * 
12
 * The domain object for the Vocabulary resource data structure
13
 * 
14
 */
15
@SuppressWarnings("serial")
16
public class Vocabulary extends DriverResource {
17
	private String name = null;
18
	private Map<String, String> nameMap = null;
19
	private Map<String, String> encodingMap = null;
20
	
21
	public Vocabulary(String name, Map<String, String> nameMap) {
22
		this.setResourceType("VocabularyDSResourceType");
23
		this.setResourceKind("VocabularyDSResources");
24
		
25
		this.name = name;
26
		initializeMaps(nameMap);
27
	}
28
	
29
	public Vocabulary(String name, Map<String, String> nameMap, Map<String, String> encodingMap) {
30
		this.setResourceType("VocabularyDSResourceType");
31
		this.setResourceKind("VocabularyDSResources");
32
		
33
		this.name = name;
34
		this.nameMap = nameMap;
35
		this.encodingMap = encodingMap;	
36
	}
37
	
38
	public void initializeMaps(Map<String, String> nameMap) {
39
		this.nameMap = nameMap;
40
		this.encodingMap = new TreeMap<String, String>();
41
		for (String name : nameMap.keySet()) {
42
			encodingMap.put(nameMap.get(name), name);
43
		}
44
	}
45

    
46
	public String getName() {
47
		return name;
48
	}
49

    
50
	public void setName(String name) {
51
		this.name = name;
52
	}
53

    
54
	public String getEncoding(String englishName) {
55
		return nameMap.get(englishName);
56
	}
57
	
58
	public String getEnglishName(String encoding) {
59
		return encodingMap.get(encoding);
60
	}
61
	
62
	public List<String> getEnglishNames() {
63
		return new ArrayList<String>(this.nameMap.keySet());
64
	}
65
	
66
	public List<String> getEncodings() {
67
		return new ArrayList<String>(this.encodingMap.keySet());
68
	}
69

    
70
	public Map<String, String> getAsMap() { return this.encodingMap; }
71
}
(10-10/11)