Author: tchemit Date: 2008-07-31 19:45:28 +0000 (Thu, 31 Jul 2008) New Revision: 948 Removed: trunk/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/util/ Modified: trunk/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/core/Generate.java trunk/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/ParserXml.java Log: use PropertiesDateRemoveFilterStream defined in lutinutil add @Override reformat Modified: trunk/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 19:35:13 UTC (rev 947) +++ trunk/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/core/Generate.java 2008-07-31 19:45:28 UTC (rev 948) @@ -19,23 +19,22 @@ package org.codelutin.i18n.plugin.core; +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 java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.Properties; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.codelutin.i18n.plugin.util.PropertiesDateRemoveFilterStream; -import org.codelutin.util.SortedProperties; -import org.codelutin.util.FileUtil; - /** * Merge des fichiers de propri�t�s avec les anciens. - * + * * @author julien - * * @goal gen * @phase generate-resources * @execute goal=get @@ -53,7 +52,7 @@ File bundleSrc = new File(src.getAbsolutePath() + File.separatorChar + artifactId + "-" + bundle + ".properties"); File bundleOut = new File(out.getAbsolutePath() + File.separatorChar + artifactId + "-" + bundle + ".properties"); - if(bundleSrc.exists()) { + if (bundleSrc.exists()) { Properties propertiesSrc = new Properties(); propertiesSrc.load(new FileInputStream(bundleSrc)); @@ -64,13 +63,13 @@ for (Object key : propertiesBundle.keySet()) { Object oldKey = propertiesBundle.get(key); Object value = propertiesSrc.get(oldKey); - + // R�cup�ration de la cl� si elle a �t� renomm� - if(!key.equals(oldKey) && value == null) { + if (!key.equals(oldKey) && value == null) { value = propertiesSrc.get(key); } - - if(value != null) { + + if (value != null) { propertiesBundle.put(key, value); } else { propertiesBundle.put(key, ""); @@ -82,14 +81,14 @@ propertiesBundle.store(filter, null); // Sauvegarde avant copie - if(genSrc && keepBackup) { + if (genSrc && keepBackup) { FileUtil.copy(bundleSrc, new File(src.getAbsolutePath() + File.separatorChar + artifactId + "-" + bundle + ".properties" + "~")); } getLog().info("Merge bundle " + bundleSrc.getAbsolutePath()); } - if(genSrc) { + if (genSrc) { // Copie des fichiers dans les sources FileUtil.copy(bundleOut, bundleSrc); getLog().info("Copy bundle " + bundleSrc.getAbsolutePath()); Modified: trunk/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 19:35:13 UTC (rev 947) +++ trunk/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension/ParserJavaActionConfig.java 2008-07-31 19:45:28 UTC (rev 948) @@ -37,18 +37,22 @@ protected static final Pattern MATCH_PATTERN = Pattern.compile("(name|shortDescription|longDescription|name2|shortDescription2|longDescription2)\\s*=\\s*\"([\\w|\\.]+)\"(|\\s*|\\s*,\\s*$)"); + @Override protected String getKeyModifierStart() { return "[\\w|\\.]+\\s*=\\s*\""; } + @Override protected String getKeyModifierEnd() { return "\"\\s*(\\)|,|\\+|$)"; } + @Override protected String getOutGetter() { return "java-action-config.getter"; } + @Override protected List<String> initAnnotations() { List<String> result = new ArrayList<String>(1); result.add("jaxx.runtime.builder.ActionConfig"); @@ -74,6 +78,7 @@ * (non-Javadoc) * @see org.codelutin.i18n.plugin.core.Parser#parseLine(java.io.File, java.lang.String) */ + @Override public void parseLine(File srcFile, String line) { String key = extract(line); if (key != null) { Modified: trunk/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 19:35:13 UTC (rev 947) +++ trunk/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin/extension/ParserXml.java 2008-07-31 19:45:28 UTC (rev 948) @@ -19,27 +19,26 @@ package org.codelutin.i18n.plugin.extension; +import org.codelutin.i18n.plugin.core.AbstractI18nParser; +import org.codelutin.i18n.plugin.core.ParserEvent; +import org.codelutin.i18n.plugin.core.ParserException; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; + +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathExpression; +import javax.xml.xpath.XPathFactory; +import java.io.BufferedInputStream; 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; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.BufferedInputStream; -import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathConstants; -import javax.xml.xpath.XPathExpression; -import javax.xml.xpath.XPathFactory; - -import org.codelutin.i18n.plugin.core.ParserEvent; -import org.codelutin.i18n.plugin.core.ParserException; -import org.codelutin.i18n.plugin.core.AbstractI18nParser; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; - /** * R�cup�ration des cha�ne � traduire depuis les fichiers xml. * @@ -63,6 +62,7 @@ /** * Fonction d'extraction de la chaine + * * @param i18nString le clef i18n * @return la chaine */ @@ -74,6 +74,7 @@ /** @return le fichier des rules de base � toujours charger */ protected abstract String getCoreFileRules(); + @Override public void init() { super.init(); this.factory = XPathFactory.newInstance(); @@ -102,7 +103,7 @@ } // D�tection de nouvelles cl�s, sauvegarde du fichier pour pouvoir le restaurer en cas de plantage - if(size != result.size()) { + if (size != result.size()) { OutputStream xmlparserOut = new FileOutputStream(out.getAbsolutePath() + File.separatorChar + getOutGetter()); result.store(xmlparserOut, null); } @@ -117,15 +118,15 @@ */ public void parseLine(File file, String key) { key = extract(key); - if(key != null) { - touchFile=true; + if (key != null) { + touchFile = true; String keyModified = key; for (ParserEvent event : events) { event.eventChangeKey(key, !oldLanguage.containsKey(key)); keyModified = event.eventGetRealKey(); } - if(oldParser.containsKey(key)) { + if (oldParser.containsKey(key)) { result.put(keyModified, oldParser.get(key)); } else { result.put(keyModified, key); @@ -139,6 +140,7 @@ /** * 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 */ @@ -151,7 +153,7 @@ // load core rules readInputStream = loadRulesFile(getCoreFileRules()); if (verbose) { - getLog().debug("core rules : "+readInputStream); + getLog().debug("core rules : " + readInputStream); } result.append(readInputStream);