source: vlo/branches/vlo-3.3-oeaw/vlo-vocabularies/src/main/java/eu/clarin/cmdi/vlo/pojo/VariantsMap.java @ 6724

Last change on this file since 6724 was 6724, checked in by davor.ostojic@oeaw.ac.at, 9 years ago
  • Property svn:mime-type set to text/plain
File size: 1.7 KB
Line 
1package eu.clarin.cmdi.vlo.pojo;
2
3import java.util.LinkedList;
4import java.util.List;
5import java.util.Map;
6import java.util.TreeMap;
7
8import javax.xml.bind.annotation.XmlAccessType;
9import javax.xml.bind.annotation.XmlAccessorType;
10import javax.xml.bind.annotation.XmlAttribute;
11import javax.xml.bind.annotation.XmlElement;
12import javax.xml.bind.annotation.XmlRootElement;
13
14/**
15 * @author dostojic
16 *
17 */
18
19
20@XmlAccessorType(XmlAccessType.FIELD)
21@XmlRootElement(name = "mappings")
22public class VariantsMap{
23       
24        @XmlAttribute
25        private String field;
26       
27        @XmlElement(name = "mapping")
28        private List<Mapping> mappings;
29
30        public List<Mapping> getMappings() {
31                return mappings;
32        }
33
34        public void setMappings(List<Mapping> mappings) {
35                this.mappings = mappings;
36        }
37               
38        public String getField() {
39                return field;
40        }
41
42        public void setField(String field) {
43                this.field = field;
44        }
45       
46       
47         /**
48     * returns inverted map variant-normalizedVal
49     *
50     */
51       
52        public Map<String, String> getInvertedMap(){
53                Map<String, String> invMap = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
54                for(Mapping m: mappings){
55                        if(m.getVariants() != null)
56                                for(Variant variant: m.getVariants())
57                                        if(!variant.isRegExp())
58                                                invMap.put(variant.getValue(), m.getValue());
59                }
60               
61                return invMap;
62        }
63       
64       
65        public List<VocabularyEntry> getMap(){
66                List map = new LinkedList<VocabularyEntry>();
67               
68                for(Mapping m: mappings)
69                        if(m.getVariants() != null)
70                                for(Variant v: m.getVariants()){                                       
71                                        map.add(new VocabularyEntry(v.getValue(), m.getValue(), v.isRegExp(), v.getCrossMappings()));
72                                }
73               
74                return map;
75               
76        }
77       
78}
Note: See TracBrowser for help on using the repository browser.