// Path: src/main/java/org/thymeleaf/itutorial/beans/Gender.java
// public enum Gender {
//     
//     FEMALE("Female gender"),
//     MALE("Male gender");
// 
//     private String description;
//     
//     Gender(final String description) {
//         this.description = description;
//     }
//     
//     public String getDescription() {
//         return this.description;
//     }
//     
// }
// 
// Path: src/main/java/org/thymeleaf/itutorial/beans/PaymentMethod.java
// public enum PaymentMethod {
//     
//     CREDIT_CARD("Credit card payment"),
//     DIRECT_DEBIT("Direct debit payment"),
//     BANK_TRANSFER("Bank transfer payment");
// 
//     private String description;
//     
//     PaymentMethod(final String description) {
//         this.description = description;
//     }
//     
//     public String getDescription() {
//         return this.description;
//     }
//     
// }
// 
// Path: src/main/java/org/thymeleaf/tools/memoryexecutor/StaticTemplateExecutor.java
// public class StaticTemplateExecutor {
//     
//     private static final String TEMPLATE_NAME = "custom";
// 
//     private final String templateMode;
//     
//     private final IContext context;
//     
//     private final IMessageResolver messageResolver;
//     
//     public StaticTemplateExecutor(final IContext context, final IMessageResolver messageResolver, final String templateMode) {
//         Validate.notNull(context, "Context must be non-null");
//         Validate.notNull(templateMode, "Template mode must be non-null");
//         Validate.notNull(messageResolver, "MessageResolver must be non-null");
//         this.context = context;
//         this.templateMode = templateMode;
//         this.messageResolver = messageResolver;
//     }
//     
//     public String processTemplateCode(final String code) {
//         Validate.notNull(code, "Code must be non-null");
//         ITemplateResolver templateResolver = new MemoryTemplateResolver(code, templateMode);
//         SpringTemplateEngine templateEngine = new SpringTemplateEngine();
//         templateEngine.setMessageResolver(messageResolver);
//         templateEngine.setTemplateResolver(templateResolver);
//         templateEngine.initialize();
//         return templateEngine.process(TEMPLATE_NAME, context);
//     }    
// }


import org.thymeleaf.templatemode.StandardTemplateModeHandlers;
import org.thymeleaf.tools.memoryexecutor.StaticTemplateExecutor;
import java.util.Locale;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.context.ApplicationContext;
import org.springframework.context.MessageSource;
import org.springframework.core.convert.ConversionService;
import org.thymeleaf.context.IWebContext;
import org.thymeleaf.itutorial.beans.Gender;
import org.thymeleaf.itutorial.beans.PaymentMethod;
import org.thymeleaf.spring3.messageresolver.SpringMessageResolver;
/*
 * =============================================================================
 *
 *   Copyright (c) 2011-2014, The THYMELEAF team (http://www.thymeleaf.org)
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
 * =============================================================================
 */
package org.thymeleaf.itutorial;


public class TemplateExecutor {

    private final StaticTemplateExecutor executor;

    public TemplateExecutor(
            final HttpServletRequest request, final HttpServletResponse response,
            final ServletContext servletContext, final MessageSource messageSource,
            final Locale locale, final ApplicationContext applicationContext,
            final ConversionService conversionService) {
        IWebContext context = new OfflineSpringWebContext(request, response, servletContext, applicationContext, conversionService);
        // Model attributes
        context.getVariables().put("product", DAO.loadProduct());
        context.getVariables().put("productList", DAO.loadAllProducts());
// Path: src/main/java/org/thymeleaf/itutorial/beans/Gender.java
// public enum Gender {
//     
//     FEMALE("Female gender"),
//     MALE("Male gender");
// 
//     private String description;
//     
//     Gender(final String description) {
//         this.description = description;
//     }
//     
//     public String getDescription() {
//         return this.description;
//     }
//     
// }
// 
// Path: src/main/java/org/thymeleaf/itutorial/beans/PaymentMethod.java
// public enum PaymentMethod {
//     
//     CREDIT_CARD("Credit card payment"),
//     DIRECT_DEBIT("Direct debit payment"),
//     BANK_TRANSFER("Bank transfer payment");
// 
//     private String description;
//     
//     PaymentMethod(final String description) {
//         this.description = description;
//     }
//     
//     public String getDescription() {
//         return this.description;
//     }
//     
// }
// 
// Path: src/main/java/org/thymeleaf/tools/memoryexecutor/StaticTemplateExecutor.java
// public class StaticTemplateExecutor {
//     
//     private static final String TEMPLATE_NAME = "custom";
// 
//     private final String templateMode;
//     
//     private final IContext context;
//     
//     private final IMessageResolver messageResolver;
//     
//     public StaticTemplateExecutor(final IContext context, final IMessageResolver messageResolver, final String templateMode) {
//         Validate.notNull(context, "Context must be non-null");
//         Validate.notNull(templateMode, "Template mode must be non-null");
//         Validate.notNull(messageResolver, "MessageResolver must be non-null");
//         this.context = context;
//         this.templateMode = templateMode;
//         this.messageResolver = messageResolver;
//     }
//     
//     public String processTemplateCode(final String code) {
//         Validate.notNull(code, "Code must be non-null");
//         ITemplateResolver templateResolver = new MemoryTemplateResolver(code, templateMode);
//         SpringTemplateEngine templateEngine = new SpringTemplateEngine();
//         templateEngine.setMessageResolver(messageResolver);
//         templateEngine.setTemplateResolver(templateResolver);
//         templateEngine.initialize();
//         return templateEngine.process(TEMPLATE_NAME, context);
//     }    
// }


// Path: src/main/java/org/thymeleaf/itutorial/TemplateExecutor.java
import org.thymeleaf.templatemode.StandardTemplateModeHandlers;
import org.thymeleaf.tools.memoryexecutor.StaticTemplateExecutor;
import java.util.Locale;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.context.ApplicationContext;
import org.springframework.context.MessageSource;
import org.springframework.core.convert.ConversionService;
import org.thymeleaf.context.IWebContext;
import org.thymeleaf.itutorial.beans.Gender;
import org.thymeleaf.itutorial.beans.PaymentMethod;
import org.thymeleaf.spring3.messageresolver.SpringMessageResolver;

/*
 * =============================================================================
 *
 *   Copyright (c) 2011-2014, The THYMELEAF team (http://www.thymeleaf.org)
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
 * =============================================================================
 */
package org.thymeleaf.itutorial;


public class TemplateExecutor {

    private final StaticTemplateExecutor executor;

    public TemplateExecutor(
            final HttpServletRequest request, final HttpServletResponse response,
            final ServletContext servletContext, final MessageSource messageSource,
            final Locale locale, final ApplicationContext applicationContext,
            final ConversionService conversionService) {
        IWebContext context = new OfflineSpringWebContext(request, response, servletContext, applicationContext, conversionService);
        // Model attributes
        context.getVariables().put("product", DAO.loadProduct());
        context.getVariables().put("productList", DAO.loadAllProducts());
        context.getVariables().put("html", "This is an <em>HTML</em> text. <b>Enjoy yourself!</b>");