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
July 2008
- 3 participants
- 152 discussions
[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
[Lutinutil-commits] r952 - in trunk: lutinutil/src/main/java/org/codelutin/util lutinutil-io/src/main/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 20:35:40 +0000 (Thu, 31 Jul 2008)
New Revision: 952
Added:
trunk/lutinutil-io/src/main/java/org/codelutin/util/CollectionUtil.java
trunk/lutinutil-io/src/main/java/org/codelutin/util/FileUtil.java
trunk/lutinutil-io/src/main/java/org/codelutin/util/PropertiesDateRemoveFilterStream.java
trunk/lutinutil-io/src/main/java/org/codelutin/util/SortedProperties.java
trunk/lutinutil-io/src/main/java/org/codelutin/util/StringUtil.java
trunk/lutinutil-io/src/main/java/org/codelutin/util/StringUtilException.java
Removed:
trunk/lutinutil/src/main/java/org/codelutin/util/CollectionUtil.java
trunk/lutinutil/src/main/java/org/codelutin/util/FileUtil.java
trunk/lutinutil/src/main/java/org/codelutin/util/PropertiesDateRemoveFilterStream.java
trunk/lutinutil/src/main/java/org/codelutin/util/SortedProperties.java
trunk/lutinutil/src/main/java/org/codelutin/util/StringUtil.java
trunk/lutinutil/src/main/java/org/codelutin/util/StringUtilException.java
Log:
mise en place de org.codelutin:lutinutil-io qui vien t 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.
Deleted: trunk/lutinutil/src/main/java/org/codelutin/util/CollectionUtil.java
===================================================================
--- trunk/lutinutil/src/main/java/org/codelutin/util/CollectionUtil.java 2008-07-31 20:12:39 UTC (rev 951)
+++ trunk/lutinutil/src/main/java/org/codelutin/util/CollectionUtil.java 2008-07-31 20:35:40 UTC (rev 952)
@@ -1,156 +0,0 @@
-/* *##%
- * Copyright (C) 2006
- * 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.
- *##%*/
-
-/* *
- * CollectionUtil.java
- *
- * Created: 23 f�vr. 2006 09:03:39
- *
- * @author poussin
- * @version $Revision$
- *
- * Last update: $Date$
- * by : $Author$
- */
-
-package org.codelutin.util;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-
-/**
- * @author poussin
- *
- */
-
-public class CollectionUtil {
-
- /**
- * Ajoute a la collection tous les elements pass�s en parametre
- * @param col la collection
- * @param e les elements a ajouter
- * @return la collection pass� en parametre
- */
- static public <A, E extends Collection<A>> E addAll(E col, A ... e) {
- Collections.addAll(col, e);
- return col;
- }
-
- /**
- * Ajoute a la liste tous les elements pass�s en parametre
- * @param col la liste
- * @param pos le premier index o� ins�rer les donn�es
- * @param e les elements a ajouter
- * @return la liste pass� en parametre
- */
- static public <A, E extends List<A>> E addAll(E col, int pos, A ... e) {
- col.addAll(pos, Arrays.asList(e));
- return col;
- }
-
- /**
- * Permet de convertir une liste non typ�e, en une liste typ�e.
- *
- * La liste en entr�e en juste bien cast�e.
- *
- * On effectue une v�rification sur le typage des �lements de la liste.
- *
- * Note : <b>Aucune liste n'est cr�ee, ni recopi�e</b>
- *
- * @param list la liste � convertir
- * @param type le type des �l�ments de la liste
- * @return la liste typ�e
- * @throws IllegalArgumentException si un �l�ment de la liste en entr�e n'est
- * pas en ad�quation 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;
- }
-
- /**
- * Permet de convertir une collection non typ�e, en une collection typ�e.
- *
- * La collection en entr�e en juste bien cast�e.
- *
- * On effectue une v�rification sur le typage des �lements de la collection.
- *
- * Note : <b>Aucune collection n'est cr�ee, ni recopi�e</b>
- *
- * @param list la collection � convertir
- * @param type le type des �l�ments de la collection
- * @return la collection typ�e
- * @throws IllegalArgumentException si un �l�ment de la collection en entr�e n'est
- * pas en ad�quation avec le type voulue.
- */
- @SuppressWarnings({"unchecked"})
- static public <O> Collection<O> toGenericCollection(Collection 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 Collection with object of type "+o.getClass()+" to "+type+" type!");
- }
- }
- return list;
- }
-
- /**
- * Permet de convertir un ensemble non typ�e, en un ensemble typ�e.
- *
- * L'ensemble en entr�e en juste bien cast�e.
- *
- * On effectue une v�rification sur le typage des �lements de la collection.
- *
- * Note : <b>Aucun ensemble n'est cr�ee, ni recopi�e</b>
- *
- * @param list l'ensemble � convertir
- * @param type le type des �l�ments de l'ensemble
- * @return l'ensemble typ�e
- * @throws IllegalArgumentException si un �l�ment de l'ensemble en entr�e n'est
- * pas en ad�quation avec le type voulue.
- */
- @SuppressWarnings({"unchecked"})
- static public <O> Set<O> toGenericSet(Set 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 Set with object of type "+o.getClass()+" to "+type+" type!");
- }
- }
- return list;
- }
-}
-
-
Deleted: trunk/lutinutil/src/main/java/org/codelutin/util/FileUtil.java
===================================================================
--- trunk/lutinutil/src/main/java/org/codelutin/util/FileUtil.java 2008-07-31 20:12:39 UTC (rev 951)
+++ trunk/lutinutil/src/main/java/org/codelutin/util/FileUtil.java 2008-07-31 20:35:40 UTC (rev 952)
@@ -1,766 +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.
- *##%*/
-
-/* *
- * FileUtil.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.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.nio.channels.FileChannel;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.LinkedList;
-import java.util.List;
-
-import javax.swing.JFileChooser;
-
-import org.apache.commons.logging.LogFactory;
-
-public class FileUtil { // FileUtil
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- static private org.apache.commons.logging.Log log = LogFactory.getLog(FileUtil.class);
-
- /** Encoding par defaut utilis� si non sp�cifi� */
- static public String ENCODING = "ISO-8859-1";
- static protected File currentDirectory = new File(".");
-
- static public void setCurrentDirectory(File dir){
- currentDirectory = dir;
- }
-
- static public class PatternChooserFilter extends javax.swing.filechooser.FileFilter {
- protected String pattern = null;
- protected String description = null;
-
- public PatternChooserFilter(String pattern, String description) {
- this.pattern = pattern;
- this.description = description;
- }
-
- @Override
- public boolean accept(File f) {
- return f.isDirectory() || f.getAbsolutePath().matches(pattern);
- }
- @Override
- public String getDescription() {
- return description;
- }
-
- }
-
-
- /**
- * Retourne le nom du fichier entre dans la boite de dialogue.
- * Si le bouton annuler est utilis�, ou qu'il y a une erreur retourne null.
- *
- * @param patternOrDescriptionFilters les filtres a utiliser, les chaines doivent etre donn�es
- * par deux, le pattern du filtre + la description du filtre
- * @return
- *
- * @see #getFile(javax.swing.filechooser.FileFilter[])
- */
- static public File getFile(String ... patternOrDescriptionFilters) {
- if (patternOrDescriptionFilters.length % 2 != 0) {
- throw new IllegalArgumentException("Arguments must be (pattern, description) couple");
- }
- javax.swing.filechooser.FileFilter [] filters = new javax.swing.filechooser.FileFilter[patternOrDescriptionFilters.length / 2];
- for (int i=0; i<filters.length; i++) {
- String pattern = patternOrDescriptionFilters[i*2];
- String description = patternOrDescriptionFilters[i*2 + 1];
- filters[i] = new PatternChooserFilter(pattern, description);
- }
- File result;
- result = getFile(filters);
- return result;
- }
-
- /**
- * Retourne le nom du fichier entre dans la boite de dialogue.
- * Si le bouton annuler est utilis�, ou qu'il y a une erreur retourne null.
- *
- * @param filters les filtres a ajouter
- * @return
- */
- static public File getFile(javax.swing.filechooser.FileFilter ... filters){
- try{
- JFileChooser chooser = new JFileChooser(currentDirectory);
-
- chooser.setDialogType(JFileChooser.CUSTOM_DIALOG);
- if (filters.length > 0) {
- if (filters.length == 1) {
- chooser.setFileFilter(filters[0]);
- } else {
- for (javax.swing.filechooser.FileFilter filter : filters) {
- chooser.addChoosableFileFilter(filter);
- }
- }
- }
- chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
- int returnVal = chooser.showDialog(null, "Ok");
- if(returnVal == JFileChooser.APPROVE_OPTION) {
- File theFile = chooser.getSelectedFile();
- if(theFile != null) {
- currentDirectory = theFile;
- return theFile.getAbsoluteFile();
- }
- }
- }
- catch(Exception eee){
- log.warn("Erreur:", eee);
- }
- return null;
- }
-
- /**
- * @param title le nom de la boite de dialogue
- * @param approvalText
- * @return le nom du repertoire entre dans la boite de dialogue.
- * Si le bouton annuler est utilis�, ou qu'il y a une erreur retourne
- * null.
- */
- static public String getDirectory(String title,String approvalText) {
- try{
- JFileChooser chooser = new JFileChooser(currentDirectory);
- chooser.setDialogType(JFileChooser.CUSTOM_DIALOG);
- chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
- chooser.setDialogTitle(title);
- int returnVal = chooser.showDialog(null,approvalText);
- if(returnVal == JFileChooser.APPROVE_OPTION) {
- File theFile = chooser.getSelectedFile();
- if(theFile != null) {
- currentDirectory = theFile;
- if(theFile.isDirectory()) {
- return theFile.getAbsolutePath();
- }
- }
- }
- else{
- return null;
- }
- } catch(Exception eee){
- log.warn("Erreur:", eee);
- }
- return null;
- }
-
- /**
- * @return le nom du repertoire entre dans la boite de dialogue.
- * Si le bouton annuler est utilis�, ou qu'il y a une erreur retourne
- * null.
- */
- static public String getDirectory() {
- return getDirectory("Ok","Ok");
- }
-
- /**
- * Permet de convertir un fichier en un tableau de byte
- *
- * @param file
- * @return
- * @throws IOException
- */
- static public byte[] fileToByte(File file) throws IOException {
- InputStream in = new BufferedInputStream(new FileInputStream(file));
- ByteArrayOutputStream result = new ByteArrayOutputStream();
- BufferedOutputStream tmp = new BufferedOutputStream(result);
- for (int b=in.read(); b != -1; b=in.read()) {
- tmp.write(b);
- }
- in.close();
- tmp.close();
-
- return result.toByteArray();
- }
-
- /**
- * Permet de convertir des bytes en fichier, le fichier sera automatiquement
- * supprim� a la fin de la JVM.
- *
- * @param bytes
- * @return le fichier temporaire contenant les bytes
- * @throws IOException
- */
- static public File byteToFile(byte[] bytes) throws IOException {
- File file = File.createTempFile("FileUtil-byteToFile", ".tmp");
- byteToFile(bytes, file);
- return file;
- }
-
- /**
- * Permet de convertir des bytes en fichier
- *
- * @param bytes
- * @param file le fichier dans lequel il faut ecrire les bytes
- * @return le fichier pass� en parametre
- * @throws IOException
- */
- static public File byteToFile(byte[] bytes, File file) throws IOException {
- OutputStream out = new BufferedOutputStream(new FileOutputStream(file));
- out.write(bytes);
- out.close();
- return file;
- }
-
- /**
- * Retourne un Reader utilisant l'encoding par defaut {@link #ENCODING}
- *
- * @param file
- * @return
- * @throws IOException
- */
- static public BufferedReader getReader(File file) throws IOException {
- return getReader(file, ENCODING);
- }
-
- /**
- * Retourne un reader utilisant l'encoding choisi et plac� dans un
- * BufferedReader
- *
- * @param file
- * @param encoding (ISO-8859-1, UTF-8, ...)
- * @return
- * @throws IOException
- */
- static public BufferedReader getReader(File file, String encoding) throws IOException {
- FileInputStream inf = new FileInputStream(file);
- InputStreamReader in = new InputStreamReader(inf, encoding);
-// FileReader in = new FileReader(file);
- BufferedReader result = new BufferedReader(in);
- return result;
- }
-
- /**
- * Retourne un Writer utilisant l'encoding par defaut {@link #ENCODING}
- *
- * @param file
- * @return
- * @throws IOException
- */
- static public BufferedWriter getWriter(File file) throws IOException {
- return getWriter(file, ENCODING);
- }
-
- /**
- * Retourne un writer utilisant l'encoding choisi et plac� dans un
- * BufferedWriter
- *
- * @param file
- * @param encoding (ISO-8859-1, UTF-8, ...)
- * @return
- * @throws IOException
- */
- static public BufferedWriter getWriter(File file, String encoding) throws IOException {
- FileOutputStream outf = new FileOutputStream(file);
- OutputStreamWriter out = new OutputStreamWriter(outf, encoding);
-// FileWriter out = new FileWriter(file);
- BufferedWriter result = new BufferedWriter(out);
- return result;
- }
-
- public static void main(String[] args) {
-
- }
-
- /**
- * Permet de creer un nouveu repertoire temporaire, l'effacement du
- * r�pertoire est a la charge de l'appelant
- * @param prefix le prefix du fichier
- * @param suffix le suffix du fichier
- * @param tmpdir le r�pertoire temporaire ou il faut creer le repertoire
- * si null on utilise java.io.tmpdir
- * @return le fichier pointant sur le nouveau repertoire
- * @throws java.io.IOException
- */
- static public File createTempDirectory(String prefix, String suffix, File tmpdir) throws IOException {
- if (tmpdir == null) {
- tmpdir = new File(System.getProperty("java.io.tmpdir"));
- }
- File result = new File(tmpdir, prefix + System.currentTimeMillis() + suffix);
- while (result.exists()) {
- result = new File(tmpdir, prefix + System.currentTimeMillis() + suffix);
- }
- if (!result.mkdirs()) {
- throw new IOException("Can't create temporary directory: " + result);
- }
- return result;
- }
- /**
- * Permet de creer un nouveu repertoire temporaire, l'effacement du
- * r�pertoire est a la charge de l'appelant
- * @param prefix
- * @param suffix
- * @return
- * @throws java.io.IOException
- */
- static public File createTempDirectory(String prefix, String suffix) throws IOException {
- return createTempDirectory(prefix, suffix, null);
- }
-
- /**
- * Regarde si le fichier f1 est plus recent que le fichier f2
- * @param f1
- * @param f2
- * @return vrai si f1 est plus recent que f2
- */
- static public boolean isNewer(File f1, File f2) {
- boolean result = f1.lastModified() > f2.lastModified();
- return result;
- }
-
- /**
- * Permet de lire un fichier et de retourner sont contenu sous forme d'une
- * chaine de carateres
- * @param file le fichier a lire
- * @throws IOException
- * @return
- */
- static public String readAsString(File file) throws IOException {
- StringBuffer result = new StringBuffer();
- char [] cbuf = new char[2000];
- BufferedReader in = getReader(file);
- int nb = in.read(cbuf);
- while (nb != -1) {
- result.append(cbuf, 0, nb);
- nb = in.read(cbuf);
- }
- in.close();
- return result.toString();
- }
-
- /**
- * Permet de sauver une chaine directement dans un fichier
- * @param file Le fichier dans lequel il faut ecrire la chaine
- * @param content Le texte a ecrire dans le fichier
- * @throws IOException if any pb while writing
- */
- static public void writeString(File file, String content) throws IOException {
- file.getParentFile().mkdirs();
- BufferedWriter out = getWriter(file);
- out.write(content);
- out.close();
- }
-
- /**
- * Permet de sauver une chaine directement dans un fichier
- * @param file Le fichier dans lequel il faut ecrire la chaine
- * @param content Le texte a ecrire dans le fichier
- * @param encoding encoding to use
- * @throws IOException if any pb while writing
- */
- static public void writeString(File file, String content,String encoding) throws IOException {
- file.getParentFile().mkdirs();
- BufferedWriter out = getWriter(file,encoding);
- out.write(content);
- out.close();
- }
-
- /**
- * Permet de donner une representation fichier pour une chaine de caractere.
- * Le fichier sera automatiquement effac� � la fin de la JVM.
- * @param content le contenu du fichier temporaire
- * @return le fichier qui contient content
- * @throws IOException
- */
- static public File getTempFile(String content) throws IOException {
- return getTempFile(content, "");
- }
-
- /**
- * Permet de donner une representation fichier pour une chaine de caractere.
- * Le fichier sera automatiquement effac� � la fin de la JVM.
- * @param content le contenu du fichier temporaire
- * @param fileSuffix l'extension du fichier cr��
- * @return le fichier qui contient content
- * @throws IOException
- */
- static public File getTempFile(String content, String fileSuffix) throws IOException {
- File result = File.createTempFile("tmp-" + FileUtil.class.getName(), fileSuffix);
- result.deleteOnExit();
- writeString(result, content);
- return result;
- }
-
- /**
- * Equivalent de la methode basename unix.
- * basename("/tmp/toto.xml", ".xml") -> "toto"
- *
- * @param file le fichier dont on souhaite le nom sans le chemin
- * @param suffixes si present represente le suffixe a eliminer du fichier
- * s'il est trouv�
- * @return le nom du fichier sans le suffixe si trouv�.
- */
- static public String basename(File file, String ... suffixes) {
- String result = file.getName();
- for(String suffixe : suffixes) {
- if (result.endsWith(suffixe)){
- result = result.substring(0, result.length() - suffixe.length());
- break;
- }
- }
- return result;
- }
-
- /**
- * Permet de r�cup�rer l'extension d'un fichier
- * @param file le fichier dont on souhaite l'extension
- * @param extchars la liste des caracteres pouvant former l'extension
- * dans l'ordre de preference. Si vide on utilise ".".
- * @return l'extension ou la chaine vide si le fichier n'a pas d'extension
- * l'extension ne contient pas le chaine de delimitation
- */
- static public String extension(File file, String ... extchars) {
- String result = "";
- String name = file.getName();
-
- if(extchars.length == 0) {
- extchars = new String[]{"."};
- }
- for (String extchar : extchars) {
- int pos = name.lastIndexOf(extchar);
- if (pos != -1) {
- result = name.substring(pos + extchar.length());
- break;
- }
- }
- return result;
- }
-
- static public interface FileAction {
- public boolean doAction(File f);
- }
-
- /**
- * Retourne tous les sous r�pertoires du r�pertoire pass� en argument.
- * @param directory un r�pertoire
- * @return une liste d'objet {@link java.io.File} de r�pertoires et ceci
- * recursivement � partir de directory, si directory
- * n'est pas un r�pertoire la liste est vide.
- */
- public static List<File> getSubDirectories(File directory) {
- class DirectoryFilter implements FileFilter {
- public boolean accept(File f) {
- return f.isDirectory();
- }
- }
- return getFilteredElements(directory, new DirectoryFilter(), true);
- }
-
- /**
- * Retourne tous les fichiers du r�pertoire pass� en argument.
- * @param directory un r�pertoire
- * @return une liste d'objet {@link java.io.File} des fichiers et ceci
- * recursivement � partir de directory, si directory n'est pas un
- * r�pertoire la liste est vide
- */
- public static List<File> getFiles(File directory) {
- class NormalFileFilter implements FileFilter {
- public boolean accept(File f) {
- return f.isFile();
- }
- }
- return getFilteredElements(directory, new NormalFileFilter(), true);
- }
-
- /**
- * Retourne les fichiers d'un r�pertoire qui s'attisfont un certain pattern.
- * La recherche est faite r�cursivement dans les sous r�pertoires
- * @param directory le r�pertoire � partir duquel il faut faire la recherche
- * @param pattern le pattern que doit respecter le fichier pour �tre dans la
- * liste r�sultante
- * @param recursively
- * @return une liste d'objet {@link java.io.File} qui ont s'attisfait le
- * pattern.
- */
- public static List<File> find(File directory, final String pattern, boolean recursively){
- final String root = directory.getAbsolutePath();
- final int rootLength = root.length();
-
- return getFilteredElements(directory, new FileFilter() {
- public boolean accept(File f) {
- String longFilename = f.getAbsolutePath();
- // + 1 to remove the first / or \
- String filename = longFilename.substring(rootLength + 1);
- return filename.matches(pattern);
- }
- }, recursively);
- }
-
- /**
- * Retourne la liste de toutes les fichiers ou r�pertoire qui s'attisfont
- * le filtre
- * @param directory repertoire � partir duquel il faut faire la recherche
- * @param ff le filtre � appliquer pour savoir si le fichier parcouru doit
- * �tre conserv� dans les r�sultats, ou null pour tous les fichiers
- * @param recursively
- * @return une liste d'objet {@link java.io.File}, qui s'attisfont le filtre
- */
- public static List<File> getFilteredElements(File directory, FileFilter ff, boolean recursively) {
- ArrayList<File> result = new ArrayList<File>();
- LinkedList<File> todo = new LinkedList<File>();
- if (directory.isDirectory()){
- todo.addAll(Arrays.asList(directory.listFiles()));
- }
- while(todo.size() > 0){
- File file = todo.removeFirst();
- if (recursively && file.isDirectory()){
- File [] childs = file.listFiles();
- if (childs != null) { // null if we don't have access to directory
- todo.addAll(Arrays.asList(childs));
- }
- }
- if(ff == null || ff.accept(file)){
- result.add(file);
- }
- }
- return result;
- }
-
- /**
- * Supprime recursivement tout le contenu d'un r�pertoire.
- * @param directory
- * @return vrai si tout se passe bien, false si la suppression d'un �lement
- * se passe mal
- */
- public static boolean deleteRecursively(String directory) {
- return deleteRecursively(new File(directory));
- }
-
- /**
- * Supprime recursivement tout le contenu d'un r�pertoire.
- * @param directory
- * @return vrai si tout se passe bien, false si la suppression d'un �lement
- * se passe mal
- */
- public static boolean deleteRecursively(File directory) {
- return walkBefore(directory, new FileAction(){
- public boolean doAction(File f) {
- return f.delete();
- }
- });
- }
-
- /**
- * Permet de faire une action avant le parcours des fichiers, c-a-d que
- * l'on fera l'action sur les fichiers contenu dans un r�pertoire
- * apr�s l'action sur le r�pertoire lui m�me.
- * @param f le fichier ou r�pertoire � partir duquel il faut commencer
- * @param fileAction l'action � effectuer sur chaque fichier
- * @return le r�sultat des fileAction execut� sur les fichiers, chaque
- * r�sultat de FileAction sont assembl� par un ET logique pour donner
- * le r�sultat final
- */
- public static boolean walkAfter(File f, FileAction fileAction) {
- boolean result=fileAction.doAction(f);
- if (f.isDirectory()) {
- File list[] = f.listFiles();
- for (int i = 0; i < list.length; i++) {
- result=result && walkAfter(list[i], fileAction);
- }
- }
- return result;
- }
-
- /**
- * Permet de faire une action ap�s le parcours des fichiers, c-a-d que
- * l'on fera l'action sur les fichiers contenu dans un r�pertoire
- * avant l'action sur le r�pertoire lui m�me.
- * @param f le fichier ou r�pertoire � partir duquel il faut commencer
- * @param fileAction l'action � effectuer sur chaque fichier
- * @return le r�sultat des fileAction execut� sur les fichiers, chaque
- * r�sultat de FileAction sont assembl� par un ET logique pour donner
- * le r�sultat final
- */
- public static boolean walkBefore(File f, FileAction fileAction) {
- boolean result=true;
- if (f.isDirectory()) {
- File list[] = f.listFiles();
- for (int i = 0; i < list.length; i++) {
- result=result && walkBefore(list[i], fileAction);
- }
- }
- return result && fileAction.doAction(f);
- }
-
- /**
- * Permet de copier le fichier source vers le fichier cible.
- * @param source le fichier source
- * @param target le fichier cible
- * @throws 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 copier le fichier source vers le fichier cible.
- * @param source le fichier source
- * @param target le fichier cible
- * @throws IOException Erreur de copie
- */
- public static void copy(String source, String target) throws IOException {
- copy(new File(source), new File(target));
- }
-
- /**
- * Copie recursivement le repertoire source dans le repertoire destination
- *
- * copyRecursively("/truc/titi", "/var/tmp") donnera le repertoire
- * "/var/tmp/titi"
- *
- * @param srcDir
- * @param destDir
- * @param includePatterns les patterns que doivent resperter les
- * fichiers/repertoires pour etre copi�. Si vide alors tout est copi�
- *
- * @throws IOException
- */
- static public void copyRecursively(File srcDir, File destDir, String ... includePatterns) throws IOException {
- copyAndRenameRecursively(srcDir, destDir, null, null, includePatterns);
- }
-
- /**
- * Copie recursivement le repertoire source dans le repertoire destination
- *
- * copyRecursively("/truc/titi", "/var/tmp", "bidulle") donnera le repertoire
- * "/var/tmp/bidulle", 'bidulle' remplacant 'titi'
- *
- * @param srcDir
- * @param destDir
- * @param renameFrom pattern to permit rename file before uncompress it
- * @param renameTo new name for file if renameFrom is applicable to it
- * you can use $1, $2, ... if you have '(' ')' in renameFrom
- * @param includePatterns les patterns que doivent resperter les
- * fichiers/repertoires pour etre copi�. Si vide alors tout est copi�
- *
- * @throws IOException
- */
- static public void copyAndRenameRecursively(File srcDir, File destDir,
- String renameFrom, String renameTo, String ... includePatterns) throws IOException {
- copyAndRenameRecursively(srcDir, destDir, true, renameFrom, renameTo, false, includePatterns);
- }
-
- /**
- * Copie recursivement le repertoire source dans le repertoire destination
- *
- * copyRecursively("/truc/titi", "/var/tmp", "bidulle") donnera le repertoire
- * "/var/tmp/bidulle", 'bidulle' remplacant 'titi'
- *
- * @param srcDir
- * @param destDir
- * @param includeSrcDir si vrai alors le repertoire source est copie dans le
- * repertoire destination et non pas seulement les fichiers qu'il contient
- * @param renameFrom pattern to permit rename file before uncompress it
- * @param renameTo new name for file if renameFrom is applicable to it
- * you can use $1, $2, ... if you have '(' ')' in renameFrom
- * @param exclude inverse include pattern interpretation
- * @param includePatterns les patterns que doivent resperter les
- * fichiers/repertoires pour etre copi�. Si vide alors tout est copi�
- *
- * @throws IOException
- */
- static public void copyAndRenameRecursively(File srcDir, File destDir,
- boolean includeSrcDir, String renameFrom, String renameTo, boolean exclude,
- String ... includePatterns) throws IOException {
- String rootSrc;
- if (includeSrcDir) {
- rootSrc = srcDir.getParent();
- } else {
- rootSrc = srcDir.getPath();
- }
- List<File> files = getFilteredElements(srcDir, null, true);
- log.debug("copyRecursively: " + files);
- for (File file : files) {
- boolean doCopy = copyRecursivelyAccept(file, includePatterns);
- if (xor(exclude, doCopy)) {
- String path = file.getPath().substring(rootSrc.length());
- if (renameFrom != null && renameTo != null) {
- String tmp = path.replaceAll(renameFrom, renameTo);
- if (log.isDebugEnabled()) {
- log.debug("rename " + path + " -> " + tmp);
- }
- path = tmp;
- }
-
- File destFile = new File(destDir, path);
- if (file.isDirectory()) {
- log.debug("create directory: " + destFile);
- destFile.mkdirs();
- } else {
- log.debug("copy " + path + " to " + destFile);
- copy(file, destFile);
- }
- }
- }
- }
-
- static private boolean xor(boolean b, boolean c) {
- if (b) return !c;
- else return c;
- }
-
- /**
- * @param file
- * @param includePatterns
- * @return
- */
- private static boolean copyRecursivelyAccept(File file, String[] includePatterns) {
- boolean result = includePatterns.length == 0;
- String filename = file.getAbsolutePath();
- for (String pattern : includePatterns) {
- result = filename.matches(pattern);
- if (result) {
- break;
- }
- }
- return result;
- }
-
-} // FileUtil
-
Deleted: trunk/lutinutil/src/main/java/org/codelutin/util/PropertiesDateRemoveFilterStream.java
===================================================================
--- trunk/lutinutil/src/main/java/org/codelutin/util/PropertiesDateRemoveFilterStream.java 2008-07-31 20:12:39 UTC (rev 951)
+++ trunk/lutinutil/src/main/java/org/codelutin/util/PropertiesDateRemoveFilterStream.java 2008-07-31 20:35:40 UTC (rev 952)
@@ -1,50 +0,0 @@
-/*
-* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais
-*
-* 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.util;
-
-import java.io.FilterOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-public 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);
- }
- }
-
-}
\ No newline at end of file
Deleted: trunk/lutinutil/src/main/java/org/codelutin/util/SortedProperties.java
===================================================================
--- trunk/lutinutil/src/main/java/org/codelutin/util/SortedProperties.java 2008-07-31 20:12:39 UTC (rev 951)
+++ trunk/lutinutil/src/main/java/org/codelutin/util/SortedProperties.java 2008-07-31 20:35:40 UTC (rev 952)
@@ -1,62 +0,0 @@
-/* *##%
- * Copyright (C) 2007
- * I18nPlugin, Code Lutin
- *
- * 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.util;
-
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Properties;
-import java.util.Vector;
-
-/**
- * Permet d'avoir les fichiers de propri�t�s tri�s.
- *
- * @author julien
- */
-public class SortedProperties extends Properties {
-
- private static final long serialVersionUID = -1147150444452577558L;
-
-
- public SortedProperties() {
- super();
- }
-
- public SortedProperties(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 = CollectionUtil.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();
- }
-}
Deleted: trunk/lutinutil/src/main/java/org/codelutin/util/StringUtil.java
===================================================================
--- trunk/lutinutil/src/main/java/org/codelutin/util/StringUtil.java 2008-07-31 20:12:39 UTC (rev 951)
+++ trunk/lutinutil/src/main/java/org/codelutin/util/StringUtil.java 2008-07-31 20:35:40 UTC (rev 952)
@@ -1,552 +0,0 @@
-/* *##%%
- * Copyright (C) 2002, 2003 Code Lutin
- *
- * 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.
- *##%%**/
-/* *
- * StringUtil.java
- *
- * Created: Sun Apr 14 2002
- *
- * @author POUSSIN Benjamin <bpoussin(a)free.fr>
- * Copyright Code Lutin
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-package org.codelutin.util;
-
-import java.awt.Color;
-import java.lang.reflect.Field;
-import java.text.DateFormat;
-import java.text.MessageFormat;
-import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-
-/**
- * Classe contenant un ensemle de methode static utiles pour la manipulation des
- * chaine de caractere mais qui ne sont pas defini dans la classe String de
- * Java.
- *
- * @author poussin
- * @created 21 octobre 2003
- */
-public class StringUtil { // StringUtil
-
- /** Constructor for the StringUtil object */
- protected StringUtil() {
- }
-
- /**
- * Cette methode retire les accents. Quand le caractere est connu, elle le
- * remplace par une version sans accent sinon, elle le supprime.
- * Les caracteres non-alphanumeriques sont supprimes.
- *
- * @param s la chaine a unaccentuer
- * @return la chaine sans accent
- */
- static public String unaccent(String s) {
- String result = "";
- for (char c : s.toCharArray()) {
- if ("����".indexOf(c) != -1) {
- result += "e";
- } else if ("���".indexOf(c) != -1) {
- result += "a";
- } else if ("�".indexOf(c) != -1) {
- result += "c";
- } else if ("��".indexOf(c) != -1) {
- result += "i";
- } else if ("��".indexOf(c) != -1) {
- result += "o";
- } else if ("���".indexOf(c) != -1) {
- result += "u";
- } else if ("����".indexOf(c) != -1) {
- result += "E";
- } else if ("���".indexOf(c) != -1) {
- result += "A";
- } else if ("�".indexOf(c) != -1) {
- result += "C";
- } else if ("��".indexOf(c) != -1) {
- result += "I";
- } else if ("��".indexOf(c) != -1) {
- result += "O";
- } else if ("���".indexOf(c) != -1) {
- result += "U";
- } else if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')
- || ('0' <= c && c <= '9') || ('.' == c) || ('-' == c)
- || ('_' == c)) {
- result += c;
- } else {
- // on ne l'ajoute pas a result donc on supprime le caractere
- // result += encodeUTF(c);
- }
- }
- return result;
- }
-
- static public String substring(String s, int begin) {
- String result;
- result = substring(s, begin, s.length());
- return result;
- }
-
- static public String substring(String s, int begin, int end) {
- if (begin < 0) {
- begin = s.length() + begin;
- }
- if (end < 0) {
- end = s.length() + end;
- }
- if (end < begin) {
- end = begin;
- }
-
- String result;
- result = s.substring(begin, end);
- return result;
- }
-
- /**
- * Met en majuscule le premier caractere de la chaine passee en parametre
- *
- * @param word La chaine a capitaliser
- * @return La chaine capitalisee
- * @deprecated you must use
- * org.apache.commons.lang.StringUtils.capitalise(String)
- */
- public static String capitalize(String word) {
- return word.substring(0, 1).toUpperCase() + word.substring(1);
- }
-
- /**
- * Met en minuscule le premier caractere de la chaine passe en parametre
- *
- * @param word La chaine a decapitaliser
- * @return La chaine decapitalisee
- * @deprecated you must use
- * org.apache.commons.lang.StringUtils.uncapitalise(String)
- */
- public static String uncapitalize(String word) {
- return word.substring(0, 1).toLowerCase() + word.substring(1);
- }
-
- /**
- * Concat�ne un tableau de chaine de caracteres en une seul chaine.
- *
- * @param s le tableau de chaines
- * @param sep le separateur a utiliser pour separer chaque chaine.
- * @return la chaine resultante de la concatenation. Si le tableau est null
- * ou vide, la chaine resultante est une chaine vide.
- * @deprecated you must use org.apache.commons.lang.StringUtils.join
- */
- public static String unsplit(String[] s, String sep) {
- if (s == null || s.length <= 0) {
- return "";
- }
-
- StringBuffer result = new StringBuffer(s[0]);
- for (int i = 1; i < s.length; i++) {
- result.append(sep).append(s[i]);
- }
- return result.toString();
- }
-
- private static final Character[] openingChars = {'(', '{', '['};
-
- private static final Character[] closingChars = {')', '}', ']'};
-
- /**
- * Split string use 'separator' as separator. If String contains "'()[]{}
- * this method count the number of open char end close char to split
- * correctly argument
- *
- * @param args string to split
- * @param separator separator use to split string
- * @return array of string
- */
- static public String[] split(String args, String separator) {
- return split(openingChars, closingChars, args, separator);
- }
-
-
- /**
- * Use to split string array representation in array according with swixat
- * seperator list
- *
- * @param stringList string that represent array
- * @return array with length > 0 if listAsString != null or null
- */
- static public String[] split(String stringList) {
- String[] result;
- result = split(stringList, ",");
- return result;
- }
-
- /**
- * Split string use 'separator' as separator. If String contains "'
- * and <code>openingChar</code> <code>closingChars</code>
- * <p/>
- * this method count the number of open char end close char to split correctly
- * argument
- *
- * @param openingChars list of opening caracteres
- * @param closingChars list of closing caracteres
- * @param args string to split
- * @param separator separator use to split string
- * @return array of string
- */
- static public String[] split(Character[] openingChars,
- Character[] closingChars,
- String args, String separator) {
- if (args == null) {
- return new String[0];
- }
-
- List<String> result = new ArrayList<String>();
-
- int start = 0;
- int end;
- StringBuffer op = new StringBuffer(); // stack of {([< currently open
- char last = '\0'; // contains " or ' if string is openned
-
- List<Character> opening = Arrays.asList(openingChars);
-
- List<Character> closing = Arrays.asList(closingChars);
-
- for (int i = 0; i < args.length(); i++) {
- char c = args.charAt(i);
- if (c == '\\') {
- // pass next char
- i++;
- } else if (last != '"' && last != '\'') {
- if (opening.contains(c)) {
- op.append(c);
- } else if (closing.contains(c)) {
- op.deleteCharAt(op.length() - 1);
- } else if (c == '"' || c == '\'') {
- // open string " or '
- last = c;
- } else if (op.length() == 0 &&
- args.regionMatches(i, separator, 0, separator.length())) {
- // end of one arguement
- end = i;
- // pass separator
- i += separator.length() - 1;
-
- String a = args.substring(start, end);
- result.add(a);
- // start of next argument
- start = end + separator.length();
- }
- } else if (c == last) {
- // close string " or '
- last = '\0';
- }
- }
-
- if (start < args.length()) {
- String a = args.substring(start, args.length());
- result.add(a);
- }
-
- return result.toArray(new String[result.size()]);
- }
-
- public static boolean toBoolean(String s) {
- return "true".equalsIgnoreCase(s);
- }
-
- public static byte toByte(String s) {
- return Byte.parseByte(s);
- }
-
- public static double toDouble(String s) {
- return Double.parseDouble(s);
- }
-
- public static float toFloat(String s) {
- return Float.parseFloat(s);
- }
-
- public static long toLong(String s) {
- return Long.parseLong(s);
- }
-
- public static short toShort(String s) {
- return Short.parseShort(s);
- }
-
- public static int toInt(String s) {
- return Integer.parseInt(s);
- }
-
- public static char toChar(String s) {
- // fixme a revoir
- return s.charAt(0);
- }
-
- public static boolean[] toArrayBoolean(String... s) {
- boolean[] result = new boolean[s.length];
- for (int i = 0; i < result.length; i++) {
- result[i] = toBoolean(s[i]);
- }
- return result;
- }
-
- public static byte[] toArrayByte(String... s) {
- byte[] result = new byte[s.length];
- for (int i = 0; i < result.length; i++) {
- result[i] = toByte(s[i]);
- }
- return result;
- }
-
- public static double[] toArrayDouble(String... s) {
- double[] result = new double[s.length];
- for (int i = 0; i < result.length; i++) {
- result[i] = toDouble(s[i]);
- }
- return result;
- }
-
- public static float[] toArrayFloat(String... s) {
- float[] result = new float[s.length];
- for (int i = 0; i < result.length; i++) {
- result[i] = toFloat(s[i]);
- }
- return result;
- }
-
- public static long[] toArrayLong(String... s) {
- long[] result = new long[s.length];
- for (int i = 0; i < result.length; i++) {
- result[i] = toLong(s[i]);
- }
- return result;
- }
-
- public static short[] toArrayShort(String... s) {
- short[] result = new short[s.length];
- for (int i = 0; i < result.length; i++) {
- result[i] = toShort(s[i]);
- }
- return result;
- }
-
- public static int[] toArrayInt(String... s) {
- int[] result = new int[s.length];
- for (int i = 0; i < result.length; i++) {
- result[i] = toInt(s[i]);
- }
- return result;
- }
-
- public static char[] toArrayChar(String... s) {
- char[] result = new char[s.length];
- for (int i = 0; i < result.length; i++) {
- result[i] = toChar(s[i]);
- }
- // fixme a revoir
- return result;
- }
-
- /**
- * Essai de convertir une chaine de caractere en une couleur si possible si
- * ce n'est pas possible retourne null.
- *
- * @param s la couleur sous la forme de string, par exemple "red",
- * "yellow" ou bien en RGB "#FFAA99", et avec un canal alpha
- * "#FFAA3366"
- * @return la couleur demand� si possible sinon null
- * @throws IllegalArgumentException
- * @throws StringUtilException if any problem while conversion
- */
- public static Color toColor(String s) throws StringUtilException {
- try {
- if (s.startsWith("#")) {
- // r�cuperation des valeurs hexa
- String hr = s.substring(1, 3);
- String hg = s.substring(3, 5);
- String hb = s.substring(5, 7);
-
- // conversion en entier
- int r = Integer.parseInt(hr, 16);
- int g = Integer.parseInt(hg, 16);
- int b = Integer.parseInt(hb, 16);
-
- if (s.length() == 9) {
- // s'il y a un canal alpha on l'utilise
- String ha = s.substring(7, 9);
- int a = Integer.parseInt(ha, 16);
- return new Color(r, g, b, a);
- } else {
- return new Color(r, g, b);
- }
- } else {
- Field f;
- f = Color.class.getField(s);
- return (Color) f.get(Color.class);
- }
- } catch (NumberFormatException e) {
- throw new StringUtilException(
- "Error during conversion from string to color", e);
- } catch (SecurityException e) {
- throw new StringUtilException(
- "Error during conversion from string to color", e);
- } catch (NoSuchFieldException e) {
- throw new StringUtilException(
- "Error during conversion from string to color", e);
- } catch (IllegalArgumentException e) {
- throw new StringUtilException(
- "Error during conversion from string to color", e);
- } catch (IllegalAccessException e) {
- throw new StringUtilException(
- "Error during conversion from string to color", e);
- }
- }
-
- public static Date toDate(String s) throws ParseException {
- return DateFormat.getDateInstance().parse(s);
- }
-
- 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 final protected double[] memoryFactors = {1024, 1024, 1024, 1024};
-
- static final protected String[] memoryUnites = {"o", "Ko", "Mo", "Go",
- "To"};
-
- static public String convertMemory(long value) {
- return convert(value, memoryFactors, memoryUnites);
- }
-
- 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;
- }
-
- /**
- * V�rifie q'une chaine de caract�re est valid pour les bloc openner closer, ie.
- * <p/>
- * que les blocs d�finit par les deux caract�res s'entrechevauchent pas.
- * <p/>
- * Exemple avec '(' ')' :
- * <p/>
- * (a(b)) est valide, par contre ((aaa))) n'est pas valide
- *
- * @param txt txte a verifier
- * @param opener le caract�re ouvrant
- * @param closer le caract�re fermant
- * @return <code>true</code> is la chaine est valide
- */
- public static boolean checkEnclosure(String txt, final char opener, char closer) {
- if (txt.indexOf(opener) == -1 && txt.indexOf(closer) == -1) {
- // ok pas de block d�tect�s
- return true;
- }
- List<Integer> opens = new ArrayList<Integer>();
- for (int i = 0; i < txt.length(); i++) {
- char c = txt.charAt(i);
- if (c == opener) {
- // add a open block
- opens.add(i);
- continue;
- }
- if (c == closer) {
- if (opens.isEmpty()) {
- // problem no block left
- return false;
- }
- // on supprime le dernier bloc
- opens.remove(opens.size() - 1);
- }
- }
- return opens.isEmpty();
- }
-
- /**
- * Convertir un nom en une constante Java
- *
- * Les seuls caract�res autoris�s sont les alpha num�riques, ains
- * que l'underscore. tous les autres caract�res seront ignor�s.
- *
- * @param name le nom � convertir
- * @return la constante g�n�r�e
- */
- public static String convertToConstantName(String name) {
- StringBuilder sb = new StringBuilder();
- char lastChar=0;
- for (int i = 0, j = name.length(); i < j; i++) {
- char c = name.charAt(i);
- if (Character.isDigit(c)) {
- sb.append(c);
- lastChar = c;
- continue;
- }
- if (!Character.isLetter(c)) {
- if (lastChar != '_') {
- sb.append('_');
- }
- lastChar='_';
- continue;
- }
- if (Character.isUpperCase(c)) {
- if (!Character.isUpperCase(lastChar)&&lastChar!='_') {
- sb.append('_');
- }
- sb.append(c);
- } else {
- sb.append(Character.toUpperCase(c));
- }
- lastChar=c;
- }
- String result = sb.toString();
- // clean tail
- while (!result.isEmpty() && result.endsWith("_")) {
- result = result.substring(0,result.length()-1);
- }
- // clean head
- while (!result.isEmpty() && result.startsWith("_")) {
- result = result.substring(1);
- }
- return result;
- }
-
-}
Deleted: trunk/lutinutil/src/main/java/org/codelutin/util/StringUtilException.java
===================================================================
--- trunk/lutinutil/src/main/java/org/codelutin/util/StringUtilException.java 2008-07-31 20:12:39 UTC (rev 951)
+++ trunk/lutinutil/src/main/java/org/codelutin/util/StringUtilException.java 2008-07-31 20:35:40 UTC (rev 952)
@@ -1,24 +0,0 @@
-/*
- * Created on Dec 7, 2004
- *
- * TODO To change the template for this generated file go to
- * Window - Preferences - Java - Code Style - Code Templates
- */
-package org.codelutin.util;
-
-/**
- * @author pineau
- *
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
- */
-public class StringUtilException extends RuntimeException {
-
- /** */
- private static final long serialVersionUID = 6148795384335489591L;
-
- public StringUtilException(String message, Exception e) {
- super(message, e);
- }
-
-}
Copied: trunk/lutinutil-io/src/main/java/org/codelutin/util/CollectionUtil.java (from rev 949, trunk/lutinutil/src/main/java/org/codelutin/util/CollectionUtil.java)
===================================================================
--- trunk/lutinutil-io/src/main/java/org/codelutin/util/CollectionUtil.java (rev 0)
+++ trunk/lutinutil-io/src/main/java/org/codelutin/util/CollectionUtil.java 2008-07-31 20:35:40 UTC (rev 952)
@@ -0,0 +1,156 @@
+/* *##%
+ * Copyright (C) 2006
+ * 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.
+ *##%*/
+
+/* *
+ * CollectionUtil.java
+ *
+ * Created: 23 f�vr. 2006 09:03:39
+ *
+ * @author poussin
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+
+package org.codelutin.util;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+
+/**
+ * @author poussin
+ *
+ */
+
+public class CollectionUtil {
+
+ /**
+ * Ajoute a la collection tous les elements pass�s en parametre
+ * @param col la collection
+ * @param e les elements a ajouter
+ * @return la collection pass� en parametre
+ */
+ static public <A, E extends Collection<A>> E addAll(E col, A ... e) {
+ Collections.addAll(col, e);
+ return col;
+ }
+
+ /**
+ * Ajoute a la liste tous les elements pass�s en parametre
+ * @param col la liste
+ * @param pos le premier index o� ins�rer les donn�es
+ * @param e les elements a ajouter
+ * @return la liste pass� en parametre
+ */
+ static public <A, E extends List<A>> E addAll(E col, int pos, A ... e) {
+ col.addAll(pos, Arrays.asList(e));
+ return col;
+ }
+
+ /**
+ * Permet de convertir une liste non typ�e, en une liste typ�e.
+ *
+ * La liste en entr�e en juste bien cast�e.
+ *
+ * On effectue une v�rification sur le typage des �lements de la liste.
+ *
+ * Note : <b>Aucune liste n'est cr�ee, ni recopi�e</b>
+ *
+ * @param list la liste � convertir
+ * @param type le type des �l�ments de la liste
+ * @return la liste typ�e
+ * @throws IllegalArgumentException si un �l�ment de la liste en entr�e n'est
+ * pas en ad�quation 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;
+ }
+
+ /**
+ * Permet de convertir une collection non typ�e, en une collection typ�e.
+ *
+ * La collection en entr�e en juste bien cast�e.
+ *
+ * On effectue une v�rification sur le typage des �lements de la collection.
+ *
+ * Note : <b>Aucune collection n'est cr�ee, ni recopi�e</b>
+ *
+ * @param list la collection � convertir
+ * @param type le type des �l�ments de la collection
+ * @return la collection typ�e
+ * @throws IllegalArgumentException si un �l�ment de la collection en entr�e n'est
+ * pas en ad�quation avec le type voulue.
+ */
+ @SuppressWarnings({"unchecked"})
+ static public <O> Collection<O> toGenericCollection(Collection 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 Collection with object of type "+o.getClass()+" to "+type+" type!");
+ }
+ }
+ return list;
+ }
+
+ /**
+ * Permet de convertir un ensemble non typ�e, en un ensemble typ�e.
+ *
+ * L'ensemble en entr�e en juste bien cast�e.
+ *
+ * On effectue une v�rification sur le typage des �lements de la collection.
+ *
+ * Note : <b>Aucun ensemble n'est cr�ee, ni recopi�e</b>
+ *
+ * @param list l'ensemble � convertir
+ * @param type le type des �l�ments de l'ensemble
+ * @return l'ensemble typ�e
+ * @throws IllegalArgumentException si un �l�ment de l'ensemble en entr�e n'est
+ * pas en ad�quation avec le type voulue.
+ */
+ @SuppressWarnings({"unchecked"})
+ static public <O> Set<O> toGenericSet(Set 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 Set with object of type "+o.getClass()+" to "+type+" type!");
+ }
+ }
+ return list;
+ }
+}
+
+
Property changes on: trunk/lutinutil-io/src/main/java/org/codelutin/util/CollectionUtil.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/lutinutil-io/src/main/java/org/codelutin/util/FileUtil.java (from rev 949, trunk/lutinutil/src/main/java/org/codelutin/util/FileUtil.java)
===================================================================
--- trunk/lutinutil-io/src/main/java/org/codelutin/util/FileUtil.java (rev 0)
+++ trunk/lutinutil-io/src/main/java/org/codelutin/util/FileUtil.java 2008-07-31 20:35:40 UTC (rev 952)
@@ -0,0 +1,766 @@
+/* *##%
+ * 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.
+ *##%*/
+
+/* *
+ * FileUtil.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.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.nio.channels.FileChannel;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.swing.JFileChooser;
+
+import org.apache.commons.logging.LogFactory;
+
+public class FileUtil { // FileUtil
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private org.apache.commons.logging.Log log = LogFactory.getLog(FileUtil.class);
+
+ /** Encoding par defaut utilis� si non sp�cifi� */
+ static public String ENCODING = "ISO-8859-1";
+ static protected File currentDirectory = new File(".");
+
+ static public void setCurrentDirectory(File dir){
+ currentDirectory = dir;
+ }
+
+ static public class PatternChooserFilter extends javax.swing.filechooser.FileFilter {
+ protected String pattern = null;
+ protected String description = null;
+
+ public PatternChooserFilter(String pattern, String description) {
+ this.pattern = pattern;
+ this.description = description;
+ }
+
+ @Override
+ public boolean accept(File f) {
+ return f.isDirectory() || f.getAbsolutePath().matches(pattern);
+ }
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ }
+
+
+ /**
+ * Retourne le nom du fichier entre dans la boite de dialogue.
+ * Si le bouton annuler est utilis�, ou qu'il y a une erreur retourne null.
+ *
+ * @param patternOrDescriptionFilters les filtres a utiliser, les chaines doivent etre donn�es
+ * par deux, le pattern du filtre + la description du filtre
+ * @return
+ *
+ * @see #getFile(javax.swing.filechooser.FileFilter[])
+ */
+ static public File getFile(String ... patternOrDescriptionFilters) {
+ if (patternOrDescriptionFilters.length % 2 != 0) {
+ throw new IllegalArgumentException("Arguments must be (pattern, description) couple");
+ }
+ javax.swing.filechooser.FileFilter [] filters = new javax.swing.filechooser.FileFilter[patternOrDescriptionFilters.length / 2];
+ for (int i=0; i<filters.length; i++) {
+ String pattern = patternOrDescriptionFilters[i*2];
+ String description = patternOrDescriptionFilters[i*2 + 1];
+ filters[i] = new PatternChooserFilter(pattern, description);
+ }
+ File result;
+ result = getFile(filters);
+ return result;
+ }
+
+ /**
+ * Retourne le nom du fichier entre dans la boite de dialogue.
+ * Si le bouton annuler est utilis�, ou qu'il y a une erreur retourne null.
+ *
+ * @param filters les filtres a ajouter
+ * @return
+ */
+ static public File getFile(javax.swing.filechooser.FileFilter ... filters){
+ try{
+ JFileChooser chooser = new JFileChooser(currentDirectory);
+
+ chooser.setDialogType(JFileChooser.CUSTOM_DIALOG);
+ if (filters.length > 0) {
+ if (filters.length == 1) {
+ chooser.setFileFilter(filters[0]);
+ } else {
+ for (javax.swing.filechooser.FileFilter filter : filters) {
+ chooser.addChoosableFileFilter(filter);
+ }
+ }
+ }
+ chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
+ int returnVal = chooser.showDialog(null, "Ok");
+ if(returnVal == JFileChooser.APPROVE_OPTION) {
+ File theFile = chooser.getSelectedFile();
+ if(theFile != null) {
+ currentDirectory = theFile;
+ return theFile.getAbsoluteFile();
+ }
+ }
+ }
+ catch(Exception eee){
+ log.warn("Erreur:", eee);
+ }
+ return null;
+ }
+
+ /**
+ * @param title le nom de la boite de dialogue
+ * @param approvalText
+ * @return le nom du repertoire entre dans la boite de dialogue.
+ * Si le bouton annuler est utilis�, ou qu'il y a une erreur retourne
+ * null.
+ */
+ static public String getDirectory(String title,String approvalText) {
+ try{
+ JFileChooser chooser = new JFileChooser(currentDirectory);
+ chooser.setDialogType(JFileChooser.CUSTOM_DIALOG);
+ chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+ chooser.setDialogTitle(title);
+ int returnVal = chooser.showDialog(null,approvalText);
+ if(returnVal == JFileChooser.APPROVE_OPTION) {
+ File theFile = chooser.getSelectedFile();
+ if(theFile != null) {
+ currentDirectory = theFile;
+ if(theFile.isDirectory()) {
+ return theFile.getAbsolutePath();
+ }
+ }
+ }
+ else{
+ return null;
+ }
+ } catch(Exception eee){
+ log.warn("Erreur:", eee);
+ }
+ return null;
+ }
+
+ /**
+ * @return le nom du repertoire entre dans la boite de dialogue.
+ * Si le bouton annuler est utilis�, ou qu'il y a une erreur retourne
+ * null.
+ */
+ static public String getDirectory() {
+ return getDirectory("Ok","Ok");
+ }
+
+ /**
+ * Permet de convertir un fichier en un tableau de byte
+ *
+ * @param file
+ * @return
+ * @throws IOException
+ */
+ static public byte[] fileToByte(File file) throws IOException {
+ InputStream in = new BufferedInputStream(new FileInputStream(file));
+ ByteArrayOutputStream result = new ByteArrayOutputStream();
+ BufferedOutputStream tmp = new BufferedOutputStream(result);
+ for (int b=in.read(); b != -1; b=in.read()) {
+ tmp.write(b);
+ }
+ in.close();
+ tmp.close();
+
+ return result.toByteArray();
+ }
+
+ /**
+ * Permet de convertir des bytes en fichier, le fichier sera automatiquement
+ * supprim� a la fin de la JVM.
+ *
+ * @param bytes
+ * @return le fichier temporaire contenant les bytes
+ * @throws IOException
+ */
+ static public File byteToFile(byte[] bytes) throws IOException {
+ File file = File.createTempFile("FileUtil-byteToFile", ".tmp");
+ byteToFile(bytes, file);
+ return file;
+ }
+
+ /**
+ * Permet de convertir des bytes en fichier
+ *
+ * @param bytes
+ * @param file le fichier dans lequel il faut ecrire les bytes
+ * @return le fichier pass� en parametre
+ * @throws IOException
+ */
+ static public File byteToFile(byte[] bytes, File file) throws IOException {
+ OutputStream out = new BufferedOutputStream(new FileOutputStream(file));
+ out.write(bytes);
+ out.close();
+ return file;
+ }
+
+ /**
+ * Retourne un Reader utilisant l'encoding par defaut {@link #ENCODING}
+ *
+ * @param file
+ * @return
+ * @throws IOException
+ */
+ static public BufferedReader getReader(File file) throws IOException {
+ return getReader(file, ENCODING);
+ }
+
+ /**
+ * Retourne un reader utilisant l'encoding choisi et plac� dans un
+ * BufferedReader
+ *
+ * @param file
+ * @param encoding (ISO-8859-1, UTF-8, ...)
+ * @return
+ * @throws IOException
+ */
+ static public BufferedReader getReader(File file, String encoding) throws IOException {
+ FileInputStream inf = new FileInputStream(file);
+ InputStreamReader in = new InputStreamReader(inf, encoding);
+// FileReader in = new FileReader(file);
+ BufferedReader result = new BufferedReader(in);
+ return result;
+ }
+
+ /**
+ * Retourne un Writer utilisant l'encoding par defaut {@link #ENCODING}
+ *
+ * @param file
+ * @return
+ * @throws IOException
+ */
+ static public BufferedWriter getWriter(File file) throws IOException {
+ return getWriter(file, ENCODING);
+ }
+
+ /**
+ * Retourne un writer utilisant l'encoding choisi et plac� dans un
+ * BufferedWriter
+ *
+ * @param file
+ * @param encoding (ISO-8859-1, UTF-8, ...)
+ * @return
+ * @throws IOException
+ */
+ static public BufferedWriter getWriter(File file, String encoding) throws IOException {
+ FileOutputStream outf = new FileOutputStream(file);
+ OutputStreamWriter out = new OutputStreamWriter(outf, encoding);
+// FileWriter out = new FileWriter(file);
+ BufferedWriter result = new BufferedWriter(out);
+ return result;
+ }
+
+ public static void main(String[] args) {
+
+ }
+
+ /**
+ * Permet de creer un nouveu repertoire temporaire, l'effacement du
+ * r�pertoire est a la charge de l'appelant
+ * @param prefix le prefix du fichier
+ * @param suffix le suffix du fichier
+ * @param tmpdir le r�pertoire temporaire ou il faut creer le repertoire
+ * si null on utilise java.io.tmpdir
+ * @return le fichier pointant sur le nouveau repertoire
+ * @throws java.io.IOException
+ */
+ static public File createTempDirectory(String prefix, String suffix, File tmpdir) throws IOException {
+ if (tmpdir == null) {
+ tmpdir = new File(System.getProperty("java.io.tmpdir"));
+ }
+ File result = new File(tmpdir, prefix + System.currentTimeMillis() + suffix);
+ while (result.exists()) {
+ result = new File(tmpdir, prefix + System.currentTimeMillis() + suffix);
+ }
+ if (!result.mkdirs()) {
+ throw new IOException("Can't create temporary directory: " + result);
+ }
+ return result;
+ }
+ /**
+ * Permet de creer un nouveu repertoire temporaire, l'effacement du
+ * r�pertoire est a la charge de l'appelant
+ * @param prefix
+ * @param suffix
+ * @return
+ * @throws java.io.IOException
+ */
+ static public File createTempDirectory(String prefix, String suffix) throws IOException {
+ return createTempDirectory(prefix, suffix, null);
+ }
+
+ /**
+ * Regarde si le fichier f1 est plus recent que le fichier f2
+ * @param f1
+ * @param f2
+ * @return vrai si f1 est plus recent que f2
+ */
+ static public boolean isNewer(File f1, File f2) {
+ boolean result = f1.lastModified() > f2.lastModified();
+ return result;
+ }
+
+ /**
+ * Permet de lire un fichier et de retourner sont contenu sous forme d'une
+ * chaine de carateres
+ * @param file le fichier a lire
+ * @throws IOException
+ * @return
+ */
+ static public String readAsString(File file) throws IOException {
+ StringBuffer result = new StringBuffer();
+ char [] cbuf = new char[2000];
+ BufferedReader in = getReader(file);
+ int nb = in.read(cbuf);
+ while (nb != -1) {
+ result.append(cbuf, 0, nb);
+ nb = in.read(cbuf);
+ }
+ in.close();
+ return result.toString();
+ }
+
+ /**
+ * Permet de sauver une chaine directement dans un fichier
+ * @param file Le fichier dans lequel il faut ecrire la chaine
+ * @param content Le texte a ecrire dans le fichier
+ * @throws IOException if any pb while writing
+ */
+ static public void writeString(File file, String content) throws IOException {
+ file.getParentFile().mkdirs();
+ BufferedWriter out = getWriter(file);
+ out.write(content);
+ out.close();
+ }
+
+ /**
+ * Permet de sauver une chaine directement dans un fichier
+ * @param file Le fichier dans lequel il faut ecrire la chaine
+ * @param content Le texte a ecrire dans le fichier
+ * @param encoding encoding to use
+ * @throws IOException if any pb while writing
+ */
+ static public void writeString(File file, String content,String encoding) throws IOException {
+ file.getParentFile().mkdirs();
+ BufferedWriter out = getWriter(file,encoding);
+ out.write(content);
+ out.close();
+ }
+
+ /**
+ * Permet de donner une representation fichier pour une chaine de caractere.
+ * Le fichier sera automatiquement effac� � la fin de la JVM.
+ * @param content le contenu du fichier temporaire
+ * @return le fichier qui contient content
+ * @throws IOException
+ */
+ static public File getTempFile(String content) throws IOException {
+ return getTempFile(content, "");
+ }
+
+ /**
+ * Permet de donner une representation fichier pour une chaine de caractere.
+ * Le fichier sera automatiquement effac� � la fin de la JVM.
+ * @param content le contenu du fichier temporaire
+ * @param fileSuffix l'extension du fichier cr��
+ * @return le fichier qui contient content
+ * @throws IOException
+ */
+ static public File getTempFile(String content, String fileSuffix) throws IOException {
+ File result = File.createTempFile("tmp-" + FileUtil.class.getName(), fileSuffix);
+ result.deleteOnExit();
+ writeString(result, content);
+ return result;
+ }
+
+ /**
+ * Equivalent de la methode basename unix.
+ * basename("/tmp/toto.xml", ".xml") -> "toto"
+ *
+ * @param file le fichier dont on souhaite le nom sans le chemin
+ * @param suffixes si present represente le suffixe a eliminer du fichier
+ * s'il est trouv�
+ * @return le nom du fichier sans le suffixe si trouv�.
+ */
+ static public String basename(File file, String ... suffixes) {
+ String result = file.getName();
+ for(String suffixe : suffixes) {
+ if (result.endsWith(suffixe)){
+ result = result.substring(0, result.length() - suffixe.length());
+ break;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Permet de r�cup�rer l'extension d'un fichier
+ * @param file le fichier dont on souhaite l'extension
+ * @param extchars la liste des caracteres pouvant former l'extension
+ * dans l'ordre de preference. Si vide on utilise ".".
+ * @return l'extension ou la chaine vide si le fichier n'a pas d'extension
+ * l'extension ne contient pas le chaine de delimitation
+ */
+ static public String extension(File file, String ... extchars) {
+ String result = "";
+ String name = file.getName();
+
+ if(extchars.length == 0) {
+ extchars = new String[]{"."};
+ }
+ for (String extchar : extchars) {
+ int pos = name.lastIndexOf(extchar);
+ if (pos != -1) {
+ result = name.substring(pos + extchar.length());
+ break;
+ }
+ }
+ return result;
+ }
+
+ static public interface FileAction {
+ public boolean doAction(File f);
+ }
+
+ /**
+ * Retourne tous les sous r�pertoires du r�pertoire pass� en argument.
+ * @param directory un r�pertoire
+ * @return une liste d'objet {@link java.io.File} de r�pertoires et ceci
+ * recursivement � partir de directory, si directory
+ * n'est pas un r�pertoire la liste est vide.
+ */
+ public static List<File> getSubDirectories(File directory) {
+ class DirectoryFilter implements FileFilter {
+ public boolean accept(File f) {
+ return f.isDirectory();
+ }
+ }
+ return getFilteredElements(directory, new DirectoryFilter(), true);
+ }
+
+ /**
+ * Retourne tous les fichiers du r�pertoire pass� en argument.
+ * @param directory un r�pertoire
+ * @return une liste d'objet {@link java.io.File} des fichiers et ceci
+ * recursivement � partir de directory, si directory n'est pas un
+ * r�pertoire la liste est vide
+ */
+ public static List<File> getFiles(File directory) {
+ class NormalFileFilter implements FileFilter {
+ public boolean accept(File f) {
+ return f.isFile();
+ }
+ }
+ return getFilteredElements(directory, new NormalFileFilter(), true);
+ }
+
+ /**
+ * Retourne les fichiers d'un r�pertoire qui s'attisfont un certain pattern.
+ * La recherche est faite r�cursivement dans les sous r�pertoires
+ * @param directory le r�pertoire � partir duquel il faut faire la recherche
+ * @param pattern le pattern que doit respecter le fichier pour �tre dans la
+ * liste r�sultante
+ * @param recursively
+ * @return une liste d'objet {@link java.io.File} qui ont s'attisfait le
+ * pattern.
+ */
+ public static List<File> find(File directory, final String pattern, boolean recursively){
+ final String root = directory.getAbsolutePath();
+ final int rootLength = root.length();
+
+ return getFilteredElements(directory, new FileFilter() {
+ public boolean accept(File f) {
+ String longFilename = f.getAbsolutePath();
+ // + 1 to remove the first / or \
+ String filename = longFilename.substring(rootLength + 1);
+ return filename.matches(pattern);
+ }
+ }, recursively);
+ }
+
+ /**
+ * Retourne la liste de toutes les fichiers ou r�pertoire qui s'attisfont
+ * le filtre
+ * @param directory repertoire � partir duquel il faut faire la recherche
+ * @param ff le filtre � appliquer pour savoir si le fichier parcouru doit
+ * �tre conserv� dans les r�sultats, ou null pour tous les fichiers
+ * @param recursively
+ * @return une liste d'objet {@link java.io.File}, qui s'attisfont le filtre
+ */
+ public static List<File> getFilteredElements(File directory, FileFilter ff, boolean recursively) {
+ ArrayList<File> result = new ArrayList<File>();
+ LinkedList<File> todo = new LinkedList<File>();
+ if (directory.isDirectory()){
+ todo.addAll(Arrays.asList(directory.listFiles()));
+ }
+ while(todo.size() > 0){
+ File file = todo.removeFirst();
+ if (recursively && file.isDirectory()){
+ File [] childs = file.listFiles();
+ if (childs != null) { // null if we don't have access to directory
+ todo.addAll(Arrays.asList(childs));
+ }
+ }
+ if(ff == null || ff.accept(file)){
+ result.add(file);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Supprime recursivement tout le contenu d'un r�pertoire.
+ * @param directory
+ * @return vrai si tout se passe bien, false si la suppression d'un �lement
+ * se passe mal
+ */
+ public static boolean deleteRecursively(String directory) {
+ return deleteRecursively(new File(directory));
+ }
+
+ /**
+ * Supprime recursivement tout le contenu d'un r�pertoire.
+ * @param directory
+ * @return vrai si tout se passe bien, false si la suppression d'un �lement
+ * se passe mal
+ */
+ public static boolean deleteRecursively(File directory) {
+ return walkBefore(directory, new FileAction(){
+ public boolean doAction(File f) {
+ return f.delete();
+ }
+ });
+ }
+
+ /**
+ * Permet de faire une action avant le parcours des fichiers, c-a-d que
+ * l'on fera l'action sur les fichiers contenu dans un r�pertoire
+ * apr�s l'action sur le r�pertoire lui m�me.
+ * @param f le fichier ou r�pertoire � partir duquel il faut commencer
+ * @param fileAction l'action � effectuer sur chaque fichier
+ * @return le r�sultat des fileAction execut� sur les fichiers, chaque
+ * r�sultat de FileAction sont assembl� par un ET logique pour donner
+ * le r�sultat final
+ */
+ public static boolean walkAfter(File f, FileAction fileAction) {
+ boolean result=fileAction.doAction(f);
+ if (f.isDirectory()) {
+ File list[] = f.listFiles();
+ for (int i = 0; i < list.length; i++) {
+ result=result && walkAfter(list[i], fileAction);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Permet de faire une action ap�s le parcours des fichiers, c-a-d que
+ * l'on fera l'action sur les fichiers contenu dans un r�pertoire
+ * avant l'action sur le r�pertoire lui m�me.
+ * @param f le fichier ou r�pertoire � partir duquel il faut commencer
+ * @param fileAction l'action � effectuer sur chaque fichier
+ * @return le r�sultat des fileAction execut� sur les fichiers, chaque
+ * r�sultat de FileAction sont assembl� par un ET logique pour donner
+ * le r�sultat final
+ */
+ public static boolean walkBefore(File f, FileAction fileAction) {
+ boolean result=true;
+ if (f.isDirectory()) {
+ File list[] = f.listFiles();
+ for (int i = 0; i < list.length; i++) {
+ result=result && walkBefore(list[i], fileAction);
+ }
+ }
+ return result && fileAction.doAction(f);
+ }
+
+ /**
+ * Permet de copier le fichier source vers le fichier cible.
+ * @param source le fichier source
+ * @param target le fichier cible
+ * @throws 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 copier le fichier source vers le fichier cible.
+ * @param source le fichier source
+ * @param target le fichier cible
+ * @throws IOException Erreur de copie
+ */
+ public static void copy(String source, String target) throws IOException {
+ copy(new File(source), new File(target));
+ }
+
+ /**
+ * Copie recursivement le repertoire source dans le repertoire destination
+ *
+ * copyRecursively("/truc/titi", "/var/tmp") donnera le repertoire
+ * "/var/tmp/titi"
+ *
+ * @param srcDir
+ * @param destDir
+ * @param includePatterns les patterns que doivent resperter les
+ * fichiers/repertoires pour etre copi�. Si vide alors tout est copi�
+ *
+ * @throws IOException
+ */
+ static public void copyRecursively(File srcDir, File destDir, String ... includePatterns) throws IOException {
+ copyAndRenameRecursively(srcDir, destDir, null, null, includePatterns);
+ }
+
+ /**
+ * Copie recursivement le repertoire source dans le repertoire destination
+ *
+ * copyRecursively("/truc/titi", "/var/tmp", "bidulle") donnera le repertoire
+ * "/var/tmp/bidulle", 'bidulle' remplacant 'titi'
+ *
+ * @param srcDir
+ * @param destDir
+ * @param renameFrom pattern to permit rename file before uncompress it
+ * @param renameTo new name for file if renameFrom is applicable to it
+ * you can use $1, $2, ... if you have '(' ')' in renameFrom
+ * @param includePatterns les patterns que doivent resperter les
+ * fichiers/repertoires pour etre copi�. Si vide alors tout est copi�
+ *
+ * @throws IOException
+ */
+ static public void copyAndRenameRecursively(File srcDir, File destDir,
+ String renameFrom, String renameTo, String ... includePatterns) throws IOException {
+ copyAndRenameRecursively(srcDir, destDir, true, renameFrom, renameTo, false, includePatterns);
+ }
+
+ /**
+ * Copie recursivement le repertoire source dans le repertoire destination
+ *
+ * copyRecursively("/truc/titi", "/var/tmp", "bidulle") donnera le repertoire
+ * "/var/tmp/bidulle", 'bidulle' remplacant 'titi'
+ *
+ * @param srcDir
+ * @param destDir
+ * @param includeSrcDir si vrai alors le repertoire source est copie dans le
+ * repertoire destination et non pas seulement les fichiers qu'il contient
+ * @param renameFrom pattern to permit rename file before uncompress it
+ * @param renameTo new name for file if renameFrom is applicable to it
+ * you can use $1, $2, ... if you have '(' ')' in renameFrom
+ * @param exclude inverse include pattern interpretation
+ * @param includePatterns les patterns que doivent resperter les
+ * fichiers/repertoires pour etre copi�. Si vide alors tout est copi�
+ *
+ * @throws IOException
+ */
+ static public void copyAndRenameRecursively(File srcDir, File destDir,
+ boolean includeSrcDir, String renameFrom, String renameTo, boolean exclude,
+ String ... includePatterns) throws IOException {
+ String rootSrc;
+ if (includeSrcDir) {
+ rootSrc = srcDir.getParent();
+ } else {
+ rootSrc = srcDir.getPath();
+ }
+ List<File> files = getFilteredElements(srcDir, null, true);
+ log.debug("copyRecursively: " + files);
+ for (File file : files) {
+ boolean doCopy = copyRecursivelyAccept(file, includePatterns);
+ if (xor(exclude, doCopy)) {
+ String path = file.getPath().substring(rootSrc.length());
+ if (renameFrom != null && renameTo != null) {
+ String tmp = path.replaceAll(renameFrom, renameTo);
+ if (log.isDebugEnabled()) {
+ log.debug("rename " + path + " -> " + tmp);
+ }
+ path = tmp;
+ }
+
+ File destFile = new File(destDir, path);
+ if (file.isDirectory()) {
+ log.debug("create directory: " + destFile);
+ destFile.mkdirs();
+ } else {
+ log.debug("copy " + path + " to " + destFile);
+ copy(file, destFile);
+ }
+ }
+ }
+ }
+
+ static private boolean xor(boolean b, boolean c) {
+ if (b) return !c;
+ else return c;
+ }
+
+ /**
+ * @param file
+ * @param includePatterns
+ * @return
+ */
+ private static boolean copyRecursivelyAccept(File file, String[] includePatterns) {
+ boolean result = includePatterns.length == 0;
+ String filename = file.getAbsolutePath();
+ for (String pattern : includePatterns) {
+ result = filename.matches(pattern);
+ if (result) {
+ break;
+ }
+ }
+ return result;
+ }
+
+} // FileUtil
+
Property changes on: trunk/lutinutil-io/src/main/java/org/codelutin/util/FileUtil.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/lutinutil-io/src/main/java/org/codelutin/util/PropertiesDateRemoveFilterStream.java (from rev 949, trunk/lutinutil/src/main/java/org/codelutin/util/PropertiesDateRemoveFilterStream.java)
===================================================================
--- trunk/lutinutil-io/src/main/java/org/codelutin/util/PropertiesDateRemoveFilterStream.java (rev 0)
+++ trunk/lutinutil-io/src/main/java/org/codelutin/util/PropertiesDateRemoveFilterStream.java 2008-07-31 20:35:40 UTC (rev 952)
@@ -0,0 +1,50 @@
+/*
+* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais
+*
+* 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.util;
+
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+public 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);
+ }
+ }
+
+}
\ No newline at end of file
Copied: trunk/lutinutil-io/src/main/java/org/codelutin/util/SortedProperties.java (from rev 949, trunk/lutinutil/src/main/java/org/codelutin/util/SortedProperties.java)
===================================================================
--- trunk/lutinutil-io/src/main/java/org/codelutin/util/SortedProperties.java (rev 0)
+++ trunk/lutinutil-io/src/main/java/org/codelutin/util/SortedProperties.java 2008-07-31 20:35:40 UTC (rev 952)
@@ -0,0 +1,62 @@
+/* *##%
+ * Copyright (C) 2007
+ * I18nPlugin, Code Lutin
+ *
+ * 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.util;
+
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Properties;
+import java.util.Vector;
+
+/**
+ * Permet d'avoir les fichiers de propri�t�s tri�s.
+ *
+ * @author julien
+ */
+public class SortedProperties extends Properties {
+
+ private static final long serialVersionUID = -1147150444452577558L;
+
+
+ public SortedProperties() {
+ super();
+ }
+
+ public SortedProperties(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 = CollectionUtil.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();
+ }
+}
Property changes on: trunk/lutinutil-io/src/main/java/org/codelutin/util/SortedProperties.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/lutinutil-io/src/main/java/org/codelutin/util/StringUtil.java (from rev 949, trunk/lutinutil/src/main/java/org/codelutin/util/StringUtil.java)
===================================================================
--- trunk/lutinutil-io/src/main/java/org/codelutin/util/StringUtil.java (rev 0)
+++ trunk/lutinutil-io/src/main/java/org/codelutin/util/StringUtil.java 2008-07-31 20:35:40 UTC (rev 952)
@@ -0,0 +1,552 @@
+/* *##%%
+ * Copyright (C) 2002, 2003 Code Lutin
+ *
+ * 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.
+ *##%%**/
+/* *
+ * StringUtil.java
+ *
+ * Created: Sun Apr 14 2002
+ *
+ * @author POUSSIN Benjamin <bpoussin(a)free.fr>
+ * Copyright Code Lutin
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+package org.codelutin.util;
+
+import java.awt.Color;
+import java.lang.reflect.Field;
+import java.text.DateFormat;
+import java.text.MessageFormat;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Classe contenant un ensemle de methode static utiles pour la manipulation des
+ * chaine de caractere mais qui ne sont pas defini dans la classe String de
+ * Java.
+ *
+ * @author poussin
+ * @created 21 octobre 2003
+ */
+public class StringUtil { // StringUtil
+
+ /** Constructor for the StringUtil object */
+ protected StringUtil() {
+ }
+
+ /**
+ * Cette methode retire les accents. Quand le caractere est connu, elle le
+ * remplace par une version sans accent sinon, elle le supprime.
+ * Les caracteres non-alphanumeriques sont supprimes.
+ *
+ * @param s la chaine a unaccentuer
+ * @return la chaine sans accent
+ */
+ static public String unaccent(String s) {
+ String result = "";
+ for (char c : s.toCharArray()) {
+ if ("����".indexOf(c) != -1) {
+ result += "e";
+ } else if ("���".indexOf(c) != -1) {
+ result += "a";
+ } else if ("�".indexOf(c) != -1) {
+ result += "c";
+ } else if ("��".indexOf(c) != -1) {
+ result += "i";
+ } else if ("��".indexOf(c) != -1) {
+ result += "o";
+ } else if ("���".indexOf(c) != -1) {
+ result += "u";
+ } else if ("����".indexOf(c) != -1) {
+ result += "E";
+ } else if ("���".indexOf(c) != -1) {
+ result += "A";
+ } else if ("�".indexOf(c) != -1) {
+ result += "C";
+ } else if ("��".indexOf(c) != -1) {
+ result += "I";
+ } else if ("��".indexOf(c) != -1) {
+ result += "O";
+ } else if ("���".indexOf(c) != -1) {
+ result += "U";
+ } else if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')
+ || ('0' <= c && c <= '9') || ('.' == c) || ('-' == c)
+ || ('_' == c)) {
+ result += c;
+ } else {
+ // on ne l'ajoute pas a result donc on supprime le caractere
+ // result += encodeUTF(c);
+ }
+ }
+ return result;
+ }
+
+ static public String substring(String s, int begin) {
+ String result;
+ result = substring(s, begin, s.length());
+ return result;
+ }
+
+ static public String substring(String s, int begin, int end) {
+ if (begin < 0) {
+ begin = s.length() + begin;
+ }
+ if (end < 0) {
+ end = s.length() + end;
+ }
+ if (end < begin) {
+ end = begin;
+ }
+
+ String result;
+ result = s.substring(begin, end);
+ return result;
+ }
+
+ /**
+ * Met en majuscule le premier caractere de la chaine passee en parametre
+ *
+ * @param word La chaine a capitaliser
+ * @return La chaine capitalisee
+ * @deprecated you must use
+ * org.apache.commons.lang.StringUtils.capitalise(String)
+ */
+ public static String capitalize(String word) {
+ return word.substring(0, 1).toUpperCase() + word.substring(1);
+ }
+
+ /**
+ * Met en minuscule le premier caractere de la chaine passe en parametre
+ *
+ * @param word La chaine a decapitaliser
+ * @return La chaine decapitalisee
+ * @deprecated you must use
+ * org.apache.commons.lang.StringUtils.uncapitalise(String)
+ */
+ public static String uncapitalize(String word) {
+ return word.substring(0, 1).toLowerCase() + word.substring(1);
+ }
+
+ /**
+ * Concat�ne un tableau de chaine de caracteres en une seul chaine.
+ *
+ * @param s le tableau de chaines
+ * @param sep le separateur a utiliser pour separer chaque chaine.
+ * @return la chaine resultante de la concatenation. Si le tableau est null
+ * ou vide, la chaine resultante est une chaine vide.
+ * @deprecated you must use org.apache.commons.lang.StringUtils.join
+ */
+ public static String unsplit(String[] s, String sep) {
+ if (s == null || s.length <= 0) {
+ return "";
+ }
+
+ StringBuffer result = new StringBuffer(s[0]);
+ for (int i = 1; i < s.length; i++) {
+ result.append(sep).append(s[i]);
+ }
+ return result.toString();
+ }
+
+ private static final Character[] openingChars = {'(', '{', '['};
+
+ private static final Character[] closingChars = {')', '}', ']'};
+
+ /**
+ * Split string use 'separator' as separator. If String contains "'()[]{}
+ * this method count the number of open char end close char to split
+ * correctly argument
+ *
+ * @param args string to split
+ * @param separator separator use to split string
+ * @return array of string
+ */
+ static public String[] split(String args, String separator) {
+ return split(openingChars, closingChars, args, separator);
+ }
+
+
+ /**
+ * Use to split string array representation in array according with swixat
+ * seperator list
+ *
+ * @param stringList string that represent array
+ * @return array with length > 0 if listAsString != null or null
+ */
+ static public String[] split(String stringList) {
+ String[] result;
+ result = split(stringList, ",");
+ return result;
+ }
+
+ /**
+ * Split string use 'separator' as separator. If String contains "'
+ * and <code>openingChar</code> <code>closingChars</code>
+ * <p/>
+ * this method count the number of open char end close char to split correctly
+ * argument
+ *
+ * @param openingChars list of opening caracteres
+ * @param closingChars list of closing caracteres
+ * @param args string to split
+ * @param separator separator use to split string
+ * @return array of string
+ */
+ static public String[] split(Character[] openingChars,
+ Character[] closingChars,
+ String args, String separator) {
+ if (args == null) {
+ return new String[0];
+ }
+
+ List<String> result = new ArrayList<String>();
+
+ int start = 0;
+ int end;
+ StringBuffer op = new StringBuffer(); // stack of {([< currently open
+ char last = '\0'; // contains " or ' if string is openned
+
+ List<Character> opening = Arrays.asList(openingChars);
+
+ List<Character> closing = Arrays.asList(closingChars);
+
+ for (int i = 0; i < args.length(); i++) {
+ char c = args.charAt(i);
+ if (c == '\\') {
+ // pass next char
+ i++;
+ } else if (last != '"' && last != '\'') {
+ if (opening.contains(c)) {
+ op.append(c);
+ } else if (closing.contains(c)) {
+ op.deleteCharAt(op.length() - 1);
+ } else if (c == '"' || c == '\'') {
+ // open string " or '
+ last = c;
+ } else if (op.length() == 0 &&
+ args.regionMatches(i, separator, 0, separator.length())) {
+ // end of one arguement
+ end = i;
+ // pass separator
+ i += separator.length() - 1;
+
+ String a = args.substring(start, end);
+ result.add(a);
+ // start of next argument
+ start = end + separator.length();
+ }
+ } else if (c == last) {
+ // close string " or '
+ last = '\0';
+ }
+ }
+
+ if (start < args.length()) {
+ String a = args.substring(start, args.length());
+ result.add(a);
+ }
+
+ return result.toArray(new String[result.size()]);
+ }
+
+ public static boolean toBoolean(String s) {
+ return "true".equalsIgnoreCase(s);
+ }
+
+ public static byte toByte(String s) {
+ return Byte.parseByte(s);
+ }
+
+ public static double toDouble(String s) {
+ return Double.parseDouble(s);
+ }
+
+ public static float toFloat(String s) {
+ return Float.parseFloat(s);
+ }
+
+ public static long toLong(String s) {
+ return Long.parseLong(s);
+ }
+
+ public static short toShort(String s) {
+ return Short.parseShort(s);
+ }
+
+ public static int toInt(String s) {
+ return Integer.parseInt(s);
+ }
+
+ public static char toChar(String s) {
+ // fixme a revoir
+ return s.charAt(0);
+ }
+
+ public static boolean[] toArrayBoolean(String... s) {
+ boolean[] result = new boolean[s.length];
+ for (int i = 0; i < result.length; i++) {
+ result[i] = toBoolean(s[i]);
+ }
+ return result;
+ }
+
+ public static byte[] toArrayByte(String... s) {
+ byte[] result = new byte[s.length];
+ for (int i = 0; i < result.length; i++) {
+ result[i] = toByte(s[i]);
+ }
+ return result;
+ }
+
+ public static double[] toArrayDouble(String... s) {
+ double[] result = new double[s.length];
+ for (int i = 0; i < result.length; i++) {
+ result[i] = toDouble(s[i]);
+ }
+ return result;
+ }
+
+ public static float[] toArrayFloat(String... s) {
+ float[] result = new float[s.length];
+ for (int i = 0; i < result.length; i++) {
+ result[i] = toFloat(s[i]);
+ }
+ return result;
+ }
+
+ public static long[] toArrayLong(String... s) {
+ long[] result = new long[s.length];
+ for (int i = 0; i < result.length; i++) {
+ result[i] = toLong(s[i]);
+ }
+ return result;
+ }
+
+ public static short[] toArrayShort(String... s) {
+ short[] result = new short[s.length];
+ for (int i = 0; i < result.length; i++) {
+ result[i] = toShort(s[i]);
+ }
+ return result;
+ }
+
+ public static int[] toArrayInt(String... s) {
+ int[] result = new int[s.length];
+ for (int i = 0; i < result.length; i++) {
+ result[i] = toInt(s[i]);
+ }
+ return result;
+ }
+
+ public static char[] toArrayChar(String... s) {
+ char[] result = new char[s.length];
+ for (int i = 0; i < result.length; i++) {
+ result[i] = toChar(s[i]);
+ }
+ // fixme a revoir
+ return result;
+ }
+
+ /**
+ * Essai de convertir une chaine de caractere en une couleur si possible si
+ * ce n'est pas possible retourne null.
+ *
+ * @param s la couleur sous la forme de string, par exemple "red",
+ * "yellow" ou bien en RGB "#FFAA99", et avec un canal alpha
+ * "#FFAA3366"
+ * @return la couleur demand� si possible sinon null
+ * @throws IllegalArgumentException
+ * @throws StringUtilException if any problem while conversion
+ */
+ public static Color toColor(String s) throws StringUtilException {
+ try {
+ if (s.startsWith("#")) {
+ // r�cuperation des valeurs hexa
+ String hr = s.substring(1, 3);
+ String hg = s.substring(3, 5);
+ String hb = s.substring(5, 7);
+
+ // conversion en entier
+ int r = Integer.parseInt(hr, 16);
+ int g = Integer.parseInt(hg, 16);
+ int b = Integer.parseInt(hb, 16);
+
+ if (s.length() == 9) {
+ // s'il y a un canal alpha on l'utilise
+ String ha = s.substring(7, 9);
+ int a = Integer.parseInt(ha, 16);
+ return new Color(r, g, b, a);
+ } else {
+ return new Color(r, g, b);
+ }
+ } else {
+ Field f;
+ f = Color.class.getField(s);
+ return (Color) f.get(Color.class);
+ }
+ } catch (NumberFormatException e) {
+ throw new StringUtilException(
+ "Error during conversion from string to color", e);
+ } catch (SecurityException e) {
+ throw new StringUtilException(
+ "Error during conversion from string to color", e);
+ } catch (NoSuchFieldException e) {
+ throw new StringUtilException(
+ "Error during conversion from string to color", e);
+ } catch (IllegalArgumentException e) {
+ throw new StringUtilException(
+ "Error during conversion from string to color", e);
+ } catch (IllegalAccessException e) {
+ throw new StringUtilException(
+ "Error during conversion from string to color", e);
+ }
+ }
+
+ public static Date toDate(String s) throws ParseException {
+ return DateFormat.getDateInstance().parse(s);
+ }
+
+ 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 final protected double[] memoryFactors = {1024, 1024, 1024, 1024};
+
+ static final protected String[] memoryUnites = {"o", "Ko", "Mo", "Go",
+ "To"};
+
+ static public String convertMemory(long value) {
+ return convert(value, memoryFactors, memoryUnites);
+ }
+
+ 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;
+ }
+
+ /**
+ * V�rifie q'une chaine de caract�re est valid pour les bloc openner closer, ie.
+ * <p/>
+ * que les blocs d�finit par les deux caract�res s'entrechevauchent pas.
+ * <p/>
+ * Exemple avec '(' ')' :
+ * <p/>
+ * (a(b)) est valide, par contre ((aaa))) n'est pas valide
+ *
+ * @param txt txte a verifier
+ * @param opener le caract�re ouvrant
+ * @param closer le caract�re fermant
+ * @return <code>true</code> is la chaine est valide
+ */
+ public static boolean checkEnclosure(String txt, final char opener, char closer) {
+ if (txt.indexOf(opener) == -1 && txt.indexOf(closer) == -1) {
+ // ok pas de block d�tect�s
+ return true;
+ }
+ List<Integer> opens = new ArrayList<Integer>();
+ for (int i = 0; i < txt.length(); i++) {
+ char c = txt.charAt(i);
+ if (c == opener) {
+ // add a open block
+ opens.add(i);
+ continue;
+ }
+ if (c == closer) {
+ if (opens.isEmpty()) {
+ // problem no block left
+ return false;
+ }
+ // on supprime le dernier bloc
+ opens.remove(opens.size() - 1);
+ }
+ }
+ return opens.isEmpty();
+ }
+
+ /**
+ * Convertir un nom en une constante Java
+ *
+ * Les seuls caract�res autoris�s sont les alpha num�riques, ains
+ * que l'underscore. tous les autres caract�res seront ignor�s.
+ *
+ * @param name le nom � convertir
+ * @return la constante g�n�r�e
+ */
+ public static String convertToConstantName(String name) {
+ StringBuilder sb = new StringBuilder();
+ char lastChar=0;
+ for (int i = 0, j = name.length(); i < j; i++) {
+ char c = name.charAt(i);
+ if (Character.isDigit(c)) {
+ sb.append(c);
+ lastChar = c;
+ continue;
+ }
+ if (!Character.isLetter(c)) {
+ if (lastChar != '_') {
+ sb.append('_');
+ }
+ lastChar='_';
+ continue;
+ }
+ if (Character.isUpperCase(c)) {
+ if (!Character.isUpperCase(lastChar)&&lastChar!='_') {
+ sb.append('_');
+ }
+ sb.append(c);
+ } else {
+ sb.append(Character.toUpperCase(c));
+ }
+ lastChar=c;
+ }
+ String result = sb.toString();
+ // clean tail
+ while (!result.isEmpty() && result.endsWith("_")) {
+ result = result.substring(0,result.length()-1);
+ }
+ // clean head
+ while (!result.isEmpty() && result.startsWith("_")) {
+ result = result.substring(1);
+ }
+ return result;
+ }
+
+}
Property changes on: trunk/lutinutil-io/src/main/java/org/codelutin/util/StringUtil.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/lutinutil-io/src/main/java/org/codelutin/util/StringUtilException.java (from rev 949, trunk/lutinutil/src/main/java/org/codelutin/util/StringUtilException.java)
===================================================================
--- trunk/lutinutil-io/src/main/java/org/codelutin/util/StringUtilException.java (rev 0)
+++ trunk/lutinutil-io/src/main/java/org/codelutin/util/StringUtilException.java 2008-07-31 20:35:40 UTC (rev 952)
@@ -0,0 +1,24 @@
+/*
+ * Created on Dec 7, 2004
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.codelutin.util;
+
+/**
+ * @author pineau
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class StringUtilException extends RuntimeException {
+
+ /** */
+ private static final long serialVersionUID = 6148795384335489591L;
+
+ public StringUtilException(String message, Exception e) {
+ super(message, e);
+ }
+
+}
Property changes on: trunk/lutinutil-io/src/main/java/org/codelutin/util/StringUtilException.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
1
0
31 Jul '08
Author: tchemit
Date: 2008-07-31 20:12:39 +0000 (Thu, 31 Jul 2008)
New Revision: 951
Modified:
trunk/lutinutil-io/
trunk/lutinutil-io/pom.xml
Log:
mise en place de org.codelutin:lutinutil-io qui vien t 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.
Property changes on: trunk/lutinutil-io
___________________________________________________________________
Name: svn:ignore
+ target
Modified: trunk/lutinutil-io/pom.xml
===================================================================
--- trunk/lutinutil-io/pom.xml 2008-07-31 20:10:38 UTC (rev 950)
+++ trunk/lutinutil-io/pom.xml 2008-07-31 20:12:39 UTC (rev 951)
@@ -53,7 +53,7 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <name>Lutin utilities library</name>
+ <name>Lutin io utilities library</name>
<version>0.30-SNAPSHOT</version>
<description>Library of usefull io class to be used in any project (with
no i18n).</description>
1
0
[Lutinutil-commits] r950 - in trunk: . lutinutil-io lutinutil-io/doc lutinutil-io/site lutinutil-io/src lutinutil-io/src/main lutinutil-io/src/main/java lutinutil-io/src/main/java/org lutinutil-io/src/main/java/org/codelutin lutinutil-io/src/test lutinutil-io/src/test/java lutinutil-io/src/test/java/org lutinutil-io/src/test/java/org/codelutin lutinutil-io/src/test/resources lutinutil-io/xdocs
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:10:38 +0000 (Thu, 31 Jul 2008)
New Revision: 950
Added:
trunk/lutinutil-io/
trunk/lutinutil-io/LICENSE.txt
trunk/lutinutil-io/changelog
trunk/lutinutil-io/doc/
trunk/lutinutil-io/doc/Todo.rst
trunk/lutinutil-io/doc/index.rst
trunk/lutinutil-io/pom.xml
trunk/lutinutil-io/site/
trunk/lutinutil-io/site/site.xml
trunk/lutinutil-io/src/
trunk/lutinutil-io/src/main/
trunk/lutinutil-io/src/main/java/
trunk/lutinutil-io/src/main/java/org/
trunk/lutinutil-io/src/main/java/org/codelutin/
trunk/lutinutil-io/src/main/java/org/codelutin/util/
trunk/lutinutil-io/src/main/resources/
trunk/lutinutil-io/src/test/
trunk/lutinutil-io/src/test/java/
trunk/lutinutil-io/src/test/java/org/
trunk/lutinutil-io/src/test/java/org/codelutin/
trunk/lutinutil-io/src/test/java/org/codelutin/util/
trunk/lutinutil-io/src/test/resources/
trunk/lutinutil-io/src/test/resources/log4j.properties
trunk/lutinutil-io/xdocs/
trunk/lutinutil-io/xdocs/navigation.xml
Log:
mise en place de org.codelutin:lutinutil-io qui vien t 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.
Added: trunk/lutinutil-io/LICENSE.txt
===================================================================
--- trunk/lutinutil-io/LICENSE.txt (rev 0)
+++ trunk/lutinutil-io/LICENSE.txt 2008-07-31 20:10:38 UTC (rev 950)
@@ -0,0 +1,280 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
Added: trunk/lutinutil-io/changelog
===================================================================
--- trunk/lutinutil-io/changelog (rev 0)
+++ trunk/lutinutil-io/changelog 2008-07-31 20:10:38 UTC (rev 950)
@@ -0,0 +1,62 @@
+ver-0-30 chemit 20080710
+ * passage en maven 2 layout directory
+ * utilisation de lutinproject 2.3
+ * suppression du code vcs du projet
+
+ver-0-26 poussin 2007????
+ * bug in concat(Object [] ...), better array type now work
+ * add unaccent in StringUtil
+
+ver-0-25 poussin 20070425
+ * add StringUtil.toArrayXXX(String ... s) methodes
+ * use generic
+
+ver-0-24 poussin
+ * ArgumentsParser have 1 as repetitionMax by default
+ * ArgumentsParser use jdk 1.5 syntaxe (..., <>)
+
+ver-0-23 poussin 20061004
+ * move i18n in lutinutil
+ * add method Resource.getConfigProperties(String, Properties) to chains
+ properties
+
+ver-0-22 poussin 20060913
+ * use Generics in CategorisedListenerSet
+ * add org.codelutin.log package (LutinLog, ...)
+ * remove org.codelutin.util.Log
+
+ver-0-21 poussin 20060907
+
+ * Add TransformedList
+ * Add FileUtil.getTempFile(String):File
+ * add FileUtil.getFile():File that prompt user
+ * add FileUtil.getDirectory(): String that prompt user
+ * add FileUtil.copyRecursively(File, File, String ... patternFilter)
+ * add ZipUtil class to compress/uncompress zip file
+ * Transparente*Reference accept null object
+
+ver-0-17 thimel 20050610
+
+ * Ajout de BoundedList et BoundedListOutOfBoundsException
+
+ver-0-16 poussin 20050526
+
+ * Ajout de la methode getConfigProperties dans Resource
+
+ver-0-9 poussin 20040728
+
+ * Ajout de methode isJar, isZip, dans Resource
+
+ver-0-3 poussin 20040405
+
+ * utilisation de maven pour la gestion du projet
+ * Ajout de ExceptionUtil
+
+ver-0-2 poussin 20031021
+
+ * ajout du parser d'argument, ArgumentsParser
+ * ajout de StringUtil
+
+ver-0-1
+
+ * premier version contient seulement Resource
Added: trunk/lutinutil-io/doc/Todo.rst
===================================================================
Added: trunk/lutinutil-io/doc/index.rst
===================================================================
--- trunk/lutinutil-io/doc/index.rst (rev 0)
+++ trunk/lutinutil-io/doc/index.rst 2008-07-31 20:10:38 UTC (rev 950)
@@ -0,0 +1,16 @@
+LutinUtil-io
+============
+
+.. contents::
+
+
+Pr�sentation
+------------
+
+Ensemble de classe Java permettant de simplifier le d�veloppement en
+factorisant des besoins que l'on retrouve dans tous les d�veloppements.
+
+Cette librairie ne permet pas de faire de traduction i18n.
+
+**Veuillez consulter la JavaDoc pour de plus ample d�tails sur les diff�rentes
+librairies.**
Added: trunk/lutinutil-io/pom.xml
===================================================================
--- trunk/lutinutil-io/pom.xml (rev 0)
+++ trunk/lutinutil-io/pom.xml 2008-07-31 20:10:38 UTC (rev 950)
@@ -0,0 +1,207 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <parent>
+ <groupId>lutinlib</groupId>
+ <artifactId>lutinproject</artifactId>
+ <version>2.3</version>
+ </parent>
+
+ <groupId>org.codelutin</groupId>
+ <artifactId>lutinutil-io</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <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>
+
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>Lutin utilities library</name>
+ <version>0.30-SNAPSHOT</version>
+ <description>Library of usefull io class to be used in any project (with
+ no i18n).</description>
+ <inceptionYear>2004</inceptionYear>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+
+ <packaging>jar</packaging>
+
+ <properties>
+
+ <!-- id du projet du labs -->
+ <labs.id>12</labs.id>
+
+ <labs.project>lutinutil</labs.project>
+
+ <!-- compile with ? -->
+ <maven.compile.source>1.6</maven.compile.source>
+ <maven.compile.target>1.6</maven.compile.target>
+
+ <!-- Lists URL -->
+ <labs.lists>http://lists.labs.libre-entreprise.org/mailman/listinfo/lutinutil</labs.lists>
+
+ <!-- maven will suffix with /${pom.artifactId} -->
+ <maven.scm.developerConnection>scm:svn:svn+ssh://${username}@${labs.host}/svnroot/lutinutil/trunk
+ </maven.scm.developerConnection>
+
+ <!-- maven will suffix with /${pom.artifactId} -->
+ <maven.scm.connection>scm:svn:svn:anonymous@${labs.host}/svnroot/lutinutil/trunk</maven.scm.connection>
+
+ </properties>
+
+ <profiles>
+ <profile>
+ <id>project</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <properties>
+ <!-- test (par defaut, on ne les execute pas) -->
+ <maven.test.skip>true</maven.test.skip>
+ <maven.reports.generate>false</maven.reports.generate>
+ </properties>
+ </profile>
+ <profile>
+ <id>tests</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <properties>
+ <!-- test (par defaut, on les execute) -->
+ <maven.test.skip>true</maven.test.skip>
+ <maven.reports.generate>false</maven.reports.generate>
+ </properties>
+ </profile>
+ <profile>
+ <id>site</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <properties>
+ <!-- test (par defaut, on ne les execute pas) -->
+ <maven.test.skip>false</maven.test.skip>
+ <maven.reports.generate>true</maven.reports.generate>
+ </properties>
+ </profile>
+ </profiles>
+
+ <build>
+ <plugins>
+ <!-- source -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <!-- javadoc -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <!--aggregate>true</aggregate-->
+ <encoding>${maven.compile.encoding}</encoding>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencyManagement>
+ <dependencies>
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ <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>
+
+</project>
Added: trunk/lutinutil-io/site/site.xml
===================================================================
--- trunk/lutinutil-io/site/site.xml (rev 0)
+++ trunk/lutinutil-io/site/site.xml 2008-07-31 20:10:38 UTC (rev 950)
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<project name="LutinUtil">
+
+ <skin>
+ <groupId>lutinlib</groupId>
+ <artifactId>lutin-site-skin</artifactId>
+ <version>0.1</version>
+ </skin>
+
+ <bannerLeft>
+ <name>Lutin Util</name>
+ </bannerLeft>
+
+ <bannerRight>
+ <src>http://www.codelutin.com/images/lutinorange-codelutin.png</src>
+ <href>http://www.codelutin.com</href>
+ </bannerRight>
+
+ <poweredBy>
+ <logo href="http://maven.apache.org" name="Maven" img="images/logos/maven-feather.png"/>
+ <logo href="http://jrst.labs.libre-entreprise.org" name="JRst" img="images/jrst-logo.png"/>
+ <logo href="http://docutils.sourceforge.net/rst.html" name="ReStructuredText" img="images/restructuredtext-logo.png"/>
+ </poweredBy>
+
+ <body>
+ <links>
+ <item name="Labs" href="http://labs.libre-entreprise.org/"/>
+ <item name="Code Lutin" href="http://www.codelutin.com/"/>
+ </links>
+
+ <menu name="Utilisateur">
+ <item name="Accueil" href="index.html"/>
+ <item href="http://lutinbuilder.labs.libre-entreprise.org/maven2/lutinlib/lutinutil/" name="T�l�chargement"/>
+ </menu>
+
+ <menu name="D�veloppeur">
+ <item name="A faire" href="Todo.html"/>
+ </menu>
+
+ ${reports}
+
+ </body>
+</project>
Added: trunk/lutinutil-io/src/test/resources/log4j.properties
===================================================================
--- trunk/lutinutil-io/src/test/resources/log4j.properties (rev 0)
+++ trunk/lutinutil-io/src/test/resources/log4j.properties 2008-07-31 20:10:38 UTC (rev 950)
@@ -0,0 +1,11 @@
+# Global logging configuration
+log4j.rootLogger=ERROR, stdout
+# Console output...
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
+#log4j.appender.stdout.layout.ConversionPattern=%%c=%c %%C=%C %%d=%d %%F=%F %%l=%l %%L=%L %%m=%m %%M=%M %%p=%p %%r=%r %%t=%t %%x=%x %%X=%X
+# package level
+log4j.logger.org.codelutin.i18n=INFO
+log4j.logger.org.codelutin.util=INFO
+log4j.logger.org.codelutin.option=INFO
Added: trunk/lutinutil-io/xdocs/navigation.xml
===================================================================
--- trunk/lutinutil-io/xdocs/navigation.xml (rev 0)
+++ trunk/lutinutil-io/xdocs/navigation.xml 2008-07-31 20:10:38 UTC (rev 950)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="ISO-8859-15"?>
+
+<project name="Lutin Util">
+ <title>Lutin Util</title>
+ <body>
+ <links>
+ <item href="http://labs.libre-entreprise.org/" name="Labs"/>
+ <item href="http://www.codelutin.com/" name="Code Lutin"/>
+ </links>
+ <menu name="Utilisateur">
+ <item href="/LutinUtil.html" name="Documentation"/>
+ <item href="http://lutinbuilder.labs.libre-entreprise.org/maven/org/codelutin/jars/" name="T�l�chargement"/>
+ </menu>
+ <menu name="Developpeur">
+ <item href="/Todo.html" name="Todo"/>
+ </menu>
+ </body>
+</project>
1
0
[Lutinutil-commits] r949 - trunk/maven-i18n-plugin
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 19:48:08 +0000 (Thu, 31 Jul 2008)
New Revision: 949
Modified:
trunk/maven-i18n-plugin/pom.xml
Log:
clean pom
Modified: trunk/maven-i18n-plugin/pom.xml
===================================================================
--- trunk/maven-i18n-plugin/pom.xml 2008-07-31 19:45:28 UTC (rev 948)
+++ trunk/maven-i18n-plugin/pom.xml 2008-07-31 19:48:08 UTC (rev 949)
@@ -24,13 +24,6 @@
<scope>compile</scope>
</dependency>
- <!--dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-model</artifactId>
- <version>2.0.4</version>
- <scope>compile</scope>
- </dependency-->
-
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
@@ -38,13 +31,6 @@
<scope>compile</scope>
</dependency>
- <!--dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- <version>1.0.5</version>
- <scope>compile</scope>
- </dependency-->
-
<dependency>
<groupId>org.codelutin</groupId>
<artifactId>lutinutil</artifactId>
@@ -113,15 +99,8 @@
<packaging>maven-plugin</packaging>
<build>
- <!--sourceDirectory>${maven.src.dir}/java</sourceDirectory>
- <testSourceDirectory>${maven.src.dir}/test</testSourceDirectory>
- <resources>
- <resource>
- <directory>${maven.src.dir}/resources</directory>
- </resource>
- </resources-->
-
<plugins>
+
<!-- source-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -135,6 +114,7 @@
</execution>
</executions>
</plugin>
+
<!-- javadoc -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -149,16 +129,6 @@
</executions>
</plugin>
- <!--Compile with ?-->
- <!--plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>${maven.compile.source}</source>
- <target>${maven.compile.target}</target>
- <encoding>${maven.compile.encoding}</encoding>
- </configuration>
- </plugin-->
</plugins>
</build>
@@ -224,80 +194,4 @@
</profile>
</profiles>
- <!--distributionManagement>
- <repository>
- <id>labs</id>
- <url>scp://labs.libre-entreprise.org/home/groups/lutinbuilder/htdocs/maven2</url>
- </repository>
-
- <site>
- <id>labs</id>
- <url>scp://labs.libre-entreprise.org/home/groups/lutinutil/htdocs/${pom.artifact…</url>
- </site>
- </distributionManagement-->
- <!-- fin de ce qui devrait etre dans le pere -->
-
-
- <!--Tracking-->
- <!--issueManagement>
- <url>http://labs.libre-entreprise.org/tracker/?group_id=12</url>
- </issueManagement-->
-
- <!--
- | surcharge des valeurs par defaut
- +-->
- <!--mailingLists>
- <mailingList>
- <name>lutinutil-cvscomit</name>
- <subscribe>http://lists.labs.libre-entreprise.org/mailman/listinfo/lutinutil-cvscommit</subscribe>
- <unsubscribe>http://lists.labs.libre-entreprise.org/mailman/listinfo/lutinutil-cvscommit</unsubscribe>
- <archive>http://lists.labs.libre-entreprise.org/pipermail/lutinutil-cvscommit/</archive>
- </mailingList>
-
- <mailingList>
- <name>lutinutil-devel</name>
- <subscribe>http://lists.labs.libre-entreprise.org/mailman/listinfo/lutinutil-devel</subscribe>
- <unsubscribe>http://lists.labs.libre-entreprise.org/mailman/listinfo/lutinutil-devel</unsubscribe>
- <archive>http://lists.labs.libre-entreprise.org/pipermail/lutinutil-devel/</archive>
- </mailingList>
-
- <mailingList>
- <name>lutinutil-user</name>
- <subscribe>http://lists.labs.libre-entreprise.org/mailman/listinfo/lutinutil-user</subscribe>
- <unsubscribe>http://lists.labs.libre-entreprise.org/mailman/listinfo/lutinutil-user</unsubscribe>
- <archive>http://lists.labs.libre-entreprise.org/pipermail/lutinutil-user/</archive>
- </mailingList>
- </mailingLists-->
-
- <!--scm>
- <url>http://cvs.labs.libre-entreprise.org/cgi-bin/cvsweb.cgi/?cvsroot=lutinutil</url>
- <connection>scm:cvs:pserver:anonymous@cvs.labs.libre-entreprise.org:/cvsroot/lutinutil:${pom.artifactId}
- </connection>
- </scm-->
- <!--
- | fin de surcharge
- +-->
- <!--profiles>
- <profile>
- <id>project</id>
-
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
-
- <properties>
-
- <maven.test.skip>true</maven.test.skip>
-
-
- <maven.src.dir>${basedir}/src</maven.src.dir>
-
-
- <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>
- </properties>
- </profile>
- </profiles-->
-
</project>
1
0
[Lutinutil-commits] r948 - in trunk/maven-i18n-plugin/src/main/java/org/codelutin/i18n/plugin: . core 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 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);
1
0
[Lutinutil-commits] r947 - trunk/maven-i18n-plugin
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 19:35:13 +0000 (Thu, 31 Jul 2008)
New Revision: 947
Modified:
trunk/maven-i18n-plugin/pom.xml
Log:
refacotr pom
Modified: trunk/maven-i18n-plugin/pom.xml
===================================================================
--- trunk/maven-i18n-plugin/pom.xml 2008-07-31 19:28:21 UTC (rev 946)
+++ trunk/maven-i18n-plugin/pom.xml 2008-07-31 19:35:13 UTC (rev 947)
@@ -2,103 +2,20 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <!--The version of maven's project object model-->
<modelVersion>4.0.0</modelVersion>
- <!--lutinproject.xml-->
- <!--parent>
- <groupId>lutinlib</groupId>
- <artifactId>lutinproject</artifactId>
- <version>2.2</version>
- </parent-->
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+ <parent>
+ <groupId>lutinlib</groupId>
+ <artifactId>lutinproject</artifactId>
+ <version>2.3</version>
+ </parent>
- <!--A unique name for this project-->
<groupId>lutinplugin</groupId>
<artifactId>maven-i18n-plugin</artifactId>
- <name>Plugin maven pour lutini18n</name>
- <!--ejb, jar, war...-->
- <packaging>maven-plugin</packaging>
-
- <!--Version-->
- <version>0.3-SNAPSHOT</version>
-
- <!--Description-->
- <description>
- Plugin pour maven 2 pour la génération des bundles pour l'internationnalisation des applications java fait par
- lutinutil-i18n
- </description>
- <inceptionYear>2007</inceptionYear>
-
-
- <!-- debut de ce qui devrait etre dans le pere -->
- <build>
- <sourceDirectory>${maven.src.dir}/java</sourceDirectory>
- <testSourceDirectory>${maven.src.dir}/test</testSourceDirectory>
- <resources>
- <resource>
- <directory>${maven.src.dir}/resources</directory>
- </resource>
- </resources>
-
- <plugins>
- <!--Compile with ?-->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>${maven.compile.source}</source>
- <target>${maven.compile.target}</target>
- <encoding>${maven.compile.encoding}</encoding>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <distributionManagement>
- <repository>
- <id>labs</id>
- <url>scp://labs.libre-entreprise.org/home/groups/lutinbuilder/htdocs/maven2</url>
- </repository>
-
- <site>
- <id>labs</id>
- <url>scp://labs.libre-entreprise.org/home/groups/lutinutil/htdocs/${pom.artifact…</url>
- </site>
- </distributionManagement>
- <!-- fin de ce qui devrait etre dans le pere -->
-
-
- <!--Tracking-->
- <issueManagement>
- <url>http://labs.libre-entreprise.org/tracker/?group_id=12</url>
- </issueManagement>
-
- <!--who the developers are for the project-->
- <contributors>
- <contributor>
- <name>Julien Ruchaud</name>
- <email>ruchaud(a)codelutin.com</email>
- <organization>Code Lutin</organization>
- <timezone>+2</timezone>
- <roles>
- <role>Développeur</role>
- </roles>
- </contributor>
- </contributors>
-
- <!--Librairies-->
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
@@ -107,12 +24,12 @@
<scope>compile</scope>
</dependency>
- <dependency>
+ <!--dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>2.0.4</version>
<scope>compile</scope>
- </dependency>
+ </dependency-->
<dependency>
<groupId>org.apache.maven</groupId>
@@ -121,12 +38,12 @@
<scope>compile</scope>
</dependency>
- <dependency>
+ <!--dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>1.0.5</version>
<scope>compile</scope>
- </dependency>
+ </dependency-->
<dependency>
<groupId>org.codelutin</groupId>
@@ -157,10 +74,179 @@
</dependency>
</dependencies>
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+ <name>Plugin maven pour lutini18n</name>
+ <version>0.3-SNAPSHOT</version>
+ <description>
+ Plugin pour maven 2 pour la génération des bundles pour l'internationnalisation des applications java fait par
+ lutinutil-i18n
+ </description>
+ <inceptionYear>2007</inceptionYear>
+
+ <contributors>
+ <contributor>
+ <name>Julien Ruchaud</name>
+ <email>ruchaud(a)codelutin.com</email>
+ <organization>Code Lutin</organization>
+ <timezone>+2</timezone>
+ <roles>
+ <role>Developer</role>
+ </roles>
+ </contributor>
+ <contributor>
+ <name>Tony Chemit</name>
+ <email>chemit(a)codelutin.com</email>
+ <organization>Code Lutin</organization>
+ <timezone>+2</timezone>
+ <roles>
+ <role>Developer</role>
+ </roles>
+ </contributor>
+ </contributors>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+
+ <packaging>maven-plugin</packaging>
+
+ <build>
+ <!--sourceDirectory>${maven.src.dir}/java</sourceDirectory>
+ <testSourceDirectory>${maven.src.dir}/test</testSourceDirectory>
+ <resources>
+ <resource>
+ <directory>${maven.src.dir}/resources</directory>
+ </resource>
+ </resources-->
+
+ <plugins>
+ <!-- source-->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>verify</phase>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <!-- javadoc -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>verify</phase>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!--Compile with ?-->
+ <!--plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>${maven.compile.source}</source>
+ <target>${maven.compile.target}</target>
+ <encoding>${maven.compile.encoding}</encoding>
+ </configuration>
+ </plugin-->
+ </plugins>
+ </build>
+
+ <properties>
+
+ <!-- id du projet du labs -->
+ <labs.id>12</labs.id>
+
+ <labs.project>lutinutil</labs.project>
+
+ <!-- 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>
+
+ <!-- Lists URL -->
+ <labs.lists>
+ http://lists.labs.libre-entreprise.org/mailman/listinfo/lutinutil
+ </labs.lists>
+
+ <!-- maven will suffix with /${pom.artifactId} -->
+ <maven.scm.developerConnection>scm:svn:svn+ssh://${username}@${labs.host}/svnroot/lutinutil/trunk
+ </maven.scm.developerConnection>
+
+ <!-- maven will suffix with /${pom.artifactId} -->
+ <maven.scm.connection>scm:svn:svn:anonymous@${labs.host}/svnroot/lutinutil/trunk</maven.scm.connection>
+
+ </properties>
+
+ <profiles>
+ <profile>
+ <id>project</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <properties>
+ <!-- test (par defaut, on ne les execute pas) -->
+ <maven.test.skip>true</maven.test.skip>
+ <maven.reports.generate>false</maven.reports.generate>
+ </properties>
+ </profile>
+ <profile>
+ <id>tests</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <properties>
+ <!-- test (par defaut, on les execute) -->
+ <maven.test.skip>false</maven.test.skip>
+ <maven.reports.generate>false</maven.reports.generate>
+ </properties>
+ </profile>
+ <profile>
+ <id>site</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <properties>
+ <!-- test (par defaut, on ne les execute pas) -->
+ <maven.test.skip>true</maven.test.skip>
+ <maven.reports.generate>true</maven.reports.generate>
+ </properties>
+ </profile>
+ </profiles>
+
+ <!--distributionManagement>
+ <repository>
+ <id>labs</id>
+ <url>scp://labs.libre-entreprise.org/home/groups/lutinbuilder/htdocs/maven2</url>
+ </repository>
+
+ <site>
+ <id>labs</id>
+ <url>scp://labs.libre-entreprise.org/home/groups/lutinutil/htdocs/${pom.artifact…</url>
+ </site>
+ </distributionManagement-->
+ <!-- fin de ce qui devrait etre dans le pere -->
+
+
+ <!--Tracking-->
+ <!--issueManagement>
+ <url>http://labs.libre-entreprise.org/tracker/?group_id=12</url>
+ </issueManagement-->
+
<!--
| surcharge des valeurs par defaut
+-->
- <mailingLists>
+ <!--mailingLists>
<mailingList>
<name>lutinutil-cvscomit</name>
<subscribe>http://lists.labs.libre-entreprise.org/mailman/listinfo/lutinutil-cvscommit</subscribe>
@@ -181,17 +267,17 @@
<unsubscribe>http://lists.labs.libre-entreprise.org/mailman/listinfo/lutinutil-user</unsubscribe>
<archive>http://lists.labs.libre-entreprise.org/pipermail/lutinutil-user/</archive>
</mailingList>
- </mailingLists>
+ </mailingLists-->
- <scm>
+ <!--scm>
<url>http://cvs.labs.libre-entreprise.org/cgi-bin/cvsweb.cgi/?cvsroot=lutinutil</url>
<connection>scm:cvs:pserver:anonymous@cvs.labs.libre-entreprise.org:/cvsroot/lutinutil:${pom.artifactId}
</connection>
- </scm>
+ </scm-->
<!--
| fin de surcharge
+-->
- <profiles>
+ <!--profiles>
<profile>
<id>project</id>
@@ -200,17 +286,18 @@
</activation>
<properties>
- <!--Test-->
+
<maven.test.skip>true</maven.test.skip>
- <!--Source base dir-->
+
<maven.src.dir>${basedir}/src</maven.src.dir>
- <!--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>
</properties>
</profile>
- </profiles>
+ </profiles-->
+
</project>
1
0