Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package pl.matisoft.soy.global.runtime.resolvers;
 
 
Created with IntelliJ IDEA. User: mati Date: 01/11/2013 Time: 16:37
public class CookieResolver implements RuntimeResolver {
    private static final Logger logger = LoggerFactory.getLogger(CookieResolver.class);
    private String prefix = "_request.cookie.";
    @Override
    public void resolveData(final HttpServletRequest requestfinal HttpServletResponse responsefinal Map<String, ? extends Objectmodelfinal SoyMapData root) {
        if (request.getCookies() == null) {
            .debug("no cookies!");
            return;
        }
        for (final Cookie cookie : request.getCookies()) {
            if (StringUtils.hasLength(cookie.getName())) {
                final String keyPrefix =  + cookie.getName();
                root.put(keyPrefix + ".name"cookie.getName());
                if (StringUtils.hasLength(cookie.getValue())) {
                    root.put(keyPrefix + ".value"cookie.getValue());
                }
                if (StringUtils.hasLength(cookie.getComment())) {
                    root.put(keyPrefix + ".comment"cookie.getComment());
                }
                if (StringUtils.hasLength(cookie.getDomain())) {
                    root.put(keyPrefix + ".domain"cookie.getDomain());
                }
                root.put(keyPrefix + ".maxAge"cookie.getMaxAge());
                if (StringUtils.hasLength(cookie.getPath())) {
                    root.put(keyPrefix + ".path"cookie.getPath());
                }
                root.put(keyPrefix + ".version"cookie.getVersion());
                root.put(keyPrefix + ".secure"cookie.getSecure());
            }
        }
    }
    public String getPrefix() {
        return ;
    }
    public void setPrefix(String prefix) {
        this. = prefix;
    }
New to GrepCode? Check out our FAQ X