git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274856 13f79535-47bb-0310-9956-ffa450edef68master
@@ -92,6 +92,12 @@ public class DemuxOutputStream extends OutputStream { | |||
/** Initial buffer size. */ | |||
private static final int INTIAL_SIZE = 132; | |||
/** Carriage return */ | |||
private static final int CR = 0x0d; | |||
/** Linefeed */ | |||
private static final int LF = 0x0a; | |||
/** Mapping from thread to buffer (Thread to BufferInfo). */ | |||
private Hashtable buffers = new Hashtable(); | |||
@@ -243,14 +249,23 @@ public class DemuxOutputStream extends OutputStream { | |||
} | |||
} | |||
public void write(byte b[], int off, int len) throws IOException { | |||
/** | |||
* Write a block of characters to the output stream | |||
* | |||
* @param b the array containg the data | |||
* @param off the offset into the array where data starts | |||
* @param len the length of block | |||
* | |||
* @throws IOException if the data cannot be written into the stream. | |||
*/ | |||
public void write(byte[] b, int off, int len) throws IOException { | |||
// find the line breaks and pass other chars through in blocks | |||
int offset = off; | |||
int blockStartOffset = offset; | |||
int remaining = len; | |||
BufferInfo bufferInfo = getBufferInfo(); | |||
while (remaining > 0) { | |||
while (remaining > 0 && b[offset] != 0x0a && b[offset] != 0x0d) { | |||
while (remaining > 0 && b[offset] != LF && b[offset] != CR) { | |||
offset++; | |||
remaining--; | |||
} | |||
@@ -259,7 +274,7 @@ public class DemuxOutputStream extends OutputStream { | |||
if (blockLength > 0) { | |||
bufferInfo.buffer.write(b, blockStartOffset, blockLength); | |||
} | |||
while (remaining > 0 && (b[offset] == 0x0a || b[offset] == 0x0d)) { | |||
while (remaining > 0 && (b[offset] == LF || b[offset] == CR)) { | |||
write(b[offset]); | |||
offset++; | |||
remaining--; | |||
@@ -655,7 +655,7 @@ public class DirectoryScanner | |||
// put in the newroots vector the include patterns without | |||
// wildcard tokens | |||
for (int icounter = 0; icounter < includes.length; icounter++) { | |||
String newpattern = | |||
String newpattern = | |||
SelectorUtils.rtrimWildcardTokens(includes[icounter]); | |||
// check whether the candidate new pattern has a parent | |||
boolean hasParent = false; | |||
@@ -716,19 +716,19 @@ public class DirectoryScanner | |||
} else { | |||
if (currentelement.length() > 0) { | |||
if (currentelement.charAt(currentelement.length() | |||
- 1) | |||
- 1) | |||
!= File.separatorChar) { | |||
currentelement = | |||
currentelement = | |||
currentelement + File.separatorChar; | |||
} | |||
} | |||
scandir(myfile, currentelement, true); | |||
} | |||
} else { | |||
if (isCaseSensitive | |||
if (isCaseSensitive | |||
&& originalpattern.equals(currentelement)) { | |||
accountForIncludedFile(currentelement, myfile); | |||
} else if (!isCaseSensitive | |||
} else if (!isCaseSensitive | |||
&& originalpattern.equalsIgnoreCase(currentelement)) { | |||
accountForIncludedFile(currentelement, myfile); | |||
} | |||
@@ -1160,7 +1160,7 @@ public class DirectoryScanner | |||
* @since Ant 1.6 | |||
*/ | |||
private File findFileCaseInsensitive(File base, String path) { | |||
File f = findFileCaseInsensitive(base, | |||
File f = findFileCaseInsensitive(base, | |||
SelectorUtils.tokenizePath(path)); | |||
return f == null ? new File(base, path) : f; | |||
} | |||
@@ -1211,7 +1211,7 @@ public class DirectoryScanner | |||
* basedir? | |||
* @since Ant 1.6 | |||
*/ | |||
private boolean isSymlink(File base, Vector pathElements) { | |||
private boolean isSymlink(File base, Vector pathElements) { | |||
if (pathElements.size() > 0) { | |||
String current = (String) pathElements.remove(0); | |||
try { | |||
@@ -502,8 +502,8 @@ public class IntrospectionHelper implements BuildListener { | |||
return; | |||
} else { | |||
// Not whitespace - fail | |||
String msg = project.getElementName(element) + | |||
" doesn't support nested text data."; | |||
String msg = project.getElementName(element) | |||
+ " doesn't support nested text data."; | |||
throw new BuildException(msg); | |||
} | |||
} | |||
@@ -703,8 +703,8 @@ public class IntrospectionHelper implements BuildListener { | |||
throws BuildException { | |||
Class at = (Class) attributeTypes.get(attributeName); | |||
if (at == null) { | |||
String msg = "Class " + bean.getName() + | |||
" doesn't support the \"" + attributeName + "\" attribute."; | |||
String msg = "Class " + bean.getName() | |||
+ " doesn't support the \"" + attributeName + "\" attribute."; | |||
throw new BuildException(msg); | |||
} | |||
return at; | |||
@@ -99,16 +99,16 @@ public class Main implements AntMain { | |||
private static PrintStream err = System.err; | |||
/** The build targets. */ | |||
private Vector targets = new Vector(5); | |||
private Vector targets = new Vector(); | |||
/** Set of properties that can be used by tasks. */ | |||
private Properties definedProps = new Properties(); | |||
/** Names of classes to add as listeners to project. */ | |||
private Vector listeners = new Vector(5); | |||
private Vector listeners = new Vector(1); | |||
/** File names of property files to load on startup. */ | |||
private Vector propertyFiles = new Vector(5); | |||
private Vector propertyFiles = new Vector(1); | |||
/** Indicates whether this build is to support interactive input */ | |||
private boolean allowInput = true; | |||
@@ -334,8 +334,8 @@ public class Main implements AntMain { | |||
+ "permissions."; | |||
throw new BuildException(msg); | |||
} catch (ArrayIndexOutOfBoundsException aioobe) { | |||
String msg = "You must specify a log file when " + | |||
"using the -log argument"; | |||
String msg = "You must specify a log file when " | |||
+ "using the -log argument"; | |||
throw new BuildException(msg); | |||
} | |||
} else if (arg.equals("-buildfile") || arg.equals("-file") | |||
@@ -344,8 +344,8 @@ public class Main implements AntMain { | |||
buildFile = new File(args[i + 1].replace('/', File.separatorChar)); | |||
i++; | |||
} catch (ArrayIndexOutOfBoundsException aioobe) { | |||
String msg = "You must specify a buildfile when " + | |||
"using the -buildfile argument"; | |||
String msg = "You must specify a buildfile when " | |||
+ "using the -buildfile argument"; | |||
throw new BuildException(msg); | |||
} | |||
} else if (arg.equals("-listener")) { | |||
@@ -353,8 +353,8 @@ public class Main implements AntMain { | |||
listeners.addElement(args[i + 1]); | |||
i++; | |||
} catch (ArrayIndexOutOfBoundsException aioobe) { | |||
String msg = "You must specify a classname when " + | |||
"using the -listener argument"; | |||
String msg = "You must specify a classname when " | |||
+ "using the -listener argument"; | |||
throw new BuildException(msg); | |||
} | |||
} else if (arg.startsWith("-D")) { | |||
@@ -421,8 +421,8 @@ public class Main implements AntMain { | |||
propertyFiles.addElement(args[i + 1]); | |||
i++; | |||
} catch (ArrayIndexOutOfBoundsException aioobe) { | |||
String msg = "You must specify a property filename when " + | |||
"using the -propertyfile argument"; | |||
String msg = "You must specify a property filename when " | |||
+ "using the -propertyfile argument"; | |||
throw new BuildException(msg); | |||
} | |||
} else if (arg.equals("-k") || arg.equals("-keep-going")) { | |||
@@ -483,6 +483,7 @@ public class Main implements AntMain { | |||
try { | |||
fis.close(); | |||
} catch (IOException e) { | |||
// ignore | |||
} | |||
} | |||
} | |||
@@ -502,7 +503,8 @@ public class Main implements AntMain { | |||
} | |||
if (logTo != null) { | |||
out = err = logTo; | |||
out = logTo; | |||
err = logTo; | |||
System.setOut(out); | |||
System.setErr(out); | |||
} | |||
@@ -605,8 +607,8 @@ public class Main implements AntMain { | |||
// use a system manager that prevents from System.exit() | |||
// only in JDK > 1.1 | |||
SecurityManager oldsm = null; | |||
if (!JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_0) && | |||
!JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) { | |||
if (!JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_0) | |||
&& !JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) { | |||
oldsm = System.getSecurityManager(); | |||
//SecurityManager can not be installed here for backwards | |||
@@ -176,8 +176,8 @@ public class PathTokenizer { | |||
// make sure we aren't going to get the path separator next | |||
if (!nextToken.equals(File.pathSeparator)) { | |||
if (nextToken.equals(":")) { | |||
if (!token.startsWith("/") && !token.startsWith("\\") | |||
&& !token.startsWith(".") | |||
if (!token.startsWith("/") && !token.startsWith("\\") | |||
&& !token.startsWith(".") | |||
&& !token.startsWith("..")) { | |||
// it indeed is a drive spec, get the next bit | |||
String oneMore = tokenizer.nextToken().trim(); | |||
@@ -2029,7 +2029,8 @@ public class Project { | |||
// Should move to a separate public class - and have API to add | |||
// listeners, etc. | |||
private static class AntRefTable extends Hashtable { | |||
Project project; | |||
private Project project; | |||
public AntRefTable(Project project) { | |||
super(); | |||
this.project = project; | |||
@@ -132,7 +132,7 @@ public class ProjectHelper { | |||
// Since the tree is composed of UE and RC - it can be reused ! | |||
// protected Hashtable processedFiles=new Hashtable(); | |||
protected Vector importStack = new Vector(); | |||
private Vector importStack = new Vector(); | |||
// Temporary - until we figure a better API | |||
/** EXPERIMENTAL WILL_CHANGE | |||
@@ -146,6 +146,8 @@ public class ProjectHelper { | |||
* Import stack. | |||
* Used to keep track of imported files. Error reporting should | |||
* display the import path. | |||
* | |||
* @return the stack of import source objects. | |||
*/ | |||
public Vector getImportStack() { | |||
return importStack; | |||
@@ -229,8 +231,8 @@ public class ProjectHelper { | |||
String helperClassName = rd.readLine(); | |||
rd.close(); | |||
if (helperClassName != null && | |||
!"".equals(helperClassName)) { | |||
if (helperClassName != null | |||
&& !"".equals(helperClassName)) { | |||
helper = newHelper(helperClassName); | |||
} | |||
@@ -349,8 +349,8 @@ public class RuntimeConfigurable implements Serializable { | |||
} | |||
// Configure the object | |||
Object target = (wrappedObject instanceof TypeAdapter) ? | |||
((TypeAdapter) wrappedObject).getProxy() : wrappedObject; | |||
Object target = (wrappedObject instanceof TypeAdapter) | |||
? ((TypeAdapter) wrappedObject).getProxy() : wrappedObject; | |||
//PropertyHelper ph=PropertyHelper.getPropertyHelper(p); | |||
IntrospectionHelper ih = | |||
@@ -77,12 +77,12 @@ public class Target implements TaskContainer { | |||
/** The "unless" condition to test on execution. */ | |||
private String unlessCondition = ""; | |||
/** List of targets this target is dependent on. */ | |||
private List/*<String>*/ dependencies = null; | |||
private List dependencies = null; | |||
/** Children of this target (tasks and data types). */ | |||
private List/*<Task|RuntimeConfigurable>*/ children = new ArrayList(5); | |||
private List children = new ArrayList(); | |||
/** Position in task list */ | |||
private int taskPosition = 0; | |||
/** Project this target belongs to. */ | |||
private Project project; | |||
/** Description of this target, if any. */ | |||
@@ -180,7 +180,7 @@ public class Target implements TaskContainer { | |||
public void startImportedTasks() { | |||
importedTasks = new ArrayList(); | |||
} | |||
/** | |||
* Adds a task to this target. | |||
* | |||
@@ -228,7 +228,7 @@ public class Target implements TaskContainer { | |||
} | |||
} | |||
return (Task[])tasks.toArray(new Task[tasks.size()]); | |||
return (Task[]) tasks.toArray(new Task[tasks.size()]); | |||
} | |||
/** | |||
@@ -204,7 +204,8 @@ public abstract class Task extends ProjectComponent { | |||
* | |||
* @exception BuildException if someting goes wrong with the build | |||
*/ | |||
public void init() throws BuildException {} | |||
public void init() throws BuildException { | |||
} | |||
/** | |||
* Called by the project to let the task do its work. This method may be | |||
@@ -215,7 +216,8 @@ public abstract class Task extends ProjectComponent { | |||
* | |||
* @exception BuildException if something goes wrong with the build | |||
*/ | |||
public void execute() throws BuildException {} | |||
public void execute() throws BuildException { | |||
} | |||
/** | |||
* Returns the file/location where this task was defined. | |||
@@ -60,17 +60,21 @@ package org.apache.tools.ant; | |||
* @author costin@dnt.ro | |||
* @author peter reilly | |||
*/ | |||
public interface TypeAdapter { | |||
public interface TypeAdapter { | |||
/** | |||
* Sets the project | |||
* | |||
* @param p the project instance. | |||
*/ | |||
public void setProject(Project p); | |||
void setProject(Project p); | |||
/** | |||
* Gets the project | |||
* | |||
* @return the project instance. | |||
*/ | |||
public Project getProject(); | |||
Project getProject(); | |||
/** | |||
* Sets the proxy object, whose methods are going to be | |||
@@ -81,17 +85,20 @@ public interface TypeAdapter { | |||
* | |||
* @param o The target object. Must not be <code>null</code>. | |||
*/ | |||
public void setProxy(Object o); | |||
void setProxy(Object o); | |||
/** | |||
* Returns the proxy object. | |||
* | |||
* @return the target proxy object | |||
*/ | |||
public Object getProxy(); | |||
Object getProxy(); | |||
/** | |||
* Check if the proxy class matchs the criteria | |||
* Check if the proxy class is compatible with this adapter - i.e. | |||
* the adapter will be able to adapt instances of the give class. | |||
* | |||
* @patam proxyClass the class to be checked. | |||
*/ | |||
public void checkProxyClass(Class proxyClass); | |||
void checkProxyClass(Class proxyClass); | |||
} |
@@ -439,8 +439,9 @@ public class UnknownElement extends Task { | |||
*/ | |||
public String getTaskName() { | |||
//return elementName; | |||
return realThing == null || !(realThing instanceof Task) ? | |||
super.getTaskName() : ((Task) realThing).getTaskName(); | |||
return realThing == null | |||
|| !(realThing instanceof Task) ? super.getTaskName() | |||
: ((Task) realThing).getTaskName(); | |||
} | |||
/** | |||
@@ -481,6 +482,4 @@ public class UnknownElement extends Task { | |||
} | |||
return false; | |||
} | |||
}// UnknownElement | |||
} |
@@ -92,7 +92,7 @@ public class XmlLogger implements BuildLogger { | |||
private PrintStream outStream; | |||
/** DocumentBuilder to use when creating the document to start with. */ | |||
private static final DocumentBuilder builder = getDocumentBuilder(); | |||
private static DocumentBuilder builder = getDocumentBuilder(); | |||
/** | |||
* Returns a default DocumentBuilder instance or throws an | |||
@@ -230,6 +230,7 @@ public class XmlLogger implements BuildLogger { | |||
try { | |||
out.close(); | |||
} catch (IOException e) { | |||
// ignore | |||
} | |||
} | |||
} | |||
@@ -104,7 +104,7 @@ public class ProjectHelper2 extends ProjectHelper { | |||
public void parse(Project project, Object source) | |||
throws BuildException { | |||
this.getImportStack().addElement(source); | |||
getImportStack().addElement(source); | |||
//System.out.println("Adding " + source); | |||
AntXMLContext context = null; | |||
context = (AntXMLContext) project.getReference("ant.parsing.context"); | |||
@@ -116,7 +116,7 @@ public class ProjectHelper2 extends ProjectHelper { | |||
project.addReference("ant.targets", context.getTargets()); | |||
} | |||
if (this.getImportStack().size() > 1) { | |||
if (getImportStack().size() > 1) { | |||
// we are in an imported file. | |||
context.setIgnoreProjectTag(true); | |||
context.getCurrentTarget().startImportedTasks(); | |||
@@ -76,6 +76,12 @@ public class LogOutputStream extends OutputStream { | |||
/** Initial buffer size. */ | |||
private static final int INTIAL_SIZE = 132; | |||
/** Carriage return */ | |||
private static final int CR = 0x0d; | |||
/** Linefeed */ | |||
private static final int LF = 0x0a; | |||
private ByteArrayOutputStream buffer | |||
= new ByteArrayOutputStream(INTIAL_SIZE); | |||
private boolean skip = false; | |||
@@ -162,13 +168,22 @@ public class LogOutputStream extends OutputStream { | |||
return level; | |||
} | |||
public void write(byte b[], int off, int len) throws IOException { | |||
/** | |||
* Write a block of characters to the output stream | |||
* | |||
* @param b the array containg the data | |||
* @param off the offset into the array where data starts | |||
* @param len the length of block | |||
* | |||
* @throws IOException if the data cannot be written into the stream. | |||
*/ | |||
public void write(byte[] b, int off, int len) throws IOException { | |||
// find the line breaks and pass other chars through in blocks | |||
int offset = off; | |||
int blockStartOffset = offset; | |||
int remaining = len; | |||
while (remaining > 0) { | |||
while (remaining > 0 && b[offset] != 0x0a && b[offset] != 0x0d) { | |||
while (remaining > 0 && b[offset] != LF && b[offset] != CR) { | |||
offset++; | |||
remaining--; | |||
} | |||
@@ -177,7 +192,7 @@ public class LogOutputStream extends OutputStream { | |||
if (blockLength > 0) { | |||
buffer.write(b, blockStartOffset, blockLength); | |||
} | |||
while (remaining > 0 && (b[offset] == 0x0a || b[offset] == 0x0d)) { | |||
while (remaining > 0 && (b[offset] == LF || b[offset] == CR)) { | |||
write(b[offset]); | |||
offset++; | |||
remaining--; | |||
@@ -298,6 +298,7 @@ public class ANTLR extends Task { | |||
public void execute() throws BuildException { | |||
validateAttributes(); | |||
//TODO: use ANTLR to parse the grammar file to do this. | |||
File generatedFile = getGeneratedFile(); | |||
boolean targetIsOutOfDate = | |||
@@ -437,6 +438,7 @@ public class ANTLR extends Task { | |||
/** | |||
* Whether the antlr version is 2.7.2 (or higher). | |||
* | |||
* @return true if the version of Antlr present is 2.7.2 or later. | |||
* @since Ant 1.6 | |||
*/ | |||
protected boolean is272() { | |||
@@ -177,8 +177,8 @@ public class Cab extends MatchingTask { | |||
boolean upToDate = true; | |||
for (int i = 0; i < files.size() && upToDate; i++) { | |||
String file = files.elementAt(i).toString(); | |||
if (fileUtils.resolveFile(baseDir, file).lastModified() > | |||
cabFile.lastModified()) { | |||
if (fileUtils.resolveFile(baseDir, file).lastModified() | |||
> cabFile.lastModified()) { | |||
upToDate = false; | |||
} | |||
} | |||
@@ -296,7 +296,9 @@ public class EchoProperties extends Task { | |||
if (null != in) { | |||
in.close(); | |||
} | |||
} catch (IOException ioe) {} | |||
} catch (IOException ioe) { | |||
//ignore | |||
} | |||
} | |||
} | |||
@@ -347,6 +349,7 @@ public class EchoProperties extends Task { | |||
try { | |||
os.close(); | |||
} catch (IOException e) { | |||
//ignore | |||
} | |||
} | |||
} | |||
@@ -390,7 +393,7 @@ public class EchoProperties extends Task { | |||
String name; | |||
Enumeration e = props.propertyNames(); | |||
while (e.hasMoreElements()) { | |||
name = (String)e.nextElement(); | |||
name = (String) e.nextElement(); | |||
Element propElement = doc.createElement(PROPERTY); | |||
propElement.setAttribute(ATTR_NAME, name); | |||
propElement.setAttribute(ATTR_VALUE, props.getProperty(name)); | |||
@@ -53,8 +53,6 @@ | |||
*/ | |||
package org.apache.tools.ant.taskdefs.optional; | |||
import java.io.File; | |||
import java.io.FileInputStream; | |||
import java.io.FileOutputStream; | |||
@@ -84,7 +82,8 @@ import org.apache.tools.ant.types.Reference; | |||
* iControl generates a control file that you can refer to | |||
* from this task using the controlfile attribute. | |||
* iContract is at | |||
* <a href="http://www.reliable-systems.com/tools/">http://www.reliable-systems.com/tools/</a> | |||
* <a href="http://www.reliable-systems.com/tools/"> | |||
* http://www.reliable-systems.com/tools/</a> | |||
* <p/> | |||
* Thanks to Rainer Schmitz for enhancements and comments. | |||
* | |||
@@ -104,55 +103,63 @@ import org.apache.tools.ant.types.Reference; | |||
* </tr> | |||
* <tr> | |||
* <td valign="top">instrumentdir</td> | |||
* <td valign="top">Indicates where the instrumented source files should go.</td> | |||
* <td valign="top">Indicates where the instrumented source | |||
* files should go.</td> | |||
* <td valign="top" align="center">Yes</td> | |||
* </tr> | |||
* <tr> | |||
* <td valign="top">repositorydir</td> | |||
* <td valign="top">Indicates where the repository source files should go.</td> | |||
* <td valign="top">Indicates where the repository source | |||
* files should go.</td> | |||
* <td valign="top" align="center">Yes</td> | |||
* </tr> | |||
* <tr> | |||
* <td valign="top">builddir</td> | |||
* <td valign="top">Indicates where the compiled instrumented classes should go. | |||
* Defaults to the value of instrumentdir. | |||
* <td valign="top">Indicates where the compiled instrumented | |||
* classes should go. Defaults to the value of | |||
* instrumentdir. | |||
* </p> | |||
* <em>NOTE:</em> Don't use the same directory for compiled instrumented classes | |||
* and uninstrumented classes. It will break the dependency checking. (Classes will | |||
* not be reinstrumented if you change them).</td> | |||
* <em>NOTE:</em> Don't use the same directory for compiled | |||
* instrumented classes and uninstrumented classes. It will break the | |||
* dependency checking. (Classes will not be reinstrumented if you | |||
* change them).</td> | |||
* <td valign="top" align="center">No</td> | |||
* </tr> | |||
* <tr> | |||
* <td valign="top">repbuilddir</td> | |||
* <td valign="top">Indicates where the compiled repository classes should go. | |||
* Defaults to the value of repositorydir.</td> | |||
* <td valign="top">Indicates where the compiled repository classes | |||
* should go. Defaults to the value of repositorydir.</td> | |||
* <td valign="top" align="center">No</td> | |||
* </tr> | |||
* <tr> | |||
* <td valign="top">pre</td> | |||
* <td valign="top">Indicates whether or not to instrument for preconditions. | |||
* Defaults to <code>true</code> unless controlfile is specified, in which case it | |||
* defaults to <code>false</code>.</td> | |||
* <td valign="top">Indicates whether or not to instrument for | |||
* preconditions. Defaults to <code>true</code> unless | |||
* controlfile is specified, in which case it defaults | |||
* to <code>false</code>.</td> | |||
* <td valign="top" align="center">No</td> | |||
* </tr> | |||
* <tr> | |||
* <td valign="top">post</td> | |||
* <td valign="top">Indicates whether or not to instrument for postconditions. | |||
* Defaults to <code>true</code> unless controlfile is specified, in which case it | |||
* defaults to <code>false</code>.</td> | |||
* <td valign="top">Indicates whether or not to instrument for | |||
* postconditions. Defaults to <code>true</code> unless | |||
* controlfile is specified, in which case it defaults | |||
* to <code>false</code>.</td> | |||
* <td valign="top" align="center">No</td> | |||
* </tr> | |||
* <tr> | |||
* <td valign="top">invariant</td> | |||
* <td valign="top">Indicates whether or not to instrument for invariants. | |||
* Defaults to <code>true</code> unless controlfile is specified, in which case it | |||
* defaults to <code>false</code>.</td> | |||
* Defaults to <code>true</code> unless controlfile is | |||
* specified, in which case it defaults to | |||
* <code>false</code>.</td> | |||
* <td valign="top" align="center">No</td> | |||
* </tr> | |||
* <tr> | |||
* <td valign="top">failthrowable</td> | |||
* <td valign="top">The full name of the Throwable (Exception) that should be | |||
* thrown when an assertion is violated. Defaults to <code>java.lang.Error</code></td> | |||
* <td valign="top">The full name of the Throwable (Exception) that | |||
* should be thrown when an assertion is violated. | |||
* Defaults to <code>java.lang.Error</code></td> | |||
* <td valign="top" align="center">No</td> | |||
* </tr> | |||
* <tr> | |||
@@ -180,22 +187,28 @@ import org.apache.tools.ant.types.Reference; | |||
* </tr> | |||
* <tr> | |||
* <td valign="top">controlfile</td> | |||
* <td valign="top">The name of the control file to pass to iContract. Consider using iControl to generate the file. | |||
* Default is not to pass a file. </td> | |||
* <td valign="top" align="center">Only if <code>updateicontrol=true</code></td> | |||
* <td valign="top">The name of the control file to pass to iContract. | |||
* Consider using iControl to generate the file. | |||
* Default is not to pass a file. </td> | |||
* <td valign="top" align="center"> | |||
* Only if <code>updateicontrol=true</code></td> | |||
* </tr> | |||
* <tr> | |||
* <td valign="top">classdir</td> | |||
* <td valign="top">Indicates where compiled (unistrumented) classes are located. | |||
* This is required in order to properly update the icontrol.properties file, not | |||
* for instrumentation.</td> | |||
* <td valign="top" align="center">Only if <code>updateicontrol=true</code></td> | |||
* <td valign="top">Indicates where compiled (unistrumented) classes are | |||
* located. This is required in order to properly update | |||
* the icontrol.properties file, not for instrumentation. | |||
* </td> | |||
* <td valign="top" align="center">Only if | |||
* <code>updateicontrol=true</code></td> | |||
* </tr> | |||
* <tr> | |||
* <td valign="top">targets</td> | |||
* <td valign="top">Name of the file that will be generated by this task, which lists all the | |||
* classes that iContract will instrument. If specified, the file will not be deleted after execution. | |||
* If not specified, a file will still be created, but it will be deleted after execution.</td> | |||
* <td valign="top">Name of the file that will be generated by this task, | |||
* which lists all the classes that iContract will | |||
* instrument. If specified, the file will not be deleted | |||
* after execution. If not specified, a file will still | |||
* be created, but it will be deleted after execution.</td> | |||
* <td valign="top" align="center">No</td> | |||
* </tr> | |||
* </table> | |||
@@ -228,8 +241,9 @@ import org.apache.tools.ant.types.Reference; | |||
*/ | |||
public class IContract extends MatchingTask { | |||
private static final String ICONTROL_PROPERTIES_HEADER = | |||
" You might want to set classRoot to point to your normal compilation class root directory."; | |||
private static final String ICONTROL_PROPERTIES_HEADER | |||
= "You might want to set classRoot to point to your normal " | |||
+ "compilation class root directory."; | |||
/** compiler to use for instrumenation */ | |||
private String icCompiler = "javac"; | |||
@@ -288,8 +302,12 @@ public class IContract extends MatchingTask { | |||
private boolean invariant = true; | |||
private boolean invariantModified = false; | |||
/** Indicates whether or not to instrument all files regardless of timestamp */ | |||
// can't be explicitly set, is set if control file exists and is newer than any source file | |||
/** | |||
* Indicates whether or not to instrument all files regardless of timestamp | |||
* | |||
* Can't be explicitly set, is set if control file exists and is newer | |||
* than any source file | |||
*/ | |||
private boolean instrumentall = false; | |||
/** | |||
@@ -534,13 +552,14 @@ public class IContract extends MatchingTask { | |||
} | |||
// We want to be notified if iContract jar is missing. This makes life easier for the user | |||
// who didn't understand that iContract is a separate library (duh!) | |||
// We want to be notified if iContract jar is missing. | |||
// This makes life easier for the user who didn't understand | |||
// that iContract is a separate library (duh!) | |||
getProject().addBuildListener(new IContractPresenceDetector()); | |||
// Prepare the directories for iContract. iContract will make them if they | |||
// don't exist, but for some reason I don't know, it will complain about the REP files | |||
// afterwards | |||
// Prepare the directories for iContract. iContract will make | |||
// them if they don't exist, but for some reason I don't know, | |||
// it will complain about the REP files afterwards | |||
Mkdir mkdir = (Mkdir) getProject().createTask("mkdir"); | |||
mkdir.setDir(instrumentDir); | |||
@@ -553,42 +572,60 @@ public class IContract extends MatchingTask { | |||
// Set the classpath that is needed for regular Javac compilation | |||
Path baseClasspath = createClasspath(); | |||
// Might need to add the core classes if we're not using Sun's Javac (like Jikes) | |||
// Might need to add the core classes if we're not using | |||
// Sun's Javac (like Jikes) | |||
String compiler = getProject().getProperty("build.compiler"); | |||
ClasspathHelper classpathHelper = new ClasspathHelper(compiler); | |||
classpathHelper.modify(baseClasspath); | |||
// Create the classpath required to compile the sourcefiles BEFORE instrumentation | |||
// Create the classpath required to compile the sourcefiles | |||
// BEFORE instrumentation | |||
Path beforeInstrumentationClasspath = ((Path) baseClasspath.clone()); | |||
beforeInstrumentationClasspath.append(new Path(getProject(), | |||
srcDir.getAbsolutePath())); | |||
// Create the classpath required to compile the sourcefiles AFTER instrumentation | |||
// Create the classpath required to compile the sourcefiles | |||
// AFTER instrumentation | |||
Path afterInstrumentationClasspath = ((Path) baseClasspath.clone()); | |||
afterInstrumentationClasspath.append(new Path(getProject(), instrumentDir.getAbsolutePath())); | |||
afterInstrumentationClasspath.append(new Path(getProject(), repositoryDir.getAbsolutePath())); | |||
afterInstrumentationClasspath.append(new Path(getProject(), srcDir.getAbsolutePath())); | |||
afterInstrumentationClasspath.append(new Path(getProject(), buildDir.getAbsolutePath())); | |||
afterInstrumentationClasspath.append(new Path(getProject(), | |||
instrumentDir.getAbsolutePath())); | |||
afterInstrumentationClasspath.append(new Path(getProject(), | |||
repositoryDir.getAbsolutePath())); | |||
afterInstrumentationClasspath.append(new Path(getProject(), | |||
srcDir.getAbsolutePath())); | |||
afterInstrumentationClasspath.append(new Path(getProject(), | |||
buildDir.getAbsolutePath())); | |||
// Create the classpath required to automatically compile the repository files | |||
// Create the classpath required to automatically compile the | |||
// repository files | |||
Path repositoryClasspath = ((Path) baseClasspath.clone()); | |||
repositoryClasspath.append(new Path(getProject(), instrumentDir.getAbsolutePath())); | |||
repositoryClasspath.append(new Path(getProject(), srcDir.getAbsolutePath())); | |||
repositoryClasspath.append(new Path(getProject(), repositoryDir.getAbsolutePath())); | |||
repositoryClasspath.append(new Path(getProject(), buildDir.getAbsolutePath())); | |||
repositoryClasspath.append(new Path(getProject(), | |||
instrumentDir.getAbsolutePath())); | |||
repositoryClasspath.append(new Path(getProject(), | |||
srcDir.getAbsolutePath())); | |||
repositoryClasspath.append(new Path(getProject(), | |||
repositoryDir.getAbsolutePath())); | |||
repositoryClasspath.append(new Path(getProject(), | |||
buildDir.getAbsolutePath())); | |||
// Create the classpath required for iContract itself | |||
Path iContractClasspath = ((Path) baseClasspath.clone()); | |||
iContractClasspath.append(new Path(getProject(), System.getProperty("java.home") + File.separator + ".." + File.separator + "lib" + File.separator + "tools.jar")); | |||
iContractClasspath.append(new Path(getProject(), srcDir.getAbsolutePath())); | |||
iContractClasspath.append(new Path(getProject(), repositoryDir.getAbsolutePath())); | |||
iContractClasspath.append(new Path(getProject(), instrumentDir.getAbsolutePath())); | |||
iContractClasspath.append(new Path(getProject(), buildDir.getAbsolutePath())); | |||
iContractClasspath.append(new Path(getProject(), | |||
System.getProperty("java.home") + File.separator + ".." | |||
+ File.separator + "lib" + File.separator + "tools.jar")); | |||
iContractClasspath.append(new Path(getProject(), | |||
srcDir.getAbsolutePath())); | |||
iContractClasspath.append(new Path(getProject(), | |||
repositoryDir.getAbsolutePath())); | |||
iContractClasspath.append(new Path(getProject(), | |||
instrumentDir.getAbsolutePath())); | |||
iContractClasspath.append(new Path(getProject(), | |||
buildDir.getAbsolutePath())); | |||
// Create a forked java process | |||
Java iContract = (Java) getProject().createTask("java"); | |||
@@ -603,18 +640,36 @@ public class IContract extends MatchingTask { | |||
args.append(directiveString()); | |||
args.append("-v").append(verbosity).append(" "); | |||
args.append("-b").append("\"").append(icCompiler).append(" -classpath ").append(beforeInstrumentationClasspath).append("\" "); | |||
args.append("-c").append("\"").append(icCompiler).append(" -classpath ").append(afterInstrumentationClasspath).append(" -d ").append(buildDir).append("\" "); | |||
args.append("-n").append("\"").append(icCompiler).append(" -classpath ").append(repositoryClasspath).append("\" "); | |||
args.append("-b").append("\"").append(icCompiler); | |||
args.append(" -classpath ").append(beforeInstrumentationClasspath); | |||
args.append("\" "); | |||
args.append("-c").append("\"").append(icCompiler); | |||
args.append(" -classpath ").append(afterInstrumentationClasspath); | |||
args.append(" -d ").append(buildDir).append("\" "); | |||
args.append("-n").append("\"").append(icCompiler); | |||
args.append(" -classpath ").append(repositoryClasspath); | |||
args.append("\" "); | |||
args.append("-d").append(failThrowable).append(" "); | |||
args.append("-o").append(instrumentDir).append(File.separator).append("@p").append(File.separator).append("@f.@e "); | |||
args.append("-k").append(repositoryDir).append(File.separator).append("@p "); | |||
args.append("-o").append(instrumentDir).append(File.separator); | |||
args.append("@p").append(File.separator).append("@f.@e "); | |||
args.append("-k").append(repositoryDir).append(File.separator); | |||
args.append("@p "); | |||
args.append(quiet ? "-q " : ""); | |||
args.append(instrumentall ? "-a " : "");// reinstrument everything if controlFile exists and is newer than any class | |||
// reinstrument everything if controlFile exists and is newer | |||
// than any class | |||
args.append(instrumentall ? "-a " : ""); | |||
args.append("@").append(targets.getAbsolutePath()); | |||
iContract.createArg().setLine(args.toString()); | |||
//System.out.println( "JAVA -classpath " + iContractClasspath + " com.reliablesystems.iContract.Tool " + args.toString() ); | |||
//System.out.println( "JAVA -classpath " + iContractClasspath | |||
// + " com.reliablesystems.iContract.Tool " + args.toString() ); | |||
// update iControlProperties if it's set. | |||
if (updateIcontrol) { | |||
@@ -624,17 +679,24 @@ public class IContract extends MatchingTask { | |||
// to read existing propertiesfile | |||
iControlProps.load(new FileInputStream("icontrol.properties")); | |||
} catch (IOException e) { | |||
log("File icontrol.properties not found. That's ok. Writing a default one."); | |||
log("File icontrol.properties not found. That's ok. " | |||
+ "Writing a default one."); | |||
} | |||
iControlProps.setProperty("sourceRoot", srcDir.getAbsolutePath()); | |||
iControlProps.setProperty("classRoot", classDir.getAbsolutePath()); | |||
iControlProps.setProperty("classpath", afterInstrumentationClasspath.toString()); | |||
iControlProps.setProperty("controlFile", controlFile.getAbsolutePath()); | |||
iControlProps.setProperty("targetsFile", targets.getAbsolutePath()); | |||
iControlProps.setProperty("sourceRoot", | |||
srcDir.getAbsolutePath()); | |||
iControlProps.setProperty("classRoot", | |||
classDir.getAbsolutePath()); | |||
iControlProps.setProperty("classpath", | |||
afterInstrumentationClasspath.toString()); | |||
iControlProps.setProperty("controlFile", | |||
controlFile.getAbsolutePath()); | |||
iControlProps.setProperty("targetsFile", | |||
targets.getAbsolutePath()); | |||
try { | |||
// to read existing propertiesfile | |||
iControlProps.store(new FileOutputStream("icontrol.properties"), ICONTROL_PROPERTIES_HEADER); | |||
iControlProps.store(new FileOutputStream("icontrol.properties"), | |||
ICONTROL_PROPERTIES_HEADER); | |||
log("Updated icontrol.properties"); | |||
} catch (IOException e) { | |||
log("Couldn't write icontrol.properties."); | |||
@@ -646,11 +708,14 @@ public class IContract extends MatchingTask { | |||
if (result != 0) { | |||
if (iContractMissing) { | |||
log("iContract can't be found on your classpath. Your classpath is:"); | |||
log("iContract can't be found on your classpath. " | |||
+ "Your classpath is:"); | |||
log(classpath.toString()); | |||
log("If you don't have the iContract jar, go get it at http://www.reliable-systems.com/tools/"); | |||
log("If you don't have the iContract jar, go get it at " | |||
+ "http://www.reliable-systems.com/tools/"); | |||
} | |||
throw new BuildException("iContract instrumentation failed. Code=" + result); | |||
throw new BuildException("iContract instrumentation failed. " | |||
+ "Code = " + result); | |||
} | |||
} else { | |||
// not dirty | |||
@@ -662,22 +727,28 @@ public class IContract extends MatchingTask { | |||
/** Checks that the required attributes are set. */ | |||
private void preconditions() throws BuildException { | |||
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 (instrumentDir == null) { | |||
throw new BuildException("instrumentdir attribute must be set!", getLocation()); | |||
throw new BuildException("instrumentdir attribute must be set!", | |||
getLocation()); | |||
} | |||
if (repositoryDir == null) { | |||
throw new BuildException("repositorydir attribute must be set!", getLocation()); | |||
throw new BuildException("repositorydir attribute must be set!", | |||
getLocation()); | |||
} | |||
if (updateIcontrol && classDir == null) { | |||
throw new BuildException("classdir attribute must be specified when updateicontrol=true!", getLocation()); | |||
throw new BuildException("classdir attribute must be specified " | |||
+ "when updateicontrol=true!", getLocation()); | |||
} | |||
if (updateIcontrol && controlFile == null) { | |||
throw new BuildException("controlfile attribute must be specified when updateicontrol=true!", getLocation()); | |||
throw new BuildException("controlfile attribute must be specified " | |||
+ "when updateicontrol=true!", getLocation()); | |||
} | |||
} | |||
@@ -706,10 +777,12 @@ public class IContract extends MatchingTask { | |||
try { | |||
if (targets == null) { | |||
targets = new File("targets"); | |||
log("Warning: targets file not specified. generating file: " + targets.getName()); | |||
log("Warning: targets file not specified. generating file: " | |||
+ targets.getName()); | |||
writeTargets = true; | |||
} else if (!targets.exists()) { | |||
log("Specified targets file doesn't exist. generating file: " + targets.getName()); | |||
log("Specified targets file doesn't exist. generating file: " | |||
+ targets.getName()); | |||
writeTargets = true; | |||
} | |||
if (writeTargets) { | |||
@@ -733,7 +806,9 @@ public class IContract extends MatchingTask { | |||
} | |||
if (!classFile.exists() || srcFile.lastModified() > classFile.lastModified()) { | |||
//log( "Found a file newer than the instrumentDir class file: " + srcFile.getPath() + " newer than " + classFile.getPath() + ". Running iContract again..." ); | |||
//log( "Found a file newer than the instrumentDir class file: " | |||
// + srcFile.getPath() + " newer than " + classFile.getPath() | |||
// + ". Running iContract again..." ); | |||
dirty = true; | |||
} | |||
} | |||
@@ -761,7 +836,10 @@ public class IContract extends MatchingTask { | |||
if (files[i].endsWith(".class")) { | |||
if (controlFileTime > srcFile.lastModified()) { | |||
if (!dirty) { | |||
log("Control file " + controlFile.getAbsolutePath() + " has been updated. Instrumenting all files..."); | |||
log("Control file " | |||
+ controlFile.getAbsolutePath() | |||
+ " has been updated. " | |||
+ "Instrumenting all files..."); | |||
} | |||
dirty = true; | |||
instrumentall = true; | |||
@@ -771,7 +849,8 @@ public class IContract extends MatchingTask { | |||
} | |||
} | |||
} catch (Throwable t) { | |||
throw new BuildException("Got an interesting exception:" + t.getMessage()); | |||
throw new BuildException("Got an interesting exception:" | |||
+ t.getMessage()); | |||
} | |||
} | |||
@@ -876,7 +955,8 @@ public class IContract extends MatchingTask { | |||
// make it public | |||
public void modify(Path path) { | |||
// depending on what compiler to use, set the includeJavaRuntime flag | |||
// depending on what compiler to use, set the | |||
// includeJavaRuntime flag | |||
if ("jikes".equals(compiler)) { | |||
icCompiler = compiler; | |||
includeJavaRuntime = true; | |||
@@ -275,25 +275,31 @@ public class Javah extends Task { | |||
} | |||
/** | |||
* Executes the task. | |||
* Execute the task | |||
* | |||
* @throws BuildException is there is a problem in the task execution. | |||
*/ | |||
public void execute() throws BuildException { | |||
// first off, make sure that we've got a srcdir | |||
if ((cls == null) && (classes.size() == 0)) { | |||
throw new BuildException("class attribute must be set!", getLocation()); | |||
throw new BuildException("class attribute must be set!", | |||
getLocation()); | |||
} | |||
if ((cls != null) && (classes.size() > 0)) { | |||
throw new BuildException("set class attribute or class element, not both.", getLocation()); | |||
throw new BuildException("set class attribute or class element, " | |||
+ "not both.", getLocation()); | |||
} | |||
if (destDir != null) { | |||
if (!destDir.isDirectory()) { | |||
throw new BuildException("destination directory \"" + destDir + "\" does not exist or is not a directory", getLocation()); | |||
throw new BuildException("destination directory \"" + destDir | |||
+ "\" does not exist or is not a directory", getLocation()); | |||
} | |||
if (outputFile != null) { | |||
throw new BuildException("destdir and outputFile are mutually exclusive", getLocation()); | |||
throw new BuildException("destdir and outputFile are mutually " | |||
+ "exclusive", getLocation()); | |||
} | |||
} | |||
@@ -305,8 +311,8 @@ public class Javah extends Task { | |||
String compiler = getProject().getProperty("build.compiler"); | |||
if (compiler == null) { | |||
if (!JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1) && | |||
!JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_2)) { | |||
if (!JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1) | |||
&& !JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_2)) { | |||
compiler = "modern"; | |||
} else { | |||
compiler = "classic"; | |||
@@ -357,9 +363,9 @@ public class Javah extends Task { | |||
Object javahMain = constructor.newInstance(new Object[] {cmd.getArguments()}); | |||
// find the run method | |||
Method runMethod = javahMainClass.getMethod("run",new Class[0]); | |||
Method runMethod = javahMainClass.getMethod("run", new Class[0]); | |||
runMethod.invoke(javahMain,new Object[0]); | |||
runMethod.invoke(javahMain, new Object[0]); | |||
} catch (Exception ex) { | |||
if (ex instanceof BuildException) { | |||
throw (BuildException) ex; | |||
@@ -135,6 +135,10 @@ public class Native2Ascii extends MatchingTask { | |||
/** | |||
* Defines the FileNameMapper to use (nested mapper element). | |||
* | |||
* @return the mapper to use for file name translations. | |||
* | |||
* @throws BuildException if more than one mapper is defined. | |||
*/ | |||
public Mapper createMapper() throws BuildException { | |||
if (mapper != null) { | |||
@@ -145,6 +149,11 @@ public class Native2Ascii extends MatchingTask { | |||
return mapper; | |||
} | |||
/** | |||
* Execute the task | |||
* | |||
* @throws BuildException is there is a problem in the task execution. | |||
*/ | |||
public void execute() throws BuildException { | |||
DirectoryScanner scanner = null; // Scanner to find our inputs | |||
@@ -252,8 +261,10 @@ public class Native2Ascii extends MatchingTask { | |||
private class ExtMapper implements FileNameMapper { | |||
public void setFrom(String s) {} | |||
public void setTo(String s) {} | |||
public void setFrom(String s) { | |||
} | |||
public void setTo(String s) { | |||
} | |||
public String[] mapFileName(String fileName) { | |||
int lastDot = fileName.lastIndexOf('.'); | |||
@@ -163,10 +163,14 @@ public class NetRexxC extends MatchingTask { | |||
private boolean suppressDeprecation = false; | |||
// constants for the messages to suppress by flags and their corresponding properties | |||
static final String MSG_METHOD_ARGUMENT_NOT_USED = "Warning: Method argument is not used"; | |||
static final String MSG_PRIVATE_PROPERTY_NOT_USED = "Warning: Private property is defined but not used"; | |||
static final String MSG_VARIABLE_NOT_USED = "Warning: Variable is set but not used"; | |||
static final String MSG_EXCEPTION_NOT_SIGNALLED = "is in SIGNALS list but is not signalled within the method"; | |||
static final String MSG_METHOD_ARGUMENT_NOT_USED | |||
= "Warning: Method argument is not used"; | |||
static final String MSG_PRIVATE_PROPERTY_NOT_USED | |||
= "Warning: Private property is defined but not used"; | |||
static final String MSG_VARIABLE_NOT_USED | |||
= "Warning: Variable is set but not used"; | |||
static final String MSG_EXCEPTION_NOT_SIGNALLED | |||
= "is in SIGNALS list but is not signalled within the method"; | |||
static final String MSG_DEPRECATION = "has been deprecated"; | |||
// other implementation variables | |||
@@ -290,7 +294,7 @@ public class NetRexxC extends MatchingTask { | |||
* false. | |||
*/ | |||
public void setJava(boolean java) { | |||
log( "The attribute java is currently unused.", Project.MSG_WARN ); | |||
log("The attribute java is currently unused.", Project.MSG_WARN); | |||
} | |||
@@ -527,7 +531,6 @@ public class NetRexxC extends MatchingTask { | |||
* with arguments like -Dant.netrexxc.verbose=verbose5 one can easily take | |||
* control of all netrexxc-tasks. | |||
*/ | |||
// Sorry for the formatting, but that way it's easier to keep in sync with the private properties (line by line). | |||
public void init() { | |||
String p; | |||
@@ -736,7 +739,7 @@ public class NetRexxC extends MatchingTask { | |||
j++; | |||
} | |||
// create a single array of arguments for the compiler | |||
String compileArgs[] = new String[compileOptionsArray.length + fileListArray.length]; | |||
String[] compileArgs = new String[compileOptionsArray.length + fileListArray.length]; | |||
for (int i = 0; i < compileOptionsArray.length; i++) { | |||
compileArgs[i] = compileOptionsArray[i]; | |||
@@ -782,38 +785,48 @@ public class NetRexxC extends MatchingTask { | |||
String l; | |||
BufferedReader in = new BufferedReader(new StringReader(out.toString())); | |||
log("replacing destdir '" + ddir + "' through sourcedir '" + sdir + "'", Project.MSG_VERBOSE); | |||
log("replacing destdir '" + ddir + "' through sourcedir '" | |||
+ sdir + "'", Project.MSG_VERBOSE); | |||
while ((l = in.readLine()) != null) { | |||
int idx; | |||
while (doReplace && ((idx = l.indexOf(ddir)) != -1)) {// path is mentioned in the message | |||
while (doReplace && ((idx = l.indexOf(ddir)) != -1)) { | |||
// path is mentioned in the message | |||
l = (new StringBuffer(l)).replace(idx, idx + dlen, sdir).toString(); | |||
} | |||
// verbose level logging for suppressed messages | |||
if (suppressMethodArgumentNotUsed && l.indexOf(MSG_METHOD_ARGUMENT_NOT_USED) != -1) { | |||
if (suppressMethodArgumentNotUsed | |||
&& l.indexOf(MSG_METHOD_ARGUMENT_NOT_USED) != -1) { | |||
log(l, Project.MSG_VERBOSE); | |||
} else if (suppressPrivatePropertyNotUsed && l.indexOf(MSG_PRIVATE_PROPERTY_NOT_USED) != -1) { | |||
} else if (suppressPrivatePropertyNotUsed | |||
&& l.indexOf(MSG_PRIVATE_PROPERTY_NOT_USED) != -1) { | |||
log(l, Project.MSG_VERBOSE); | |||
} else if (suppressVariableNotUsed && l.indexOf(MSG_VARIABLE_NOT_USED) != -1) { | |||
} else if (suppressVariableNotUsed | |||
&& l.indexOf(MSG_VARIABLE_NOT_USED) != -1) { | |||
log(l, Project.MSG_VERBOSE); | |||
} else if (suppressExceptionNotSignalled && l.indexOf(MSG_EXCEPTION_NOT_SIGNALLED) != -1) { | |||
} else if (suppressExceptionNotSignalled | |||
&& l.indexOf(MSG_EXCEPTION_NOT_SIGNALLED) != -1) { | |||
log(l, Project.MSG_VERBOSE); | |||
} else if (suppressDeprecation && l.indexOf(MSG_DEPRECATION) != -1) { | |||
} else if (suppressDeprecation | |||
&& l.indexOf(MSG_DEPRECATION) != -1) { | |||
log(l, Project.MSG_VERBOSE); | |||
} else if (l.indexOf("Error:") != -1) {// error level logging for compiler errors | |||
} else if (l.indexOf("Error:") != -1) { | |||
// error level logging for compiler errors | |||
log(l, Project.MSG_ERR); | |||
} else if (l.indexOf("Warning:") != -1) {// warning for all warning messages | |||
} else if (l.indexOf("Warning:") != -1) { | |||
// warning for all warning messages | |||
log(l, Project.MSG_WARN); | |||
} else { | |||
log(l, Project.MSG_INFO);// info level for the rest. | |||
log(l, Project.MSG_INFO); // info level for the rest. | |||
} | |||
} | |||
if (rc > 1) { | |||
throw new BuildException("Compile failed, messages should have been provided."); | |||
throw new BuildException("Compile failed, messages should " | |||
+ "have been provided."); | |||
} | |||
} catch (IOException ioe) { | |||
throw new BuildException("Unexpected IOException while playing with Strings", | |||
ioe); | |||
throw new BuildException("Unexpected IOException while " | |||
+ "playing with Strings", ioe); | |||
} finally { | |||
// need to reset java.class.path property | |||
// since the NetRexx compiler has no option for the classpath | |||
@@ -902,8 +915,8 @@ public class NetRexxC extends MatchingTask { | |||
target.append(File.pathSeparator); | |||
target.append(f.getAbsolutePath()); | |||
} else { | |||
log("Dropping from classpath: " + | |||
f.getAbsolutePath(), Project.MSG_VERBOSE); | |||
log("Dropping from classpath: " | |||
+ f.getAbsolutePath(), Project.MSG_VERBOSE); | |||
} | |||
} | |||
@@ -98,7 +98,8 @@ import org.apache.tools.ant.types.EnumeratedAttribute; | |||
*The <propertyfile> task must have:<br> | |||
* <ul><li>file</li></ul> | |||
*Other parameters are:<br> | |||
* <ul><li>comment, key, operation, type and value (the final four being eliminated shortly)</li></ul> | |||
* <ul><li>comment, key, operation, type and value (the final four being | |||
* eliminated shortly)</li></ul> | |||
* | |||
*The <entry> task must have:<br> | |||
* <ul><li>key</li></ul> | |||
@@ -253,7 +254,9 @@ public class PropertyFile extends Task { | |||
if (bos != null) { | |||
try { | |||
bos.close(); | |||
} catch (IOException ioex) {} | |||
} catch (IOException ioex) { | |||
// ignore | |||
} | |||
} | |||
} | |||
} | |||
@@ -506,8 +509,8 @@ public class PropertyFile extends Task { | |||
* fields | |||
*/ | |||
private void checkParameters() throws BuildException { | |||
if (type == Type.STRING_TYPE && | |||
operation == Operation.DECREMENT_OPER) { | |||
if (type == Type.STRING_TYPE | |||
&& operation == Operation.DECREMENT_OPER) { | |||
throw new BuildException("- is not suported for string " | |||
+ "properties (key:" + key + ")"); | |||
} | |||
@@ -518,8 +521,7 @@ public class PropertyFile extends Task { | |||
if (key == null) { | |||
throw new BuildException("key is mandatory"); | |||
} | |||
if (type == Type.STRING_TYPE && | |||
pattern != null) { | |||
if (type == Type.STRING_TYPE && pattern != null) { | |||
throw new BuildException("pattern is not suported for string " | |||
+ "properties (key:" + key + ")"); | |||
} | |||
@@ -631,16 +633,9 @@ public class PropertyFile extends Task { | |||
private static final String MONTH = "month"; | |||
private static final String YEAR = "year"; | |||
private static final String[] units = { | |||
MILLISECOND, | |||
SECOND, | |||
MINUTE, | |||
HOUR, | |||
DAY, | |||
WEEK, | |||
MONTH, | |||
YEAR | |||
}; | |||
private static final String[] UNITS | |||
= {MILLISECOND, SECOND, MINUTE, HOUR, | |||
DAY, WEEK, MONTH, YEAR }; | |||
private Hashtable calendarFields = new Hashtable(); | |||
@@ -663,7 +658,7 @@ public class PropertyFile extends Task { | |||
} | |||
public String[] getValues() { | |||
return units; | |||
return UNITS; | |||
} | |||
} | |||
} |
@@ -98,7 +98,9 @@ public class RenameExtensions extends MatchingTask { | |||
/** | |||
* The string that files must end in to be renamed | |||
**/ | |||
* | |||
* @param from the extension of files being renamed. | |||
*/ | |||
public void setFromExtension(String from) { | |||
fromExtension = from; | |||
} | |||
@@ -106,6 +108,8 @@ public class RenameExtensions extends MatchingTask { | |||
/** | |||
* The string that renamed files will end with on | |||
* completion | |||
* | |||
* @param to the extension of the renamed files. | |||
*/ | |||
public void setToExtension(String to) { | |||
toExtension = to; | |||
@@ -114,6 +118,8 @@ public class RenameExtensions extends MatchingTask { | |||
/** | |||
* store replace attribute - this determines whether the target file | |||
* should be overwritten if present | |||
* | |||
* @param replace if true overwrite any target files that exist. | |||
*/ | |||
public void setReplace(boolean replace) { | |||
this.replace = replace; | |||
@@ -121,6 +127,8 @@ public class RenameExtensions extends MatchingTask { | |||
/** | |||
* Set the source dir to find the files to be renamed. | |||
* | |||
* @param srcDir the source directory. | |||
*/ | |||
public void setSrcDir(File srcDir) { | |||
this.srcDir = srcDir; | |||
@@ -128,6 +136,8 @@ public class RenameExtensions extends MatchingTask { | |||
/** | |||
* Executes the task. | |||
* | |||
* @throws BuildException is there is a problem in the task execution. | |||
*/ | |||
public void execute() throws BuildException { | |||
@@ -220,9 +220,11 @@ public class ReplaceRegExp extends Task { | |||
* <li>g : Global replacement. Replace all occurences found | |||
* <li>i : Case Insensitive. Do not consider case in the match | |||
* <li>m : Multiline. Treat the string as multiple lines of input, | |||
* using "^" and "$" as the start or end of any line, respectively, rather than start or end of string. | |||
* using "^" and "$" as the start or end of any line, respectively, | |||
* rather than start or end of string. | |||
* <li> s : Singleline. Treat the string as a single line of input, using | |||
* "." to match any character, including a newline, which normally, it would not match. | |||
* "." to match any character, including a newline, which normally, | |||
* it would not match. | |||
*</ul> | |||
*/ | |||
public void setFlags(String flags) { | |||
@@ -334,13 +336,11 @@ public class ReplaceRegExp extends Task { | |||
boolean changes = false; | |||
log("Replacing pattern '" + regex.getPattern(getProject()) + | |||
"' with '" + subs.getExpression(getProject()) + | |||
"' in '" + f.getPath() + "'" + | |||
(byline ? " by line" : "") + | |||
(flags.length() > 0 ? " with flags: '" + flags + "'" : "") + | |||
".", | |||
Project.MSG_VERBOSE); | |||
log("Replacing pattern '" + regex.getPattern(getProject()) | |||
+ "' with '" + subs.getExpression(getProject()) | |||
+ "' in '" + f.getPath() + "'" + (byline ? " by line" : "") | |||
+ (flags.length() > 0 ? " with flags: '" + flags + "'" : "") | |||
+ ".", Project.MSG_VERBOSE); | |||
if (byline) { | |||
StringBuffer linebuf = new StringBuffer(); | |||
@@ -450,6 +450,7 @@ public class ReplaceRegExp extends Task { | |||
r.close(); | |||
} | |||
} catch (Exception e) { | |||
// ignore any secondary exceptions | |||
} | |||
try { | |||
@@ -457,6 +458,7 @@ public class ReplaceRegExp extends Task { | |||
w.close(); | |||
} | |||
} catch (Exception e) { | |||
// ignore any secondary exceptions | |||
} | |||
if (temp != null) { | |||
temp.delete(); | |||
@@ -465,8 +467,12 @@ public class ReplaceRegExp extends Task { | |||
} | |||
public void execute() | |||
throws BuildException { | |||
/** | |||
* Execute the task | |||
* | |||
* @throws BuildException is there is a problem in the task execution. | |||
*/ | |||
public void execute() throws BuildException { | |||
if (regex == null) { | |||
throw new BuildException("No expression to match."); | |||
} | |||
@@ -516,7 +522,7 @@ public class ReplaceRegExp extends Task { | |||
FileSet fs = (FileSet) (filesets.elementAt(i)); | |||
DirectoryScanner ds = fs.getDirectoryScanner(getProject()); | |||
String files[] = ds.getIncludedFiles(); | |||
String[] files = ds.getIncludedFiles(); | |||
for (int j = 0; j < files.length; j++) { | |||
File f = new File(fs.getDir(getProject()), files[j]); | |||
@@ -126,6 +126,11 @@ public class Rpm extends Task { | |||
*/ | |||
private File error; | |||
/** | |||
* Execute the task | |||
* | |||
* @throws BuildException is there is a problem in the task execution. | |||
*/ | |||
public void execute() throws BuildException { | |||
Commandline toExecute = new Commandline(); | |||
@@ -161,7 +166,9 @@ public class Rpm extends Task { | |||
} else { | |||
if (output != null) { | |||
try { | |||
outputstream = new PrintStream(new BufferedOutputStream(new FileOutputStream(output))); | |||
BufferedOutputStream bos | |||
= new BufferedOutputStream(new FileOutputStream(output)); | |||
outputstream = new PrintStream(bos); | |||
} catch (IOException e) { | |||
throw new BuildException(e, getLocation()); | |||
} | |||
@@ -170,7 +177,9 @@ public class Rpm extends Task { | |||
} | |||
if (error != null) { | |||
try { | |||
errorstream = new PrintStream(new BufferedOutputStream(new FileOutputStream(error))); | |||
BufferedOutputStream bos | |||
= new BufferedOutputStream(new FileOutputStream(error)); | |||
errorstream = new PrintStream(bos); | |||
} catch (IOException e) { | |||
throw new BuildException(e, getLocation()); | |||
} | |||
@@ -198,12 +207,16 @@ public class Rpm extends Task { | |||
if (output != null) { | |||
try { | |||
outputstream.close(); | |||
} catch (IOException e) {} | |||
} catch (IOException e) { | |||
// ignore any secondary error | |||
} | |||
} | |||
if (error != null) { | |||
try { | |||
errorstream.close(); | |||
} catch (IOException e) {} | |||
} catch (IOException e) { | |||
// ignore any secondary error | |||
} | |||
} | |||
} | |||
} | |||
@@ -213,6 +226,8 @@ public class Rpm extends Task { | |||
* subdirectories, SPECS, SOURCES, BUILD, SRPMS ; optional. | |||
* If this isn't specified, | |||
* the <tt>baseDir</tt> value is used | |||
* | |||
* @param td the directory containing the normal RPM directories. | |||
*/ | |||
public void setTopDir(File td) { | |||
this.topDir = td; | |||
@@ -81,8 +81,8 @@ public class Script extends Task { | |||
for (Enumeration e = dictionary.keys(); e.hasMoreElements();) { | |||
String key = (String) e.nextElement(); | |||
boolean isValid = key.length() > 0 && | |||
Character.isJavaIdentifierStart(key.charAt(0)); | |||
boolean isValid = key.length() > 0 | |||
&& Character.isJavaIdentifierStart(key.charAt(0)); | |||
for (int i = 1; isValid && i < key.length(); i++) { | |||
isValid = Character.isJavaIdentifierPart(key.charAt(i)); | |||
@@ -112,7 +112,7 @@ public class Script extends Task { | |||
BSFManager manager = new BSFManager (); | |||
for (Enumeration e = beans.keys() ; e.hasMoreElements() ;) { | |||
for (Enumeration e = beans.keys(); e.hasMoreElements();) { | |||
String key = (String) e.nextElement(); | |||
Object value = beans.get(key); | |||
manager.declareBean(key, value, value.getClass()); | |||
@@ -137,7 +137,7 @@ public class Script extends Task { | |||
/** | |||
* Defines the language (required). | |||
* | |||
* @param msg Sets the value for the script variable. | |||
* @param language the scripting language name for the script. | |||
*/ | |||
public void setLanguage(String language) { | |||
this.language = language; | |||
@@ -146,7 +146,7 @@ public class Script extends Task { | |||
/** | |||
* Load the script from an external file ; optional. | |||
* | |||
* @param msg Sets the value for the script variable. | |||
* @param fileName the name of the file containing the script source. | |||
*/ | |||
public void setSrc(String fileName) { | |||
File file = new File(fileName); | |||
@@ -155,7 +155,7 @@ public class Script extends Task { | |||
} | |||
int count = (int) file.length(); | |||
byte data[] = new byte[count]; | |||
byte[] data = new byte[count]; | |||
try { | |||
FileInputStream inStream = new FileInputStream(file); | |||
@@ -169,9 +169,9 @@ public class Script extends Task { | |||
} | |||
/** | |||
* The script text. | |||
* Set the script text. | |||
* | |||
* @param msg Sets the value for the script variable. | |||
* @param text a component of the script text to be added. | |||
*/ | |||
public void addText(String text) { | |||
this.script += text; | |||
@@ -70,8 +70,7 @@ import org.apache.tools.ant.taskdefs.Java; | |||
* @author <a href="mailto:marcus.boerger@post.rwth-aachen.de">Marcus | |||
* Börger</a> | |||
*/ | |||
public class StyleBook | |||
extends Java { | |||
public class StyleBook extends Java { | |||
protected File m_targetDirectory; | |||
protected File m_skinDirectory; | |||
protected String m_loaderConfig; | |||
@@ -209,8 +209,8 @@ public class TraXLiaison implements XSLTLiaison, ErrorListener, XSLTLoggerAware | |||
reader.setEntityResolver(entityResolver); | |||
src = new SAXSource(reader, new InputSource(is)); | |||
} else { | |||
throw new IllegalStateException("xcatalog specified, but " + | |||
"parser doesn't support SAX"); | |||
throw new IllegalStateException("xcatalog specified, but " | |||
+ "parser doesn't support SAX"); | |||
} | |||
} else { | |||
src = new StreamSource(is); | |||
@@ -305,8 +305,8 @@ public class TraXLiaison implements XSLTLiaison, ErrorListener, XSLTLoggerAware | |||
// specific attributes for the transformer | |||
for (int i = 0; i < attributes.size(); i++) { | |||
final Object[] pair = (Object[])attributes.elementAt(i); | |||
tfactory.setAttribute((String)pair[0], pair[1]); | |||
final Object[] pair = (Object[]) attributes.elementAt(i); | |||
tfactory.setAttribute((String) pair[0], pair[1]); | |||
} | |||
if (uriResolver != null) { | |||
@@ -87,8 +87,10 @@ import org.xml.sax.helpers.ParserAdapter; | |||
* Checks XML files are valid (or only well formed). The | |||
* task uses the SAX2 parser implementation provided by JAXP by default | |||
* (probably the one that is used by Ant itself), but one can specify any | |||
* SAX1/2 parser if needed | |||
* @author Raphael Pierquin <a href="mailto:raphael.pierquin@agisphere.com">raphael.pierquin@agisphere.com</a> | |||
* SAX1/2 parser if needed. | |||
* | |||
* @author Raphael Pierquin <a href="mailto:raphael.pierquin@agisphere.com"> | |||
* raphael.pierquin@agisphere.com</a> | |||
* @author Nick Pellow <a href="mailto:nick@svana.org">nick@svana.org</a> | |||
*/ | |||
public class XMLValidateTask extends Task { | |||
@@ -98,7 +100,7 @@ public class XMLValidateTask extends Task { | |||
*/ | |||
private static FileUtils fu = FileUtils.newFileUtils(); | |||
protected static String INIT_FAILED_MSG = | |||
protected static final String INIT_FAILED_MSG = | |||
"Could not start xml validation: "; | |||
// ant task properties | |||
@@ -108,8 +110,10 @@ public class XMLValidateTask extends Task { | |||
protected boolean lenient = false; | |||
protected String readerClassName = null; | |||
protected File file = null; // file to be validated | |||
protected Vector filesets = new Vector(); // sets of file to be validated | |||
/** file to be validated */ | |||
protected File file = null; | |||
/** sets of file to be validated */ | |||
protected Vector filesets = new Vector(); | |||
protected Path classpath; | |||
@@ -137,7 +141,6 @@ public class XMLValidateTask extends Task { | |||
* parser yields an error. | |||
*/ | |||
public void setFailOnError(boolean fail) { | |||
failOnError = fail; | |||
} | |||
@@ -147,35 +150,35 @@ public class XMLValidateTask extends Task { | |||
* If set to <code>true</true> (default), log a warn message for each SAX warn event. | |||
*/ | |||
public void setWarn(boolean bool) { | |||
warn = bool; | |||
} | |||
/** | |||
* Specify whether the parser should be validating. Default is <code>true</code>. | |||
* Specify whether the parser should be validating. Default | |||
* is <code>true</code>. | |||
* <p> | |||
* If set to false, the validation will fail only if the parsed document is not well formed XML. | |||
* If set to false, the validation will fail only if the parsed document | |||
* is not well formed XML. | |||
* <p> | |||
* this option is ignored if the specified class with {@link #setClassName(String)} is not a SAX2 | |||
* XMLReader. | |||
* this option is ignored if the specified class | |||
* with {@link #setClassName(String)} is not a SAX2 XMLReader. | |||
*/ | |||
public void setLenient(boolean bool) { | |||
lenient = bool; | |||
} | |||
/** | |||
* Specify the class name of the SAX parser to be used. (optional) | |||
* @param className should be an implementation of SAX2 <code>org.xml.sax.XMLReader</code> | |||
* or SAX2 <code>org.xml.sax.Parser</code>. | |||
* <p> if className is an implementation of <code>org.xml.sax.Parser</code>, {@link #setLenient(boolean)}, | |||
* @param className should be an implementation of SAX2 | |||
* <code>org.xml.sax.XMLReader</code> or SAX2 <code>org.xml.sax.Parser</code>. | |||
* <p> if className is an implementation of | |||
* <code>org.xml.sax.Parser</code>, {@link #setLenient(boolean)}, | |||
* will be ignored. | |||
* <p> if not set, the default will be used. | |||
* @see org.xml.sax.XMLReader | |||
* @see org.xml.sax.Parser | |||
*/ | |||
public void setClassName(String className) { | |||
readerClassName = className; | |||
} | |||
@@ -184,7 +187,6 @@ public class XMLValidateTask extends Task { | |||
* Specify the classpath to be searched to load the parser (optional) | |||
*/ | |||
public void setClasspath(Path classpath) { | |||
if (this.classpath == null) { | |||
this.classpath = classpath; | |||
} else { | |||
@@ -268,7 +270,8 @@ public class XMLValidateTask extends Task { | |||
int fileProcessed = 0; | |||
if (file == null && (filesets.size() == 0)) { | |||
throw new BuildException("Specify at least one source - a file or a fileset."); | |||
throw new BuildException("Specify at least one source - " | |||
+ "a file or a fileset."); | |||
} | |||
initValidator(); | |||
@@ -293,7 +296,7 @@ public class XMLValidateTask extends Task { | |||
DirectoryScanner ds = fs.getDirectoryScanner(getProject()); | |||
String[] files = ds.getIncludedFiles(); | |||
for (int j = 0; j < files.length ; j++) { | |||
for (int j = 0; j < files.length; j++) { | |||
File srcFile = new File(fs.getDir(getProject()), files[j]); | |||
doValidate(srcFile); | |||
fileProcessed++; | |||
@@ -352,8 +355,8 @@ public class XMLValidateTask extends Task { | |||
Project.MSG_VERBOSE); | |||
} else { | |||
throw new BuildException(INIT_FAILED_MSG | |||
+ reader.getClass().getName() | |||
+ " implements nor SAX1 Parser nor SAX2 XMLReader."); | |||
+ reader.getClass().getName() | |||
+ " implements nor SAX1 Parser nor SAX2 XMLReader."); | |||
} | |||
} | |||
@@ -420,7 +423,8 @@ public class XMLValidateTask extends Task { | |||
if (errorHandler.getFailure()) { | |||
if (failOnError) { | |||
throw new BuildException(afile + " is not a valid XML document."); | |||
throw new BuildException(afile | |||
+ " is not a valid XML document."); | |||
} else { | |||
log(afile + " is not a valid XML document", Project.MSG_ERR); | |||
} | |||
@@ -480,11 +484,12 @@ public class XMLValidateTask extends Task { | |||
try { | |||
int line = e.getLineNumber(); | |||
int col = e.getColumnNumber(); | |||
return new URL(sysID).getFile() + | |||
(line == -1 ? "" : (":" + line + | |||
(col == -1 ? "" : (":" + col)))) + | |||
": " + e.getMessage(); | |||
return new URL(sysID).getFile() | |||
+ (line == -1 ? "" : (":" + line | |||
+ (col == -1 ? "" : (":" + col)))) | |||
+ ": " + e.getMessage(); | |||
} catch (MalformedURLException mfue) { | |||
// ignore and just return exception message | |||
} | |||
} | |||
return e.getMessage(); | |||
@@ -499,7 +504,7 @@ public class XMLValidateTask extends Task { | |||
public class Attribute { | |||
/** The name of the attribute to set. | |||
* | |||
* Valid attributes <a href=http://www.saxproject.org/apidoc/org/xml/sax/package-summary.html#package_description">include.</a> | |||
* Valid attributes <a href="http://www.saxproject.org/apidoc/org/xml/sax/package-summary.html#package_description">include.</a> | |||
*/ | |||
private String attributeName = null; | |||
@@ -108,17 +108,23 @@ public class XalanLiaison implements XSLTLiaison { | |||
if (xslStream != null) { | |||
xslStream.close(); | |||
} | |||
} catch (IOException ignored) {} | |||
} catch (IOException ignored) { | |||
//ignore | |||
} | |||
try { | |||
if (fis != null) { | |||
fis.close(); | |||
} | |||
} catch (IOException ignored) {} | |||
} catch (IOException ignored) { | |||
//ignore | |||
} | |||
try { | |||
if (fos != null) { | |||
fos.close(); | |||
} | |||
} catch (IOException ignored) {} | |||
} catch (IOException ignored) { | |||
//ignore | |||
} | |||
} | |||
} | |||
@@ -72,6 +72,8 @@ import org.apache.tools.ant.BuildException; | |||
* to a script. | |||
* The script is meant to use get self.token and | |||
* set self.token in the reply. | |||
* | |||
* @author Not Specified. | |||
*/ | |||
public class ScriptFilter extends TokenFilter.ChainableReaderFilter { | |||
/** The language - attribute of element */ | |||
@@ -90,7 +92,7 @@ public class ScriptFilter extends TokenFilter.ChainableReaderFilter { | |||
/** | |||
* Defines the language (required). | |||
* | |||
* @param msg Sets the value for the script variable. | |||
* @param language the scripting language name for the script. | |||
*/ | |||
public void setLanguage(String language) { | |||
this.language = language; | |||
@@ -105,8 +107,8 @@ public class ScriptFilter extends TokenFilter.ChainableReaderFilter { | |||
for (Enumeration e = dictionary.keys(); e.hasMoreElements();) { | |||
String key = (String) e.nextElement(); | |||
boolean isValid = key.length() > 0 && | |||
Character.isJavaIdentifierStart(key.charAt(0)); | |||
boolean isValid = key.length() > 0 | |||
&& Character.isJavaIdentifierStart(key.charAt(0)); | |||
for (int i = 1; isValid && i < key.length(); i++) { | |||
isValid = Character.isJavaIdentifierPart(key.charAt(i)); | |||
@@ -116,8 +118,7 @@ public class ScriptFilter extends TokenFilter.ChainableReaderFilter { | |||
if (isValid) { | |||
beans.put(key, dictionary.get(key)); | |||
} | |||
} | |||
catch (Throwable t) { | |||
} catch (Throwable t) { | |||
throw new BuildException(t); | |||
//System.err.println("What the helll"); | |||
} | |||
@@ -203,8 +204,7 @@ public class ScriptFilter extends TokenFilter.ChainableReaderFilter { | |||
try { | |||
manager.exec(language, "<ANT>", 0, 0, script); | |||
return getToken(); | |||
} | |||
catch (BSFException be) { | |||
} catch (BSFException be) { | |||
Throwable t = be; | |||
Throwable te = be.getTargetException(); | |||
if (te != null) { | |||
@@ -220,7 +220,7 @@ public class ScriptFilter extends TokenFilter.ChainableReaderFilter { | |||
/** | |||
* Load the script from an external file ; optional. | |||
* | |||
* @param msg Sets the value for the script variable. | |||
* @param fileName the name of the file containing the script source. | |||
*/ | |||
public void setSrc(String fileName) { | |||
File file = new File(fileName); | |||
@@ -229,7 +229,7 @@ public class ScriptFilter extends TokenFilter.ChainableReaderFilter { | |||
} | |||
int count = (int) file.length(); | |||
byte data[] = new byte[count]; | |||
byte[] data = new byte[count]; | |||
try { | |||
FileInputStream inStream = new FileInputStream(file); | |||
@@ -245,7 +245,7 @@ public class ScriptFilter extends TokenFilter.ChainableReaderFilter { | |||
/** | |||
* The script text. | |||
* | |||
* @param msg Sets the value for the script variable. | |||
* @param text a component of the script text to be added. | |||
*/ | |||
public void addText(String text) { | |||
this.script += text; | |||
@@ -61,6 +61,8 @@ import java.lang.ref.WeakReference; | |||
/** | |||
* This is a reference that really is is Weak, as it uses the | |||
* appropriate java.lang.ref class. | |||
* | |||
* @author Not Specified. | |||
*/ | |||
public class WeakishReference12 extends WeakishReference { | |||
@@ -78,6 +80,8 @@ public class WeakishReference12 extends WeakishReference { | |||
/** | |||
* Returns this reference object's referent. | |||
* | |||
* @return referent. | |||
*/ | |||
public Object get() { | |||
return weakref.get(); | |||