001    /**
002     * Copyright (c) 2000-present 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.kernel.servlet.taglib.ui;
016    
017    import com.liferay.portal.kernel.util.LocaleUtil;
018    
019    import java.util.Locale;
020    import java.util.Set;
021    
022    /**
023     * @author Julio Camarero
024     */
025    public class LanguageEntry {
026    
027            public LanguageEntry(
028                    Set<String> duplicateLanguages, Locale currentLocale, Locale locale,
029                    String url, boolean disabled) {
030    
031                    _duplicateLanguages = duplicateLanguages;
032                    _locale = locale;
033                    _url = url;
034                    _disabled = disabled;
035    
036                    _languageId = LocaleUtil.toLanguageId(locale);
037    
038                    if (LocaleUtil.equals(locale, currentLocale)) {
039                            _selected = true;
040                    }
041                    else {
042                            _selected = false;
043                    }
044            }
045    
046            public String getLanguageId() {
047                    return _languageId;
048            }
049    
050            public Locale getLocale() {
051                    return _locale;
052            }
053    
054            public String getLongDisplayName() {
055                    return LocaleUtil.getLongDisplayName(_locale, _duplicateLanguages);
056            }
057    
058            public String getShortDisplayName() {
059                    return LocaleUtil.getShortDisplayName(_locale, _duplicateLanguages);
060            }
061    
062            public String getURL() {
063                    return _url;
064            }
065    
066            public String getW3cLanguageId() {
067                    return LocaleUtil.toW3cLanguageId(_languageId);
068            }
069    
070            public boolean isDisabled() {
071                    return _disabled;
072            }
073    
074            public boolean isSelected() {
075                    return _selected;
076            }
077    
078            private final boolean _disabled;
079            private final Set<String> _duplicateLanguages;
080            private final String _languageId;
081            private final Locale _locale;
082            private final boolean _selected;
083            private final String _url;
084    
085    }