Revision 2212 org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/namestranslator/BaseNamesTranslator.java
BaseNamesTranslator.java | ||
---|---|---|
91 | 91 |
return this.translatedNames.get(index); |
92 | 92 |
} |
93 | 93 |
|
94 |
@Override |
|
94 | 95 |
public int addSource(String sourceName) { |
95 | 96 |
if (this.sourceNames.contains(sourceName)) { |
96 | 97 |
throw new IllegalArgumentException("Source name already exists in the name translator"); |
... | ... | |
144 | 145 |
if (StringUtils.isBlank(sourceName)) { |
145 | 146 |
sourceName = DEFAULT_FIELD_NAME; |
146 | 147 |
} |
147 |
int len = sourceName.length(); |
|
148 | 148 |
if (!this.translatedNames.contains(sourceName)) { |
149 | 149 |
return sourceName; |
150 | 150 |
} |
151 |
String translatedName = sourceName;
|
|
151 |
String translatedName; |
|
152 | 152 |
for (int i = 0; i < 255; i++) { |
153 | 153 |
translatedName = sourceName + i; |
154 | 154 |
if (!this.translatedNames.contains(translatedName)) { |
... | ... | |
156 | 156 |
} |
157 | 157 |
} |
158 | 158 |
|
159 |
/* |
|
160 |
* Should not get here |
|
161 |
*/ |
|
159 |
// Should not get here |
|
162 | 160 |
return sourceName + "_" + (System.currentTimeMillis() % 1000000); |
163 | 161 |
} |
164 | 162 |
|
... | ... | |
168 | 166 |
if (StringUtils.isBlank(sourceName)) { |
169 | 167 |
sourceName = DEFAULT_FIELD_NAME; |
170 | 168 |
} |
171 |
int len = sourceName.length(); |
|
172 | 169 |
return !this.translatedNames.contains(sourceName); |
173 | 170 |
} |
174 | 171 |
|
175 | 172 |
public static void registerPersistence() { |
176 | 173 |
|
177 | 174 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
178 |
if (manager.getDefinition("ClassName") == null) {
|
|
175 |
if (manager.getDefinition("BaseNamesTranslator") == null) {
|
|
179 | 176 |
DynStruct definition = manager.addDefinition(BaseNamesTranslator.class, |
180 | 177 |
"BaseNamesTranslator", "BaseNamesTranslator persistence definition", null, null); |
181 | 178 |
definition.addDynFieldBoolean("hasTranslations"); |
... | ... | |
226 | 223 |
this.rebuild(); |
227 | 224 |
return; |
228 | 225 |
} |
229 |
if(this.sourceNames.toList().isEmpty()) {
|
|
226 |
if(this.sourceNames.isEmpty()) { |
|
230 | 227 |
this.sourceNames = updateSources; |
231 | 228 |
this.rebuild(); |
232 | 229 |
return; |
Also available in: Unified diff