Border border = null;
StringTokenizer st = new StringTokenizer(attr.getValue(), "(,)"); // border type + parameters
int n = st.countTokens() - 1; // number of parameter to create a border
String borderType = st.nextToken().trim();
Method method = null;
ConverterLibrary cvtlib = ConverterLibrary.getInstance();
//
// Special case for single parameter construction, give priority to String Type
//
if (n == 0) {
try {
method = BorderFactory.class.getMethod("create" + borderType);
} catch (NoSuchMethodException e) {
// intent. empty
}
if (method == null) { // try with empty string
n = 1;
st = new StringTokenizer(" ", "(,)");
}
}
if (n == 1) {
try {
method = BorderFactory.class.getMethod("create" + borderType, new Class[]{String.class});
} catch (NoSuchMethodException e) {
// no need to do anything here.
}
}
for (int i = 0; method == null && i < METHODS.length; i++) {
if (METHODS[i].getParameterTypes().length == n && METHODS[i].getName().endsWith(borderType)) {
method = METHODS[i];
for (int j = 0; j < method.getParameterTypes().length; j++) {
if (String.class.equals(method.getParameterTypes()[j])) {
continue;
}
if (null == cvtlib.getConverter(method.getParameterTypes()[j])) {
method = null;
break;
}
}
}
}
try {
Object[] args = new Object[n];
for (int i = 0; i < n; i++) { // fill argument array
Converter converter = cvtlib.getConverter(method.getParameterTypes()[i]);
Attribute attrib = new Attribute(String.class.equals(converter.convertsTo()) ? "title" : "NA", st.nextToken().trim());
if (converter != null) {
args[i] = converter.convert(method.getParameterTypes()[i], attrib, localizer);
} else {
args[i] = attrib.getValue();