private void addBehaviors(NodeList behaviors, String namespace)
throws XPathExpressionException {
Application app = getApplication();
Verifier verifier = Verifier.getCurrentInstance();
for (int i = 0, size = behaviors.getLength(); i < size; i++) {
Node behavior = behaviors.item(i);
NodeList children = ((Element) behavior)
.getElementsByTagNameNS(namespace, "*");
String behaviorId = null;
String behaviorClass = null;
for (int c = 0, csize = children.getLength(); c < csize; c++) {
Node n = children.item(c);
if (n.getNodeType() == Node.ELEMENT_NODE) {
if (BEHAVIOR_ID.equals(n.getLocalName())) {
behaviorId = getNodeText(n);
} else if (BEHAVIOR_CLASS.equals(n.getLocalName())) {
behaviorClass = getNodeText(n);
}
}
}
if (behaviorId != null && behaviorClass != null) {
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE,
MessageFormat.format(
"Calling Application.addBehavior({0},{1})",
behaviorId,
behaviorClass));
}
if (verifier != null) {
verifier.validateObject(Verifier.ObjectType.BEHAVIOR,
behaviorClass,
Behavior.class);
}
app.addBehavior(behaviorId, behaviorClass);
}