Author: echatellier Date: 2012-08-10 15:22:56 +0200 (Fri, 10 Aug 2012) New Revision: 3719 Url: http://forge.codelutin.com/repositories/revision/isis-fish/3719 Log: Remove cpdetector (not used anymore) Modified: trunk/pom.xml trunk/src/main/java/fr/ifremer/isisfish/util/CompileHelper.java trunk/src/test/java/fr/ifremer/isisfish/util/CompileHelperTest.java Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2012-08-10 13:15:37 UTC (rev 3718) +++ trunk/pom.xml 2012-08-10 13:22:56 UTC (rev 3719) @@ -385,13 +385,6 @@ <scope>compile</scope> </dependency> - <!--<dependency> - <groupId>net.sourceforge.cpdetector</groupId> - <artifactId>cpdetector</artifactId> - <version>1.0.7</version> - <scope>compile</scope> - </dependency> --> - <dependency> <groupId>com.sun</groupId> <artifactId>tools</artifactId> Modified: trunk/src/main/java/fr/ifremer/isisfish/util/CompileHelper.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/util/CompileHelper.java 2012-08-10 13:15:37 UTC (rev 3718) +++ trunk/src/main/java/fr/ifremer/isisfish/util/CompileHelper.java 2012-08-10 13:22:56 UTC (rev 3719) @@ -386,96 +386,4 @@ } return result; } - - /*protected static CodepageDetectorProxy getCodepageDetector() { - - if (detector == null) { - detector = CodepageDetectorProxy.getInstance(); // A singleton. - - // Add the implementations of info.monitorenter.cpdetector.io.ICodepageDetector: - // This one is quick if we deal with unicode codepages: - detector.add(new ByteOrderMarkDetector()); - // The first instance delegated to tries to detect the meta charset attribut in html pages. - detector.add(new ParsingDetector(true)); // be verbose about parsing. - // This one does the tricks of exclusion and frequency detection, if first implementation is - // unsuccessful: - detector.add(JChardetFacade.getInstance()); // Another singleton. - detector.add(ASCIIDetector.getInstance()); // Fallback, see javadoc. - } - return detector; - }*/ - - /* - * Convert all files to UTF-8. - * - * @param files fiels to convert - * @return converted file list - * - public static List<File> convertToUnicode(List<File> files) { - - CodepageDetectorProxy myDetector = getCodepageDetector(); - - for (File file : files) { - try { - Charset charset = myDetector.detectCodepage(file.toURI().toURL()); - - if (log.isDebugEnabled()) { - log.debug("Charset for " + file.getAbsolutePath() + " is " + charset); - } - - if (charset != null && !charset.name().equalsIgnoreCase("utf-8")) { - - if (log.isDebugEnabled()) { - log.debug("Convert " + file.getAbsolutePath() + " to unicode"); - } - - File tmpFile = File.createTempFile(file.getName(), ".copy"); - tmpFile.deleteOnExit(); - - // direct copy - InputStream is = new FileInputStream(file); - OutputStream os = new FileOutputStream(tmpFile); - try { - IOUtils.copy(is, os); - } - finally { - is.close(); - os.close(); - } - - // copy using cp transaltion - is = new FileInputStream(tmpFile); - os = new FileOutputStream(file); - Reader ir = new InputStreamReader(is, charset); - Writer ow = new OutputStreamWriter(new FileOutputStream(file), "utf-8"); - try { - IOUtils.copy(ir, ow); - } - finally { - ir.close(); - ow.close(); - is.close(); - os.close(); - } - - } - else { - if (log.isDebugEnabled()) { - log.debug("File " + file.getAbsolutePath() + " already in unicode : skip"); - } - } - } catch (MalformedURLException e) { - if (log.isErrorEnabled()) { - log.error("Can't convert file in unicode", e); - } - } catch (IOException e) { - if (log.isErrorEnabled()) { - log.error("Can't convert file in unicode", e); - } - } - - } - - return files; - }*/ } Modified: trunk/src/test/java/fr/ifremer/isisfish/util/CompileHelperTest.java =================================================================== --- trunk/src/test/java/fr/ifremer/isisfish/util/CompileHelperTest.java 2012-08-10 13:15:37 UTC (rev 3718) +++ trunk/src/test/java/fr/ifremer/isisfish/util/CompileHelperTest.java 2012-08-10 13:22:56 UTC (rev 3719) @@ -27,19 +27,17 @@ import java.io.File; import java.io.IOException; -import java.lang.reflect.Method; import java.net.URL; import java.net.URLClassLoader; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.apache.commons.io.FileUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.nuiton.util.FileUtil; import org.junit.Assert; import org.junit.Test; +import org.nuiton.util.FileUtil; import fr.ifremer.isisfish.AbstractIsisFishTest; import fr.ifremer.isisfish.equation.PopulationReproductionEquation; @@ -183,64 +181,7 @@ fB.delete(); FileUtil.deleteRecursively(dest); } - - /* - * Save a file as non utf-8 encoded. - * Convert to uft-8. - * Assert that file has been converted. - * @throws IOException - * - @Test - public void convertToUnicodeTest() throws IOException { - String content = getFirstClassContent("ConvertToUnicode"); - // add un accent - content = content.replace("code", "cod\u00E9"); - - File nonUnicodeFile = File.createTempFile("ConvertToUnicode", ".java", getTestDirectory()); - FileUtil.writeString(nonUnicodeFile, content, "ISO-8859-15"); - - if (log.isDebugEnabled()) { - log.debug("Saved file " + nonUnicodeFile.getAbsolutePath() + " as ISO-8859-15"); - } - - CompileHelper.convertToUnicode(Collections.singletonList(nonUnicodeFile)); - - // don't support encoding String newContent = FileUtil.readAsString(nonUnicodeFile); - String newContent = FileUtils.readFileToString(nonUnicodeFile, "UTF-8"); - Assert.assertTrue(newContent.indexOf("cod\u00E9") > 0); - - nonUnicodeFile.delete(); - }*/ - - /* - * Try to convert file already in UTF-8. - * - * @throws IOException - * - @Test - public void convertToUnicodeUselessTest() throws IOException { - String content = getFirstClassContent("UselessConvertToUnicode"); - - // add un accent - content = content.replace("code", "cod\u00E9"); - - File nonUnicodeFile = File.createTempFile("UselessConvertToUnicode", ".java", getTestDirectory()); - FileUtil.writeString(nonUnicodeFile, content, "UTF-8"); - - if (log.isDebugEnabled()) { - log.debug("Saved file " + nonUnicodeFile.getAbsolutePath() + " as UTF-8"); - } - - CompileHelper.convertToUnicode(Collections.singletonList(nonUnicodeFile)); - - // don't support encoding String newContent = FileUtil.readAsString(nonUnicodeFile); - String newContent = FileUtils.readFileToString(nonUnicodeFile, "UTF-8"); - Assert.assertTrue(newContent.indexOf("cod\u00E9") > 0); - - nonUnicodeFile.delete(); - }*/ - /** * Test que le contenu du fichier java correspondant à l'equation est * corectement généré.