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.portlet.dynamicdatamapping.model;
016    
017    import com.liferay.portal.kernel.util.LocaleUtil;
018    
019    import java.util.HashMap;
020    import java.util.Locale;
021    import java.util.Map;
022    import java.util.Set;
023    
024    /**
025     * @author Marcellus Tavares
026     */
027    public class UnlocalizedValue implements Value {
028    
029            public UnlocalizedValue(String value) {
030                    _values.put(LocaleUtil.ROOT, value);
031            }
032    
033            @Override
034            public void addString(Locale locale, String value) {
035                    _values.put(LocaleUtil.ROOT, value);
036            }
037    
038            @Override
039            public Set<Locale> getAvailableLocales() {
040                    return _values.keySet();
041            }
042    
043            @Override
044            public Locale getDefaultLocale() {
045                    return LocaleUtil.ROOT;
046            }
047    
048            @Override
049            public String getString(Locale locale) {
050                    return _values.get(LocaleUtil.ROOT);
051            }
052    
053            @Override
054            public Map<Locale, String> getValues() {
055                    return _values;
056            }
057    
058            @Override
059            public boolean isLocalized() {
060                    return false;
061            }
062    
063            @Override
064            public void setDefaultLocale(Locale defaultLocale) {
065                    throw new UnsupportedOperationException();
066            }
067    
068            private final Map<Locale, String> _values = new HashMap<Locale, String>();
069    
070    }