Author: tchemit Date: 2011-01-31 09:01:45 +0100 (Mon, 31 Jan 2011) New Revision: 1868 Url: http://nuiton.org/repositories/revision/i18n/1868 Log: Evolution #1241: Remove all the deprecated api from version 2.1 Removed: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/KeysModifier.java trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserEvent.java Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserGWTJavaMojo.java trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJspMojo.java trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserTapestryMojo.java trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidationMojo.java trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlUserMojo.java trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18n.java Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java 2011-01-27 08:53:24 UTC (rev 1867) +++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java 2011-01-31 08:01:45 UTC (rev 1868) @@ -44,22 +44,6 @@ /** @return the outGetter to use for the instance (java.getter,...) */ protected abstract String getOutGetter(); - /** - * @return the starting regex expression to catch keys in key modifier - * @deprecated since 1.2, no more used, incompatible with multi-threading - * parsing - */ - @Deprecated - protected abstract String getKeyModifierStart(); - - /** - * @return the ending regex expression to catch keys in key modifier - * @deprecated since 1.2, no more used, incompatible with multi-threading - * parsing - */ - @Deprecated - protected abstract String getKeyModifierEnd(); - /** @return the default includes to add to directory scanner */ protected abstract String[] getDefaultIncludes(); @@ -89,21 +73,6 @@ protected File cp; /** - * To activate the modification of keys - * <p/> - * <b>Note :</b> By default not active, since it requires to have UI available - * and this is not acceptable for server build. - * <p/> - * <b>Note :</b> At the moment the fully fonctionnality is no more available - * and will be recode in a separated goal (one day...) - * - * @parameter expression="${i18n.keysModifier}" default-value="false" - * @deprecated since 1.2, will no more used - */ - @Deprecated - protected boolean keysModifier; - - /** * To treate default entry offered by the mojo. * * @parameter expression="${i18n.treateDefaultEntry}" default-value="true" @@ -209,11 +178,7 @@ @Override protected void doAction() throws Exception { - if (keysModifier) { - getLog().warn("\n" + - "\nWarning : keysModifier is deprecated and has no more effect." + - "\n"); - } + if (!silent && strictMode) { getLog().info("config - strictMode is on (all files will be" + " parsed)."); Deleted: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/KeysModifier.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/KeysModifier.java 2011-01-27 08:53:24 UTC (rev 1867) +++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/KeysModifier.java 2011-01-31 08:01:45 UTC (rev 1868) @@ -1,246 +0,0 @@ -/* - * #%L - * I18n :: Maven Plugin - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2007 - 2010 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>. - * #L% - */ - -package org.nuiton.i18n.plugin.parser; - -import org.nuiton.plugin.PluginHelper; - -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JTextField; -import java.awt.Container; -import java.awt.GridLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * IHM permettant de modifier les clés de traduction en direct dans les fichiers - * parsés et les fichiers de propriétés. - * - * @author julien - * @deprecated since 1.2, no more used actually, since we are using - * multi-thread parsing which is not compatible with a sequential - * parsing. - */ -@Deprecated -public class KeysModifier extends JFrame implements ParserEvent { - - private static final long serialVersionUID = 1L; - - // Modification des clés dans le fichier - - protected List<String> newKeys; - - protected boolean needModifiedFile; - - protected String patternLeft; - - protected String patternRight; - - protected String encoding; - - // Interface - - protected JLabel name = new JLabel(); - - protected JLabel path = new JLabel(); - - protected JTextField key = new JTextField(); - - protected JTextField pattern = new JTextField(".*"); - - protected JCheckBox onlyNewKey = new JCheckBox(); - - protected JButton next = new JButton("Next >>"); - - private static KeysModifier keysModifier; - - /** - * Récupération d'une instance de l'interface - * - * @param patternLeft left pattern - * @param patternRight right pattern - * @param encoding encoding - * @return the shared instance with new config - */ - public static KeysModifier getInstance(String patternLeft, - String patternRight, - String encoding) { - if (keysModifier == null) { - keysModifier = new KeysModifier(); - } - - - keysModifier.encoding = encoding; - keysModifier.patternLeft = patternLeft; - keysModifier.patternRight = patternRight; - - return keysModifier; - } - - /** Contructeur de l'interface */ - private KeysModifier() { - setLayout(new GridLayout(9, 2, 10, 10)); - - Container pane = getContentPane(); - pane.add(new JLabel("--- File information ---")); - pane.add(new JLabel()); - - pane.add(new JLabel("Name :")); - pane.add(name); - - pane.add(new JLabel("Path : ")); - pane.add(path); - - pane.add(new JLabel("--- Files language ---")); - pane.add(new JLabel()); - - pane.add(new JLabel("Key :")); - pane.add(key); - - pane.add(new JLabel("--- Filters ---")); - pane.add(new JLabel()); - - pane.add(new JLabel("Pattern :")); - pane.add(pattern); - - pane.add(new JLabel("Only new key :")); - pane.add(onlyNewKey); - - pane.add(new JLabel()); - pane.add(next); - - next.addActionListener(new EventNextKey()); - addWindowListener(new EventWindows()); - - setTitle("Keys modifier"); - setSize(800, 400); -// pack(); - setVisible(true); - } - - @Override - public void eventChangeFile(File file) { - name.setText(file.getName()); - path.setText(file.getPath()); - key.setText(""); - repaint(); - - newKeys = new ArrayList<String>(); - needModifiedFile = false; - } - - @Override - public void eventNextFile(File file) { - if (needModifiedFile) { - String content; - int region = 0; - - try { - content = PluginHelper.readAsString(file, encoding); - } catch (IOException e) { - throw new ParserException(e); - } - - for (Iterator<String> iterator = newKeys.iterator(); - iterator.hasNext();) { - String oldKey = iterator.next(); - String realKey = iterator.next(); - Pattern p = Pattern.compile('(' + patternLeft + - ")(" + Pattern.quote(oldKey) + - ")(" + patternRight + ')'); - Matcher matcher = p.matcher(content); - matcher.region(region, content.length()); - matcher.find(); - region = matcher.start(); - content = matcher.replaceFirst("$1" + realKey + "$3"); - } - - try { - PluginHelper.writeString(file, content, encoding); - } catch (IOException e) { - throw new ParserException(e); - } - } - } - - @Override - public synchronized void eventChangeKey(String keyI18n, boolean newKey) { - key.setText(keyI18n); - newKeys.add(key.getText()); - repaint(); - if (isVisible() && - keyI18n.matches(pattern.getText()) && - (!onlyNewKey.isSelected() || newKey)) { - try { - wait(); - } catch (InterruptedException e) { - throw new ParserException(e); - } - } - } - - @Override - public String eventGetRealKey() { - newKeys.add(key.getText()); - needModifiedFile |= !newKeys.get(newKeys.size() - 1).equals( - newKeys.get(newKeys.size() - 2)); - return key.getText(); - } - - /** Action sur le boutton pour passer a la cle suivante */ - class EventNextKey implements ActionListener { - @Override - public void actionPerformed(ActionEvent e) { - eventNextKey(); - } - } - - /** Action sur la fermeture de la frame */ - class EventWindows extends WindowAdapter { - - @Override - public void windowClosing(WindowEvent e) { - setVisible(false); - eventNextKey(); - } - } - - /** Permet de passer à la clé suivante */ - public synchronized void eventNextKey() { - notifyAll(); - } -} Deleted: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserEvent.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserEvent.java 2011-01-27 08:53:24 UTC (rev 1867) +++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserEvent.java 2011-01-31 08:01:45 UTC (rev 1868) @@ -1,70 +0,0 @@ -/* - * #%L - * I18n :: Maven Plugin - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit - * %% - * 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>. - * #L% - */ - -package org.nuiton.i18n.plugin.parser; - -import java.io.File; - -/** - * Permet d'ajouter des évènements sur les parsers - * - * @author julien - * @deprecated since 1.2, no more used actually, since we are using - * multi-thread parsing which is not compatible with a sequential - * parsing. - */ -@Deprecated -public interface ParserEvent { - - /** - * Méthode appelée quand on change de fichier parsé - * - * @param file le nouveau fichier a parser - */ - void eventChangeFile(File file); - - /** - * Méthode appelée après le parsing du fichier - * - * @param file le prochain fichier a parser - */ - void eventNextFile(File file); - - /** - * Méthode appelée quand on change de clé - * - * @param keyI18n la clef i18n - * @param newKey la nouvelle clef i18n - */ - void eventChangeKey(String keyI18n, boolean newKey); - - /** - * Méthode appelée pour récupérer la nouvelle valeur de clé - * - * @return la nouvelle clé - */ - String eventGetRealKey(); - -} Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserGWTJavaMojo.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserGWTJavaMojo.java 2011-01-27 08:53:24 UTC (rev 1867) +++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserGWTJavaMojo.java 2011-01-31 08:01:45 UTC (rev 1868) @@ -135,18 +135,6 @@ } @Override - @Deprecated - protected String getKeyModifierStart() { - return "_\\(\\s*\""; - } - - @Override - @Deprecated - protected String getKeyModifierEnd() { - return "\"\\s*(\\)|,|\\+|$)"; - } - - @Override protected String getOutGetter() { return outputGetter; } Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java 2011-01-27 08:53:24 UTC (rev 1867) +++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java 2011-01-31 08:01:45 UTC (rev 1868) @@ -102,18 +102,6 @@ } @Override - @Deprecated - protected String getKeyModifierStart() { - return "_\\(\\s*\""; - } - - @Override - @Deprecated - protected String getKeyModifierEnd() { - return "\"\\s*(\\)|,|\\+|$)"; - } - - @Override protected String getOutGetter() { return outputGetter; } Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJspMojo.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJspMojo.java 2011-01-27 08:53:24 UTC (rev 1867) +++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJspMojo.java 2011-01-31 08:01:45 UTC (rev 1868) @@ -186,19 +186,6 @@ }; } - - @Override - @Deprecated - protected String getKeyModifierStart() { - return "=\\s*[\"\']"; - } - - @Override - @Deprecated - protected String getKeyModifierEnd() { - return "[\"\']"; - } - /** * To transform jsp files to valid xml files. * <p/> Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserTapestryMojo.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserTapestryMojo.java 2011-01-27 08:53:24 UTC (rev 1867) +++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserTapestryMojo.java 2011-01-31 08:01:45 UTC (rev 1868) @@ -133,18 +133,6 @@ } @Override - @Deprecated - protected String getKeyModifierStart() { - return "_\\(\\s*\""; - } - - @Override - @Deprecated - protected String getKeyModifierEnd() { - return "\"\\s*(\\)|,|\\+|$)"; - } - - @Override protected String getOutGetter() { return outputGetter; } Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidationMojo.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidationMojo.java 2011-01-27 08:53:24 UTC (rev 1867) +++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidationMojo.java 2011-01-31 08:01:45 UTC (rev 1868) @@ -217,16 +217,4 @@ } }; } - - @Override - @Deprecated - protected String getKeyModifierStart() { - return "=\\s*[\"\']"; - } - - @Override - @Deprecated - protected String getKeyModifierEnd() { - return "[\"\']"; - } } Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlUserMojo.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlUserMojo.java 2011-01-27 08:53:24 UTC (rev 1867) +++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlUserMojo.java 2011-01-31 08:01:45 UTC (rev 1868) @@ -135,16 +135,6 @@ } @Override - protected String getKeyModifierStart() { - return null; - } - - @Override - protected String getKeyModifierEnd() { - return null; - } - - @Override public FileUpdater newFileUpdater(SourceEntry entry) { return new MirroredFileUpdater("", "", entry.getBasedir(), cp) { Modified: trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18n.java =================================================================== --- trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18n.java 2011-01-27 08:53:24 UTC (rev 1867) +++ trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18n.java 2011-01-31 08:01:45 UTC (rev 1868) @@ -57,22 +57,6 @@ /** Logger */ private static final Log log = LogFactory.getLog(I18n.class); - /** @deprecated since 2.1, will be removed in version 3.0 */ - @Deprecated - public static final String ISO_8859_1_ENCONDING = "ISO-8859-1"; - - /** @deprecated since 2.1, will be removed in version 3.0 */ - @Deprecated - public static final String UTF_8_ENCONDING = "UTF-8"; - - /** @deprecated since 2.1, will be removed in version 3.0 */ - @Deprecated - public static final String DEFAULT_ENCODING = ISO_8859_1_ENCONDING; - - /** @deprecated since 2.1, will be removed in version 3.0 */ - @Deprecated - public static final Locale DEFAULT_LOCALE = Locale.UK; - /** * I18n initializer, * @@ -89,25 +73,7 @@ /** Filtre a appliquer avant de retourner les chaines */ protected static I18nFilter filter; - private static final Object[] EMPTY_OBJECT_ARRAY = new Object[0]; - /** - * Sets the initializer to use to init the I18n system. - * <p/> - * You must inovke this method before any invocation of methods {@code - * init(XXX)}. - * - * @param initializer the initializer to set. - * @see DefaultI18nInitializer - * @deprecated since 2.1, will be removed in version 3.0, use instead the - * method {@link I18n#init(I18nInitializer, Locale)}. - */ - @Deprecated - public static void setInitializer(I18nInitializer initializer) { - I18n.initializer = initializer; - } - - /** * Change le filtre des chaines traduites * * @param filter l'objet filtre a utiliser @@ -156,57 +122,6 @@ initStore(initializer, locale); } - /** - * Initialize I18n with default initializer and default locale of the system. - * <p/> - * <strong>We recommand not to use any longer this method.</strong> - * - * @deprecated since 2.1, will be removed in version 3.0, prefer use the - * {@link #init(I18nInitializer, Locale)} instead. - */ - @Deprecated - public static void init() { - if (log.isWarnEnabled()) { - log.warn("Using deprecated init method."); - } - init(null, (Locale) null); - } - - /** - * Initialize I18n with default initializer and given locale. - * <p/> - * <strong>We recommand not to use any longer this method.</strong> - * - * @param language une chaine representant la langue à utiliser fr, en, ... - * @param country une chaine representant le pays à utiliser FR, GB, ... - * @deprecated since 2.1, will be removed in version 3.0, prefer use the - * {@link #init(I18nInitializer, Locale)} instead. - */ - @Deprecated - public static void init(String language, String country) { - if (log.isWarnEnabled()) { - log.warn("Using deprecated init method."); - } - init(null, I18nUtil.newLocale(language, country)); - } - - /** - * Initialize I18n with default initializer and given {@code locale}. - * <p/> - * <strong>We recommand not to use any longer this method.</strong> - * - * @param locale language to use - * @deprecated since 2.1, will be removed in version 3.0, prefer use the - * {@link #init(I18nInitializer, Locale)} instead. - */ - @Deprecated - public static void init(Locale locale) { - if (log.isWarnEnabled()) { - log.warn("Using deprecated init method."); - } - init(null, locale); - } - public static void reload() { checkInit(); @@ -384,21 +299,6 @@ } /** - * Get the i18n initializer. - * <p/> - * If no one was specified, then use the {@link ClassPathI18nInitializer}. - * - * @return the i81n initializer to used to init system - * @deprecated since 2.1, will be removed in version 3.0, the initializer - * will no more be saved in this class but directly in the - * {@link I18nStore}. - */ - @Deprecated - public static I18nInitializer getInitializer() { - return initializer; - } - - /** * Get the i18n store. * <p/> * If store is not init, then instanciate it. @@ -514,13 +414,14 @@ protected static I18nInitializer getDefaultInitializer() { - I18nInitializer initializer; + I18nInitializer initializer = new ClassPathI18nInitializer(); - // will be removed in version 3.0 - if (I18n.initializer != null) { - initializer = I18n.initializer; - } else { - initializer = new ClassPathI18nInitializer(); + if (log.isWarnEnabled()) { + log.warn("\n\nI18n was not initialized! will init it with " + + "default initializer and default locale, it might " + + "not translate anything fro you...\nPlease use the " + + "method I18n.init(I18nInitializer, Locale) before " + + "any calling to a translation...\n\n"); } return initializer; } @@ -537,15 +438,7 @@ if (store == null) { - if (log.isWarnEnabled()) { - - log.warn("\n\nI18n was not initialized! will init it with " + - "default initializer and default locale, it might " + - "not translate anything fro you...\nPlease use the " + - "method I18n.init(I18nInitializer, Locale) before " + - "any calling to a translation...\n\n"); - } - init(null, (Locale) null); + init(null, null); } }