public static DynamicSAXElementVisitorList getList(ExecutionContext executionContext) {
return (DynamicSAXElementVisitorList) executionContext.getAttribute(DynamicSAXElementVisitorList.class);
}
public static void addDynamicVisitor(SAXVisitor visitor, ExecutionContext executionContext) {
SmooksContentHandler contentHandler = SmooksContentHandler.getHandler(executionContext);
SmooksContentHandler nestedContentHandler = contentHandler.getNestedContentHandler();
if(nestedContentHandler == null) {
DynamicSAXElementVisitorList list = getList(executionContext);
if(visitor instanceof SAXVisitBefore) {
list.visitBefores.add((SAXVisitBefore) visitor);
}
if(visitor instanceof SAXVisitChildren) {
list.childVisitors.add((SAXVisitChildren) visitor);
}
if(visitor instanceof SAXVisitAfter) {
list.visitAfters.add((SAXVisitAfter) visitor);
}
} else {
addDynamicVisitor(visitor, nestedContentHandler.getExecutionContext());
}
}