r375 - in trunk/nuiton-processor/src: main/java/org/nuiton/processor main/java/org/nuiton/processor/filters test/java/org/nuiton/processor
Author: tchemit Date: 2011-01-31 09:11:58 +0100 (Mon, 31 Jan 2011) New Revision: 375 Url: http://nuiton.org/repositories/revision/processor/375 Log: Evolution #1274: Remove deprecated api Removed: trunk/nuiton-processor/src/main/java/org/nuiton/processor/I18nExtractor.java trunk/nuiton-processor/src/main/java/org/nuiton/processor/LicenseProcessor.java trunk/nuiton-processor/src/main/java/org/nuiton/processor/filters/I18nFilter.java trunk/nuiton-processor/src/main/java/org/nuiton/processor/filters/LicenseFilter.java trunk/nuiton-processor/src/test/java/org/nuiton/processor/CommonTest.java trunk/nuiton-processor/src/test/java/org/nuiton/processor/LicenseProcessorTest.java Deleted: trunk/nuiton-processor/src/main/java/org/nuiton/processor/I18nExtractor.java =================================================================== --- trunk/nuiton-processor/src/main/java/org/nuiton/processor/I18nExtractor.java 2011-01-27 08:54:00 UTC (rev 374) +++ trunk/nuiton-processor/src/main/java/org/nuiton/processor/I18nExtractor.java 2011-01-31 08:11:58 UTC (rev 375) @@ -1,190 +0,0 @@ -/* - * #%L - * Nuiton Processor :: Api - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2002 - 2010 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - - -/* * - * I18nExtractor.java - * - * Created: Aug 16, 2004 - * - * @author Cédric Pineau <pineau@codelutin.com> - * @version $Revision$ - * - * Last update : $Date$ - * by : */ - -package org.nuiton.processor; - -import org.nuiton.processor.filters.I18nFilter; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.LineNumberReader; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * @deprecated since 1.1, will not be replaced in this project, but you can find - * it in I18n project. Will be remove soon. - */ -@Deprecated -public class I18nExtractor { - - protected I18nFilter filter = new I18nFilter(); - - protected Map<String, List<String>> store = - new HashMap<String, List<String>>(); - - /** - * Process input file to target. - * - * @param srcFiles source files - * @param outputFile target file - * @param encoding encoding used to read and write files - * @throws IOException if any io problems - * @since 1.0.4 - */ - public void extract(File[] srcFiles, File outputFile, String encoding) throws IOException { - PrintWriter writer = new PrintWriter( - new BufferedWriter( - new OutputStreamWriter( - new FileOutputStream(outputFile), encoding))); - try { - for (File srcFile : srcFiles) { - processFile(srcFile, encoding); - } - - for (Object o : store.keySet()) { - String i18nString = (String) o; - List<?> locations = store.get(i18nString); - for (Object location1 : locations) { - String location = (String) location1; - writer.println("# " + location); - } - writer.println(i18nString + "="); - } - } finally { - writer.close(); - } - } - - /** - * @param srcFiles source files - * @param outputFile target file - * @throws IOException if any io problems - * @deprecated since 1.0.4, prefer use the {@link #extract(File[], File, String)} - */ - @Deprecated - public void extract(File[] srcFiles, File outputFile) throws IOException { - extract(srcFiles, outputFile, "UTF-8"); -// PrintWriter writer = new PrintWriter( -// new BufferedWriter( -// new OutputStreamWriter( -// new FileOutputStream(outputFile), "UTF-8"))); -// try { -// for (File srcFile : srcFiles) { -// processFile(srcFile); -// } -// -// for (Object o : store.keySet()) { -// String i18nString = (String) o; -// List<?> locations = store.get(i18nString); -// for (Object location1 : locations) { -// String location = (String) location1; -// writer.println("# " + location); -// } -// writer.println(i18nString + "="); -// } -// } finally { -// writer.close(); -// } - } - - protected void processFile(File srcFile, String encoding) throws IOException { - LineNumberReader lnr = new LineNumberReader( - new InputStreamReader(new FileInputStream(srcFile), encoding)); - try { - while (lnr.ready()) { - String line = lnr.readLine(); - int lineNumber = lnr.getLineNumber(); - processLine(line, srcFile, lineNumber); - } - } finally { - lnr.close(); - } - } - - protected void processLine(String line, File srcFile, int lineNumber) { - String i18nStringsSet = filter.parse(line); - if (I18nFilter.EMPTY_STRING.equals(i18nStringsSet)) { - // Found a set of i18n Strings, split it. - String[] i18nStrings = i18nStringsSet.split("="); - for (String i18nString : i18nStrings) { - List<String> locations = store.get(i18nString); - if (locations == null) { - locations = new ArrayList<String>(); - store.put(i18nString, locations); - } - locations.add(srcFile.getPath() + "(" + lineNumber + ")"); - } - } - } - - public static void main(String[] args) { - Logger logger = Logger.getLogger("org.nuiton.processor.I18nExtractor."); - - if (args.length < 2) { - logger.log(Level.SEVERE, - "Please give at least sources and destination file"); - System.exit(0); - } else if (args.length > 2) { - File[] sources = new File[args.length - 1]; - for (int i = 0; i < args.length - 1; i++) { - sources[i] = new File(args[i]); - } - File destination = new File(args[args.length - 1]); - try { - String encoding = ProcessorUtil.DEFAULT_ENCODING; - logger.log(Level.INFO, "Will use system encoding " + encoding); - new I18nExtractor().extract(sources, destination, encoding); - } catch (IOException eee) { - - logger.log(Level.SEVERE, - "Error during i18n extraction : " + eee, eee); - } - } - - } -} Deleted: trunk/nuiton-processor/src/main/java/org/nuiton/processor/LicenseProcessor.java =================================================================== --- trunk/nuiton-processor/src/main/java/org/nuiton/processor/LicenseProcessor.java 2011-01-27 08:54:00 UTC (rev 374) +++ trunk/nuiton-processor/src/main/java/org/nuiton/processor/LicenseProcessor.java 2011-01-31 08:11:58 UTC (rev 375) @@ -1,81 +0,0 @@ -/* - * #%L - * Nuiton Processor :: Api - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2002 - 2010 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -package org.nuiton.processor; - -import org.nuiton.processor.filters.LicenseFilter; - -import java.io.File; -import java.io.IOException; - -/** - * This class is a processor of source header. - * - * @author tchemit <chemit@codelutin.com> - * @see LicenseFilter - * @deprecated since 1.1, will not be replaced in this project, but you can find - * it in maven-license-plugin project. Will be remove soon. - */ -@Deprecated -public class LicenseProcessor extends Processor { - - protected LicenseFilter licenseFilter; - - public LicenseProcessor(String header) { - licenseFilter = new LicenseFilter(header); - setInputFilter(licenseFilter); - } - - public LicenseFilter getLicenceFilter() { - return licenseFilter; - } - - /** - * Process input file to target. - * - * @param filein source file - * @param fileout target file - * @param encoding encoding used to read and write files - * @throws IOException if any io problems - * @since 1.0.4 - */ - public void process(File filein, File fileout, String encoding) throws IOException { - ProcessorUtil.doProcess(this, filein, fileout, encoding); - } - - /** - * Process input file to target. - * - * @param filein source file - * @param fileout target file - * @throws IOException if any io problems - * @deprecated since 1.0.4, prefer use the method {@link #process(File, File, String)} - */ - @Deprecated - public void process(File filein, File fileout) throws IOException { - process(filein, fileout, ProcessorUtil.DEFAULT_ENCODING); - } -} - Deleted: trunk/nuiton-processor/src/main/java/org/nuiton/processor/filters/I18nFilter.java =================================================================== --- trunk/nuiton-processor/src/main/java/org/nuiton/processor/filters/I18nFilter.java 2011-01-27 08:54:00 UTC (rev 374) +++ trunk/nuiton-processor/src/main/java/org/nuiton/processor/filters/I18nFilter.java 2011-01-31 08:11:58 UTC (rev 375) @@ -1,164 +0,0 @@ -/* - * #%L - * Nuiton Processor :: Api - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2002 - 2010 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - - -/******************************************************************************* - * I18nFilter.java - * - * Created: Sun Sep 1 2002 - * - * @author <poussin@codelutin.com> Copyright Code Lutin - * - * @version $Revision$ - * - * Mise a jour: $Date$ par : */ - -package org.nuiton.processor.filters; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - - -/** - * @deprecated since 1.1, will not be replaced in this project, but you can find - * it in I18n project. Will be remove soon. - */ -@Deprecated -public class I18nFilter extends DefaultFilter { // I18nFilter - - private String header = "_\\(\\s*\""; - private String footer = "\"\\s*(\\)|,|\\+|$)"; - - private Pattern headerPattern = Pattern.compile(getHeader()); - - private Pattern footerPattern = Pattern.compile(getFooter()); - - private Matcher matcher; - - protected void setFooter(String footer) { - this.footer = footer; - } - - protected void setHeader(String header) { - this.header = header; - } - - @Override - protected String getHeader() { - return header; - } - - @Override - protected String getFooter() { - return footer; - } - - @Override - public int getMatchIndexFor(String input, String sequence) { - int index = NOT_FOUND; - - setMatcher(null); - if (sequence.equals(getHeader())) { - setMatcher(getHeaderPattern().matcher(input)); - } else if (sequence.equals(getFooter())){ - setMatcher(getFooterPattern().matcher(input)); - } - if (getMatcher() != null) { - try { - getMatcher().find(); - index = getMatcher().start(); - } catch (RuntimeException e) {} - } - - return index; - } - - @Override - public int getMatchLengthFor(String sequence) { - int length = NOT_FOUND; - - try { - length = getMatcher().end()-getMatcher().start(); - } catch (RuntimeException e) {} - - return length; - } - - /** - * methode appele lorsqu'on a la chaine entiere entre le header et le - * footer. - * - * @param ch - * la chaine trouve - * @return ce qu'il faut ecrire dans le fichier de sortie - */ - @Override - protected String performInFilter(String ch) { - return ch.replaceAll("\"\\s*\\+\\s*\"","") + "="; - } - - @Override - public String performHeaderFooterFilter(String ch) { - return ch.substring(ch.indexOf('"')+1, ch.lastIndexOf('"')); - } - - /** - * methode appele lorsqu'on a la chaine entiere a l'exterieur du - * header/footer - * - * @param ch - * la chaine trouve - * @return ce qu'il faut ecrire dans le fichier de sortie - */ - @Override - protected String performOutFilter(String ch) { - return EMPTY_STRING; - } - - /** - * @return Returns the footerPattern. - */ - protected Pattern getFooterPattern() { - return footerPattern; - } - /** - * @return Returns the headerPattern. - */ - protected Pattern getHeaderPattern() { - return headerPattern; - } - /** - * @return Returns the matcher. - */ - protected Matcher getMatcher() { - return matcher; - } - /** - * @param matcher The matcher to set. - */ - protected void setMatcher(Matcher matcher) { - this.matcher = matcher; - } -} // I18nFilter Deleted: trunk/nuiton-processor/src/main/java/org/nuiton/processor/filters/LicenseFilter.java =================================================================== --- trunk/nuiton-processor/src/main/java/org/nuiton/processor/filters/LicenseFilter.java 2011-01-27 08:54:00 UTC (rev 374) +++ trunk/nuiton-processor/src/main/java/org/nuiton/processor/filters/LicenseFilter.java 2011-01-31 08:11:58 UTC (rev 375) @@ -1,131 +0,0 @@ -/* - * #%L - * Nuiton Processor :: Api - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2002 - 2010 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -package org.nuiton.processor.filters; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Un filtre pour remplacer la license d'un fichier source java. - * <p/> - * fixme : il faut ne pas autoriser le process de fichier java qui ne sont pas - * valide selon le header - footer... - * - * @author tchemit <chemit@codelutin.com> - * - * @deprecated since 1.1, will not be replaced in this project, but you can find - * it in maven-license-plugin project. Will be remove soon. - */ -@Deprecated -public class LicenseFilter extends DefaultFilter { - - /** to use log facility, just put in your code: log.info(\"...\"); */ - static private final Log log = LogFactory.getLog(LicenseFilter.class); - - public static final String HEADER = "*" + "#" + "#" + "%"; - - public static final String FOOTER = "#" + "#" + "%" + "*"; - - /** - * la licence a insere dans le header du fichier source. Ce header est - * formatte en commentaire (chaque ligne commence par un ' * ', sauf pour - * la premiere et derniere ligne). - */ - protected String licenseHeader; - - /** flag pour indiquer si la licence a ete trouvee entre le header et - * le footer */ - protected boolean touched; - - /** flag pour indiquer si on a rencontree le header du filtre */ - protected boolean detectHeader; - - public LicenseFilter(String licenseHeader) { - this.licenseHeader = " " + licenseHeader + " "; - } - - @Override - protected String performInFilter(String ch) { - if (log.isDebugEnabled()) { - log.debug(ch); - } - if (touched) { - // on autorise pas deux process de la licence dans un fichier java - throw new IllegalStateException("Can only have one license " + - "processor open tag " + HEADER); - } - if (getMatchIndexFor(ch, HEADER) == NOT_FOUND) { - // on est bien dans la license, on peut effectuer le changement - touched = true; - return HEADER + licenseHeader + FOOTER; - } - // ce cas arrive lorsque l'on a parcouru tout le fichier avec detection - // de la balise header mais sans balise footer - // et on arrive dans cette methode dans le flush du filter - return ch; - } - - @Override - protected String performOutFilter(String ch) { - if (log.isDebugEnabled()) { - log.debug(ch); - } - return ch; - } - - @Override - protected String getHeader() { - return HEADER; - } - - @Override - protected String getFooter() { - return FOOTER; - } - - @Override - protected void changeState(State newState) { - super.changeState(newState); - if (newState == State.SEARCH_FOOTER) { - // on a decouvert un header - detectHeader = true; - } - } - - public boolean wasTouched() { - return touched; - } - - public boolean isDetectHeader() { - return detectHeader; - } - - public void reset() { - touched = false; - detectHeader = false; - state = State.SEARCH_HEADER; - } -} Deleted: trunk/nuiton-processor/src/test/java/org/nuiton/processor/CommonTest.java =================================================================== --- trunk/nuiton-processor/src/test/java/org/nuiton/processor/CommonTest.java 2011-01-27 08:54:00 UTC (rev 374) +++ trunk/nuiton-processor/src/test/java/org/nuiton/processor/CommonTest.java 2011-01-31 08:11:58 UTC (rev 375) @@ -1,118 +0,0 @@ -/* - * #%L - * Nuiton Processor :: Api - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2002 - 2010 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - -package org.nuiton.processor; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.codehaus.plexus.util.IOUtil; -import org.junit.Assert; - -/** - * - * @author fdesbois - * @deprecated since 1.1, Please do not make a framework from one test... Will be removed soon and not replaced, - */ -@Deprecated -public abstract class CommonTest { - - protected static File basedir; - protected static File testdir; - - static private final Log log = LogFactory.getLog(CommonTest.class); - - //@BeforeClass - public static void initClass() throws Exception { - basedir = getBasedir(); - testdir = getFile(basedir, "target", "test-classes", "org", "nuiton", - "processor", "result"); - boolean b = testdir.exists() || testdir.mkdirs(); - if (!b) { - throw new IOException("Could not create directory : "+testdir); - } - } - - protected void checkPattern(String pattern, - boolean required, - File f, - String encoding) throws IOException { - - if (log.isDebugEnabled()) { - log.debug("check generated file " + f); - } - - Assert.assertTrue("generated file " + f + " was not found...", - f.exists() - ); - - String content = readAsString(f, encoding); - - String errorMessage = required ? "could not find the pattern : " : - "should not have found pattern :"; - Assert.assertEquals(errorMessage + pattern + " in file " + f, - required, content.contains(pattern)); - } - - public static String readAsString(File file, - String encoding) throws IOException { - FileInputStream inf = new FileInputStream(file); - BufferedReader in = - new BufferedReader(new InputStreamReader(inf, encoding)); - try { - return IOUtil.toString(in); - } finally { - in.close(); - } - } - - public static File getFile(File base, String... paths) { - StringBuilder buffer = new StringBuilder(); - for (String path : paths) { - buffer.append(File.separator).append(path); - } - File f = new File(base, buffer.substring(1)); - return f; - } - - public static File getBasedir() { - String basedirPath = System.getProperty("basedir"); - - if (basedirPath == null) { - basedirPath = new File("").getAbsolutePath(); - } - - return new File(basedirPath); - } -} Deleted: trunk/nuiton-processor/src/test/java/org/nuiton/processor/LicenseProcessorTest.java =================================================================== --- trunk/nuiton-processor/src/test/java/org/nuiton/processor/LicenseProcessorTest.java 2011-01-27 08:54:00 UTC (rev 374) +++ trunk/nuiton-processor/src/test/java/org/nuiton/processor/LicenseProcessorTest.java 2011-01-31 08:11:58 UTC (rev 375) @@ -1,158 +0,0 @@ -/* - * #%L - * Nuiton Processor :: Api - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2002 - 2010 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -package org.nuiton.processor; - - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.codehaus.plexus.util.IOUtil; -import org.junit.BeforeClass; - -import org.junit.Assert; -import org.junit.Test; - -/** - * - * @author tchemit <chemit@codelutin.com> - * @since 1.0.1 - * @deprecated since 1.1, will not be replaced in this project, but you can find - * it in maven-license-plugin project. Will be remove soon. - */ -@Deprecated -public class LicenseProcessorTest { - - /** to use log facility, just put in your code: log.info(\"...\"); */ - static private final Log log = LogFactory.getLog(LicenseProcessorTest.class); - static File basedir; - static File testdir; - - public static final String UTF_8 = "utf-8"; - - @BeforeClass - public static void initClass() throws Exception { - basedir = getBasedir(); - testdir = getFile(basedir, "target", - "test-classes", - "org", "nuiton", "processor", "result"); - boolean b = testdir.exists() || testdir.mkdirs(); - if (!b) { - throw new IOException("Could not create directory : "+testdir); - } - } - - @Test - public void testProcessor() throws IOException { - - File in = getFile(basedir, "target", - "test-classes", "org", "nuiton", - "processor", "LicenseProcessorTest.java2"); - File out = getFile(testdir, in.getName()); - LicenseProcessor processor = new LicenseProcessor("my license"); - processor.process(in, out, UTF_8); - String content = readAsString(out, UTF_8); - if (log.isDebugEnabled()) { - log.debug("output : " + out); - log.debug(content); - } - checkPattern("// MUST BE THERE!", true, out); - checkPattern("my license", false, out); - } - - @Test - public void testProcessor2() throws IOException { - - File in = getFile(basedir, "target", "test-classes", "org", "nuiton", - "processor", "LicenseProcessorTest_1.java2"); - File out = new File(testdir, in.getName()); - LicenseProcessor processor = new LicenseProcessor("my license"); - processor.process(in, out,UTF_8); - String content = readAsString(out, UTF_8); - if (log.isDebugEnabled()) { - log.debug("output : " + out); - log.debug(content); - } - checkPattern("// MUST BE THERE!", true, out); - checkPattern("my license", true, out); - } - - protected void checkPattern(String pattern, - boolean required, - File f) throws IOException { - - if (log.isDebugEnabled()) { - log.debug("check generated file " + f); - } - - Assert.assertTrue("generated file " + f + " was not found...", - f.exists() - ); - String content = readAsString(f, UTF_8); - - String errorMessage = required ? - "could not find the pattern : " : - "should not have found pattern :"; - Assert.assertEquals(errorMessage + pattern + " in file " + f, - required, - content.contains(pattern) - ); - } - - static public String readAsString(File file, - String encoding) throws IOException { - FileInputStream inf = new FileInputStream(file); - BufferedReader in = - new BufferedReader(new InputStreamReader(inf, encoding)); - try { - return IOUtil.toString(in); - } finally { - in.close(); - } - } - - public static File getFile(File base, String... paths) { - StringBuilder buffer = new StringBuilder(); - for (String path : paths) { - buffer.append(File.separator).append(path); - } - File f = new File(base, buffer.substring(1)); - return f; - } - - public static File getBasedir() { - String basedirPath = System.getProperty("basedir"); - - if (basedirPath == null) { - basedirPath = new File("").getAbsolutePath(); - } - - return new File(basedirPath); - } -}
participants (1)
-
tchemit@users.nuiton.org