You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
752 B
33 lines
752 B
8 years ago
|
package sig.modules.utils;
|
||
|
|
||
|
import java.util.Arrays;
|
||
|
|
||
|
import sig.TextUtils;
|
||
|
|
||
|
public class SemiValidString {
|
||
|
final public static String ERROR_VALUE = "nil";
|
||
|
String[] values;
|
||
|
|
||
|
public SemiValidString(String[] vals) {
|
||
|
this.values = vals;
|
||
|
}
|
||
|
|
||
|
public String getValidString() {
|
||
|
for (String val : values) {
|
||
|
if (passesTestConditions(val)) {
|
||
|
return val;
|
||
|
}
|
||
|
}
|
||
|
System.out.println("WARNING! Could not find valid value for SemiValidString["+values.length+"]!");
|
||
|
return ERROR_VALUE;
|
||
|
}
|
||
|
|
||
|
public boolean passesTestConditions(String testval) {
|
||
|
return !(testval.equalsIgnoreCase("nil") || TextUtils.isNumeric(testval));
|
||
|
}
|
||
|
|
||
|
public String toString() {
|
||
|
return "SemiValidString "+Arrays.toString(values);
|
||
|
}
|
||
|
}
|