[Lutinprocessor-commits] r182 - lutinprocessor/trunk/src/main/java/org/codelutin/processor/ant
Author: chatellier Date: 2009-02-20 15:55:13 +0000 (Fri, 20 Feb 2009) New Revision: 182 Modified: lutinprocessor/trunk/src/main/java/org/codelutin/processor/ant/I18nExtractorTask.java Log: Improve code style, remove warning Modified: lutinprocessor/trunk/src/main/java/org/codelutin/processor/ant/I18nExtractorTask.java =================================================================== --- lutinprocessor/trunk/src/main/java/org/codelutin/processor/ant/I18nExtractorTask.java 2009-02-20 15:49:02 UTC (rev 181) +++ lutinprocessor/trunk/src/main/java/org/codelutin/processor/ant/I18nExtractorTask.java 2009-02-20 15:55:13 UTC (rev 182) @@ -1,5 +1,5 @@ /* *##% Lutin file processor - * Copyright (C) 2002 - 2008 CodeLutin + * Copyright (C) 2002 - 2009 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 @@ -15,8 +15,21 @@ * License along with this program. If not, see * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */ -/* * - * I18nExtractorTask.java +package org.codelutin.processor.ant; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.DirectoryScanner; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.taskdefs.MatchingTask; +import org.codelutin.processor.I18nExtractor; + +/** + * I18nExtractorTask. * * Created: Aug 16, 2004 * @@ -26,49 +39,39 @@ * Last update : $Date$ * by : $Author$ */ +public class I18nExtractorTask extends MatchingTask { + public static final int MSG_VERBOSE = Project.MSG_VERBOSE; -package org.codelutin.processor.ant; + protected File srcDir; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; + protected File destFile; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.DirectoryScanner; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.taskdefs.MatchingTask; -import org.codelutin.processor.I18nExtractor; + protected String[] includes = new String[] {}; -public class I18nExtractorTask extends MatchingTask { + protected String[] excludes = new String[] {}; + protected String[] srcFileNames; + public I18nExtractorTask() { + } protected void doExecute() throws BuildException { // creation du repertoire pour le fichier destination destFile.getParentFile().mkdirs(); - ArrayList fileList = new ArrayList(); - for (int i=0; i<srcFileNames.length ; i++) { + List<File> fileList = new ArrayList<File>(); + for (int i = 0; i < srcFileNames.length; i++) { fileList.add(new File(srcFileNames[i])); } try { - new I18nExtractor().extract((File[]) fileList.toArray(new File[0]), destFile); - } catch (IOException eee) { + new I18nExtractor() + .extract(fileList.toArray(new File[0]), destFile); + } catch (IOException eee) { throw new BuildException(eee); } } - static int MSG_VERBOSE = Project.MSG_VERBOSE; - - protected File srcDir; - protected File destFile; - protected String[] includes = new String[] { - }; - protected String[] excludes = new String[] { - }; - protected String[] srcFileNames; - public void setSrcdir(File srcDir) { this.srcDir = srcDir; } @@ -80,22 +83,19 @@ public void execute() throws BuildException { // first of all, make sure that we've got a srcdir if (srcDir == null) { - throw new BuildException( - "srcdir attribute must be set!", - getLocation()); + throw new BuildException("srcdir attribute must be set!", + getLocation()); } if (!srcDir.exists()) { - throw new BuildException( - "srcdir \"" + srcDir.getPath() + "\" does not exist!", - getLocation()); + throw new BuildException("srcdir \"" + srcDir.getPath() + + "\" does not exist!", getLocation()); } if (destFile == null) { - throw new BuildException( - "destFile attribute must be set!", + throw new BuildException("destFile attribute must be set!", getLocation()); } - + // Build the list of files to compute buildFileList(); @@ -109,11 +109,13 @@ DirectoryScanner ds = getDirectoryScanner(srcDir); String[] includes = getIncludes(); - if (includes.length > 0) + if (includes.length > 0) { ds.setIncludes(includes); + } String[] excludes = getExcludes(); - if (excludes.length > 0) + if (excludes.length > 0) { ds.setExcludes(excludes); + } ds.scan(); @@ -122,10 +124,11 @@ } protected boolean isNewer(String filein, String fileout) { - boolean result = - new File(filein).lastModified() > new File(fileout).lastModified(); - if (result) + boolean result = new File(filein).lastModified() > new File(fileout) + .lastModified(); + if (result) { log(filein + " is newer than " + fileout, MSG_VERBOSE); + } return result; } @@ -145,5 +148,4 @@ this.excludes = excludes.split(","); } - }
participants (1)
-
chatellierï¼ users.labs.libre-entreprise.org