001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.model.impl;
016    
017    import com.liferay.portal.kernel.util.CookieKeys;
018    import com.liferay.portal.kernel.util.RemotePreference;
019    
020    import javax.servlet.http.Cookie;
021    
022    /**
023     * @author Carlos Sierra Andr??s
024     */
025    public class CookieRemotePreference implements RemotePreference {
026    
027            public CookieRemotePreference(Cookie cookie) {
028                    _cookie = cookie;
029    
030                    String cookieName = cookie.getName();
031    
032                    _name = cookieName.substring(
033                            CookieKeys.REMOTE_PREFERENCE_PREFIX.length());
034            }
035    
036            public Cookie getCookie() {
037                    return _cookie;
038            }
039    
040            @Override
041            public String getName() {
042                    return _name;
043            }
044    
045            @Override
046            public String getValue() {
047                    return _cookie.getValue();
048            }
049    
050            private Cookie _cookie;
051            private String _name;
052    
053    }