001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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    }