Nuiton-utils-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- 3157 discussions
[Lutinutil-commits] r962 - in tags/04082008_beforeUTF8: . maven-i18n-plugin maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/core maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/ui
by tchemit@users.labs.libre-entreprise.org 04 Aug '08
by tchemit@users.labs.libre-entreprise.org 04 Aug '08
04 Aug '08
Author: tchemit
Date: 2008-08-04 11:30:42 +0000 (Mon, 04 Aug 2008)
New Revision: 962
Added:
tags/04082008_beforeUTF8/maven-i18n-plugin/
tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/PluginHelper.java
Modified:
tags/04082008_beforeUTF8/maven-i18n-plugin/pom.xml
tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/core/AbstractI18nParser.java
tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/core/AbstractI18nPlugin.java
tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/core/Generate.java
tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/core/Getter.java
tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/core/Parser.java
tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/core/ParserEvent.java
tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/core/ParserException.java
tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension/ParserJava.java
tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension/ParserJavaActionConfig.java
tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension/ParserJavaTabConfig.java
tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension/ParserJaxx.java
tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension/ParserSwixat.java
tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension/ParserXml.java
tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/ui/KeysModifier.java
Log:
before UTF8
Copied: tags/04082008_beforeUTF8/maven-i18n-plugin (from rev 955, trunk/maven-i18n-plugin)
Modified: tags/04082008_beforeUTF8/maven-i18n-plugin/pom.xml
===================================================================
--- trunk/maven-i18n-plugin/pom.xml 2008-07-31 21:07:05 UTC (rev 955)
+++ tags/04082008_beforeUTF8/maven-i18n-plugin/pom.xml 2008-08-04 11:30:42 UTC (rev 962)
@@ -31,12 +31,12 @@
<scope>compile</scope>
</dependency>
- <dependency>
+ <!--dependency>
<groupId>org.codelutin</groupId>
<artifactId>lutinutil-no-i18n</artifactId>
<version>0.30-SNAPSHOT</version>
<scope>compile</scope>
- </dependency>
+ </dependency-->
<dependency>
<groupId>lutinlib</groupId>
@@ -64,7 +64,7 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
<name>Plugin maven pour lutini18n</name>
- <version>0.3-SNAPSHOT</version>
+ <version>0.4</version>
<description>
Plugin pour maven 2 pour la génération des bundles pour l'internationnalisation des applications java fait par
lutinutil-i18n
@@ -142,7 +142,7 @@
<!-- compile with ? -->
<maven.compile.source>1.6</maven.compile.source>
<maven.compile.target>1.6</maven.compile.target>
- <maven.compile.encoding>ISO-8859-15</maven.compile.encoding>
+ <maven.compile.encoding>UTF-8</maven.compile.encoding>
<!-- Lists URL -->
<labs.lists>
Added: tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/PluginHelper.java
===================================================================
--- tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/PluginHelper.java (rev 0)
+++ tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/PluginHelper.java 2008-08-04 11:30:42 UTC (rev 962)
@@ -0,0 +1,275 @@
+/**
+ * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * This program is free software; you
+ * can redistribute it and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation; either version 2
+ * 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 Public License for more details. You
+ * should have received a copy of the GNU General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place
+ * - Suite 330, Boston, MA 02111-1307, USA.
+ * # #%
+ */
+package org.codelutin.i18n.plugin;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.nio.channels.FileChannel;
+import java.text.MessageFormat;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Properties;
+import java.util.Vector;
+
+/**
+ * Une classe pour mutualiser toutes les méthodes utiles dans ce plugin.
+ * <p/>
+ * Note : On a dupliqué ici du code de la librairie lutinutil, pour casser la dépendance ver ce projet qui utilise ce plugin
+ * et donc introduit un cycle dans le graphe des dépendances, ce qui n'est pas souhaitable.
+ *
+ * @author chemit
+ */
+public class PluginHelper {
+
+ /**
+ * @param root le repertoire ou sont stockes les fichiers i18n
+ * @param artifactId le nom de l'artifact
+ * @param bundle le nom du bundle
+ * @param create <code>true</code> pour creer le fichier si non present
+ * @return le fichier i18n
+ * @throws java.io.IOException si probleme lors de la creation du fichier
+ */
+ public static File getI18nFile(File root, String artifactId, String bundle, boolean create) throws IOException {
+ File file = new File(root.getAbsolutePath() + File.separatorChar + artifactId + "-" + bundle + ".properties");
+ if (create && !file.exists()) {
+ if (!file.exists()) {
+ file.getParentFile().mkdirs();
+ }
+ file.createNewFile();
+ }
+ return file;
+ }
+
+ /**
+ * @param root le repertoire ou sont stockes les fichiers getter
+ * @param getter le nom du getter
+ * @param create <code>true</code> pour creer le fichier si non present
+ * @return le fichier i18n
+ * @throws java.io.IOException si probleme lors de la creation du fichier
+ */
+ public static File getGetterFile(File root, String getter, boolean create) throws IOException {
+ File file = new File(root.getAbsolutePath() + File.separatorChar + getter);
+ if (create && !file.exists()) {
+ if (!file.exists()) {
+ file.getParentFile().mkdirs();
+ }
+ file.createNewFile();
+ }
+ return file;
+ }
+
+ /**
+ * @param root le repertoire ou sont stockes les fichiers getter
+ * @param getter le nom du getter
+ * @return le fichier i18n
+ */
+ public static File getGetterFileBackup(File root, String getter) {
+ return new File(root.getAbsolutePath() + File.separatorChar + getter + '~');
+ }
+
+ /**
+ * @param root le reertoire ou sont stockes les fichiers i18n
+ * @param artifactId le nom de l'artifact
+ * @param bundle le nom du bundle
+ * @return le fichier i18n de backup
+ */
+ public static File getI18nFileBackup(File root, String artifactId, String bundle) {
+ return new File(root.getAbsolutePath() + File.separatorChar + artifactId + "-" + bundle + ".properties~");
+ }
+
+ /**
+ * Permet de copier le fichier source vers le fichier cible.
+ *
+ * @param source le fichier source
+ * @param target le fichier cible
+ * @throws java.io.IOException Erreur de copie
+ */
+ public static void copy(File source, File target) throws IOException {
+ target.getParentFile().mkdirs();
+ FileChannel sourceChannel = new FileInputStream(source).getChannel();
+ FileChannel targetChannel = new FileOutputStream(target).getChannel();
+ sourceChannel.transferTo(0, sourceChannel.size(), targetChannel);
+ // or
+ // targetChannel.transferFrom(sourceChannel, 0, sourceChannel.size());
+ sourceChannel.close();
+ targetChannel.close();
+ }
+
+ /**
+ * Permet de lire un fichier et de retourner sont contenu sous forme d'une
+ * chaine de carateres
+ *
+ * @param file le fichier a lire
+ * @param encoding encoding to read file
+ * @return the content of the file
+ * @throws IOException if IO pb
+ */
+ static public String readAsString(File file, String encoding) throws IOException {
+ StringBuffer result = new StringBuffer();
+ char[] cbuf = new char[2000];
+ FileInputStream inf = new FileInputStream(file);
+ BufferedReader in = new BufferedReader(new InputStreamReader(inf, encoding));
+ int nb = in.read(cbuf);
+ while (nb != -1) {
+ result.append(cbuf, 0, nb);
+ nb = in.read(cbuf);
+ }
+ in.close();
+ return result.toString();
+ }
+
+ static public void writeString(File file, String content, String encoding) throws IOException {
+ file.getParentFile().mkdirs();
+ BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), encoding));
+ out.write(content);
+ out.close();
+ }
+
+ /**
+ * Permet de convertir une liste non typee, en une liste typee.
+ * <p/>
+ * La liste en entree en juste bien castee.
+ * <p/>
+ * On effectue une verification sur le typage des elements de la liste.
+ * <p/>
+ * Note : <b>Aucune liste n'est creee, ni recopiee</b>
+ *
+ * @param list la liste a convertir
+ * @param type le type des elements de la liste
+ * @return la liste typee
+ * @throws IllegalArgumentException si un element de la liste en entree n'est
+ * pas en adequation avec le type voulue.
+ */
+ @SuppressWarnings({"unchecked"})
+ static public <O> List<O> toGenericList(List list, Class<O> type) throws IllegalArgumentException {
+ if (list.isEmpty()) {
+ return list;
+ }
+ for (Object o : list) {
+ if (!(type.isAssignableFrom(o.getClass()))) {
+ throw new IllegalArgumentException("can not cast List with object of type " + o.getClass() + " to " + type + " type!");
+ }
+ }
+ return list;
+ }
+
+
+ static final protected double[] timeFactors = {1000000, 1000, 60, 60, 24};
+
+ static final protected String[] timeUnites = {"ns", "ms", "s", "m", "h",
+ "d"};
+
+ static public String convertTime(long value) {
+ return convert(value, timeFactors, timeUnites);
+ }
+
+ static public String convertTime(long value, long value2) {
+ return convertTime(value2 - value);
+ }
+
+ static public String convert(long value, double[] factors, String[] unites) {
+ long sign = value == 0 ? 1 : value / Math.abs(value);
+ int i = 0;
+ double tmp = Math.abs(value);
+ while (i < factors.length && i < unites.length && tmp > factors[i]) {
+ tmp = tmp / factors[i++];
+ }
+
+ tmp *= sign;
+ String result;
+ result = MessageFormat.format("{0,number,0.###}{1}", tmp,
+ unites[i]);
+ return result;
+ }
+
+ /**
+ * Permet d'avoir les fichiers de proprietes tries.
+ *
+ * @author julien
+ */
+ public static class I18nProperties extends Properties {
+
+ private static final long serialVersionUID = -1147150444452577558L;
+
+
+ public I18nProperties() {
+ super();
+ }
+
+ public I18nProperties(Properties defaults) {
+ super(defaults);
+ }
+
+ @Override
+ public synchronized Enumeration<Object> keys() {
+ List<Object> objects = Collections.list(super.keys());
+ Vector<Object> result;
+ try {
+ // Attention, si les clef ne sont pas des string, ca ne marchera pas
+ List<String> list = toGenericList(objects, String.class);
+ Collections.sort(list);
+ result = new Vector<Object>(list);
+ } catch (IllegalArgumentException e) {
+ // keys are not string !!!
+ // can not sort keys
+ result = new Vector<Object>(objects);
+ }
+ return result.elements();
+ }
+
+ public void store(File bundleOut) throws IOException {
+ super.store(new PropertiesDateRemoveFilterStream(new FileOutputStream(bundleOut)), null);
+ }
+ }
+
+ public static class PropertiesDateRemoveFilterStream extends FilterOutputStream {
+
+ private boolean firstLineOver;
+ char endChar;
+
+ public PropertiesDateRemoveFilterStream(OutputStream out) {
+ super(out);
+ firstLineOver = false;
+ String lineSeparator = java.security.AccessController
+ .doPrivileged(new sun.security.action.GetPropertyAction(
+ "line.separator"));
+ endChar = lineSeparator.charAt(lineSeparator.length() - 1);
+ }
+
+ @Override
+ public void write(int b) throws IOException {
+ if (!firstLineOver) {
+ char c = (char) b;
+ if (c == endChar) {
+ firstLineOver = true;
+ }
+ } else {
+ out.write(b);
+ }
+ }
+
+ }
+
+
+}
Modified: tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/core/AbstractI18nParser.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/core/AbstractI18nParser.java 2008-07-31 21:07:05 UTC (rev 955)
+++ tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/core/AbstractI18nParser.java 2008-08-04 11:30:42 UTC (rev 962)
@@ -20,11 +20,15 @@
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
+import org.codelutin.i18n.plugin.PluginHelper;
import org.codelutin.i18n.plugin.ui.KeysModifier;
-import org.codelutin.util.FileUtil;
+import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -36,6 +40,7 @@
* @author tony
*/
public abstract class AbstractI18nParser extends AbstractI18nPlugin implements Parser {
+
/** @return the outGetter to use for the instance (java.getter,...) */
protected abstract String getOutGetter();
@@ -82,13 +87,23 @@
oldParser = new Properties();
oldLanguage = new Properties();
out.mkdirs();
- // �v�nements
+ // �v�nements
if (keysModifier) {
- addParserEvent(KeysModifier.getInstance(getKeyModifierStart(), getKeyModifierEnd()));
+ addParserEvent(KeysModifier.getInstance(getKeyModifierStart(), getKeyModifierEnd(), encoding));
}
treadedFiles = new ArrayList<File>();
}
+ /**
+ * Test if a file is up to date and do not treate.
+ *
+ * @param basedir the basdir of sourceentry
+ * @param file1 the file path relative to basedir
+ * @param file the file to treate @return <code>true</code> if file is uptodate, says needs no treatment.
+ * @return <code>true</code> if file is up to date and do not need to be parsed
+ */
+ protected abstract boolean isFileUptodate(File basedir, File file1, String file);
+
/*
* (non-Javadoc)
* @see org.apache.maven.plugin.AbstractMojo#execute()
@@ -102,25 +117,27 @@
}
try {
// Reprise sur un ancien parsing
- File oldParserFile = new File(out.getAbsolutePath() + File.separatorChar + getOutGetter());
- File saveFile = new File(out.getAbsolutePath() + File.separatorChar + getOutGetter() + "~");
-
- if (!oldParserFile.exists()) {
+ File oldParserFile = PluginHelper.getGetterFile(out, getOutGetter(), true);
+ //File oldParserFile = new File(out.getAbsolutePath() + File.separatorChar + getOutGetter());
+ File saveFile = PluginHelper.getGetterFileBackup(out, getOutGetter());
+ //File saveFile = new File(out.getAbsolutePath() + File.separatorChar + getOutGetter() + "~");
+
+ /*if (!oldParserFile.exists()) {
oldParserFile.getParentFile().mkdirs();
}
- oldParserFile.createNewFile();
+ oldParserFile.createNewFile();*/
+
oldParser.load(new FileInputStream(oldParserFile));
+ PluginHelper.copy(oldParserFile, saveFile);
- FileUtil.copy(oldParserFile, saveFile);
-
-
- // Anciennes cl�s disponnibles
- File oldLanguageFile = new File(src.getAbsolutePath() + File.separatorChar + artifactId + "-" + bundles[0] + ".properties");
- if (!oldLanguageFile.exists()) {
+ // Anciennes cl�s disponnibles
+ File oldLanguageFile = PluginHelper.getI18nFile(src, artifactId, bundles[0], true);
+ //File oldLanguageFile = new File(src.getAbsolutePath() + File.separatorChar + artifactId + "-" + bundles[0] + ".properties");
+ /*if (!oldLanguageFile.exists()) {
oldLanguageFile.getParentFile().mkdirs();
}
- oldLanguageFile.createNewFile();
+ oldLanguageFile.createNewFile();*/
oldLanguage.load(new FileInputStream(oldLanguageFile));
// Parsing
@@ -139,7 +156,7 @@
}
- public void parse() {
+ public void parse() throws IOException {
if (treateDefaultEntry) {
addDefaultEntry();
}
@@ -158,7 +175,7 @@
if (verbose) {
getLog().debug(getLogEntry(" parse <" + entry + "> [incoming file(s) : " + foundFiles.length + "]", 0, 0, 0));
} else {
- getLog().info(getLogEntry(" parse <" + entry .getBasedir()+ "> [incoming file(s) : " + foundFiles.length + "]", 0, 0, 0));
+ getLog().info(getLogEntry(" parse <" + entry.getBasedir() + "> [incoming file(s) : " + foundFiles.length + "]", 0, 0, 0));
}
// launch parser for found files
parseEntry(entry.getBasedir(), foundFiles);
@@ -186,7 +203,7 @@
entries = list.toArray(new SourceEntry[list.size()]);
}
- protected void parseEntry(File basedir, String[] files) {
+ protected void parseEntry(File basedir, String[] files) throws IOException {
long t00 = System.nanoTime();
for (int i = 0; i < files.length; i++) {
String file1 = files[i];
@@ -197,8 +214,21 @@
event.eventChangeFile(file);
}
touchFile = false;
- parseFile(file);
+ int size = result.size();
+ if (strictMode || !isFileUptodate(basedir, file, file1)) {
+ // on parse toujours en mode strict ou que le fichier n'est pas à jour
+ getLog().info("parseFile " + file);
+ parseFile(file);
+ }
+
+ // D�tection de nouvelles cl�s, sauvegarde du fichier pour pouvoir le restaurer en cas de plantage
+ if (size != result.size()) {
+ saveProperties0();
+ }
if (touchFile) {
+ if (verbose) {
+ getLog().info("touched file " + file);
+ }
treadedFiles.add(file);
if (verbose) {
getLog().debug(getLogEntry(fileName, i, t000, t00));
@@ -209,4 +239,17 @@
}
}
}
+
+ protected void saveProperties0() throws IOException {
+ OutputStream outputStream = null;
+ try {
+ outputStream = new BufferedOutputStream(new FileOutputStream(PluginHelper.getGetterFile(out, getOutGetter(), false)));
+ //outputStream = new BufferedOutputStream(new FileOutputStream(out.getAbsolutePath() + File.separatorChar + getOutGetter()));
+ result.store(outputStream, null);
+ } finally {
+ if (outputStream != null) {
+ outputStream.close();
+ }
+ }
+ }
}
Modified: tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/core/AbstractI18nPlugin.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/core/AbstractI18nPlugin.java 2008-07-31 21:07:05 UTC (rev 955)
+++ tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/core/AbstractI18nPlugin.java 2008-08-04 11:30:42 UTC (rev 962)
@@ -19,66 +19,65 @@
package org.codelutin.i18n.plugin.core;
+import org.apache.maven.plugin.AbstractMojo;
+import org.codelutin.i18n.plugin.PluginHelper;
+import org.codelutin.i18n.plugin.PluginHelper.I18nProperties;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
-import org.apache.maven.plugin.AbstractMojo;
-import org.codelutin.util.SortedProperties;
-import org.codelutin.util.StringUtil;
-
/**
- * Classe permettant d'obenir les param�tres pendant les diff�rentes phases
+ * Classe permettant d'obenir les parametres pendant les différentes phases
* du plugin.
- *
+ *
* @author julien
*/
public abstract class AbstractI18nPlugin extends AbstractMojo {
/**
- * @description Langues des bundles g�n�r�s.
+ * @description Langues des bundles generes.
* @parameter expression="${i18n.bundles}" default-value=""
* @required
*/
protected String[] bundles;
/**
- * @description R�pertoire sources des fichiers i18n.
+ * @description Repertoire sources des fichiers i18n.
* @parameter expression="${i18n.src}" default-value="${basedir}/src/resources/i18n"
* @required
*/
protected File src;
/**
- * @description Met les fichiers g�n�r�s dans le r�pertoire des sources i18n.
+ * @description Met les fichiers generes dans le repertoire des sources i18n.
* @parameter expression="${i18n.genSrc}" default-value="true"
*/
protected boolean genSrc;
-
+
/**
- * @description R�pertoire des fichiers g�n�r�s i18n.
+ * @description Répertoire des fichiers generes i18n.
* @parameter expression="${i18n.out}" default-value="${basedir}/target/gen/i18n"
* @required
*/
protected File out;
/**
- * @description Active la modification de cl�
+ * @description Active la modification de cle
* @parameter expression="${i18n.keysModifier}" default-value="false"
*/
protected boolean keysModifier;
/**
* @description verbose
- * @parameter expression="${i18n.verbose}" default-value="${maven.verbose}"
+ * @parameter expression="${i18n.verbose}" default-value="false"
*/
protected boolean verbose;
-
+
/**
* @description Nom du projet.
* @parameter expression="${i18n.artifactId}" default-value="${project.artifactId}"
@@ -91,79 +90,93 @@
* @parameter expression="${i18n.keepBackup}" default-value="true"
*/
protected boolean keepBackup;
-
+
/**
+ * @description ne conserve que les clef scannees (et donc traite tous les fichiers)
+ * @parameter expression="${i18n.strictMode}" default-value="false"
+ */
+ protected boolean strictMode;
+
+ /**
+ * @description ne conserve que les clef scannees (et donc traite tous les fichiers)
+ * @parameter expression="${i18n.encoding}" default-value="${maven.compile.encoding}"
+ * @required
+ */
+ protected String encoding;
+
+ /**
* Log
* Do not use a instance of, use a lazy instancier
*/
//protected Log log = getLog();
-
+
/**
- * R�pertoire de stockage des fichiers i18n pour la r�cup�ration des fichiers
+ * Répertoire de stockage des fichiers i18n pour la recuperation des fichiers
* de traduction entre librairie
*/
protected static String DIRECTORY_INSTALL = "i18n" + File.separatorChar;
-
- /**
- * Liste des �v�nements
- */
+
+ /** Liste des évènements */
protected List<ParserEvent> events = new ArrayList<ParserEvent>();
/**
- * Ajoute un �v�nement
- * @param parserEvent l'�v�nement d'ajout
+ * Ajoute un évènement
+ *
+ * @param parserEvent l'évènement d'ajout
*/
protected void addParserEvent(ParserEvent parserEvent) {
this.events.add(parserEvent);
}
-
+
/**
- * Supprime un �v�nement
- * @param parserEvent l'�v�nement de suppression
+ * Supprime un évènement
+ *
+ * @param parserEvent l'évènement de suppression
*/
protected void removeParserEvent(ParserEvent parserEvent) {
this.events.remove(parserEvent);
}
-
- /**
- * Concat�ne deux fichiers de propri�t�s
- * @param in le fichier entrant
+
+ /**
+ * Concatène deux fichiers de proprietes
+ *
+ * @param in le fichier entrant
* @param out le fichier sortant
- * @throws FileNotFoundException si fichier non trouv�
- * @throws IOException si probl�me pendant la sauvegarde
+ * @throws FileNotFoundException si fichier non trouvé
+ * @throws IOException si problème pendant la sauvegarde
*/
protected void concactProperties(File in, File out) throws IOException {
- Properties propertiesIn = new SortedProperties();
+ Properties propertiesIn = new I18nProperties();
propertiesIn.load(new FileInputStream(in));
-
- Properties propertiesOut = new SortedProperties();
+
+ I18nProperties propertiesOut = new I18nProperties();
propertiesOut.load(new FileInputStream(out));
propertiesOut.putAll(propertiesIn);
- propertiesOut.store(new FileOutputStream(out), null);
+ propertiesOut.store(out);
}
/**
- * Construit une chaine de log format�e.
+ * Construit une chaine de log formatée.
*
* @param msg le prefix du message
- * @param nbFiles le nombre de fichiers actuellement trait�s
+ * @param nbFiles le nombre de fichiers actuellement traités
* @param time le time de traitement de ce fichier
* @param all le temps de traitement de tous les fichiers
- * @return la chaine de log format�e
+ * @return la chaine de log formatée
*/
protected String getLogEntry(String msg, int nbFiles, long time, long all) {
long now = System.nanoTime();
long delta = now - time;
- String s = "["+artifactId+"] i18n."+getClass().getSimpleName() + " : " + msg;
+ String s = "[" + artifactId + "] i18n." + getClass().getSimpleName() + " : " + msg;
if (time > 0) {
- s += " (" + StringUtil.convertTime(delta) + ")";
+ s += " (" + PluginHelper.convertTime(delta) + ")";
}
if (all > 0 && nbFiles > -1) {
- s += "(total time:" + StringUtil.convertTime(now - all) + ") ( ~ " + StringUtil.convertTime(((now - all) / (nbFiles + 1))) + " / file)";
+ s += "(total time:" + PluginHelper.convertTime(now - all) + ") ( ~ " + PluginHelper.convertTime(((now - all) / (nbFiles + 1))) + " / file)";
}
return s;
}
- /** Taille du buffer pour les lectures/�critures */
+ /** Taille du buffer pour les lectures/écritures */
protected static final int BUFFER_SIZE = 8 * 1024;
}
Modified: tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/core/Generate.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/core/Generate.java 2008-07-31 21:07:05 UTC (rev 955)
+++ tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/core/Generate.java 2008-08-04 11:30:42 UTC (rev 962)
@@ -21,18 +21,16 @@
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
-import org.codelutin.util.FileUtil;
-import org.codelutin.util.PropertiesDateRemoveFilterStream;
-import org.codelutin.util.SortedProperties;
+import org.codelutin.i18n.plugin.PluginHelper;
+import org.codelutin.i18n.plugin.PluginHelper.I18nProperties;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
/**
- * Merge des fichiers de propri�t�s avec les anciens.
+ * Merge des fichiers de propriétés avec les anciens.
*
* @author julien
* @goal gen
@@ -49,40 +47,49 @@
for (String bundle : bundles) {
try {
// Merge
- File bundleSrc = new File(src.getAbsolutePath() + File.separatorChar + artifactId + "-" + bundle + ".properties");
- File bundleOut = new File(out.getAbsolutePath() + File.separatorChar + artifactId + "-" + bundle + ".properties");
+ //File bundleSrc = new File(src.getAbsolutePath() + File.separatorChar + artifactId + "-" + bundle + ".properties");
+ //File bundleOut = new File(out.getAbsolutePath() + File.separatorChar + artifactId + "-" + bundle + ".properties");
+ File bundleSrc = PluginHelper.getI18nFile(src, artifactId, bundle, false);
+ File bundleOut = PluginHelper.getI18nFile(out, artifactId, bundle, false);
if (bundleSrc.exists()) {
+
Properties propertiesSrc = new Properties();
propertiesSrc.load(new FileInputStream(bundleSrc));
- Properties propertiesBundle = new SortedProperties();
- propertiesBundle.load(new FileInputStream(bundleOut));
+ I18nProperties propertiesOut = new I18nProperties();
- // Parcours des cl�s
- for (Object key : propertiesBundle.keySet()) {
- Object oldKey = propertiesBundle.get(key);
+ if (!strictMode) {
+ // push back in bundle out, all the bundle src keys
+ propertiesOut.putAll(propertiesSrc);
+ }
+ propertiesOut.load(new FileInputStream(bundleOut));
+
+ // Parcours des clés
+ for (Object key : propertiesOut.keySet()) {
+ Object oldKey = propertiesOut.get(key);
Object value = propertiesSrc.get(oldKey);
- // R�cup�ration de la cl� si elle a �t� renomm�
+ // Récupération de la clé si elle a été renommée
if (!key.equals(oldKey) && value == null) {
value = propertiesSrc.get(key);
}
if (value != null) {
- propertiesBundle.put(key, value);
+ propertiesOut.put(key, value);
} else {
- propertiesBundle.put(key, "");
+ propertiesOut.put(key, "");
}
}
- FileOutputStream fileOutputStream = new FileOutputStream(bundleOut);
- PropertiesDateRemoveFilterStream filter = new PropertiesDateRemoveFilterStream(fileOutputStream);
- propertiesBundle.store(filter, null);
+ //saveBundle(bundleOut, propertiesOut);
+ propertiesOut.store(bundleOut);
+
// Sauvegarde avant copie
if (genSrc && keepBackup) {
- FileUtil.copy(bundleSrc, new File(src.getAbsolutePath() + File.separatorChar + artifactId + "-" + bundle + ".properties" + "~"));
+ PluginHelper.copy(bundleSrc, PluginHelper.getI18nFileBackup(src, artifactId, bundle));
+ //FileUtil.copy(bundleSrc, new File(src.getAbsolutePath() + File.separatorChar + artifactId + "-" + bundle + ".properties" + "~"));
}
getLog().info("Merge bundle " + bundleSrc.getAbsolutePath());
@@ -90,7 +97,7 @@
if (genSrc) {
// Copie des fichiers dans les sources
- FileUtil.copy(bundleOut, bundleSrc);
+ PluginHelper.copy(bundleOut, bundleSrc);
getLog().info("Copy bundle " + bundleSrc.getAbsolutePath());
}
@@ -100,4 +107,10 @@
}
}
}
+
+ /*void saveBundle(File bundleOut, Properties propertiesBundle) throws IOException {
+ FileOutputStream fileOutputStream = new FileOutputStream(bundleOut);
+ PropertiesDateRemoveFilterStream filter = new PropertiesDateRemoveFilterStream(fileOutputStream);
+ propertiesBundle.store(filter, null);
+ }*/
}
Modified: tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/core/Getter.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/core/Getter.java 2008-07-31 21:07:05 UTC (rev 955)
+++ tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/core/Getter.java 2008-08-04 11:30:42 UTC (rev 962)
@@ -19,19 +19,18 @@
package org.codelutin.i18n.plugin.core;
-import java.io.File;
-import java.io.IOException;
-
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.codehaus.plexus.util.DirectoryScanner;
-import org.codelutin.util.FileUtil;
+import org.codelutin.i18n.plugin.PluginHelper;
+import java.io.File;
+import java.io.IOException;
+
/**
- * R�cup�re les diff�rents fichiers des parsers en un fichier de propri�t�s.
- *
+ * Récupère les différents fichiers des parsers en un fichier de propriétés.
+ *
* @author julien
- *
* @goal get
* @phase generate-resources
*/
@@ -45,16 +44,17 @@
try {
File bundleGetters = new File(out.getAbsolutePath() + File.separatorChar + artifactId + ".properties");
bundleGetters.createNewFile();
-
+
DirectoryScanner ds = new DirectoryScanner();
ds.setBasedir(out);
- ds.setIncludes(new String[] {"*.getter"});
+ ds.setIncludes(new String[]{"*.getter"});
ds.scan();
String[] files = ds.getIncludedFiles();
- // Fusion des fichiers propri�t�s des diff�rents parsers
+ // Fusion des fichiers propriétés des différents parsers
for (String file : files) {
- File bundleGetter = new File(out.getAbsolutePath() + File.separatorChar + file);
+ File bundleGetter = PluginHelper.getGetterFile(out, file, false);
+ //File bundleGetter = new File(out.getAbsolutePath() + File.separatorChar + file);
concactProperties(bundleGetter, bundleGetters);
if (genSrc) {
bundleGetter.delete();
@@ -62,13 +62,14 @@
getLog().info("Create bundle with " + bundleGetter.getAbsolutePath());
}
- // Cr�ation des bundles
+ // Création des bundles
for (String bundle : bundles) {
- File bundleOut = new File(out.getAbsolutePath() + File.separatorChar + artifactId + "-" + bundle + ".properties");
- FileUtil.copy(bundleGetters, bundleOut);
+ //File bundleOut = new File(out.getAbsolutePath() + File.separatorChar + artifactId + "-" + bundle + ".properties");
+ File bundleOut = PluginHelper.getI18nFile(out, artifactId, bundle, false);
+ PluginHelper.copy(bundleGetters, bundleOut);
getLog().info("Generate bundle " + bundleOut.getAbsolutePath());
}
-
+
bundleGetters.delete();
} catch (IOException e) {
getLog().error("File Error I/O ", e);
Modified: tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/core/Parser.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/core/Parser.java 2008-07-31 21:07:05 UTC (rev 955)
+++ tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/core/Parser.java 2008-08-04 11:30:42 UTC (rev 962)
@@ -20,30 +20,31 @@
package org.codelutin.i18n.plugin.core;
import java.io.File;
+import java.io.IOException;
/**
- * Interface type pour la d�finition d'un nouveau parser.
+ * Interface type pour la définition d'un nouveau parser.
* <p/>
- * Une implantation abstraite est propos�e : {@link AbstractI18nParser}.
+ * Une implantation abstraite est proposée : {@link AbstractI18nParser}.
*
* @author julien
*/
public interface Parser {
/** Lancement du parser */
- public void parse();
+ public void parse() throws IOException;
/**
* Parse sur un fichier
*
- * @param file le fichier � parser
+ * @param file le fichier à parser
*/
public void parseFile(File file);
/**
* Parse une partie du fichier
*
- * @param file le fichier � parser
+ * @param file le fichier à parser
* @param args ? TODO
*/
public void parseLine(File file, String args);
Modified: tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/core/ParserEvent.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/core/ParserEvent.java 2008-07-31 21:07:05 UTC (rev 955)
+++ tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/core/ParserEvent.java 2008-08-04 11:30:42 UTC (rev 962)
@@ -22,7 +22,7 @@
import java.io.File;
/**
- * Permet d'ajouter des �v�nements sur les parsers
+ * Permet d'ajouter des évènements sur les parsers
*
* @author julien
*
@@ -30,26 +30,26 @@
public interface ParserEvent {
/**
- * M�thode appel�e quand on change de fichier pars�
+ * M�thode appelée quand on change de fichier parsé
* @param file
*/
public void eventChangeFile(File file);
/**
- * M�thode appel�e apr�s le parsing du fichier
+ * Méthode appelée après le parsing du fichier
* @param file
*/
public void eventNextFile(File file);
/**
- * M�thode appel�e quand on change de cl�
+ * M�thode appelée quand on change de clé
* @param keyI18n
* @param newKey
*/
public void eventChangeKey(String keyI18n, boolean newKey);
/**
- * M�thode appel�e pour r�cup�rer la nouvelle valeur de cl�
+ * M�thode appelée pour récupérer la nouvelle valeur de clé
* @return
*/
public String eventGetRealKey();
Modified: tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/core/ParserException.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/core/ParserException.java 2008-07-31 21:07:05 UTC (rev 955)
+++ tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/core/ParserException.java 2008-08-04 11:30:42 UTC (rev 962)
@@ -20,7 +20,7 @@
package org.codelutin.i18n.plugin.core;
/**
- * Permet la gestion des exceptions dans les parsers et dans les �v�nements
+ * Permet la gestion des exceptions dans les parsers et dans les évènements
*
* @author julien
*
Modified: tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension/ParserJava.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension/ParserJava.java 2008-07-31 21:07:05 UTC (rev 955)
+++ tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension/ParserJava.java 2008-08-04 11:30:42 UTC (rev 962)
@@ -19,36 +19,19 @@
package org.codelutin.i18n.plugin.extension;
-import org.apache.maven.artifact.Artifact;
import org.apache.maven.project.MavenProject;
import org.codelutin.i18n.plugin.core.AbstractI18nParser;
import org.codelutin.i18n.plugin.core.ParserEvent;
import org.codelutin.i18n.plugin.core.ParserException;
-import org.codelutin.i18n.plugin.core.SourceEntry;
import org.codelutin.processor.filters.I18nFilter;
-import org.codelutin.util.FileUtil;
-import java.io.BufferedOutputStream;
-import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
-import java.io.OutputStream;
-import java.lang.annotation.Annotation;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-import java.util.regex.Pattern;
/**
- * R�cup�ration des cha�ne � traduire depuis les fichiers java.
+ * Récupération des chaine a traduire depuis les fichiers java.
*
* @author julien
* @goal parserJava
@@ -69,33 +52,21 @@
protected File defaultBasedir;
/**
- * @description D�pendance du projet.
+ * @description Dependance du projet.
* @parameter default-value="${project}"
* @readonly
*/
protected MavenProject project;
/**
- * @description R�pertoire sources des fichiers i18n.
+ * @description Repertoire sources des fichiers i18n.
* @parameter expression="${i18n.cp}" default-value="${basedir}/target/classes"
* @required
*/
protected File cp;
- /**
- * @description pour utiliser l'annotation I18nable pour traiter les fichiers
- * @parameter expression="${i18n.ea}" default-value="false"
- */
- protected boolean ea;
+ //protected List<String> annotationClass;
- /**
- * @description pour d�couvrir les fichiers I18nable.
- * @parameter expression="${i18n.detectea}" default-value="false"
- */
- protected boolean detectea;
-
- protected List<String> annotationClass;
-
protected String[] getDefaultIncludes() {
return new String[]{defaultIncludes};
}
@@ -119,33 +90,40 @@
protected I18nFilter filter;
- protected URLClassLoader loader;
- protected Annotation annotation;
+ //protected URLClassLoader loader;
+ //protected Annotation annotation;
@Override
public void init() {
super.init();
filter = new I18nFilter();
- if (detectea) {
+ /*if (detectea) {
// in detect mode, we do not filter by ea, try all files
ea = false;
}
if (ea) {
// in ea mode, we do not detect anything
detectea = false;
- }
+ }*/
- if (ea || detectea) {
+ /*if (ea || detectea) {
loader = initClassLoader();
annotationClass = initAnnotations();
- }
+ }*/
}
- protected List<String> initAnnotations() {
- return Collections.singletonList("org.codelutin.i18n.I18nable");
+ protected boolean isFileUptodate(File basedir, File file1, String file) {
+ String clazzFile = file.substring(0, file.length() - 4) + "class";
+ File clazz = new File(cp + File.separator + clazzFile);
+
+ return clazz.exists() && file1.lastModified() < clazz.lastModified();
}
- @Override
+ /*protected List<String> initAnnotations() {
+ return Collections.singletonList("org.codelutin.i18n.I18nable");
+ }*/
+
+ /*@Override
protected String[] getFilesForEntry(SourceEntry entry) {
if (detectea || !ea) {
@@ -155,29 +133,28 @@
// filter by annotation
return entry.getIncludedFiles(getDefaultBasedir(), getDefaultIncludes(), loader, annotationClass, getLog());
- }
+ }*/
/*
* (non-Javadoc)
* @see org.codelutin.i18n.plugin.core.Parser#parseFile(java.io.File)
*/
+
public void parseFile(File srcFile) {
try {
- int size = result.size();
- parseFile0(srcFile);
-
- // D�tection de nouvelles cl�s, sauvegarde du fichier pour pouvoir le restaurer en cas de plantage
- if (size != result.size()) {
- saveProperties0();
+ LineNumberReader lnr = new LineNumberReader(new InputStreamReader(new FileInputStream(srcFile)));
+ while (lnr.ready()) {
+ String line = lnr.readLine();
+ parseLine(srcFile, line);
}
- if (touchFile && detectea) {
+ /*if (touchFile && detectea) {
Annotation annotation = currentEntry.getAnnotation(srcFile, loader, annotationClass, getLog());
if (annotation == null) {
addAnnotation(srcFile);
}
- }
+ }*/
} catch (Exception e) {
throw new ParserException(e);
}
@@ -209,7 +186,7 @@
}
}
- private void addAnnotation(File srcFile) throws IOException {
+ /*private void addAnnotation(File srcFile) throws IOException {
String classname = srcFile.getName();
@@ -249,30 +226,18 @@
outputStream.close();
}
}
- }
+ }*/
- protected void saveProperties0() throws IOException {
- OutputStream outputStream = null;
- try {
- outputStream = new BufferedOutputStream(new FileOutputStream(out.getAbsolutePath() + File.separatorChar + getOutGetter()));
- result.store(outputStream, null);
- } finally {
- if (outputStream != null) {
- outputStream.close();
- }
- }
- }
-
- protected void parseFile0(File srcFile) throws IOException {
+ /*protected void parseFile0(File srcFile) throws IOException {
LineNumberReader lnr = new LineNumberReader(new InputStreamReader(new FileInputStream(srcFile)));
while (lnr.ready()) {
String line = lnr.readLine();
parseLine(srcFile, line);
}
- }
+ }*/
- @SuppressWarnings({"unchecked"})
- protected URLClassLoader initClassLoader() {
+ /*@SuppressWarnings({"unchecked"})
+ private URLClassLoader initClassLoader() {
URLClassLoader loader = null;
if (project != null) {
URLClassLoader result;
@@ -309,5 +274,5 @@
}
}
return loader;
- }
+ }*/
}
Modified: tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension/ParserJavaActionConfig.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension/ParserJavaActionConfig.java 2008-07-31 21:07:05 UTC (rev 955)
+++ tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension/ParserJavaActionConfig.java 2008-08-04 11:30:42 UTC (rev 962)
@@ -21,8 +21,6 @@
import org.codelutin.i18n.plugin.core.ParserEvent;
import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -52,20 +50,21 @@
return "java-action-config.getter";
}
- @Override
+ /*@Override
protected List<String> initAnnotations() {
- List<String> result = new ArrayList<String>(1);
- result.add("jaxx.runtime.builder.ActionConfig");
- result.add("jaxx.runtime.builder.SelectActionConfig");
- result.add("jaxx.runtime.builder.TabContentConfig");
- result.add("jaxx.runtime.builder.ToggleActionConfig");
+ List<String> result = new ArrayList<String>(4);
+ result.add("org.codelutin.jaxx.action.ActionConfig");
+ result.add("org.codelutin.jaxx.action.SelectActionConfig");
+ result.add("org.codelutin.jaxx.action.TabContentConfig");
+ result.add("org.codelutin.jaxx.action.ToggleActionConfig");
return result;
- }
+ }*/
/*
* (non-Javadoc)
* @see org.codelutin.i18n.plugin.extension.XmlParser#extract(java.lang.String)
*/
+
public String extract(String i18nString) {
Matcher matcher = MATCH_PATTERN.matcher(i18nString.trim());
if (matcher.matches()) {
Modified: tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension/ParserJavaTabConfig.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension/ParserJavaTabConfig.java 2008-07-31 21:07:05 UTC (rev 955)
+++ tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension/ParserJavaTabConfig.java 2008-08-04 11:30:42 UTC (rev 962)
@@ -14,8 +14,6 @@
*/
package org.codelutin.i18n.plugin.extension;
-import java.util.Collections;
-
/**
* Un paseur java pour scanner les annotations TabContentConfig.
*
@@ -30,9 +28,9 @@
return "java-tab-config.getter";
}
- @Override
+ /*@Override
protected java.util.List<String> initAnnotations() {
return Collections.singletonList("org.codelutin.i18n.I18nable");
- }
+ }*/
}
Modified: tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension/ParserJaxx.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension/ParserJaxx.java 2008-07-31 21:07:05 UTC (rev 955)
+++ tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension/ParserJaxx.java 2008-08-04 11:30:42 UTC (rev 962)
@@ -19,8 +19,10 @@
package org.codelutin.i18n.plugin.extension;
+import java.io.File;
+
/**
- * R�cup�ration des cha�ne � traduire depuis les fichiers xml Jaxx.
+ * Récupération des chaine à traduire depuis les fichiers xml Jaxx.
*
* @author julien
* @goal parserJaxx
@@ -35,7 +37,7 @@
protected String defaultIncludes;
/**
- * @description R�gles xml.
+ * @description Règles xml.
* @parameter expression="${i18n.rulesJaxx}" default-value="jaxx.rules"
*/
protected String rulesJaxx;
@@ -44,6 +46,10 @@
return new String[]{defaultIncludes};
}
+ protected boolean isFileUptodate(File basedir, File file1, String file) {
+ return false;
+ }
+
protected String getOutGetter() {
return "jaxx.getter";
}
Modified: tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension/ParserSwixat.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension/ParserSwixat.java 2008-07-31 21:07:05 UTC (rev 955)
+++ tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension/ParserSwixat.java 2008-08-04 11:30:42 UTC (rev 962)
@@ -19,8 +19,10 @@
package org.codelutin.i18n.plugin.extension;
+import java.io.File;
+
/**
- * R�cup�ration des cha�ne � traduire depuis les fichiers xml Swixat.
+ * Récupération des chaines à traduire depuis les fichiers xml Swixat.
*
* @author julien
* @goal parserSwixat
@@ -35,7 +37,7 @@
protected String defaultIncludes;
/**
- * @description R�gles xml.
+ * @description R�gles xml.
* @parameter expression="${i18n.rulesSwixat}" default-value="swixat.rules"
*/
protected String rulesSwixat;
@@ -44,7 +46,11 @@
return new String[]{defaultIncludes};
}
+ protected boolean isFileUptodate(File basedir, File file1, String file) {
+ return false;
+ }
+
protected String getKeyModifierStart() {
return "=\\s*[\"\']";
}
Modified: tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension/ParserXml.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension/ParserXml.java 2008-07-31 21:07:05 UTC (rev 955)
+++ tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension/ParserXml.java 2008-08-04 11:30:42 UTC (rev 962)
@@ -34,19 +34,17 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.OutputStream;
/**
- * R�cup�ration des cha�ne � traduire depuis les fichiers xml.
+ * Récupération des chaines à traduire depuis les fichiers xml.
*
* @author julien
*/
public abstract class ParserXml extends AbstractI18nParser {
- /** Taille du buffer pour les lectures/�critures */
+ /** Taille du buffer pour les lectures/écritures */
protected static final int BUFFER_SIZE = 8 * 1024;
/**
@@ -71,7 +69,7 @@
/** @return le fichier des rules */
protected abstract String getFileRules();
- /** @return le fichier des rules de base � toujours charger */
+ /** @return le fichier des rules de base à toujours charger */
protected abstract String getCoreFileRules();
@Override
@@ -88,12 +86,12 @@
*/
public void parseFile(File file) {
NodeList list;
- InputSource inputSource = new InputSource(file.getAbsolutePath()); // TODO: A d�placer pour les performances
+ InputSource inputSource = new InputSource(file.getAbsolutePath()); // TODO: A d�placer pour les performances
try {
int size = result.size();
- // Recherche des cl�s � partir d'un xpath
+ // Recherche des clés à partir d'un xpath
XPathExpression expression = xpath.compile(rules);
list = (NodeList) expression.evaluate(inputSource, XPathConstants.NODESET);
@@ -102,10 +100,11 @@
parseLine(file, node.getTextContent());
}
- // D�tection de nouvelles cl�s, sauvegarde du fichier pour pouvoir le restaurer en cas de plantage
+ // Détection de nouvelles clés, sauvegarde du fichier pour pouvoir le restaurer en cas de plantage
if (size != result.size()) {
- OutputStream xmlparserOut = new FileOutputStream(out.getAbsolutePath() + File.separatorChar + getOutGetter());
- result.store(xmlparserOut, null);
+ saveProperties0();
+ //OutputStream xmlparserOut = new FileOutputStream(out.getAbsolutePath() + File.separatorChar + getOutGetter());
+ //result.store(xmlparserOut, null);
}
} catch (Exception e) {
throw new ParserException(e);
@@ -139,10 +138,10 @@
}
/**
- * R�cup�re le xpath � partir d'un fichier
+ * Récupère le xpath à partir d'un fichier
*
- * @param fileRules le nom du fichier contant les r�gles
- * @return le xpath � partir d'un fichier
+ * @param fileRules le nom du fichier contant les règles
+ * @return le xpath à partir d'un fichier
*/
private String getRules(String fileRules) {
StringBuilder result = new StringBuilder();
@@ -211,7 +210,7 @@
*
* @param in le flux entrant
* @return le contenu du flux
- * @throws IOException si probl�me de lecture dans flux entrant
+ * @throws IOException si problème de lecture dans flux entrant
*/
private String readInputStream(InputStream in) throws IOException {
StringBuilder sb = new StringBuilder();
@@ -225,7 +224,7 @@
String result = sb.toString().trim();
result = result.replaceAll("#.*\n", ""); // suppression des commentaires
result = result.replaceAll("\\s+", " | "); // contruction du xpath avec des ou
- result = result.replaceAll("(^ \\| )|( \\| $)", ""); // suppression des ou de d�but ee fin
+ result = result.replaceAll("(^ \\| )|( \\| $)", ""); // suppression des ou de début ee fin
return result;
}
}
Modified: tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/ui/KeysModifier.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/ui/KeysModifier.java 2008-07-31 21:07:05 UTC (rev 955)
+++ tags/04082008_beforeUTF8/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/ui/KeysModifier.java 2008-08-04 11:30:42 UTC (rev 962)
@@ -19,6 +19,15 @@
package org.codelutin.i18n.plugin.ui;
+import org.codelutin.i18n.plugin.PluginHelper;
+import org.codelutin.i18n.plugin.core.ParserEvent;
+import org.codelutin.i18n.plugin.core.ParserException;
+
+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;
@@ -33,32 +42,22 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JTextField;
-
-import org.codelutin.i18n.plugin.core.ParserEvent;
-import org.codelutin.i18n.plugin.core.ParserException;
-import org.codelutin.util.FileUtil;
-
/**
- * IHM permettant de modifier les cl�s de traduction en direct dans les fichiers
- * pars�s et les fichiers de propri�t�s.
- *
+ * 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
- *
*/
public class KeysModifier extends JFrame implements ParserEvent {
private static final long serialVersionUID = 1L;
-
- // Modification des cl�s dans le fichier
+
+ // 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();
@@ -66,33 +65,33 @@
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;
-
- private static KeysModifier keysModifier;
-
/**
- * Rc�cup�ration d'une instance de l'interface
- * @param patternLeft
- * @param patternRight
- * @return
+ * 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) {
- if(keysModifier == null) {
+ 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
- * @param patternLeft
- * @param patternRight
- */
+
+ /** Contructeur de l'interface */
private KeysModifier() {
setLayout(new GridLayout(9, 2, 10, 10));
@@ -142,7 +141,7 @@
path.setText(file.getPath());
key.setText("");
repaint();
-
+
newKeys = new ArrayList<String>();
needModifiedFile = false;
}
@@ -152,12 +151,12 @@
* @see org.codelutin.i18n.plugin.core.ParserEvent#eventNextFile(java.io.File)
*/
public void eventNextFile(File file) {
- if(needModifiedFile) {
+ if (needModifiedFile) {
String content = "";
int region = 0;
try {
- content = FileUtil.readAsString(file);
+ content = PluginHelper.readAsString(file, encoding);
} catch (IOException e) {
throw new ParserException(e);
}
@@ -174,22 +173,22 @@
}
try {
- FileUtil.writeString(file, content);
+ PluginHelper.writeString(file, content, encoding);
} catch (IOException e) {
throw new ParserException(e);
}
}
}
-
+
/*
- * (non-Javadoc)
- * @see org.codelutin.i18n.plugin.core.ParserEvent#eventChangeKey(java.lang.String)
- */
+ * (non-Javadoc)
+ * @see org.codelutin.i18n.plugin.core.ParserEvent#eventChangeKey(java.lang.String)
+ */
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)) {
+ if (isVisible() && keyI18n.matches(pattern.getText()) && (!onlyNewKey.isSelected() || newKey)) {
try {
wait();
} catch (InterruptedException e) {
@@ -208,36 +207,42 @@
return key.getText();
}
- /**
- * Action sur le boutton pour passer � la cl� suivante
- */
+ /** Action sur le boutton pour passer � la cl� suivante */
class EventNextKey implements ActionListener {
public void actionPerformed(ActionEvent e) {
eventNextKey();
}
}
- /**
- * Action sur la fermeture de la frame
- */
+ /** Action sur la fermeture de la frame */
class EventWindows implements WindowListener {
- public void windowClosed(WindowEvent e) {}
- public void windowActivated(WindowEvent e) {}
+ public void windowClosed(WindowEvent e) {
+ }
+
+ public void windowActivated(WindowEvent e) {
+ }
+
public void windowClosing(WindowEvent e) {
setVisible(false);
eventNextKey();
}
- public void windowDeactivated(WindowEvent e) {}
- public void windowDeiconified(WindowEvent e) {}
- public void windowIconified(WindowEvent e) {}
- public void windowOpened(WindowEvent e) {}
+ public void windowDeactivated(WindowEvent e) {
+ }
+
+ public void windowDeiconified(WindowEvent e) {
+ }
+
+ public void windowIconified(WindowEvent e) {
+ }
+
+ public void windowOpened(WindowEvent e) {
+ }
+
}
- /**
- * Permet de passer � la cl� suivante
- */
+ /** Permet de passer à la clé suivante */
public synchronized void eventNextKey() {
notifyAll();
}
1
0
Author: tchemit
Date: 2008-08-04 11:30:40 +0000 (Mon, 04 Aug 2008)
New Revision: 961
Added:
tags/04082008_beforeUTF8/
Log:
before UTF8
1
0
Author: tchemit
Date: 2008-08-04 11:29:49 +0000 (Mon, 04 Aug 2008)
New Revision: 960
Removed:
tags/before_0-4_and_UTF8/
Log:
1
0
[Lutinutil-commits] r959 - tags/before_0-4_and_UTF8
by tchemit@users.labs.libre-entreprise.org 04 Aug '08
by tchemit@users.labs.libre-entreprise.org 04 Aug '08
04 Aug '08
Author: tchemit
Date: 2008-08-04 11:29:21 +0000 (Mon, 04 Aug 2008)
New Revision: 959
Added:
tags/before_0-4_and_UTF8/maven-i18n-plugin/
Log:
tag before version 0-4 and project in UTF-8
Copied: tags/before_0-4_and_UTF8/maven-i18n-plugin (from rev 958, trunk/maven-i18n-plugin)
1
0
Author: tchemit
Date: 2008-08-04 11:29:18 +0000 (Mon, 04 Aug 2008)
New Revision: 958
Added:
tags/before_0-4_and_UTF8/
Log:
tag before version 0-4 and project in UTF-8
1
0
[Lutinutil-commits] r957 - trunk/lutinutil/src/main/java/org/codelutin/i18n
by bpoussin@users.labs.libre-entreprise.org 01 Aug '08
by bpoussin@users.labs.libre-entreprise.org 01 Aug '08
01 Aug '08
Author: bpoussin
Date: 2008-08-01 14:22:01 +0000 (Fri, 01 Aug 2008)
New Revision: 957
Added:
trunk/lutinutil/src/main/java/org/codelutin/i18n/I18nf.java
Log:
ajout d'une nouvelle classe qui utilise String.format au lieu
de MessageFormat
Added: trunk/lutinutil/src/main/java/org/codelutin/i18n/I18nf.java
===================================================================
--- trunk/lutinutil/src/main/java/org/codelutin/i18n/I18nf.java (rev 0)
+++ trunk/lutinutil/src/main/java/org/codelutin/i18n/I18nf.java 2008-08-01 14:22:01 UTC (rev 957)
@@ -0,0 +1,84 @@
+/* *##%
+ * Copyright (C) 2002-2008 Code Lutin, Benjamin Poussin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ *##%*/
+
+package org.codelutin.i18n;
+
+
+import java.util.Arrays;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Transition class during project switch between MessageFormat.format syntax
+ * to String.format syntax.
+ *
+ * @author poussin
+ * @version $Revision$
+ *
+ * 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
+ * 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;
+ }
+ }
+}
1
0
[Lutinutil-commits] r956 - trunk/lutinutil-no-i18n
by tchemit@users.labs.libre-entreprise.org 31 Jul '08
by tchemit@users.labs.libre-entreprise.org 31 Jul '08
31 Jul '08
Author: tchemit
Date: 2008-07-31 21:17:40 +0000 (Thu, 31 Jul 2008)
New Revision: 956
Modified:
trunk/lutinutil-no-i18n/pom.xml
Log:
remove unused dependencies
Modified: trunk/lutinutil-no-i18n/pom.xml
===================================================================
--- trunk/lutinutil-no-i18n/pom.xml 2008-07-31 21:07:05 UTC (rev 955)
+++ trunk/lutinutil-no-i18n/pom.xml 2008-07-31 21:17:40 UTC (rev 956)
@@ -28,24 +28,6 @@
<artifactId>commons-logging</artifactId>
</dependency>
- <dependency>
- <groupId>commons-primitives</groupId>
- <artifactId>commons-primitives</artifactId>
- </dependency>
-
- <dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- </dependency>
-
- <dependency>
- <groupId>commons-beanutils</groupId>
- <artifactId>commons-beanutils</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-toolchain</artifactId>
- </dependency>
</dependencies>
@@ -175,33 +157,6 @@
<scope>compile</scope>
</dependency>
- <dependency>
- <groupId>commons-primitives</groupId>
- <artifactId>commons-primitives</artifactId>
- <version>1.0</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- <version>3.2.1</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>commons-beanutils</groupId>
- <artifactId>commons-beanutils</artifactId>
- <version>1.7.0</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-toolchain</artifactId>
- <version>1.0</version>
- <scope>test</scope>
- </dependency>
-
</dependencies>
</dependencyManagement>
1
0
[Lutinutil-commits] r955 - in trunk: lutinutil/src/test/java/org/codelutin/util lutinutil-no-i18n/src/test/java/org/codelutin/util
by tchemit@users.labs.libre-entreprise.org 31 Jul '08
by tchemit@users.labs.libre-entreprise.org 31 Jul '08
31 Jul '08
Author: tchemit
Date: 2008-07-31 21:07:05 +0000 (Thu, 31 Jul 2008)
New Revision: 955
Added:
trunk/lutinutil-no-i18n/src/test/java/org/codelutin/util/CollectionUtilTest.java
trunk/lutinutil-no-i18n/src/test/java/org/codelutin/util/FileUtilTest.java
trunk/lutinutil-no-i18n/src/test/java/org/codelutin/util/StringUtilTest.java
Removed:
trunk/lutinutil/src/test/java/org/codelutin/util/CollectionUtilTest.java
trunk/lutinutil/src/test/java/org/codelutin/util/FileUtilTest.java
trunk/lutinutil/src/test/java/org/codelutin/util/StringUtilTest.java
Log:
utilisation du projet lutinutil-no-i18n pour les classes utilitaires sans i18n. et ceci pour casser le cycle entre lutinutil et maven-i18n-plugin
Deleted: trunk/lutinutil/src/test/java/org/codelutin/util/CollectionUtilTest.java
===================================================================
--- trunk/lutinutil/src/test/java/org/codelutin/util/CollectionUtilTest.java 2008-07-31 20:57:32 UTC (rev 954)
+++ trunk/lutinutil/src/test/java/org/codelutin/util/CollectionUtilTest.java 2008-07-31 21:07:05 UTC (rev 955)
@@ -1,38 +0,0 @@
-package org.codelutin.util;
-
-import junit.framework.TestCase;
-
-import java.util.List;
-import java.util.ArrayList;
-
-/**
- * CollectionUtil Tester.
- *
- * @author chemit
- * @version 1.0
- * @since <pre>02/04/2008</pre>
- */
-public class CollectionUtilTest extends TestCase {
- public CollectionUtilTest(String name) {
- super(name);
- }
-
- public void testToGenericList() throws Exception {
- List<String> list = new ArrayList<String>();
- list.add("a");
- list.add("b");
- list.add("c");
-
- assertEquals(CollectionUtil.toGenericList(list,String.class),list);
- assertEquals(CollectionUtil.toGenericList(list,Object.class),list);
-
- try {
- CollectionUtil.toGenericList(list,Integer.class);
- fail();
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
-
- }
-
-}
Deleted: trunk/lutinutil/src/test/java/org/codelutin/util/FileUtilTest.java
===================================================================
--- trunk/lutinutil/src/test/java/org/codelutin/util/FileUtilTest.java 2008-07-31 20:57:32 UTC (rev 954)
+++ trunk/lutinutil/src/test/java/org/codelutin/util/FileUtilTest.java 2008-07-31 21:07:05 UTC (rev 955)
@@ -1,92 +0,0 @@
-/* *##%
- * Copyright (C) 2002, 2003, 2004 Code Lutin, C�dric Pineau,
- * Benjamin Poussin
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * 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 Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *##%*/
-
-/* *
- * FileUtilTest.java
- *
- * Created: 22 nov. 2004
- *
- * @author Benjamin Poussin <poussin(a)codelutin.com>
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-
-package org.codelutin.util;
-
-import java.util.List;
-import junit.framework.TestCase;
-import java.io.File;
-
-public class FileUtilTest extends TestCase { // FileUtilTest
-
- public void testFind() throws Exception {
- List result = FileUtil.find (new File("."), ".*FileUtil.*", true);
- assertTrue(result.size() != 0);
- }
-
- public void testBasename() throws Exception {
- String result = FileUtil.basename(new File("/tmp/toto.xml"), ".xml");
- assertEquals("toto", result);
- }
-
- public void testExtension() throws Exception {
- String result = FileUtil.extension(new File("/tmp/toto.xml"));
- assertEquals("xml", result);
- result = FileUtil.extension(new File("/tmp/toto.xml"), ".", "o");
- assertEquals("xml", result);
- result = FileUtil.extension(new File("/tmp/toto.xml"), "t", ".");
- assertEquals("o.xml", result);
- }
-
- public void testCopyRecursively () throws Exception {
- File srcDir = FileUtil.createTempDirectory("test-copyRecursively", "");
- File destDir1 = FileUtil.createTempDirectory("test-copyRecursively", "");
- File destDir2 = FileUtil.createTempDirectory("test-copyRecursively", "");
-
- new File(srcDir, "toto").createNewFile();
- new File(srcDir, "titi").createNewFile();
- new File(srcDir, "tutu").createNewFile();
- new File(srcDir, "tata").createNewFile();
- File subdir = new File(srcDir, "subdir");
- subdir.mkdirs();
- new File(subdir, "tyty").createNewFile();
- new File(subdir, "titi").createNewFile();
-
- FileUtil.copyRecursively(srcDir, destDir1);
-
- FileUtil.copyRecursively(srcDir, destDir2, ".*titi$");
- }
-
- public void testFileToByteToFile () throws Exception {
- String content = "testFileToByteToFile";
- File file = FileUtil.getTempFile(content);
-
- byte[] bytes = FileUtil.fileToByte(file);
- File dest = File.createTempFile("testFileToByteToFile", ".txt");
- dest.deleteOnExit();
- FileUtil.byteToFile(bytes, dest);
-
- assertEquals(file.length(), dest.length());
- assertEquals(content, FileUtil.readAsString(dest));
- }
-
-} // FileUtilTest
-
Deleted: trunk/lutinutil/src/test/java/org/codelutin/util/StringUtilTest.java
===================================================================
--- trunk/lutinutil/src/test/java/org/codelutin/util/StringUtilTest.java 2008-07-31 20:57:32 UTC (rev 954)
+++ trunk/lutinutil/src/test/java/org/codelutin/util/StringUtilTest.java 2008-07-31 21:07:05 UTC (rev 955)
@@ -1,159 +0,0 @@
-/* *##%
- * Copyright (C) 2002, 2003 Code Lutin, C�dric Pineau,
- Benjamin Poussin
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * 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 Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *##%*/
-
-/*******************************************************************************
- * StringUtilTest.java
- *
- * Created: 7 oct. 2004
- *
- * @author Benjamin Poussin <poussin(a)codelutin.com>
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-
-package org.codelutin.util;
-
-import java.awt.Color;
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-public class StringUtilTest extends TestCase { // StringUtilTest
-
- public void testSubstring() throws Exception {
- String s = "Bonjour le monde";
- String r = StringUtil.substring(s, -5);
- assertEquals("monde", r);
-
- r = StringUtil.substring(s, 7, -5);
- assertEquals(" le ", r);
-
- r = StringUtil.substring(s, 0, s.length());
- assertEquals(s, r);
-
- r = StringUtil.substring(s, -5, s.length());
- assertEquals("monde", r);
-
- r = StringUtil.substring("a", 1, -1);
- assertEquals("", r);
-
- r = StringUtil.substring("", 0, -1);
- assertEquals("", r);
-
- }
-
- public void testToColor() throws Exception {
- Color c;
-
- c = StringUtil.toColor("#FF55AA");
- assertEquals(c, new Color(255, 85, 170));
-
- c = StringUtil.toColor("#FF55AA55");
- assertEquals(c, new Color(255, 85, 170, 85));
-
- try{
- c = null;
- c = StringUtil.toColor("toto");
- assertFalse(true);
- }catch(StringUtilException eee){
- assertNull(c);
- }
-
- try{
- c = null;
- c = StringUtil.toColor("#ZRETJ4040R");
- assertFalse(true);
- }catch(StringUtilException eee){
- assertNull(c);
- }
- }
-
- public void testSplit() {
- assertTrue(Arrays.equals(StringUtil.split("toto,titi,tutu"), new String[]{"toto","titi","tutu"}));
- assertTrue(Arrays.equals(StringUtil.split("toto"), new String[]{"toto"}));
- assertTrue(Arrays.equals(StringUtil.split(""), new String[0]));
- assertTrue(Arrays.equals(StringUtil.split(null), new String[0]));
-
- String argTest = "toto, titi, titi($tru('roer'), erke), \"t|u(t{u\\\"ti[ti'\", fin";
- String [] arg = StringUtil.split(argTest);
- assertEquals(5, arg.length);
-
- argTest = "";
- arg = StringUtil.split(argTest);
- assertEquals(0, arg.length);
-
- argTest = "tptp";
- arg = StringUtil.split(argTest);
- assertEquals(1, arg.length);
-
- argTest = ",ooo|ooo|o|,ooo'ooo(',ooo-";
- arg = StringUtil.split(argTest, "ooo");
- assertEquals(5, arg.length);
-
- }
-
- public void testConvert() throws Exception {
- assertEquals("365d", StringUtil.convertTime(31536000000000000L));
- assertEquals("2d", StringUtil.convertTime(172800000000000L));
- assertEquals("2h", StringUtil.convertTime(7200000000000L));
- assertEquals("2m", StringUtil.convertTime(120000000000L));
- assertEquals("2,02s", StringUtil.convertTime(2020000002L));
- assertEquals("2s", StringUtil.convertTime(2000000002L));
- assertEquals("2s", StringUtil.convertTime(2000000000L));
- assertEquals("2ms", StringUtil.convertTime(2000000L));
- assertEquals("2ns", StringUtil.convertTime(2L));
- assertEquals("0ns", StringUtil.convertTime(0L));
-
- assertEquals("0o", StringUtil.convertMemory(0L));
- assertEquals("2o", StringUtil.convertMemory(2L));
- assertEquals("2Ko", StringUtil.convertMemory(2048L));
- assertEquals("2Mo", StringUtil.convertMemory(2097152L));
- assertEquals("2Mo", StringUtil.convertMemory(2097154L));
- assertEquals("2,094Mo", StringUtil.convertMemory(2196152L));
- assertEquals("2Go", StringUtil.convertMemory(2147483648L));
- assertEquals("2To", StringUtil.convertMemory(2199023255552L));
- assertEquals("2000To", StringUtil.convertMemory(2199023255552000L));
-
- assertEquals("-2Mo", StringUtil.convertMemory(-2097152L));
- assertEquals("-2Mo", StringUtil.convertMemory(-2097154L));
- assertEquals("-2,094Mo", StringUtil.convertMemory(-2196152L));
- }
-
- public void testUnaccent() throws Exception {
- assertEquals( "-aaaeeeeiioouuuc0123456789AAAEEEEIIOOUUUC._",
- StringUtil.unaccent("-��������������� 0123456789 ���������������._"));
- }
-
- public void testConvertToConstantName() throws Exception {
- assertEquals("YES",StringUtil.convertToConstantName("yes"));
- assertEquals("YES",StringUtil.convertToConstantName("*$$?YEs"));
- assertEquals("YES",StringUtil.convertToConstantName("_yes!$*_"));
- assertEquals("YES",StringUtil.convertToConstantName("_Yes____"));
-
- assertEquals("YES_OR_NO",StringUtil.convertToConstantName("__yesOrNo_"));
- assertEquals("YES_OR_NO",StringUtil.convertToConstantName("Yes-or-!*=No"));
- assertEquals("YES_OR_NO",StringUtil.convertToConstantName("_yes__or__no"));
- assertEquals("YES_OR_NO",StringUtil.convertToConstantName("_YesOR___No"));
-
- }
-
-} // StringUtilTest
-
Copied: trunk/lutinutil-no-i18n/src/test/java/org/codelutin/util/CollectionUtilTest.java (from rev 953, trunk/lutinutil/src/test/java/org/codelutin/util/CollectionUtilTest.java)
===================================================================
--- trunk/lutinutil-no-i18n/src/test/java/org/codelutin/util/CollectionUtilTest.java (rev 0)
+++ trunk/lutinutil-no-i18n/src/test/java/org/codelutin/util/CollectionUtilTest.java 2008-07-31 21:07:05 UTC (rev 955)
@@ -0,0 +1,38 @@
+package org.codelutin.util;
+
+import junit.framework.TestCase;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * CollectionUtil Tester.
+ *
+ * @author chemit
+ * @version 1.0
+ * @since <pre>02/04/2008</pre>
+ */
+public class CollectionUtilTest extends TestCase {
+ public CollectionUtilTest(String name) {
+ super(name);
+ }
+
+ public void testToGenericList() throws Exception {
+ List<String> list = new ArrayList<String>();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+
+ assertEquals(CollectionUtil.toGenericList(list, String.class), list);
+ assertEquals(CollectionUtil.toGenericList(list, Object.class), list);
+
+ try {
+ CollectionUtil.toGenericList(list, Integer.class);
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertTrue(true);
+ }
+
+ }
+
+}
Property changes on: trunk/lutinutil-no-i18n/src/test/java/org/codelutin/util/CollectionUtilTest.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/lutinutil-no-i18n/src/test/java/org/codelutin/util/FileUtilTest.java (from rev 953, trunk/lutinutil/src/test/java/org/codelutin/util/FileUtilTest.java)
===================================================================
--- trunk/lutinutil-no-i18n/src/test/java/org/codelutin/util/FileUtilTest.java (rev 0)
+++ trunk/lutinutil-no-i18n/src/test/java/org/codelutin/util/FileUtilTest.java 2008-07-31 21:07:05 UTC (rev 955)
@@ -0,0 +1,93 @@
+/* *##%
+ * Copyright (C) 2002, 2003, 2004 Code Lutin, C�dric Pineau,
+ * Benjamin Poussin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *##%*/
+
+/* *
+ * FileUtilTest.java
+ *
+ * Created: 22 nov. 2004
+ *
+ * @author Benjamin Poussin <poussin(a)codelutin.com>
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+
+package org.codelutin.util;
+
+import junit.framework.TestCase;
+
+import java.io.File;
+import java.util.List;
+
+public class FileUtilTest extends TestCase { // FileUtilTest
+
+ public void testFind() throws Exception {
+ List result = FileUtil.find(new File("."), ".*FileUtil.*", true);
+ assertTrue(result.size() != 0);
+ }
+
+ public void testBasename() throws Exception {
+ String result = FileUtil.basename(new File("/tmp/toto.xml"), ".xml");
+ assertEquals("toto", result);
+ }
+
+ public void testExtension() throws Exception {
+ String result = FileUtil.extension(new File("/tmp/toto.xml"));
+ assertEquals("xml", result);
+ result = FileUtil.extension(new File("/tmp/toto.xml"), ".", "o");
+ assertEquals("xml", result);
+ result = FileUtil.extension(new File("/tmp/toto.xml"), "t", ".");
+ assertEquals("o.xml", result);
+ }
+
+ public void testCopyRecursively() throws Exception {
+ File srcDir = FileUtil.createTempDirectory("test-copyRecursively", "");
+ File destDir1 = FileUtil.createTempDirectory("test-copyRecursively", "");
+ File destDir2 = FileUtil.createTempDirectory("test-copyRecursively", "");
+
+ new File(srcDir, "toto").createNewFile();
+ new File(srcDir, "titi").createNewFile();
+ new File(srcDir, "tutu").createNewFile();
+ new File(srcDir, "tata").createNewFile();
+ File subdir = new File(srcDir, "subdir");
+ subdir.mkdirs();
+ new File(subdir, "tyty").createNewFile();
+ new File(subdir, "titi").createNewFile();
+
+ FileUtil.copyRecursively(srcDir, destDir1);
+
+ FileUtil.copyRecursively(srcDir, destDir2, ".*titi$");
+ }
+
+ public void testFileToByteToFile() throws Exception {
+ String content = "testFileToByteToFile";
+ File file = FileUtil.getTempFile(content);
+
+ byte[] bytes = FileUtil.fileToByte(file);
+ File dest = File.createTempFile("testFileToByteToFile", ".txt");
+ dest.deleteOnExit();
+ FileUtil.byteToFile(bytes, dest);
+
+ assertEquals(file.length(), dest.length());
+ assertEquals(content, FileUtil.readAsString(dest));
+ }
+
+} // FileUtilTest
+
Property changes on: trunk/lutinutil-no-i18n/src/test/java/org/codelutin/util/FileUtilTest.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/lutinutil-no-i18n/src/test/java/org/codelutin/util/StringUtilTest.java (from rev 953, trunk/lutinutil/src/test/java/org/codelutin/util/StringUtilTest.java)
===================================================================
--- trunk/lutinutil-no-i18n/src/test/java/org/codelutin/util/StringUtilTest.java (rev 0)
+++ trunk/lutinutil-no-i18n/src/test/java/org/codelutin/util/StringUtilTest.java 2008-07-31 21:07:05 UTC (rev 955)
@@ -0,0 +1,159 @@
+/* *##%
+ * Copyright (C) 2002, 2003 Code Lutin, C�dric Pineau,
+ Benjamin Poussin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *##%*/
+
+/*******************************************************************************
+ * StringUtilTest.java
+ *
+ * Created: 7 oct. 2004
+ *
+ * @author Benjamin Poussin <poussin(a)codelutin.com>
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+
+package org.codelutin.util;
+
+import junit.framework.TestCase;
+
+import java.awt.Color;
+import java.util.Arrays;
+
+public class StringUtilTest extends TestCase { // StringUtilTest
+
+ public void testSubstring() throws Exception {
+ String s = "Bonjour le monde";
+ String r = StringUtil.substring(s, -5);
+ assertEquals("monde", r);
+
+ r = StringUtil.substring(s, 7, -5);
+ assertEquals(" le ", r);
+
+ r = StringUtil.substring(s, 0, s.length());
+ assertEquals(s, r);
+
+ r = StringUtil.substring(s, -5, s.length());
+ assertEquals("monde", r);
+
+ r = StringUtil.substring("a", 1, -1);
+ assertEquals("", r);
+
+ r = StringUtil.substring("", 0, -1);
+ assertEquals("", r);
+
+ }
+
+ public void testToColor() throws Exception {
+ Color c;
+
+ c = StringUtil.toColor("#FF55AA");
+ assertEquals(c, new Color(255, 85, 170));
+
+ c = StringUtil.toColor("#FF55AA55");
+ assertEquals(c, new Color(255, 85, 170, 85));
+
+ try {
+ c = null;
+ c = StringUtil.toColor("toto");
+ assertFalse(true);
+ } catch (StringUtilException eee) {
+ assertNull(c);
+ }
+
+ try {
+ c = null;
+ c = StringUtil.toColor("#ZRETJ4040R");
+ assertFalse(true);
+ } catch (StringUtilException eee) {
+ assertNull(c);
+ }
+ }
+
+ public void testSplit() {
+ assertTrue(Arrays.equals(StringUtil.split("toto,titi,tutu"), new String[]{"toto", "titi", "tutu"}));
+ assertTrue(Arrays.equals(StringUtil.split("toto"), new String[]{"toto"}));
+ assertTrue(Arrays.equals(StringUtil.split(""), new String[0]));
+ assertTrue(Arrays.equals(StringUtil.split(null), new String[0]));
+
+ String argTest = "toto, titi, titi($tru('roer'), erke), \"t|u(t{u\\\"ti[ti'\", fin";
+ String[] arg = StringUtil.split(argTest);
+ assertEquals(5, arg.length);
+
+ argTest = "";
+ arg = StringUtil.split(argTest);
+ assertEquals(0, arg.length);
+
+ argTest = "tptp";
+ arg = StringUtil.split(argTest);
+ assertEquals(1, arg.length);
+
+ argTest = ",ooo|ooo|o|,ooo'ooo(',ooo-";
+ arg = StringUtil.split(argTest, "ooo");
+ assertEquals(5, arg.length);
+
+ }
+
+ public void testConvert() throws Exception {
+ assertEquals("365d", StringUtil.convertTime(31536000000000000L));
+ assertEquals("2d", StringUtil.convertTime(172800000000000L));
+ assertEquals("2h", StringUtil.convertTime(7200000000000L));
+ assertEquals("2m", StringUtil.convertTime(120000000000L));
+ assertEquals("2,02s", StringUtil.convertTime(2020000002L));
+ assertEquals("2s", StringUtil.convertTime(2000000002L));
+ assertEquals("2s", StringUtil.convertTime(2000000000L));
+ assertEquals("2ms", StringUtil.convertTime(2000000L));
+ assertEquals("2ns", StringUtil.convertTime(2L));
+ assertEquals("0ns", StringUtil.convertTime(0L));
+
+ assertEquals("0o", StringUtil.convertMemory(0L));
+ assertEquals("2o", StringUtil.convertMemory(2L));
+ assertEquals("2Ko", StringUtil.convertMemory(2048L));
+ assertEquals("2Mo", StringUtil.convertMemory(2097152L));
+ assertEquals("2Mo", StringUtil.convertMemory(2097154L));
+ assertEquals("2,094Mo", StringUtil.convertMemory(2196152L));
+ assertEquals("2Go", StringUtil.convertMemory(2147483648L));
+ assertEquals("2To", StringUtil.convertMemory(2199023255552L));
+ assertEquals("2000To", StringUtil.convertMemory(2199023255552000L));
+
+ assertEquals("-2Mo", StringUtil.convertMemory(-2097152L));
+ assertEquals("-2Mo", StringUtil.convertMemory(-2097154L));
+ assertEquals("-2,094Mo", StringUtil.convertMemory(-2196152L));
+ }
+
+ public void testUnaccent() throws Exception {
+ assertEquals("-aaaeeeeiioouuuc0123456789AAAEEEEIIOOUUUC._",
+ StringUtil.unaccent("-��������������� 0123456789 ���������������._"));
+ }
+
+ public void testConvertToConstantName() throws Exception {
+ assertEquals("YES", StringUtil.convertToConstantName("yes"));
+ assertEquals("YES", StringUtil.convertToConstantName("*$$?YEs"));
+ assertEquals("YES", StringUtil.convertToConstantName("_yes!$*_"));
+ assertEquals("YES", StringUtil.convertToConstantName("_Yes____"));
+
+ assertEquals("YES_OR_NO", StringUtil.convertToConstantName("__yesOrNo_"));
+ assertEquals("YES_OR_NO", StringUtil.convertToConstantName("Yes-or-!*=No"));
+ assertEquals("YES_OR_NO", StringUtil.convertToConstantName("_yes__or__no"));
+ assertEquals("YES_OR_NO", StringUtil.convertToConstantName("_YesOR___No"));
+
+ }
+
+} // StringUtilTest
+
Property changes on: trunk/lutinutil-no-i18n/src/test/java/org/codelutin/util/StringUtilTest.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
1
0
[Lutinutil-commits] r954 - in trunk: lutinutil lutinutil-no-i18n maven-i18n-plugin maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension
by tchemit@users.labs.libre-entreprise.org 31 Jul '08
by tchemit@users.labs.libre-entreprise.org 31 Jul '08
31 Jul '08
Author: tchemit
Date: 2008-07-31 20:57:32 +0000 (Thu, 31 Jul 2008)
New Revision: 954
Modified:
trunk/lutinutil-no-i18n/pom.xml
trunk/lutinutil/pom.xml
trunk/maven-i18n-plugin/pom.xml
trunk/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension/ParserJava.java
trunk/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension/ParserJavaTabConfig.java
Log:
utilisation du projet lutinutil-no-i18n pour les classes utilitaires sans i18n. et ceci pour casser le cycle entre lutinutil et maven-i18n-plugin
Modified: trunk/lutinutil/pom.xml
===================================================================
--- trunk/lutinutil/pom.xml 2008-07-31 20:45:42 UTC (rev 953)
+++ trunk/lutinutil/pom.xml 2008-07-31 20:57:32 UTC (rev 954)
@@ -18,39 +18,39 @@
<artifactId>lutinutil</artifactId>
<dependencies>
+
<dependency>
+ <groupId>org.codelutin</groupId>
+ <artifactId>lutinutil-no-i18n</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
- <!--scope>compile</scope-->
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
- <!--scope>compile</scope-->
</dependency>
<dependency>
<groupId>commons-primitives</groupId>
<artifactId>commons-primitives</artifactId>
- <!--scope>compile</scope-->
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
- <!--scope>compile</scope-->
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
- <!--scope>compile</scope-->
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-toolchain</artifactId>
- <!--scope>test</scope-->
</dependency>
</dependencies>
@@ -198,6 +198,12 @@
<dependencies>
<dependency>
+ <groupId>org.codelutin</groupId>
+ <artifactId>lutinutil-no-i18n</artifactId>
+ <version>0.30-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
Modified: trunk/lutinutil-no-i18n/pom.xml
===================================================================
--- trunk/lutinutil-no-i18n/pom.xml 2008-07-31 20:45:42 UTC (rev 953)
+++ trunk/lutinutil-no-i18n/pom.xml 2008-07-31 20:57:32 UTC (rev 954)
@@ -15,7 +15,7 @@
</parent>
<groupId>org.codelutin</groupId>
- <artifactId>lutinutil-io</artifactId>
+ <artifactId>lutinutil-no-i18n</artifactId>
<dependencies>
<dependency>
@@ -53,10 +53,11 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <name>Lutin io utilities library</name>
+ <name>Lutin utilities (no i18n) library</name>
<version>0.30-SNAPSHOT</version>
- <description>Library of usefull io class to be used in any project (with
- no i18n).</description>
+ <description>Library of usefull class to be used in any project (with
+ no i18n mecanism).
+ </description>
<inceptionYear>2004</inceptionYear>
<!-- ************************************************************* -->
@@ -126,7 +127,7 @@
<build>
<plugins>
- <!-- source -->
+ <!-- source -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
Modified: trunk/maven-i18n-plugin/pom.xml
===================================================================
--- trunk/maven-i18n-plugin/pom.xml 2008-07-31 20:45:42 UTC (rev 953)
+++ trunk/maven-i18n-plugin/pom.xml 2008-07-31 20:57:32 UTC (rev 954)
@@ -33,7 +33,7 @@
<dependency>
<groupId>org.codelutin</groupId>
- <artifactId>lutinutil</artifactId>
+ <artifactId>lutinutil-no-i18n</artifactId>
<version>0.30-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
Modified: trunk/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension/ParserJava.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension/ParserJava.java 2008-07-31 20:45:42 UTC (rev 953)
+++ trunk/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension/ParserJava.java 2008-07-31 20:57:32 UTC (rev 954)
@@ -21,8 +21,6 @@
import org.apache.maven.artifact.Artifact;
import org.apache.maven.project.MavenProject;
-import static org.codelutin.i18n.I18n._;
-import org.codelutin.i18n.I18nable;
import org.codelutin.i18n.plugin.core.AbstractI18nParser;
import org.codelutin.i18n.plugin.core.ParserEvent;
import org.codelutin.i18n.plugin.core.ParserException;
@@ -44,9 +42,9 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
+import java.util.Collections;
import java.util.List;
import java.util.Set;
-import java.util.Collections;
import java.util.regex.Pattern;
/**
@@ -144,7 +142,7 @@
}
protected List<String> initAnnotations() {
- return Collections.singletonList(org.codelutin.i18n.I18nable.class.getName());
+ return Collections.singletonList("org.codelutin.i18n.I18nable");
}
@Override
@@ -217,7 +215,7 @@
classname = classname.substring(0, classname.length() - 5);
- getLog().info(getLogEntry("add annotation to class "+ classname,0,0,0));
+ getLog().info(getLogEntry("add annotation to class " + classname, 0, 0, 0));
BufferedWriter outputStream = null;
try {
@@ -233,11 +231,11 @@
if (!foundDeclaration) {
// test if the annotion already exist ?
String line2 = line.trim();
- if (line2.startsWith("@I18nable") || line2.startsWith("@" + I18nable.class.getName())) {
+ if (line2.startsWith("@I18nable") || line2.startsWith("@org.codelutin.i18n.I18nable")) {
foundDeclaration = true;
} else if (TYPE_PATTERN.matcher(line2).matches()) {
foundDeclaration = true;
- outputStream.write('@' + I18nable.class.getName() + '\n');
+ outputStream.write("@org.codelutin.i18n.I18nable\n");
}
}
outputStream.write(line);
@@ -299,9 +297,9 @@
result = new URLClassLoader(url);
}
} catch (MalformedURLException eee) {
- throw new RuntimeException(_("Can't create ClassLoader for script, bad directory: {0} for reason {1}", cp, eee.getMessage()), eee);
+ throw new RuntimeException("Can't create ClassLoader for script, bad directory:" + cp + " for reason " + eee.getMessage(), eee);
} catch (IOException e) {
- throw new RuntimeException(_("Can't create ClassLoader for script, bad directory: {0} for reason {1}", cp, e.getMessage()), e);
+ throw new RuntimeException("Can't create ClassLoader for script, bad directory: " + cp + " for reason " + e.getMessage(), e);
}
loader = result;
}
Modified: trunk/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension/ParserJavaTabConfig.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension/ParserJavaTabConfig.java 2008-07-31 20:45:42 UTC (rev 953)
+++ trunk/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension/ParserJavaTabConfig.java 2008-07-31 20:57:32 UTC (rev 954)
@@ -32,7 +32,7 @@
@Override
protected java.util.List<String> initAnnotations() {
- return Collections.singletonList(org.codelutin.i18n.I18nable.class.getName());
+ return Collections.singletonList("org.codelutin.i18n.I18nable");
}
}
1
0
Author: tchemit
Date: 2008-07-31 20:45:42 +0000 (Thu, 31 Jul 2008)
New Revision: 953
Added:
trunk/lutinutil-no-i18n/
Removed:
trunk/lutinutil-io/
Log:
mise en place de org.codelutin:lutinutil-no-i18n qui vient de lutinutil mais ne permet aucune traduction i18n.
ceci est fait pour casser le cycle entre le projet maven-i18n-plugin et lutinutil.
lutinutil va d?\195?\169pendre de ce projet donc grace aux dependances transitives, cela reste transparent pour le reste des projets.
Copied: trunk/lutinutil-no-i18n (from rev 952, trunk/lutinutil-io)
1
0