class DecoupledTemplateLogicUtils {


    private static final Logger logger = LoggerFactory.getLogger(DecoupledTemplateLogicUtils.class);




    public static DecoupledTemplateLogic computeDecoupledTemplateLogic(
            final IEngineConfiguration configuration,
            final String ownerTemplate, final String template, final Set<String> templateSelectors,
            final ITemplateResource resource, final TemplateMode templateMode,
            final IMarkupParser parser) throws IOException, ParseException {<FILL_FUNCTION_BODY>}



    private DecoupledTemplateLogicUtils() {
        super();
    }

}


        Validate.notNull(configuration, "Engine Configuration cannot be null");
        Validate.notNull(template, "Template cannot be null");
        Validate.notNull(resource, "Template Resource cannot be null");
        Validate.notNull(templateMode, "Template Mode cannot be null");

        final IDecoupledTemplateLogicResolver decoupledTemplateLogicResolver = configuration.getDecoupledTemplateLogicResolver();

        final ITemplateResource decoupledResource =
                decoupledTemplateLogicResolver.resolveDecoupledTemplateLogic(
                        configuration, ownerTemplate, template, templateSelectors, resource, templateMode);

        if (!decoupledResource.exists()) {

            if (logger.isTraceEnabled()) {
                logger.trace(
                        "[THYMELEAF][{}] Decoupled logic for template \"{}\" could not be resolved as relative resource \"{}\". " +
                        "This does not need to be an error, as templates may lack a corresponding decoupled logic file.",
                        new Object[] {TemplateEngine.threadIndex(), LoggingUtils.loggifyTemplateName(template), decoupledResource.getDescription()});
            }

            return null;
        }


        if (logger.isTraceEnabled()) {
            logger.trace(
                    "[THYMELEAF][{}] Decoupled logic for template \"{}\" has been resolved as relative resource \"{}\"",
                    new Object[] {TemplateEngine.threadIndex(), LoggingUtils.loggifyTemplateName(template), decoupledResource.getDescription()});
        }


        /*
         * The decoupled template logic resource exists, so we should parse it before the template itself, in order
         * to obtain the logic to be injected on the "real" template during parsing.
         */

        final DecoupledTemplateLogicBuilderMarkupHandler decoupledMarkupHandler =
                new DecoupledTemplateLogicBuilderMarkupHandler(template, templateMode);

        parser.parse(decoupledResource.reader(), decoupledMarkupHandler);

        return decoupledMarkupHandler.getDecoupledTemplateLogic();

    
<no_super_class>