1 | package org.biohackathon.SPARQLBuilder.OWL;
|
---|
2 |
|
---|
3 | import java.util.ArrayList;
|
---|
4 | import java.util.HashSet;
|
---|
5 |
|
---|
6 | public class LabelMap {
|
---|
7 |
|
---|
8 | private String resourceURI = null;
|
---|
9 | private HashSet<Label> labels = null;
|
---|
10 |
|
---|
11 | public LabelMap(){
|
---|
12 | labels = new HashSet<Label>();
|
---|
13 | }
|
---|
14 |
|
---|
15 |
|
---|
16 | public LabelMap(String resourceURI, Label[] labelArray) {
|
---|
17 | labels = new HashSet<Label>();
|
---|
18 | this.resourceURI = resourceURI;
|
---|
19 | if( labelArray != null ){
|
---|
20 | for(Label label: labelArray){
|
---|
21 | labels.add(label);
|
---|
22 | }
|
---|
23 | }
|
---|
24 | }
|
---|
25 |
|
---|
26 | public void addLabel(Label label){
|
---|
27 | labels.add(label);
|
---|
28 | }
|
---|
29 |
|
---|
30 |
|
---|
31 | public Label[] getLabels(){
|
---|
32 | return labels.toArray(new Label[0]);
|
---|
33 | }
|
---|
34 |
|
---|
35 | public Label[] getLabels(String language){
|
---|
36 | Label[] lbs = getLabels();
|
---|
37 | ArrayList<Label> labelAL = new ArrayList<Label>();
|
---|
38 | for(Label label: lbs){
|
---|
39 | if( language == null ){
|
---|
40 | labelAL.add(label);
|
---|
41 | }else{
|
---|
42 | if( language.equals(label.getLanguage())){
|
---|
43 | labelAL.add(label);
|
---|
44 | }
|
---|
45 | }
|
---|
46 | }
|
---|
47 | return labelAL.toArray(new Label[0]);
|
---|
48 | }
|
---|
49 |
|
---|
50 | public void setResourceURI(String uri){
|
---|
51 | resourceURI = uri;
|
---|
52 | }
|
---|
53 |
|
---|
54 | public String getResourceURI(){
|
---|
55 | return resourceURI;
|
---|
56 | }
|
---|
57 |
|
---|
58 | }
|
---|