Statistics
| Revision:

gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.lib / src / main / java / org / gvsig / tools / namestranslator / NamesTranslator.java @ 2206

History | View | Annotate | Download (4.8 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
package org.gvsig.tools.namestranslator;
25

    
26
import java.util.List;
27
import java.util.function.Function;
28
import org.gvsig.tools.lang.Cloneable;
29

    
30
/**
31
 *
32
 * @author jjdelcerro
33
 */
34
public interface NamesTranslator extends Cloneable {
35

    
36
  public static NamesTranslator createTrimTranslator(int maxNameLen) {
37
    return new TrimNamesTranslator(maxNameLen);
38
  }
39

    
40
  public static NamesTranslator createBaseTranslator() {
41
      return new BaseNamesTranslator();
42
  }
43
  
44
  public static NamesTranslator createDummyTranslator() {
45
    return new DummyNamesTranslator();
46
  }
47

    
48
  /**
49
   * Assign the list of source names and generate the list of translations from them.
50
   * If any of the source names collide with another, it will create the 
51
   * translation using the "getSugestion" method.
52
   * 
53
   * @param names 
54
   */
55
  public void setSourceNames(String[] names);
56
  
57
  /**
58
   * Assign the list of source names and generate the list of translations from them.
59
   * If any of the source names collide with another, it will create the 
60
   * translation using the "getSugestion" method.
61
   *
62
   * @param names 
63
   */
64
  public void setSourceNames(Iterable<String> names);
65

    
66
  /**
67
   * Assign the list of source names and generate the list of translations from them.
68
   * If any of the source names collide with another, it will create the 
69
   * translation using the "getSugestion" method.
70
   *
71
   * @param objs
72
   * @param name_getter 
73
   */
74
  public void setSourceNames(Iterable objs, Function<Object, String> name_getter);
75

    
76
  /** 
77
   * Return the list of source names.
78
   * 
79
   * @return 
80
   */
81
  public List<String> getSourceNames();
82

    
83
  /** 
84
   * Return the list of translated names.
85
   * 
86
   * @return 
87
   */
88
  public List<String> getTranslatedNames();
89

    
90
  /** 
91
   * Return the list of translated names as a String array.
92
   * 
93
   * @return 
94
   */
95
  public String[] getTranslatedNamesAsArray();
96

    
97
  /**
98
   * Returns the translation corresponding to the source name indicated 
99
   * in the "sourceName" parameter.
100
   * 
101
   * @param sourceName
102
   * @return 
103
   */
104
  public String getTranslation(String sourceName);
105

    
106
  /**
107
   * Returns the source name corresponding to the translation indicated 
108
   * in the "translationName" parameter.
109
   * 
110
   * @param translatedName
111
   * @return 
112
   */
113
  public String getSource(String translatedName);
114

    
115
  /**
116
   * Returns the translation corresponding to the source name indicated 
117
   * in the "index" parameter.
118
   * 
119
   * @param index
120
   * @return 
121
   */
122
  public String getTranslation(int index);
123

    
124
  /**
125
   * Returns the source name corresponding to the translation indicated 
126
   * in the "index" parameter.
127
   * 
128
   * @param index
129
   * @return 
130
   */
131
  public String getSource(int index);
132

    
133
  /**
134
   * Check if the name passed as a parameter collides with 
135
   * any existing translation.
136
   * If it collides it generates a new name from the past as a parameter 
137
   * and returns it. If it does not collide, it returns.
138
   * 
139
   * @param name
140
   * @return 
141
   */
142
  public String getSuggestion(String name);
143
  
144
  /**
145
   * Returns true if the name passed as a parameter does not collide 
146
   * with any of the existing translations.
147
   * 
148
   * @param name
149
   * @return 
150
   */
151
  public boolean isValid(String name);
152
  
153
  /**
154
   * Assign the translation "translationName" to the name "sourceName".
155
   * If it collides with some other, change the translation of the colliding 
156
   * and return its index. If it does not collide it returns -1.
157
   * 
158
   * @param sourceName
159
   * @param translatedName
160
   * @return 
161
   */
162
  public int setTranslation(String sourceName, String translatedName);
163
  
164
  public void rebuild();
165
  
166
  public int addSource(String sourceName);
167
  
168
  @Override
169
  public NamesTranslator clone() throws CloneNotSupportedException;
170
  
171
  public void updateSourceNames(String[] names);
172

    
173
  public void updateSourceNames(Iterable<String> names);
174

    
175
  public void updateSourceNames(Iterable objs, Function<Object, String> name_getter);
176

    
177
}