git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1091095 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Matthew Jason Benson 2011-04-11 15:06:32 +00:00
parent 93666dd2f2
commit 77c0ffce3c
1 changed files with 11 additions and 9 deletions

View File

@ -37,18 +37,20 @@ public class LookupTranslator extends CharSequenceTranslator {
*
* @param lookup CharSequence[][] table of size [*][2]
*/
public LookupTranslator(CharSequence[][] lookup) {
public LookupTranslator(CharSequence[]... lookup) {
lookupMap = new HashMap<CharSequence, CharSequence>();
int _shortest = Integer.MAX_VALUE;
int _longest = 0;
for(CharSequence[] seq : lookup) {
this.lookupMap.put(seq[0], seq[1]);
int sz = seq[0].length();
if(sz < _shortest) {
_shortest = sz;
}
if(sz > _longest) {
_longest = sz;
if (lookup != null) {
for (CharSequence[] seq : lookup) {
this.lookupMap.put(seq[0], seq[1]);
int sz = seq[0].length();
if(sz < _shortest) {
_shortest = sz;
}
if(sz > _longest) {
_longest = sz;
}
}
}
shortest = _shortest;