class ModelBuilderTemplateHandler extends AbstractTemplateHandler {

    private final List<IEngineTemplateEvent> events;
    private final IEngineConfiguration configuration;
    private final TemplateData templateData;



    public ModelBuilderTemplateHandler(final IEngineConfiguration configuration, final TemplateData templateData) {
        super();
        Validate.notNull(configuration, "Configuration cannot be null");
        Validate.notNull(templateData, "Template Data cannot be null");
        this.configuration = configuration;
        this.templateData = templateData;
        this.events = new ArrayList<IEngineTemplateEvent>(100);
    }



    public TemplateModel getModel() {
        return new TemplateModel(this.configuration, this.templateData, this.events.toArray(new IEngineTemplateEvent[this.events.size()]));
    }


    // Note we are NOT implementing the setContext method, because we don't need it at all when just using
    // this handler for parsing (we are not processing anything!)



    @Override
    public void handleTemplateStart(final ITemplateStart templateStart) {
        this.events.add(TemplateStart.asEngineTemplateStart(templateStart));
        // The engine event we might have created is not forwarded - this makes cache creating transparent to the handler chain
        super.handleTemplateStart(templateStart);
    }


    @Override
    public void handleTemplateEnd(final ITemplateEnd templateEnd) {
        this.events.add(TemplateEnd.asEngineTemplateEnd(templateEnd));
        // The engine event we might have created is not forwarded - this makes cache creating transparent to the handler chain
        super.handleTemplateEnd(templateEnd);
    }





    @Override
    public void handleText(final IText text) {
        this.events.add(Text.asEngineText(text));
        // The engine event we might have created is not forwarded - this makes cache creating transparent to the handler chain
        super.handleText(text);
    }



    @Override
    public void handleComment(final IComment comment) {
        this.events.add(Comment.asEngineComment(comment));
        // The engine event we might have created is not forwarded - this makes cache creating transparent to the handler chain
        super.handleComment(comment);
    }


    @Override
    public void handleCDATASection(final ICDATASection cdataSection) {<FILL_FUNCTION_BODY>}




    @Override
    public void handleStandaloneElement(final IStandaloneElementTag standaloneElementTag) {
        this.events.add(StandaloneElementTag.asEngineStandaloneElementTag(standaloneElementTag));
        // The engine event we might have created is not forwarded - this makes cache creating transparent to the handler chain
        super.handleStandaloneElement(standaloneElementTag);
    }


    @Override
    public void handleOpenElement(final IOpenElementTag openElementTag) {
        this.events.add(OpenElementTag.asEngineOpenElementTag(openElementTag));
        // The engine event we might have created is not forwarded - this makes cache creating transparent to the handler chain
        super.handleOpenElement(openElementTag);
    }


    @Override
    public void handleCloseElement(final ICloseElementTag closeElementTag) {
        this.events.add(CloseElementTag.asEngineCloseElementTag(closeElementTag));
        // The engine event we might have created is not forwarded - this makes cache creating transparent to the handler chain
        super.handleCloseElement(closeElementTag);
    }




    @Override
    public void handleDocType(final IDocType docType) {
        this.events.add(DocType.asEngineDocType(docType));
        // The engine event we might have created is not forwarded - this makes cache creating transparent to the handler chain
        super.handleDocType(docType);
    }




    @Override
    public void handleXMLDeclaration(final IXMLDeclaration xmlDeclaration) {
        this.events.add(XMLDeclaration.asEngineXMLDeclaration(xmlDeclaration));
        // The engine event we might have created is not forwarded - this makes cache creating transparent to the handler chain
        super.handleXMLDeclaration(xmlDeclaration);
    }




    @Override
    public void handleProcessingInstruction(final IProcessingInstruction processingInstruction) {
        this.events.add(ProcessingInstruction.asEngineProcessingInstruction(processingInstruction));
        // The engine event we might have created is not forwarded - this makes cache creating transparent to the handler chain
        super.handleProcessingInstruction(processingInstruction);
    }


    
}

        this.events.add(CDATASection.asEngineCDATASection(cdataSection));
        // The engine event we might have created is not forwarded - this makes cache creating transparent to the handler chain
        super.handleCDATASection(cdataSection);
    
<methods>public void handleCDATASection(org.thymeleaf.model.ICDATASection) ,public void handleCloseElement(org.thymeleaf.model.ICloseElementTag) ,public void handleComment(org.thymeleaf.model.IComment) ,public void handleDocType(org.thymeleaf.model.IDocType) ,public void handleOpenElement(org.thymeleaf.model.IOpenElementTag) ,public void handleProcessingInstruction(org.thymeleaf.model.IProcessingInstruction) ,public void handleStandaloneElement(org.thymeleaf.model.IStandaloneElementTag) ,public void handleTemplateEnd(org.thymeleaf.model.ITemplateEnd) ,public void handleTemplateStart(org.thymeleaf.model.ITemplateStart) ,public void handleText(org.thymeleaf.model.IText) ,public void handleXMLDeclaration(org.thymeleaf.model.IXMLDeclaration) ,public void setContext(org.thymeleaf.context.ITemplateContext) ,public void setNext(org.thymeleaf.engine.ITemplateHandler) <variables>private org.thymeleaf.context.ITemplateContext context,private org.thymeleaf.engine.ITemplateHandler next