gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.lib / src / main / java / org / gvsig / tools / namestranslator / DummyNamesTranslator.java @ 2217
History | View | Annotate | Download (3.3 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2020 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
|
25 |
package org.gvsig.tools.namestranslator; |
26 |
|
27 |
import java.util.ArrayList; |
28 |
import java.util.List; |
29 |
import java.util.function.Function; |
30 |
|
31 |
/**
|
32 |
*
|
33 |
* @author jjdelcerro
|
34 |
*/
|
35 |
public class DummyNamesTranslator |
36 |
extends AbstractNamesTranslator
|
37 |
implements NamesTranslator
|
38 |
{ |
39 |
|
40 |
protected SimpleList translatedNames;
|
41 |
|
42 |
protected DummyNamesTranslator() {
|
43 |
|
44 |
} |
45 |
|
46 |
@Override
|
47 |
protected void build() { |
48 |
this.translatedNames = new SimpleList(); |
49 |
for (String sourceName : sourceNames) { |
50 |
this.translatedNames.add(sourceName);
|
51 |
} |
52 |
|
53 |
} |
54 |
|
55 |
@Override
|
56 |
public List<String> getSourceNames() { |
57 |
return this.sourceNames.toList(); |
58 |
} |
59 |
|
60 |
@Override
|
61 |
public List<String> getTranslatedNames() { |
62 |
return this.translatedNames.toList(); |
63 |
} |
64 |
|
65 |
@Override
|
66 |
public String getTranslation(String sourceName) { |
67 |
int n = this.sourceNames.indexOf(sourceName); |
68 |
if( n<0 ) { |
69 |
return null; |
70 |
} |
71 |
return this.translatedNames.get(n); |
72 |
} |
73 |
|
74 |
@Override
|
75 |
public String getSource(String name) { |
76 |
return name;
|
77 |
} |
78 |
|
79 |
@Override
|
80 |
public String getSuggestion(String name) { |
81 |
return name;
|
82 |
} |
83 |
|
84 |
@Override
|
85 |
public String getTranslation(int index) { |
86 |
return this.translatedNames.get(index); |
87 |
} |
88 |
|
89 |
@Override
|
90 |
public int setTranslation(String sourceName, String translatedName) { |
91 |
int n = this.sourceNames.indexOf(sourceName); |
92 |
if( n>=0 ) { |
93 |
this.translatedNames.set(n, translatedName);
|
94 |
} |
95 |
return -1; |
96 |
} |
97 |
|
98 |
@Override
|
99 |
public void rebuild() { |
100 |
this.build();
|
101 |
} |
102 |
|
103 |
@Override
|
104 |
public int addSource(String sourceName) { |
105 |
if (this.sourceNames.contains(sourceName)) { |
106 |
throw new IllegalArgumentException("Source name already exists in the name translator"); |
107 |
} |
108 |
String sugName = getSuggestion(sourceName);
|
109 |
return this.setTranslation(sourceName, sugName); |
110 |
} |
111 |
|
112 |
@Override
|
113 |
public void updateSourceNames(String[] names) { |
114 |
|
115 |
} |
116 |
|
117 |
@Override
|
118 |
public void updateSourceNames(Iterable<String> names) { |
119 |
|
120 |
} |
121 |
|
122 |
@Override
|
123 |
public void updateSourceNames(Iterable objs, Function<Object, String> name_getter) { |
124 |
|
125 |
} |
126 |
|
127 |
@Override
|
128 |
public List<String> getAllTranslations(String sourceName) { |
129 |
return new ArrayList(); |
130 |
} |
131 |
|
132 |
@Override
|
133 |
public void clear() { |
134 |
|
135 |
} |
136 |
|
137 |
@Override
|
138 |
public boolean hasDuplicateSources() { |
139 |
return false; |
140 |
} |
141 |
|
142 |
} |