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.model.impl;
016    
017    import com.liferay.portal.kernel.json.JSON;
018    import com.liferay.portal.kernel.language.LanguageUtil;
019    import com.liferay.portal.model.CountryConstants;
020    
021    import java.util.Locale;
022    
023    /**
024     * @author Brian Wing Shun Chan
025     * @author Hugo Huijser
026     */
027    public class CountryImpl extends CountryBaseImpl {
028    
029            @Override
030            public String getName(Locale locale) {
031                    String name = LanguageUtil.get(
032                            locale, CountryConstants.NAME_PREFIX + getName());
033    
034                    if (!name.startsWith(CountryConstants.NAME_PREFIX)) {
035                            return name;
036                    }
037    
038                    return getName();
039            }
040    
041            @Override
042            public String getNameCurrentLanguageId() {
043                    return _nameCurrentLanguageId;
044            }
045    
046            @JSON
047            @Override
048            public String getNameCurrentValue() {
049                    Locale locale = getLocale(_nameCurrentLanguageId);
050    
051                    return getName(locale);
052            }
053    
054            @Override
055            public void setNameCurrentLanguageId(String languageId) {
056                    _nameCurrentLanguageId = languageId;
057            }
058    
059            private String _nameCurrentLanguageId;
060    
061    }