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) {
030    
031                    _duplicateLanguages = duplicateLanguages;
032                    _locale = locale;
033                    _url = url;
034    
035                    _languageId = LocaleUtil.toLanguageId(locale);
036    
037                    if (LocaleUtil.equals(locale, currentLocale)) {
038                            _selected = true;
039                    }
040                    else {
041                            _selected = false;
042                    }
043            }
044    
045            public String getLanguageId() {
046                    return _languageId;
047            }
048    
049            public Locale getLocale() {
050                    return _locale;
051            }
052    
053            public String getLongDisplayName() {
054                    return LocaleUtil.getLongDisplayName(_locale, _duplicateLanguages);
055            }
056    
057            public String getShortDisplayName() {
058                    return LocaleUtil.getShortDisplayName(_locale, _duplicateLanguages);
059            }
060    
061            public String getURL() {
062                    return _url;
063            }
064    
065            public String getW3cLanguageId() {
066                    return LocaleUtil.toW3cLanguageId(_languageId);
067            }
068    
069            public boolean isSelected() {
070                    return _selected;
071            }
072    
073            private final Set<String> _duplicateLanguages;
074            private final String _languageId;
075            private final Locale _locale;
076            private final boolean _selected;
077            private final String _url;
078    
079    }