Author: chatellier Date: 2008-10-29 10:14:54 +0000 (Wed, 29 Oct 2008) New Revision: 1229 Removed: lutinutil/trunk/src/main/java/org/codelutin/i18n/I18nf.java Modified: lutinutil/trunk/changelog lutinutil/trunk/pom.xml lutinutil/trunk/src/main/java/org/codelutin/i18n/I18n.java lutinutil/trunk/src/main/java/org/codelutin/i18n/Language.java lutinutil/trunk/src/main/java/org/codelutin/i18n/LocaleEditor.java lutinutil/trunk/src/main/java/org/codelutin/log/LutinLog.java lutinutil/trunk/src/main/java/org/codelutin/log/LutinLogEvent.java lutinutil/trunk/src/main/java/org/codelutin/log/LutinLogFactory.java lutinutil/trunk/src/main/java/org/codelutin/log/LutinProgressEvent.java lutinutil/trunk/src/main/java/org/codelutin/log/ProgressMonitorFrame.java lutinutil/trunk/src/main/java/org/codelutin/util/ApplicationConfig.java lutinutil/trunk/src/main/java/org/codelutin/util/ObjectUtil.java Log: Remove duplicated i18nf class and remove deprecated i18n code Version bump to next major snapshot Modified: lutinutil/trunk/changelog =================================================================== --- lutinutil/trunk/changelog 2008-10-26 13:58:03 UTC (rev 1228) +++ lutinutil/trunk/changelog 2008-10-29 10:14:54 UTC (rev 1229) @@ -1,3 +1,6 @@ +ver 1.0 ??? ??? + * Remove deprecated I18n._ and replace by temporary code + ver-0-31 chemit 2008???? * always build javadoc * Change group id Modified: lutinutil/trunk/pom.xml =================================================================== --- lutinutil/trunk/pom.xml 2008-10-26 13:58:03 UTC (rev 1228) +++ lutinutil/trunk/pom.xml 2008-10-29 10:14:54 UTC (rev 1229) @@ -53,7 +53,7 @@ <!-- ************************************************************* --> <name>Lutin utilities library</name> - <version>0.32-SNAPSHOT</version> + <version>1.0-SNAPSHOT</version> <description>Library of usefull class to be used in any project.</description> <inceptionYear>2004</inceptionYear> Modified: lutinutil/trunk/src/main/java/org/codelutin/i18n/I18n.java =================================================================== --- lutinutil/trunk/src/main/java/org/codelutin/i18n/I18n.java 2008-10-26 13:58:03 UTC (rev 1228) +++ lutinutil/trunk/src/main/java/org/codelutin/i18n/I18n.java 2008-10-29 10:14:54 UTC (rev 1229) @@ -30,15 +30,16 @@ package org.codelutin.i18n; -import org.codelutin.i18n.bundle.I18nBundleManager; -import org.codelutin.util.ConverterUtil; - import java.net.URL; -import java.text.MessageFormat; import java.util.Arrays; import java.util.Locale; import java.util.logging.Logger; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.codelutin.i18n.bundle.I18nBundleManager; +import org.codelutin.util.ConverterUtil; + /** * This class is a facility for internationalization. To use it in your soft, * you can either : @@ -60,6 +61,9 @@ */ public class I18n { + /** to use log facility, just put in your code: log.info(\"...\"); */ + private static Log log = LogFactory.getLog(I18n.class); + public static final String ISO_8859_1_ENCONDING = "ISO-8859-1"; public static final String UTF_8_ENCONDING = "UTF-8"; @@ -102,16 +106,6 @@ } /** - * Initialise la librairie. - * - * @param language une chaine representant la langue à utiliser fr, en, ... - * @deprecated - */ - public static void init(String language) { - init(language, null, null); - } - - /** * Initialise la librairie * * @param language une chaine representant la langue à utiliser fr, en, ... @@ -159,14 +153,11 @@ /** * Retourne la chaine traduite si possible. * - * @param message message formate avec la m?me syntaxe que {@link MessageFormat} + * @param message message formate avec la meme syntaxe que {@link String#format} * @param args les parametres pour le message. * @return la traduction si possible ou la chaine passee en parametre * sinon. - * @deprecated use {@link I18nf#_} that used String.format. When all project are - * switched this method use String.format too. */ - @Deprecated public static String _(String message, Object... args) { String result = message; Language language = loader == null ? null : loader.getLanguage(); @@ -174,49 +165,46 @@ result = language.translate(message); } try { - return applyFilter(MessageFormat.format(result, args)); + return applyFilter(String.format(result, args)); } catch (Exception eee) { try { - return applyFilter(MessageFormat.format(message, args)); + return applyFilter(String.format(message, args)); } catch (Exception zzz) { - Logger.getLogger("org.codelutin.i18n.I18n").warning(_("lutinutil.error.i18n.untranslated.message", message)); + log.warn(I18n._("lutinutil.error.i18n.untranslated.message", message)); return applyFilter(message); } } } /** - * Retourne la chaine passé en argument - * - * @param message la chaine à traduire - * @return la chaine passée en argument - * sinon. - */ - public static String n_(String message) { - return message; - } - - /** * Retourne la chaine passée en argument. * * @param message message formate avec la meme syntaxe que {@link - * MessageFormat}Message + * java.text.MessageFormat} * @param args les parametres pour le message. * @return le message passe en argument mais formatte * avec les parametres - * @deprecated use {@link I18nf#n_} that used String.format. When all project are - * switched this method use String.format too. */ - @Deprecated public static String n_(String message, Object... args) { try { - return MessageFormat.format(message, args); + return String.format(message, args); } catch (Exception eee) { - Logger.getLogger("org.codelutin.i18n.I18n").warning(I18n._("lutinutil.error.i18n.unformated.message", message, Arrays.toString(args))); + log.warn(I18n._("lutinutil.error.i18n.unformated.message", message, Arrays.toString(args))); return message; } } + /** + * Retourne la chaine passé en argument + * + * @param message la chaine à traduire + * @return la chaine passée en argument + * sinon. + */ + public static String n_(String message) { + return message; + } + public static String getRecordFilePath() { return recordFilePath; } @@ -308,17 +296,19 @@ * @return the required loader with given encoding */ protected static synchronized I18nLoader getLoader(String encoding) { - if (encoding == null) { - encoding = DEFAULT_ENCODING; + + String localEncoding = encoding; + if (localEncoding == null) { + localEncoding = DEFAULT_ENCODING; } if (loader == null) { - loader = new I18nLoader(encoding); + loader = new I18nLoader(localEncoding); } else { - if (!loader.getEncoding().equals(encoding)) { + if (!loader.getEncoding().equals(localEncoding)) { // close previous loader but not the bundle manager loader.close(); // open a new loader - loader = new I18nLoader(encoding); + loader = new I18nLoader(localEncoding); } } return loader; Deleted: lutinutil/trunk/src/main/java/org/codelutin/i18n/I18nf.java =================================================================== --- lutinutil/trunk/src/main/java/org/codelutin/i18n/I18nf.java 2008-10-26 13:58:03 UTC (rev 1228) +++ lutinutil/trunk/src/main/java/org/codelutin/i18n/I18nf.java 2008-10-29 10:14:54 UTC (rev 1229) @@ -1,84 +0,0 @@ -/* *##% Lutin utilities library - * Copyright (C) 2004 - 2008 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 - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */ - -package org.codelutin.i18n; - - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.util.Arrays; - -/** - * Transition class during project switch between MessageFormat.format syntax - * to String.format syntax. - * - * @author poussin - * @version $Revision$ - * <p/> - * Last update: $Date$ - * by : $Author$ - */ -public class I18nf extends I18n { - - /** to use log facility, just put in your code: log.info(\"...\"); */ - static private Log log = LogFactory.getLog(I18nf.class); - - /** - * Retourne la chaine traduite si possible. - * - * @param message message formate avec la meme syntaxe que {@link String#format} - * @param args les parametres pour le message. - * @return la traduction si possible ou la chaine passee en parametre - * sinon. - */ - public static String _(String message, Object... args) { - String result = message; - Language language = loader == null ? null : loader.getLanguage(); - if (language != null) { - result = language.translate(message); - } - try { - return applyFilter(String.format(result, args)); - } catch (Exception eee) { - try { - return applyFilter(String.format(message, args)); - } catch (Exception zzz) { - log.warn(I18n._("lutinutil.error.i18n.untranslated.message", message)); - return applyFilter(message); - } - } - } - - /** - * Retourne la chaine passée en argument. - * - * @param message message formate avec la meme syntaxe que {@link - * java.text.MessageFormat} - * @param args les parametres pour le message. - * @return le message passe en argument mais formatte - * avec les parametres - */ - public static String n_(String message, Object... args) { - try { - return String.format(message, args); - } catch (Exception eee) { - log.warn(I18n._("lutinutil.error.i18n.unformated.message", message, Arrays.toString(args))); - return message; - } - } -} Modified: lutinutil/trunk/src/main/java/org/codelutin/i18n/Language.java =================================================================== --- lutinutil/trunk/src/main/java/org/codelutin/i18n/Language.java 2008-10-26 13:58:03 UTC (rev 1228) +++ lutinutil/trunk/src/main/java/org/codelutin/i18n/Language.java 2008-10-29 10:14:54 UTC (rev 1229) @@ -148,7 +148,7 @@ return sentence; } try { - Enumeration e = resource.propertyNames(); + Enumeration<?> e = resource.propertyNames(); // Look for the given sentence through all translations while (e.hasMoreElements()) { String key = (String) e.nextElement(); Modified: lutinutil/trunk/src/main/java/org/codelutin/i18n/LocaleEditor.java =================================================================== --- lutinutil/trunk/src/main/java/org/codelutin/i18n/LocaleEditor.java 2008-10-26 13:58:03 UTC (rev 1228) +++ lutinutil/trunk/src/main/java/org/codelutin/i18n/LocaleEditor.java 2008-10-29 10:14:54 UTC (rev 1229) @@ -32,6 +32,9 @@ */ public class LocaleEditor extends JComboBox { + /** serialVersionUID */ + private static final long serialVersionUID = -6777873426011538807L; + protected Locale[] type; public static LocaleEditor newEditor(Locale... type) { Modified: lutinutil/trunk/src/main/java/org/codelutin/log/LutinLog.java =================================================================== --- lutinutil/trunk/src/main/java/org/codelutin/log/LutinLog.java 2008-10-26 13:58:03 UTC (rev 1228) +++ lutinutil/trunk/src/main/java/org/codelutin/log/LutinLog.java 2008-10-29 10:14:54 UTC (rev 1229) @@ -146,6 +146,7 @@ /** * apres un start le temps avant de mettre le progress en marche (<=0 pour jamais) + * @param time time */ public void setActivateProgressMonitorTime(long time) { activeProgressMonitorTime = time; @@ -167,7 +168,7 @@ fireProgressEvent(LutinProgressEvent.ProgressType.start); } /** - * @return + * @return ProgressMonitorFrame */ protected Component getProgressMonitorFrame() { if (progressMonitorFrame == null) { @@ -181,8 +182,9 @@ } /** - * si on a demande a ce que la tache soit arretee - * @return + * Si on a demande a ce que la tache soit arretee. + * + * @return stopped state */ public boolean isAskStopTask() { boolean result = progressState == ProgressState.stopAsked; @@ -218,9 +220,9 @@ } /** - * donne le timeout particulier pour une tache + * Donne le timeout particulier pour une tache. * - * @return + * @return timeout */ public long getTimeout() { return timeout; Modified: lutinutil/trunk/src/main/java/org/codelutin/log/LutinLogEvent.java =================================================================== --- lutinutil/trunk/src/main/java/org/codelutin/log/LutinLogEvent.java 2008-10-26 13:58:03 UTC (rev 1228) +++ lutinutil/trunk/src/main/java/org/codelutin/log/LutinLogEvent.java 2008-10-29 10:14:54 UTC (rev 1229) @@ -48,7 +48,12 @@ user, trace, debug, info, warn, error, fatal } - /** @param source */ + /** + * @param source + * @param logType + * @param msg + * @param eee + */ public LutinLogEvent(Object source, LogType logType, String msg, Throwable eee) { super(source); this.logType = logType; Modified: lutinutil/trunk/src/main/java/org/codelutin/log/LutinLogFactory.java =================================================================== --- lutinutil/trunk/src/main/java/org/codelutin/log/LutinLogFactory.java 2008-10-26 13:58:03 UTC (rev 1228) +++ lutinutil/trunk/src/main/java/org/codelutin/log/LutinLogFactory.java 2008-10-29 10:14:54 UTC (rev 1229) @@ -63,7 +63,7 @@ return instance; } - static public LutinLog getLutinLog(Class clazz) { + static public LutinLog getLutinLog(Class<?> clazz) { LutinLogFactory factory = LutinLogFactory.getInstance(); LutinLog result = (LutinLog) factory.getInstance(clazz); return result; Modified: lutinutil/trunk/src/main/java/org/codelutin/log/LutinProgressEvent.java =================================================================== --- lutinutil/trunk/src/main/java/org/codelutin/log/LutinProgressEvent.java 2008-10-26 13:58:03 UTC (rev 1228) +++ lutinutil/trunk/src/main/java/org/codelutin/log/LutinProgressEvent.java 2008-10-29 10:14:54 UTC (rev 1229) @@ -44,7 +44,10 @@ min, max, value, askStop, cancelAskStop, start, end } - /** @param source */ + /** + * @param source + * @param type + */ public LutinProgressEvent(Object source, ProgressType type) { super(source); this.type = type; Modified: lutinutil/trunk/src/main/java/org/codelutin/log/ProgressMonitorFrame.java =================================================================== --- lutinutil/trunk/src/main/java/org/codelutin/log/ProgressMonitorFrame.java 2008-10-26 13:58:03 UTC (rev 1228) +++ lutinutil/trunk/src/main/java/org/codelutin/log/ProgressMonitorFrame.java 2008-10-29 10:14:54 UTC (rev 1229) @@ -45,6 +45,8 @@ public class ProgressMonitorFrame extends JFrame { + /** serialVersionUID */ + private static final long serialVersionUID = 3878314562707954612L; protected LutinLog lutinLog; protected JLabel label; protected JProgressBar progress; Modified: lutinutil/trunk/src/main/java/org/codelutin/util/ApplicationConfig.java =================================================================== --- lutinutil/trunk/src/main/java/org/codelutin/util/ApplicationConfig.java 2008-10-26 13:58:03 UTC (rev 1228) +++ lutinutil/trunk/src/main/java/org/codelutin/util/ApplicationConfig.java 2008-10-29 10:14:54 UTC (rev 1229) @@ -21,7 +21,7 @@ import org.apache.commons.beanutils.ConvertUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import static org.codelutin.i18n.I18nf._; +import static org.codelutin.i18n.I18n._; import java.io.File; import java.io.FileWriter; Modified: lutinutil/trunk/src/main/java/org/codelutin/util/ObjectUtil.java =================================================================== --- lutinutil/trunk/src/main/java/org/codelutin/util/ObjectUtil.java 2008-10-26 13:58:03 UTC (rev 1228) +++ lutinutil/trunk/src/main/java/org/codelutin/util/ObjectUtil.java 2008-10-29 10:14:54 UTC (rev 1229) @@ -33,7 +33,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; -import static org.codelutin.i18n.I18nf._; +import static org.codelutin.i18n.I18n._; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory;