@SuppressWarnings({ "unchecked", "WeakerAccess", "UnusedReturnValue" }) public Document popCreator(ExecutionContext executionContext) { Stack<DOMCreator> domCreatorStack = (Stack<DOMCreator>) executionContext.getAttribute(DOMCreator.class); if(domCreatorStack == null) { throw new IllegalStateException("No DOM Creator Stack available."); } else { try { // Remove the current DOMCreators from the dynamic visitor list... if(!domCreatorStack.isEmpty()) { DOMCreator removedCreator = domCreatorStack.pop(); DynamicSAXElementVisitorList.removeDynamicVisitor(removedCreator, executionContext); return removedCreator.document; } else { return null; } } finally { // Reinstate parent DOMCreators in the dynamic visitor list... if(!domCreatorStack.isEmpty()) { DynamicSAXElementVisitorList.addDynamicVisitor(domCreatorStack.peek(), executionContext); } } } }
public Document popCreator(ExecutionContext executionContext) { Stack<DOMCreator> domCreatorStack = (Stack<DOMCreator>) executionContext.getAttribute(DOMCreator.class); if(domCreatorStack == null) { throw new IllegalStateException("No DOM Creator Stack available."); } else { try { // Remove the current DOMCreators from the dynamic visitor list... if(!domCreatorStack.isEmpty()) { DOMCreator removedCreator = domCreatorStack.pop(); DynamicSAXElementVisitorList.removeDynamicVisitor(removedCreator, executionContext); return removedCreator.document; } else { return null; } } finally { // Reinstate parent DOMCreators in the dynamic visitor list... if(!domCreatorStack.isEmpty()) { DynamicSAXElementVisitorList.addDynamicVisitor(domCreatorStack.peek(), executionContext); } } } }
@SuppressWarnings({ "unchecked", "WeakerAccess", "UnusedReturnValue" }) public Document popCreator(ExecutionContext executionContext) { Stack<DOMCreator> domCreatorStack = (Stack<DOMCreator>) executionContext.getAttribute(DOMCreator.class); if(domCreatorStack == null) { throw new IllegalStateException("No DOM Creator Stack available."); } else { try { // Remove the current DOMCreators from the dynamic visitor list... if(!domCreatorStack.isEmpty()) { DOMCreator removedCreator = domCreatorStack.pop(); DynamicSAXElementVisitorList.removeDynamicVisitor(removedCreator, executionContext); return removedCreator.document; } else { return null; } } finally { // Reinstate parent DOMCreators in the dynamic visitor list... if(!domCreatorStack.isEmpty()) { DynamicSAXElementVisitorList.addDynamicVisitor(domCreatorStack.peek(), executionContext); } } } }
@SuppressWarnings({ "unchecked", "WeakerAccess", "UnusedReturnValue" }) public Document popCreator(ExecutionContext executionContext) { Stack<DOMCreator> domCreatorStack = (Stack<DOMCreator>) executionContext.getAttribute(DOMCreator.class); if(domCreatorStack == null) { throw new IllegalStateException("No DOM Creator Stack available."); } else { try { // Remove the current DOMCreators from the dynamic visitor list... if(!domCreatorStack.isEmpty()) { DOMCreator removedCreator = domCreatorStack.pop(); DynamicSAXElementVisitorList.removeDynamicVisitor(removedCreator, executionContext); return removedCreator.document; } else { return null; } } finally { // Reinstate parent DOMCreators in the dynamic visitor list... if(!domCreatorStack.isEmpty()) { DynamicSAXElementVisitorList.addDynamicVisitor(domCreatorStack.peek(), executionContext); } } } }
private void pushCreator(DOMCreator domCreator, ExecutionContext executionContext) { Stack<DOMCreator> domCreatorStack = (Stack<DOMCreator>) executionContext.getAttribute(DOMCreator.class); if(domCreatorStack == null) { domCreatorStack = new Stack<DOMCreator>(); executionContext.setAttribute(DOMCreator.class, domCreatorStack); } else if(!domCreatorStack.isEmpty()) { // We need to remove the current DOMCreator from the dynamic visitor list because // we want to stop nodes being added to it and instead, have them added to the new // DOM. This prevents a single huge DOM being created for a huge message (being processed // via SAX) because it maintains a hierarchy of model. Inner model can represent collection // entry instances, with a single model for a single collection entry only being held in memory // at any point in time i.e. old ones are overwritten and so freed for GC. DynamicSAXElementVisitorList.removeDynamicVisitor(domCreatorStack.peek(), executionContext); } DynamicSAXElementVisitorList.addDynamicVisitor(domCreator, executionContext); domCreatorStack.push(domCreator); }
@SuppressWarnings("unchecked") private void pushCreator(DOMCreator domCreator, ExecutionContext executionContext) { Stack<DOMCreator> domCreatorStack = (Stack<DOMCreator>) executionContext.getAttribute(DOMCreator.class); if(domCreatorStack == null) { domCreatorStack = new Stack<DOMCreator>(); executionContext.setAttribute(DOMCreator.class, domCreatorStack); } else if(!domCreatorStack.isEmpty()) { // We need to remove the current DOMCreator from the dynamic visitor list because // we want to stop nodes being added to it and instead, have them added to the new // DOM. This prevents a single huge DOM being created for a huge message (being processed // via SAX) because it maintains a hierarchy of model. Inner model can represent collection // entry instances, with a single model for a single collection entry only being held in memory // at any point in time i.e. old ones are overwritten and so freed for GC. DynamicSAXElementVisitorList.removeDynamicVisitor(domCreatorStack.peek(), executionContext); } DynamicSAXElementVisitorList.addDynamicVisitor(domCreator, executionContext); domCreatorStack.push(domCreator); }
@SuppressWarnings("unchecked") private void pushCreator(DOMCreator domCreator, ExecutionContext executionContext) { Stack<DOMCreator> domCreatorStack = (Stack<DOMCreator>) executionContext.getAttribute(DOMCreator.class); if(domCreatorStack == null) { domCreatorStack = new Stack<DOMCreator>(); executionContext.setAttribute(DOMCreator.class, domCreatorStack); } else if(!domCreatorStack.isEmpty()) { // We need to remove the current DOMCreator from the dynamic visitor list because // we want to stop nodes being added to it and instead, have them added to the new // DOM. This prevents a single huge DOM being created for a huge message (being processed // via SAX) because it maintains a hierarchy of model. Inner model can represent collection // entry instances, with a single model for a single collection entry only being held in memory // at any point in time i.e. old ones are overwritten and so freed for GC. DynamicSAXElementVisitorList.removeDynamicVisitor(domCreatorStack.peek(), executionContext); } DynamicSAXElementVisitorList.addDynamicVisitor(domCreator, executionContext); domCreatorStack.push(domCreator); }
@SuppressWarnings("unchecked") private void pushCreator(DOMCreator domCreator, ExecutionContext executionContext) { Stack<DOMCreator> domCreatorStack = (Stack<DOMCreator>) executionContext.getAttribute(DOMCreator.class); if(domCreatorStack == null) { domCreatorStack = new Stack<DOMCreator>(); executionContext.setAttribute(DOMCreator.class, domCreatorStack); } else if(!domCreatorStack.isEmpty()) { // We need to remove the current DOMCreator from the dynamic visitor list because // we want to stop nodes being added to it and instead, have them added to the new // DOM. This prevents a single huge DOM being created for a huge message (being processed // via SAX) because it maintains a hierarchy of model. Inner model can represent collection // entry instances, with a single model for a single collection entry only being held in memory // at any point in time i.e. old ones are overwritten and so freed for GC. DynamicSAXElementVisitorList.removeDynamicVisitor(domCreatorStack.peek(), executionContext); } DynamicSAXElementVisitorList.addDynamicVisitor(domCreator, executionContext); domCreatorStack.push(domCreator); }
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()); } }
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()); } }
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()); } }
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()); } }
@SuppressWarnings("unchecked") public void visitBefore(SAXElement saxElement, ExecutionContext executionContext) throws SmooksException, IOException { Map<String, SAXSerializer> fragmentSerializers = (Map<String, SAXSerializer>) executionContext.getAttribute(FragmentSerializer.class); if(fragmentSerializers == null) { fragmentSerializers = new HashMap<String, SAXSerializer>(); executionContext.setAttribute(FragmentSerializer.class, fragmentSerializers); } SAXSerializer serializer = new SAXSerializer(); fragmentSerializers.put(bindTo, serializer); if(!omitXMLDeclaration) { serializer.fragmentWriter.write("<?xml version=\"1.0\"?>\n"); } // Now add a dynamic visitor... DynamicSAXElementVisitorList.addDynamicVisitor(serializer, executionContext); notifyStartBean(new Fragment(saxElement), executionContext); }
@SuppressWarnings("unchecked") public void visitBefore(SAXElement saxElement, ExecutionContext executionContext) throws SmooksException, IOException { Map<String, SAXSerializer> fragmentSerializers = (Map<String, SAXSerializer>) executionContext.getAttribute(FragmentSerializer.class); if(fragmentSerializers == null) { fragmentSerializers = new HashMap<String, SAXSerializer>(); executionContext.setAttribute(FragmentSerializer.class, fragmentSerializers); } SAXSerializer serializer = new SAXSerializer(); fragmentSerializers.put(bindTo, serializer); if(!omitXMLDeclaration) { serializer.fragmentWriter.write("<?xml version=\"1.0\"?>\n"); } // Now add a dynamic visitor... DynamicSAXElementVisitorList.addDynamicVisitor(serializer, executionContext); notifyStartBean(new Fragment(saxElement), executionContext); }