All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nuiton.i18n.plugin.bundle.csv.I18nBundleModel Maven / Gradle / Ivy

package org.nuiton.i18n.plugin.bundle.csv;

/*
 * #%L
 * I18n :: Maven Plugin
 * %%
 * Copyright (C) 2007 - 2014 CodeLutin
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Lesser Public License for more details.
 * 
 * You should have received a copy of the GNU General Lesser Public
 * License along with this program.  If not, see
 * .
 * #L%
 */

import org.nuiton.csv.ValueGetterSetter;
import org.nuiton.csv.ext.AbstractImportExportModel;

import java.util.Locale;

/**
 * Created on 7/26/14.
 *
 * @author Tony Chemit - [email protected]
 * @since 3.3
 */
public class I18nBundleModel extends AbstractImportExportModel {

    public I18nBundleModel(char separator, Locale[] locales) {
        super(separator);

        newMandatoryColumn("key");
        newColumnForExport("key");

        for (final Locale locale : locales) {

            ValueGetterSetter getterSetter = new ValueGetterSetter() {
                @Override
                public String get(I18nBundleModelRow row) throws Exception {
                    return row.getLocaleValue(locale);
                }

                @Override
                public void set(I18nBundleModelRow row, String s) throws Exception {
                    row.setLocaleValue(locale, s);
                }
            };
            newColumnForExport(locale.getCountry(), getterSetter);
            newMandatoryColumn(locale.getCountry(), getterSetter);
        }
    }

    @Override
    public I18nBundleModelRow newEmptyInstance() {
        return new I18nBundleModelRow();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy