git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274857 13f79535-47bb-0310-9956-ffa450edef68master
@@ -65,8 +65,10 @@ import org.apache.tools.ant.util.FileUtils; | |||
* | |||
* @author Magesh Umasankar | |||
*/ | |||
public abstract class BaseFilterReader | |||
extends FilterReader { | |||
public abstract class BaseFilterReader extends FilterReader { | |||
/** Buffer size used when reading */ | |||
private static final int BUFFER_SIZE = 8192; | |||
/** Have the parameters passed been interpreted? */ | |||
private boolean initialized = false; | |||
@@ -116,7 +118,7 @@ public abstract class BaseFilterReader | |||
* | |||
* @exception IOException If an I/O error occurs | |||
*/ | |||
public final int read(final char cbuf[], final int off, | |||
public final int read(final char[] cbuf, final int off, | |||
final int len) throws IOException { | |||
for (int i = 0; i < len; i++) { | |||
final int ch = read(); | |||
@@ -232,6 +234,6 @@ public abstract class BaseFilterReader | |||
* reading | |||
*/ | |||
protected final String readFully() throws IOException { | |||
return FileUtils.readFully(in, 8192); | |||
return FileUtils.readFully(in, BUFFER_SIZE); | |||
} | |||
} |
@@ -70,8 +70,7 @@ import org.apache.tools.ant.types.Parameter; | |||
* | |||
* @author Magesh Umasankar | |||
*/ | |||
public final class HeadFilter | |||
extends BaseParamFilterReader | |||
public final class HeadFilter extends BaseParamFilterReader | |||
implements ChainableReader { | |||
/** Parameter name for the number of lines to be returned. */ | |||
private static final String LINES_KEY = "lines"; | |||
@@ -83,7 +82,7 @@ public final class HeadFilter | |||
private long linesRead = 0; | |||
/** Default number of lines to show */ | |||
private static int DEFAULT_NUM_LINES = 10; | |||
private static final int DEFAULT_NUM_LINES = 10; | |||
/** Number of lines to be returned in the filtered stream. */ | |||
private long lines = DEFAULT_NUM_LINES; | |||
@@ -62,6 +62,8 @@ import java.io.Reader; | |||
* (if you have more complex Java parsing needs, use a real lexer). | |||
* Since this class heavily relies on the single char read function, | |||
* you are reccomended to make it work on top of a buffered reader. | |||
* | |||
* @author Not Specified. | |||
*/ | |||
public final class StripJavaComments | |||
extends BaseFilterReader | |||
@@ -73,8 +73,7 @@ import org.apache.tools.ant.types.Parameter; | |||
* | |||
* @author Magesh Umasankar | |||
*/ | |||
public final class TailFilter | |||
extends BaseParamFilterReader | |||
public final class TailFilter extends BaseParamFilterReader | |||
implements ChainableReader { | |||
/** Parameter name for the number of lines to be returned. */ | |||
private static final String LINES_KEY = "lines"; | |||
@@ -85,8 +84,11 @@ public final class TailFilter | |||
/** Number of lines currently read in. */ | |||
private long linesRead = 0; | |||
/** Default number of lines to show */ | |||
private static final int DEFAULT_NUM_LINES = 10; | |||
/** Number of lines to be returned in the filtered stream. */ | |||
private long lines = 10; | |||
private long lines = DEFAULT_NUM_LINES; | |||
/** Number of lines to be skipped. */ | |||
private long skip = 0; | |||
@@ -150,15 +152,17 @@ public final class TailFilter | |||
while (line == null || line.length() == 0) { | |||
line = lineTokenizer.getToken(in); | |||
line = tailFilter(line); | |||
if (line == null) | |||
if (line == null) { | |||
return -1; | |||
} | |||
linePos = 0; | |||
} | |||
int ch = line.charAt(linePos); | |||
linePos++; | |||
if (linePos == line.length()) | |||
if (linePos == line.length()) { | |||
line = null; | |||
} | |||
return ch; | |||
} | |||
@@ -183,7 +187,7 @@ public final class TailFilter | |||
/** | |||
* Sets the number of lines to be skipped in the filtered stream. | |||
* | |||
* @param lines the number of lines to be skipped in the filtered stream | |||
* @param skip the number of lines to be skipped in the filtered stream | |||
*/ | |||
public final void setSkip(final long skip) { | |||
this.skip = skip; | |||
@@ -245,7 +249,7 @@ public final class TailFilter | |||
* null at the end of outputting the lines | |||
*/ | |||
private String tailFilter(String line) { | |||
if (! completedReadAhead) { | |||
if (!completedReadAhead) { | |||
if (line != null) { | |||
lineList.add(line); | |||
if (lines == -1) { | |||
@@ -178,8 +178,8 @@ public final class ChainReaderHelper { | |||
} | |||
if (clazz != null) { | |||
if (!FilterReader.class.isAssignableFrom(clazz)) { | |||
throw new BuildException(className + | |||
" does not extend java.io.FilterReader"); | |||
throw new BuildException(className | |||
+ " does not extend java.io.FilterReader"); | |||
} | |||
final Constructor[] constructors = | |||
clazz.getConstructors(); | |||
@@ -188,16 +188,17 @@ public final class ChainReaderHelper { | |||
for (; j < constructors.length; j++) { | |||
Class[] types = constructors[j] | |||
.getParameterTypes(); | |||
if (types.length == 1 && | |||
types[0].isAssignableFrom(Reader.class)) { | |||
if (types.length == 1 | |||
&& types[0].isAssignableFrom(Reader.class)) { | |||
consPresent = true; | |||
break; | |||
} | |||
} | |||
if ( !consPresent) { | |||
throw new BuildException( className + | |||
" does not define a public constructor" + | |||
" that takes in a Reader as its single argument."); | |||
if (!consPresent) { | |||
throw new BuildException(className | |||
+ " does not define a public constructor" | |||
+ " that takes in a Reader as its " | |||
+ "single argument."); | |||
} | |||
final Reader[] rdr = {instream}; | |||
instream = | |||
@@ -235,13 +236,14 @@ public final class ChainReaderHelper { | |||
* classes, even if they have public methods. | |||
*/ | |||
private void setProjectOnObject(Object obj) { | |||
if (project == null) | |||
if (project == null) { | |||
return; | |||
} | |||
if (obj instanceof BaseFilterReader) { | |||
((BaseFilterReader) obj).setProject(project); | |||
return; | |||
} | |||
project.setProjectReference( obj ); | |||
project.setProjectReference(obj); | |||
} | |||
/** | |||
@@ -146,7 +146,9 @@ public class Untar extends Expand { | |||
if (tis != null) { | |||
try { | |||
tis.close(); | |||
} catch (IOException e) {} | |||
} catch (IOException e) { | |||
// ignore | |||
} | |||
} | |||
} | |||
} | |||
@@ -187,7 +189,7 @@ public class Untar extends Expand { | |||
* @return valid values | |||
*/ | |||
public String[] getValues() { | |||
return new String[] { NONE, GZIP, BZIP2 }; | |||
return new String[] {NONE, GZIP, BZIP2}; | |||
} | |||
/** | |||
@@ -88,10 +88,11 @@ import org.apache.tools.ant.types.EnumeratedAttribute; | |||
*/ | |||
public class WaitFor extends ConditionBase { | |||
private long maxWaitMillis = 1000l * 60l * 3l; // default max wait time | |||
private long maxWaitMultiplier = 1l; | |||
private long checkEveryMillis = 500l; | |||
private long checkEveryMultiplier = 1l; | |||
/** default max wait time */ | |||
private long maxWaitMillis = 1000L * 60L * 3L; | |||
private long maxWaitMultiplier = 1L; | |||
private long checkEveryMillis = 500L; | |||
private long checkEveryMultiplier = 1L; | |||
private String timeoutProperty; | |||
/** | |||
@@ -159,6 +160,7 @@ public class WaitFor extends ConditionBase { | |||
try { | |||
Thread.sleep(checkEveryMillis); | |||
} catch (InterruptedException e) { | |||
// ignore | |||
} | |||
} | |||
@@ -192,12 +194,12 @@ public class WaitFor extends ConditionBase { | |||
private Hashtable timeTable = new Hashtable(); | |||
public Unit() { | |||
timeTable.put(MILLISECOND, new Long(1l)); | |||
timeTable.put(SECOND, new Long(1000l)); | |||
timeTable.put(MINUTE, new Long(1000l * 60l)); | |||
timeTable.put(HOUR, new Long(1000l * 60l * 60l)); | |||
timeTable.put(DAY, new Long(1000l * 60l * 60l * 24l)); | |||
timeTable.put(WEEK, new Long(1000l * 60l * 60l * 24l * 7l)); | |||
timeTable.put(MILLISECOND, new Long(1L)); | |||
timeTable.put(SECOND, new Long(1000L)); | |||
timeTable.put(MINUTE, new Long(1000L * 60L)); | |||
timeTable.put(HOUR, new Long(1000L * 60L * 60L)); | |||
timeTable.put(DAY, new Long(1000L * 60L * 60L * 24L)); | |||
timeTable.put(WEEK, new Long(1000L * 60L * 60L * 24L * 7L)); | |||
} | |||
public long getMultiplier() { | |||
@@ -390,12 +390,12 @@ public class CSharp extends DotnetCompile { | |||
*@return The Definitions Parameter to CSC | |||
*/ | |||
protected String getDefinitionsParameter() { | |||
String predecessors=super.getDefinitionsParameter(); | |||
String predecessors = super.getDefinitionsParameter(); | |||
if (notEmpty(definitions)) { | |||
if (predecessors==null) { | |||
predecessors= "/define:"; | |||
if (predecessors == null) { | |||
predecessors = "/define:"; | |||
} | |||
return predecessors+ definitions; | |||
return predecessors + definitions; | |||
} else { | |||
return predecessors; | |||
} | |||
@@ -132,8 +132,9 @@ public class DotnetBaseMatchingTask extends MatchingTask { | |||
* @return number of files out of date | |||
*/ | |||
protected int buildFileList(NetCommand command, Hashtable filesToBuild, long outputTimestamp) { | |||
int filesOutOfDate=0; | |||
boolean scanImplicitFileset=getSrcDir()!=null || filesets.size()==0; | |||
int filesOutOfDate = 0; | |||
boolean scanImplicitFileset | |||
= getSrcDir() != null || filesets.size() == 0; | |||
if (scanImplicitFileset) { | |||
//scan for an implicit fileset if there was a srcdir set | |||
//or there was no srcDir set but the @ | |||
@@ -151,7 +152,7 @@ public class DotnetBaseMatchingTask extends MatchingTask { | |||
//get any included source directories | |||
for (int i = 0; i < filesets.size(); i++) { | |||
FileSet fs = (FileSet) filesets.elementAt(i); | |||
filesOutOfDate+= command.scanOneFileset( | |||
filesOutOfDate += command.scanOneFileset( | |||
fs.getDirectoryScanner(getProject()), | |||
filesToBuild, | |||
outputTimestamp); | |||
@@ -166,9 +167,9 @@ public class DotnetBaseMatchingTask extends MatchingTask { | |||
* @param command the command to append to | |||
*/ | |||
protected void addFilesToCommand(Hashtable filesToBuild, NetCommand command) { | |||
int count=filesToBuild.size(); | |||
log("compiling " + count + " file" + ((count== 1) ? "" : "s")); | |||
Enumeration files=filesToBuild.elements(); | |||
int count = filesToBuild.size(); | |||
log("compiling " + count + " file" + ((count == 1) ? "" : "s")); | |||
Enumeration files = filesToBuild.elements(); | |||
while (files.hasMoreElements()) { | |||
File file = (File) files.nextElement(); | |||
command.addArgument(file.toString()); | |||
@@ -195,8 +196,8 @@ public class DotnetBaseMatchingTask extends MatchingTask { | |||
*/ | |||
protected void addFilesAndExecute(NetCommand command, boolean ignoreTimestamps) { | |||
long outputTimestamp = getOutputFileTimestamp(); | |||
Hashtable filesToBuild =new Hashtable(); | |||
int filesOutOfDate = buildFileList(command,filesToBuild, outputTimestamp); | |||
Hashtable filesToBuild = new Hashtable(); | |||
int filesOutOfDate = buildFileList(command, filesToBuild, outputTimestamp); | |||
//add the files to the command | |||
addFilesToCommand(filesToBuild, command); | |||
@@ -206,7 +207,7 @@ public class DotnetBaseMatchingTask extends MatchingTask { | |||
if (filesOutOfDate > 0) { | |||
command.runCommand(); | |||
} else { | |||
log("output file is up to date",Project.MSG_VERBOSE); | |||
log("output file is up to date", Project.MSG_VERBOSE); | |||
} | |||
} | |||
@@ -192,7 +192,7 @@ public abstract class DotnetCompile | |||
"System.Windows.Forms.dll", | |||
"System.XML.dll"}; | |||
protected static final String REFERENCE_OPTION= "/reference:"; | |||
protected static final String REFERENCE_OPTION = "/reference:"; | |||
/** | |||
* debug flag. Controls generation of debug information. | |||
@@ -235,7 +235,7 @@ public abstract class DotnetCompile | |||
/** | |||
* filesets of references | |||
*/ | |||
protected Vector referenceFilesets =new Vector(); | |||
protected Vector referenceFilesets = new Vector(); | |||
/** | |||
@@ -558,7 +558,7 @@ public abstract class DotnetCompile | |||
*@param dirName The new DestDir value | |||
*/ | |||
public void setDestDir(File dirName) { | |||
log( "DestDir currently unused", Project.MSG_WARN ); | |||
log("DestDir currently unused", Project.MSG_WARN); | |||
} | |||
@@ -567,7 +567,7 @@ public abstract class DotnetCompile | |||
* @param targetType | |||
*/ | |||
public void setTargetType(TargetTypes targetType) { | |||
this.targetType=targetType.getValue(); | |||
this.targetType = targetType.getValue(); | |||
} | |||
/** | |||
* Set the type of target. | |||
@@ -579,12 +579,12 @@ public abstract class DotnetCompile | |||
public void setTargetType(String ttype) | |||
throws BuildException { | |||
ttype = ttype.toLowerCase(); | |||
if (ttype.equals("exe") || ttype.equals("library") || | |||
ttype.equals("module") || ttype.equals("winexe")) { | |||
if (ttype.equals("exe") || ttype.equals("library") | |||
|| ttype.equals("module") || ttype.equals("winexe")) { | |||
targetType = ttype; | |||
} else { | |||
throw new BuildException("targetType " + ttype | |||
+ " is not one of 'exe', 'module', 'winexe' or 'library'" ); | |||
+ " is not one of 'exe', 'module', 'winexe' or 'library'"); | |||
} | |||
} | |||
@@ -706,8 +706,8 @@ public abstract class DotnetCompile | |||
* @return a string beginning /D: or null for no definitions | |||
*/ | |||
protected String getDefinitionsParameter() throws BuildException { | |||
StringBuffer defines=new StringBuffer(); | |||
Enumeration defEnum=definitionList.elements(); | |||
StringBuffer defines = new StringBuffer(); | |||
Enumeration defEnum = definitionList.elements(); | |||
while (defEnum.hasMoreElements()) { | |||
//loop through all definitions | |||
DotnetDefine define = (DotnetDefine) defEnum.nextElement(); | |||
@@ -717,10 +717,10 @@ public abstract class DotnetCompile | |||
defines.append(getDefinitionsDelimiter()); | |||
} | |||
} | |||
if (defines.length()==0) { | |||
if (defines.length() == 0) { | |||
return null; | |||
} else { | |||
return "/D:"+defines; | |||
return "/D:" + defines; | |||
} | |||
} | |||
@@ -847,10 +847,10 @@ public abstract class DotnetCompile | |||
fillInSharedParameters(command); | |||
addResources(command); | |||
addCompilerSpecificOptions(command); | |||
int referencesOutOfDate=addReferenceFilesets(command, | |||
getOutputFileTimestamp()); | |||
int referencesOutOfDate | |||
= addReferenceFilesets(command, getOutputFileTimestamp()); | |||
//if the refs are out of date, force a build. | |||
boolean forceBuild= referencesOutOfDate > 0; | |||
boolean forceBuild = referencesOutOfDate > 0; | |||
addFilesAndExecute(command, forceBuild); | |||
} | |||
@@ -903,7 +903,7 @@ public abstract class DotnetCompile | |||
* resource setting | |||
*/ | |||
protected void addResources(NetCommand command) { | |||
Enumeration e=resources.elements(); | |||
Enumeration e = resources.elements(); | |||
while (e.hasMoreElements()) { | |||
DotnetResource resource = (DotnetResource) e.nextElement(); | |||
command.addArgument(createResourceParameter(resource)); | |||
@@ -927,7 +927,7 @@ public abstract class DotnetCompile | |||
protected int addReferenceFilesets(NetCommand command, long outputTimestamp) { | |||
int filesOutOfDate = 0; | |||
Hashtable filesToBuild=new Hashtable(); | |||
Hashtable filesToBuild = new Hashtable(); | |||
for (int i = 0; i < referenceFilesets.size(); i++) { | |||
FileSet fs = (FileSet) referenceFilesets.elementAt(i); | |||
filesOutOfDate += command.scanOneFileset( | |||
@@ -936,10 +936,10 @@ public abstract class DotnetCompile | |||
outputTimestamp); | |||
} | |||
//bail out early if there were no files | |||
if (filesToBuild.size()==0) { | |||
if (filesToBuild.size() == 0) { | |||
return 0; | |||
} | |||
StringBuffer referenceList= new StringBuffer(REFERENCE_OPTION); | |||
StringBuffer referenceList = new StringBuffer(REFERENCE_OPTION); | |||
//now scan the hashtable and add the files | |||
Enumeration files = filesToBuild.elements(); | |||
while (files.hasMoreElements()) { | |||
@@ -948,7 +948,7 @@ public abstract class DotnetCompile | |||
referenceList.append(file.toString()); | |||
referenceList.append(getReferenceDelimiter()); | |||
} else { | |||
log("ignoring "+file+" as it is not a managed executable", | |||
log("ignoring " + file + " as it is not a managed executable", | |||
Project.MSG_VERBOSE); | |||
} | |||
@@ -989,7 +989,7 @@ public abstract class DotnetCompile | |||
* @todo look at the PE header of the exe and see if it is managed or not. | |||
*/ | |||
protected static boolean isFileManagedBinary(File file) { | |||
String filename= file.toString().toLowerCase(); | |||
String filename = file.toString().toLowerCase(); | |||
return filename.endsWith(".exe") || filename.endsWith(".dll") | |||
|| filename.endsWith(".netmodule"); | |||
} | |||
@@ -106,7 +106,7 @@ public class DotnetDefine { | |||
* @throws BuildException | |||
*/ | |||
public String getValue(Task owner) throws BuildException { | |||
if (name==null) { | |||
if (name == null) { | |||
throw new BuildException("No name provided for the define element", | |||
owner.getLocation()); | |||
} | |||
@@ -123,7 +123,7 @@ public class DotnetDefine { | |||
* @return true if the condition is valid | |||
*/ | |||
public boolean isSet(Task owner) { | |||
Project p=owner.getProject(); | |||
Project p = owner.getProject(); | |||
if (ifCond != null && p.getProperty(ifCond) == null) { | |||
return false; | |||
} else if (unlessCond != null && p.getProperty(unlessCond) != null) { | |||
@@ -160,10 +160,11 @@ public class Ilasm | |||
* any extra command options? | |||
*/ | |||
protected String extraOptions; | |||
/** | |||
* filesets of references | |||
*/ | |||
protected Vector referenceFilesets =new Vector(); | |||
protected Vector referenceFilesets = new Vector(); | |||
/** | |||
@@ -245,7 +246,8 @@ public class Ilasm | |||
* @ant.attribute ignore="true" | |||
*/ | |||
public void setOwner(String s) { | |||
log("This option is not supported by ILASM as of Beta-2, and will be ignored", Project.MSG_WARN); | |||
log("This option is not supported by ILASM as of Beta-2, " | |||
+ "and will be ignored", Project.MSG_WARN); | |||
} | |||
@@ -523,7 +525,7 @@ public class Ilasm | |||
* @todo look at the PE header of the exe and see if it is managed or not. | |||
*/ | |||
protected static boolean isFileManagedBinary(File file) { | |||
String filename= file.toString().toLowerCase(); | |||
String filename = file.toString().toLowerCase(); | |||
return filename.endsWith(".exe") || filename.endsWith(".dll") | |||
|| filename.endsWith(".netmodule"); | |||
} | |||
@@ -89,17 +89,17 @@ public class ImportTypelib extends Task { | |||
/** | |||
* /sysarray | |||
*/ | |||
private boolean useSysArray=false; | |||
private boolean useSysArray = false; | |||
/** | |||
* /unsafe | |||
*/ | |||
private boolean unsafe=false; | |||
private boolean unsafe = false; | |||
/** | |||
* extra commands? | |||
*/ | |||
private String extraOptions=null; | |||
private String extraOptions = null; | |||
/** | |||
* name the output file. required | |||
@@ -170,7 +170,7 @@ public class ImportTypelib extends Task { | |||
throw new BuildException( | |||
"source file is a directory"); | |||
} | |||
if (namespace==null) { | |||
if (namespace == null) { | |||
throw new BuildException("No namespace"); | |||
} | |||
} | |||
@@ -181,13 +181,13 @@ public class ImportTypelib extends Task { | |||
*/ | |||
public void execute() throws BuildException { | |||
validate(); | |||
log("Importing typelib "+srcFile | |||
+" to assembly "+destFile | |||
+" in namespace "+namespace, Project.MSG_VERBOSE); | |||
log("Importing typelib " + srcFile | |||
+ " to assembly " + destFile | |||
+ " in namespace " + namespace, Project.MSG_VERBOSE); | |||
//rebuild unless the dest file is newer than the source file | |||
if (srcFile.exists() && destFile.exists() && | |||
srcFile.lastModified() <= destFile.lastModified()) { | |||
log("The typelib is up to date",Project.MSG_VERBOSE); | |||
if (srcFile.exists() && destFile.exists() | |||
&& srcFile.lastModified() <= destFile.lastModified()) { | |||
log("The typelib is up to date", Project.MSG_VERBOSE); | |||
return; | |||
} | |||
@@ -205,7 +205,5 @@ public class ImportTypelib extends Task { | |||
command.addArgument("/unsafe"); | |||
} | |||
command.addArgument(extraOptions); | |||
} | |||
} |
@@ -210,7 +210,7 @@ public class NetCommand { | |||
if (argument2 != null && argument2.length() != 0) { | |||
commandLine.createArgument().setValue(argument1 + argument2); | |||
} | |||
} | |||
} | |||
/** | |||
* set up the command sequence.. | |||
@@ -218,10 +218,10 @@ public class NetCommand { | |||
protected void prepareExecutor() { | |||
// default directory to the project's base directory | |||
if (owner == null) { | |||
throw new RuntimeException("no owner"); | |||
throw new RuntimeException("no owner"); | |||
} | |||
if (owner.getProject() == null) { | |||
throw new RuntimeException("Owner has no project"); | |||
throw new RuntimeException("Owner has no project"); | |||
} | |||
File dir = owner.getProject().getBaseDir(); | |||
ExecuteStreamHandler handler = new LogStreamHandler(owner, | |||
@@ -213,7 +213,7 @@ public class VisualBasicCompile extends DotnetCompile { | |||
/** | |||
* Specifies the root namespace for all type declarations. | |||
* @param a root namespace. | |||
* @param rootNamespace a root namespace. | |||
*/ | |||
public void setRootNamespace(String rootNamespace) { | |||
this.rootNamespace = rootNamespace; | |||
@@ -364,7 +364,7 @@ public class VisualBasicCompile extends DotnetCompile { | |||
protected void validate() | |||
throws BuildException { | |||
super.validate(); | |||
if (getDestFile()==null) { | |||
if (getDestFile() == null) { | |||
throw new BuildException("DestFile was not specified"); | |||
} | |||
} | |||
@@ -239,17 +239,17 @@ public class WsdlToDotnet extends Task { | |||
//set source and rebuild options | |||
boolean rebuild = true; | |||
if (srcFile!=null) { | |||
if (srcFile != null) { | |||
command.addArgument(srcFile.toString()); | |||
//rebuild unless the dest file is newer than the source file | |||
if (srcFile.exists() && destFile.exists() && | |||
srcFile.lastModified() <= destFile.lastModified()) { | |||
if (srcFile.exists() && destFile.exists() | |||
&& srcFile.lastModified() <= destFile.lastModified()) { | |||
rebuild = false; | |||
} | |||
} else { | |||
//no source file? must be a url, which has no dependency | |||
//handling | |||
rebuild=true; | |||
rebuild = true; | |||
command.addArgument(url); | |||
} | |||
if (rebuild) { | |||
@@ -71,7 +71,7 @@ import org.apache.tools.ant.Project; | |||
* <p>Moved out of MatchingTask to make it a standalone object that | |||
* could be referenced (by scripts for example). | |||
* | |||
* @author Arnout J. Kuiper <a href="mailto:ajkuiper@wxs.nl">ajkuiper@wxs.nl</a> | |||
* @author Arnout J. Kuiper <a href="mailto:ajkuiper@wxs.nl">ajkuiper@wxs.nl</a> | |||
* @author Stefano Mazzocchi <a href="mailto:stefano@apache.org">stefano@apache.org</a> | |||
* @author Sam Ruby <a href="mailto:rubys@us.ibm.com">rubys@us.ibm.com</a> | |||
* @author Jon S. Stevens <a href="mailto:jon@clearink.com">jon@clearink.com</a> | |||
@@ -85,7 +85,7 @@ public class PatternSet extends DataType { | |||
/** | |||
* inner class to hold a name on list. "If" and "Unless" attributes | |||
* may be used to invalidate the entry based on the existence of a | |||
* may be used to invalidate the entry based on the existence of a | |||
* property (typically set thru the use of the Available task). | |||
*/ | |||
public class NameEntry { | |||
@@ -93,8 +93,8 @@ public class PatternSet extends DataType { | |||
private String ifCond; | |||
private String unlessCond; | |||
public void setName(String name) { | |||
this.name = name; | |||
public void setName(String name) { | |||
this.name = name; | |||
} | |||
public void setIf(String cond) { | |||
@@ -109,8 +109,8 @@ public class PatternSet extends DataType { | |||
return name; | |||
} | |||
public String evalName(Project p) { | |||
return valid(p) ? name : null; | |||
public String evalName(Project p) { | |||
return valid(p) ? name : null; | |||
} | |||
private boolean valid(Project p) { | |||
@@ -127,7 +127,7 @@ public class PatternSet extends DataType { | |||
if ((ifCond != null) || (unlessCond != null)) { | |||
buf.append(":"); | |||
String connector = ""; | |||
if (ifCond != null) { | |||
buf.append("if->"); | |||
buf.append(ifCond); | |||
@@ -153,7 +153,7 @@ public class PatternSet extends DataType { | |||
* instance. | |||
* | |||
* <p>You must not set another attribute or nest elements inside | |||
* this element if you make it a reference.</p> | |||
* this element if you make it a reference.</p> | |||
*/ | |||
public void setRefid(Reference r) throws BuildException { | |||
if (!includeList.isEmpty() || !excludeList.isEmpty()) { | |||
@@ -202,7 +202,7 @@ public class PatternSet extends DataType { | |||
} | |||
return addPatternToList(includesFileList); | |||
} | |||
/** | |||
* add a name entry on the exclude list | |||
*/ | |||
@@ -212,7 +212,7 @@ public class PatternSet extends DataType { | |||
} | |||
return addPatternToList(excludeList); | |||
} | |||
/** | |||
* add a name entry on the exclude files list | |||
*/ | |||
@@ -224,7 +224,7 @@ public class PatternSet extends DataType { | |||
} | |||
/** | |||
* Appends <code>includes</code> to the current list of include patterns. | |||
* Appends <code>includes</code> to the current list of include patterns. | |||
* Patterns may be separated by a comma or a space. | |||
* | |||
* @param includes the string containing the include patterns | |||
@@ -242,7 +242,7 @@ public class PatternSet extends DataType { | |||
} | |||
/** | |||
* Appends <code>excludes</code> to the current list of exclude patterns. | |||
* Appends <code>excludes</code> to the current list of exclude patterns. | |||
* Patterns may be separated by a comma or a space. | |||
* | |||
* @param excludes the string containing the exclude patterns | |||
@@ -271,7 +271,7 @@ public class PatternSet extends DataType { | |||
/** | |||
* Sets the name of the file containing the includes patterns. | |||
* | |||
* @param includesFile The file to fetch the include patterns from. | |||
* @param includesFile The file to fetch the include patterns from. | |||
*/ | |||
public void setIncludesfile(File includesFile) throws BuildException { | |||
if (isReference()) { | |||
@@ -283,7 +283,7 @@ public class PatternSet extends DataType { | |||
/** | |||
* Sets the name of the file containing the excludes patterns. | |||
* | |||
* @param excludesFile The file to fetch the exclude patterns from. | |||
* @param excludesFile The file to fetch the exclude patterns from. | |||
*/ | |||
public void setExcludesfile(File excludesFile) throws BuildException { | |||
if (isReference()) { | |||
@@ -291,21 +291,21 @@ public class PatternSet extends DataType { | |||
} | |||
createExcludesFile().setName(excludesFile.getAbsolutePath()); | |||
} | |||
/** | |||
* Reads path matching patterns from a file and adds them to the | |||
* includes or excludes list (as appropriate). | |||
* includes or excludes list (as appropriate). | |||
*/ | |||
private void readPatterns(File patternfile, Vector patternlist, Project p) | |||
throws BuildException { | |||
BufferedReader patternReader = null; | |||
try { | |||
// Get a FileReader | |||
patternReader = | |||
new BufferedReader(new FileReader(patternfile)); | |||
// Create one NameEntry in the appropriate pattern list for each | |||
patternReader = | |||
new BufferedReader(new FileReader(patternfile)); | |||
// Create one NameEntry in the appropriate pattern list for each | |||
// line in the file. | |||
String line = patternReader.readLine(); | |||
while (line != null) { | |||
@@ -316,14 +316,14 @@ public class PatternSet extends DataType { | |||
line = patternReader.readLine(); | |||
} | |||
} catch (IOException ioe) { | |||
String msg = "An error occured while reading from pattern file: " | |||
String msg = "An error occured while reading from pattern file: " | |||
+ patternfile; | |||
throw new BuildException(msg, ioe); | |||
} finally { | |||
if (null != patternReader) { | |||
try { | |||
patternReader.close(); | |||
} catch (IOException ioe) { | |||
} catch (IOException ioe) { | |||
//Ignore exception | |||
} | |||
} | |||
@@ -344,7 +344,7 @@ public class PatternSet extends DataType { | |||
createInclude().setName(incl[i]); | |||
} | |||
} | |||
String[] excl = other.getExcludePatterns(p); | |||
if (excl != null) { | |||
for (int i = 0; i < excl.length; i++) { | |||
@@ -384,14 +384,14 @@ public class PatternSet extends DataType { | |||
if (isReference()) { | |||
return getRef(p).hasPatterns(p); | |||
} else { | |||
return includesFileList.size() > 0 || excludesFileList.size() > 0 | |||
return includesFileList.size() > 0 || excludesFileList.size() > 0 | |||
|| includeList.size() > 0 || excludeList.size() > 0; | |||
} | |||
} | |||
/** | |||
* Performs the check for circular references and returns the | |||
* referenced PatternSet. | |||
* referenced PatternSet. | |||
*/ | |||
private PatternSet getRef(Project p) { | |||
if (!isChecked()) { | |||
@@ -399,7 +399,7 @@ public class PatternSet extends DataType { | |||
stk.push(this); | |||
dieOnCircularReference(stk, p); | |||
} | |||
Object o = getRefid().getReferencedObject(p); | |||
if (!(o instanceof PatternSet)) { | |||
String msg = getRefid().getRefId() + " doesn\'t denote a patternset"; | |||
@@ -418,7 +418,7 @@ public class PatternSet extends DataType { | |||
} | |||
Vector tmpNames = new Vector(); | |||
for (Enumeration e = list.elements() ; e.hasMoreElements() ;) { | |||
for (Enumeration e = list.elements(); e.hasMoreElements();) { | |||
NameEntry ne = (NameEntry) e.nextElement(); | |||
String pattern = ne.evalName(p); | |||
if (pattern != null && pattern.length() > 0) { | |||
@@ -430,7 +430,7 @@ public class PatternSet extends DataType { | |||
tmpNames.copyInto(result); | |||
return result; | |||
} | |||
/** | |||
* Read includesfile ot excludesfile if not already done so. | |||
*/ | |||
@@ -473,8 +473,8 @@ public class PatternSet extends DataType { | |||
} | |||
public String toString() { | |||
return "patternSet{ includes: " + includeList + | |||
" excludes: " + excludeList + " }"; | |||
return "patternSet{ includes: " + includeList | |||
+ " excludes: " + excludeList + " }"; | |||
} | |||
} |