private void addConverters(NodeList converters, String namespace) {
Application application = getApplication();
Verifier verifier = Verifier.getCurrentInstance();
for (int i = 0, size = converters.getLength(); i < size; i++) {
Node converter = converters.item(i);
NodeList children = ((Element) converter)
.getElementsByTagNameNS(namespace, "*");
String converterId = null;
String converterClass = null;
String converterForClass = null;
for (int c = 0, csize = children.getLength(); c < csize; c++) {
Node n = children.item(c);
if (CONVERTER_ID.equals(n.getLocalName())) {
converterId = getNodeText(n);
} else if (CONVERTER_CLASS.equals(n.getLocalName())) {
converterClass = getNodeText(n);
} else if (CONVERTER_FOR_CLASS.equals(n.getLocalName())) {
converterForClass = getNodeText(n);
}
}
if (converterId != null && converterClass != null) {
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE,
MessageFormat.format(
"[Converter by ID] Calling Application.addConverter({0}, {1}",
converterId,
converterClass));
}
if (verifier != null) {
verifier.validateObject(Verifier.ObjectType.CONVERTER,
converterClass,
Converter.class);
}
application.addConverter(converterId, converterClass);
} else if (converterClass != null && converterForClass != null) {
try {
Class cfcClass = Util.loadClass(converterForClass,
this.getClass());
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE,
MessageFormat.format(
"[Converter for Class] Calling Application.addConverter({0}, {1}",
converterForClass,
converterClass));
}
if (verifier != null) {
verifier.validateObject(Verifier.ObjectType.CONVERTER,
converterClass,
Converter.class);
}
application.addConverter(cfcClass, converterClass);
} catch (ClassNotFoundException cnfe) {