class StandardEngineContextFactory implements IEngineContextFactory {




    public StandardEngineContextFactory() {
        super();
    }




    public IEngineContext createEngineContext(
            final IEngineConfiguration configuration, final TemplateData templateData,
            final Map<String, Object> templateResolutionAttributes, final IContext context) {<FILL_FUNCTION_BODY>}


}


        Validate.notNull(context, "Context object cannot be null");

        // NOTE calling getVariableNames() on an IWebContext would be very expensive, as it would mean
        // calling HttpServletRequest#getAttributeNames(), which is very slow in some common implementations
        // (e.g. Apache Tomcat). So it's a good thing we might have tried to reuse the IEngineContext
        // before calling this factory.
        final Set<String> variableNames = context.getVariableNames();

        if (variableNames == null || variableNames.isEmpty()) {
            if (Contexts.isWebContext(context)) {
                final IWebContext webContext = Contexts.asWebContext(context);
                return new WebEngineContext(
                        configuration, templateData, templateResolutionAttributes,
                        webContext.getExchange(),
                        webContext.getLocale(), Collections.EMPTY_MAP);
            }
            return new EngineContext(
                    configuration, templateData, templateResolutionAttributes,
                    context.getLocale(), Collections.EMPTY_MAP);
        }

        final Map<String,Object> variables = new LinkedHashMap<String, Object>(variableNames.size() + 1, 1.0f);
        for (final String variableName : variableNames) {
            variables.put(variableName, context.getVariable(variableName));
        }
        if (Contexts.isWebContext(context)) {
            final IWebContext webContext = Contexts.asWebContext(context);
            return new WebEngineContext(
                    configuration, templateData, templateResolutionAttributes,
                    webContext.getExchange(),
                    webContext.getLocale(), variables);
        }

        return new EngineContext(
                configuration, templateData, templateResolutionAttributes,
                context.getLocale(), variables);

    
<no_super_class>