git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1376015 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -163,6 +163,7 @@ public class PropertyHelper implements GetProperty { | |||
| String property, Object value, PropertyHelper propertyHelper); | |||
| } | |||
| //TODO PropertyEnumerator Delegate type, would improve PropertySet | |||
| // -------------------------------------------------------- | |||
| // | |||
| @@ -113,10 +113,10 @@ public class ManifestTask extends Task { | |||
| */ | |||
| public void addConfiguredSection(Manifest.Section section) | |||
| throws ManifestException { | |||
| Enumeration attributeKeys = section.getAttributeKeys(); | |||
| Enumeration<String> attributeKeys = section.getAttributeKeys(); | |||
| while (attributeKeys.hasMoreElements()) { | |||
| Attribute attribute = section.getAttribute( | |||
| (String) attributeKeys.nextElement()); | |||
| attributeKeys.nextElement()); | |||
| checkAttribute(attribute); | |||
| } | |||
| nestedManifest.addConfiguredSection(section); | |||
| @@ -249,9 +249,9 @@ public class ManifestTask extends Task { | |||
| } | |||
| //look for and print warnings | |||
| for (Enumeration e = nestedManifest.getWarnings(); | |||
| for (Enumeration<String> e = nestedManifest.getWarnings(); | |||
| e.hasMoreElements();) { | |||
| log("Manifest warning: " + (String) e.nextElement(), | |||
| log("Manifest warning: " + e.nextElement(), | |||
| Project.MSG_WARN); | |||
| } | |||
| try { | |||
| @@ -263,7 +263,7 @@ public abstract class MatchingTask extends Task implements SelectorContainer { | |||
| * | |||
| * @return an enumerator that goes through each of the selectors | |||
| */ | |||
| public Enumeration selectorElements() { | |||
| public Enumeration<FileSelector> selectorElements() { | |||
| return fileset.selectorElements(); | |||
| } | |||
| @@ -37,7 +37,7 @@ import org.apache.tools.ant.ProjectComponent; | |||
| import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.BuildException; | |||
| import org.apache.tools.ant.filters.util.ChainReaderHelper; | |||
| import org.apache.tools.ant.util.LineOrientedOutputStream; | |||
| import org.apache.tools.ant.types.FilterChain; | |||
| import org.apache.tools.ant.util.LineOrientedOutputStreamRedirector; | |||
| import org.apache.tools.ant.util.StringUtils; | |||
| import org.apache.tools.ant.util.TeeOutputStream; | |||
| @@ -51,7 +51,7 @@ import org.apache.tools.ant.util.KeepAliveOutputStream; | |||
| /** | |||
| * The Redirector class manages the setup and connection of input and output | |||
| * redirection for an Ant project component. | |||
| * | |||
| * | |||
| * @since Ant 1.6 | |||
| */ | |||
| public class Redirector { | |||
| @@ -157,13 +157,13 @@ public class Redirector { | |||
| private PrintStream errorPrintStream = null; | |||
| /** The output filter chains */ | |||
| private Vector outputFilterChains; | |||
| private Vector<FilterChain> outputFilterChains; | |||
| /** The error filter chains */ | |||
| private Vector errorFilterChains; | |||
| private Vector<FilterChain> errorFilterChains; | |||
| /** The input filter chains */ | |||
| private Vector inputFilterChains; | |||
| private Vector<FilterChain> inputFilterChains; | |||
| /** The output encoding */ | |||
| private String outputEncoding = DEFAULT_ENCODING; | |||
| @@ -194,7 +194,7 @@ public class Redirector { | |||
| /** | |||
| * Create a redirector instance for the given task | |||
| * | |||
| * | |||
| * @param managingTask | |||
| * the task for which the redirector is to work | |||
| */ | |||
| @@ -204,7 +204,7 @@ public class Redirector { | |||
| /** | |||
| * Create a redirector instance for the given task | |||
| * | |||
| * | |||
| * @param managingTask | |||
| * the project component for which the redirector is to work | |||
| * @since Ant 1.6.3 | |||
| @@ -215,7 +215,7 @@ public class Redirector { | |||
| /** | |||
| * Set the input to use for the task | |||
| * | |||
| * | |||
| * @param input | |||
| * the file from which input is read. | |||
| */ | |||
| @@ -225,7 +225,7 @@ public class Redirector { | |||
| /** | |||
| * Set the input to use for the task | |||
| * | |||
| * | |||
| * @param input | |||
| * the files from which input is read. | |||
| */ | |||
| @@ -241,7 +241,7 @@ public class Redirector { | |||
| /** | |||
| * Set the string to use as input | |||
| * | |||
| * | |||
| * @param inputString | |||
| * the string which is used as the input source | |||
| */ | |||
| @@ -254,7 +254,7 @@ public class Redirector { | |||
| /** | |||
| * Set whether to include the value of the input string in log messages. | |||
| * Defaults to true. | |||
| * | |||
| * | |||
| * @param logInputString | |||
| * true or false. | |||
| * @since Ant 1.7 | |||
| @@ -265,7 +265,7 @@ public class Redirector { | |||
| /** | |||
| * Set a stream to use as input. | |||
| * | |||
| * | |||
| * @param inputStream | |||
| * the stream from which input will be read | |||
| * @since Ant 1.6.3 | |||
| @@ -279,7 +279,7 @@ public class Redirector { | |||
| /** | |||
| * File the output of the process is redirected to. If error is not | |||
| * redirected, it too will appear in the output | |||
| * | |||
| * | |||
| * @param out | |||
| * the file to which output stream is written | |||
| */ | |||
| @@ -290,7 +290,7 @@ public class Redirector { | |||
| /** | |||
| * Files the output of the process is redirected to. If error is not | |||
| * redirected, it too will appear in the output | |||
| * | |||
| * | |||
| * @param out | |||
| * the files to which output stream is written | |||
| */ | |||
| @@ -306,7 +306,7 @@ public class Redirector { | |||
| /** | |||
| * Set the output encoding. | |||
| * | |||
| * | |||
| * @param outputEncoding | |||
| * <code>String</code>. | |||
| */ | |||
| @@ -322,7 +322,7 @@ public class Redirector { | |||
| /** | |||
| * Set the error encoding. | |||
| * | |||
| * | |||
| * @param errorEncoding | |||
| * <code>String</code>. | |||
| */ | |||
| @@ -337,7 +337,7 @@ public class Redirector { | |||
| /** | |||
| * Set the input encoding. | |||
| * | |||
| * | |||
| * @param inputEncoding | |||
| * <code>String</code>. | |||
| */ | |||
| @@ -353,7 +353,7 @@ public class Redirector { | |||
| /** | |||
| * Controls whether error output of exec is logged. This is only useful when | |||
| * output is being redirected and error output is desired in the Ant log | |||
| * | |||
| * | |||
| * @param logError | |||
| * if true the standard error is sent to the Ant log system and | |||
| * not sent to output. | |||
| @@ -368,7 +368,7 @@ public class Redirector { | |||
| * This <code>Redirector</code>'s subordinate | |||
| * <code>PropertyOutputStream</code>s will not set their respective | |||
| * properties <code>while (appendProperties && append)</code>. | |||
| * | |||
| * | |||
| * @param appendProperties | |||
| * whether to append properties. | |||
| */ | |||
| @@ -380,7 +380,7 @@ public class Redirector { | |||
| /** | |||
| * Set the file to which standard error is to be redirected. | |||
| * | |||
| * | |||
| * @param error | |||
| * the file to which error is to be written | |||
| */ | |||
| @@ -390,7 +390,7 @@ public class Redirector { | |||
| /** | |||
| * Set the files to which standard error is to be redirected. | |||
| * | |||
| * | |||
| * @param error | |||
| * the file to which error is to be written | |||
| */ | |||
| @@ -406,7 +406,7 @@ public class Redirector { | |||
| /** | |||
| * Property name whose value should be set to the output of the process. | |||
| * | |||
| * | |||
| * @param outputProperty | |||
| * the name of the property to be set with the task's output. | |||
| */ | |||
| @@ -423,7 +423,7 @@ public class Redirector { | |||
| /** | |||
| * Whether output should be appended to or overwrite an existing file. | |||
| * Defaults to false. | |||
| * | |||
| * | |||
| * @param append | |||
| * if true output and error streams are appended to their | |||
| * respective files, if specified. | |||
| @@ -441,7 +441,7 @@ public class Redirector { | |||
| * If true, (error and non-error) output will be "teed", redirected as | |||
| * specified while being sent to Ant's logging mechanism as if no | |||
| * redirection had taken place. Defaults to false. | |||
| * | |||
| * | |||
| * @param alwaysLog | |||
| * <code>boolean</code> | |||
| * @since Ant 1.6.3 | |||
| @@ -458,7 +458,7 @@ public class Redirector { | |||
| /** | |||
| * Whether output and error files should be created even when empty. | |||
| * Defaults to true. | |||
| * | |||
| * | |||
| * @param createEmptyFiles | |||
| * <code>boolean</code>. | |||
| */ | |||
| @@ -473,7 +473,7 @@ public class Redirector { | |||
| /** | |||
| * Property name whose value should be set to the error of the process. | |||
| * | |||
| * | |||
| * @param errorProperty | |||
| * the name of the property to be set with the error output. | |||
| */ | |||
| @@ -489,11 +489,11 @@ public class Redirector { | |||
| /** | |||
| * Set the input <code>FilterChain</code>s. | |||
| * | |||
| * | |||
| * @param inputFilterChains | |||
| * <code>Vector</code> containing <code>FilterChain</code>. | |||
| */ | |||
| public void setInputFilterChains(Vector inputFilterChains) { | |||
| public void setInputFilterChains(Vector<FilterChain> inputFilterChains) { | |||
| synchronized (inMutex) { | |||
| this.inputFilterChains = inputFilterChains; | |||
| } | |||
| @@ -501,11 +501,11 @@ public class Redirector { | |||
| /** | |||
| * Set the output <code>FilterChain</code>s. | |||
| * | |||
| * | |||
| * @param outputFilterChains | |||
| * <code>Vector</code> containing <code>FilterChain</code>. | |||
| */ | |||
| public void setOutputFilterChains(Vector outputFilterChains) { | |||
| public void setOutputFilterChains(Vector<FilterChain> outputFilterChains) { | |||
| synchronized (outMutex) { | |||
| this.outputFilterChains = outputFilterChains; | |||
| } | |||
| @@ -513,11 +513,11 @@ public class Redirector { | |||
| /** | |||
| * Set the error <code>FilterChain</code>s. | |||
| * | |||
| * | |||
| * @param errorFilterChains | |||
| * <code>Vector</code> containing <code>FilterChain</code>. | |||
| */ | |||
| public void setErrorFilterChains(Vector errorFilterChains) { | |||
| public void setErrorFilterChains(Vector<FilterChain> errorFilterChains) { | |||
| synchronized (errMutex) { | |||
| this.errorFilterChains = errorFilterChains; | |||
| } | |||
| @@ -525,12 +525,12 @@ public class Redirector { | |||
| /** | |||
| * Set a property from a ByteArrayOutputStream | |||
| * | |||
| * | |||
| * @param baos | |||
| * contains the property value. | |||
| * @param propertyName | |||
| * the property name. | |||
| * | |||
| * | |||
| * @exception IOException | |||
| * if the value cannot be read form the stream. | |||
| */ | |||
| @@ -746,10 +746,10 @@ public class Redirector { | |||
| /** | |||
| * Create the StreamHandler to use with our Execute instance. | |||
| * | |||
| * | |||
| * @return the execute stream handler to manage the input, output and error | |||
| * streams. | |||
| * | |||
| * | |||
| * @throws BuildException | |||
| * if the execute stream handler cannot be created. | |||
| */ | |||
| @@ -762,7 +762,7 @@ public class Redirector { | |||
| /** | |||
| * Pass output sent to System.out to specified output. | |||
| * | |||
| * | |||
| * @param output | |||
| * the data to be output | |||
| */ | |||
| @@ -777,16 +777,16 @@ public class Redirector { | |||
| /** | |||
| * Handle an input request | |||
| * | |||
| * | |||
| * @param buffer | |||
| * the buffer into which data is to be read. | |||
| * @param offset | |||
| * the offset into the buffer at which data is stored. | |||
| * @param length | |||
| * the amount of data to read | |||
| * | |||
| * | |||
| * @return the number of bytes read | |||
| * | |||
| * | |||
| * @exception IOException | |||
| * if the data cannot be read | |||
| */ | |||
| @@ -804,7 +804,7 @@ public class Redirector { | |||
| /** | |||
| * Process data due to a flush operation. | |||
| * | |||
| * | |||
| * @param output | |||
| * the data being flushed. | |||
| */ | |||
| @@ -820,7 +820,7 @@ public class Redirector { | |||
| /** | |||
| * Process error output | |||
| * | |||
| * | |||
| * @param output | |||
| * the error output data. | |||
| */ | |||
| @@ -835,7 +835,7 @@ public class Redirector { | |||
| /** | |||
| * Handle a flush operation on the error stream | |||
| * | |||
| * | |||
| * @param output | |||
| * the error information being flushed. | |||
| */ | |||
| @@ -851,7 +851,7 @@ public class Redirector { | |||
| /** | |||
| * Get the output stream for the redirector | |||
| * | |||
| * | |||
| * @return the redirector's output stream or null if no output has been | |||
| * configured | |||
| */ | |||
| @@ -863,7 +863,7 @@ public class Redirector { | |||
| /** | |||
| * Get the error stream for the redirector | |||
| * | |||
| * | |||
| * @return the redirector's error stream or null if no output has been | |||
| * configured | |||
| */ | |||
| @@ -875,7 +875,7 @@ public class Redirector { | |||
| /** | |||
| * Get the input stream for the redirector | |||
| * | |||
| * | |||
| * @return the redirector's input stream or null if no output has been | |||
| * configured | |||
| */ | |||
| @@ -887,10 +887,10 @@ public class Redirector { | |||
| /** | |||
| * Complete redirection. | |||
| * | |||
| * | |||
| * This operation will close any streams and create any specified property | |||
| * values. | |||
| * | |||
| * | |||
| * @throws IOException | |||
| * if the output properties cannot be read from their output | |||
| * streams. | |||
| @@ -49,24 +49,24 @@ public class AntAnalyzer extends AbstractAnalyzer { | |||
| * @param classes a vector to be populated with the names of the | |||
| * dependency classes. | |||
| */ | |||
| protected void determineDependencies(Vector files, Vector classes) { | |||
| protected void determineDependencies(Vector<File> files, Vector<String> classes) { | |||
| // we get the root classes and build up a set of | |||
| // classes upon which they depend | |||
| Hashtable dependencies = new Hashtable(); | |||
| Hashtable containers = new Hashtable(); | |||
| Hashtable toAnalyze = new Hashtable(); | |||
| for (Enumeration e = getRootClasses(); e.hasMoreElements();) { | |||
| String classname = (String) e.nextElement(); | |||
| Hashtable<String, String> dependencies = new Hashtable<String, String>(); | |||
| Hashtable<File, File> containers = new Hashtable<File, File>(); | |||
| Hashtable<String, String> toAnalyze = new Hashtable<String, String>(); | |||
| for (Enumeration<String> e = getRootClasses(); e.hasMoreElements();) { | |||
| String classname = e.nextElement(); | |||
| toAnalyze.put(classname, classname); | |||
| } | |||
| int count = 0; | |||
| int maxCount = isClosureRequired() ? MAX_LOOPS : 1; | |||
| Hashtable analyzedDeps = null; | |||
| Hashtable<String, String> analyzedDeps = null; | |||
| while (toAnalyze.size() != 0 && count++ < maxCount) { | |||
| analyzedDeps = new Hashtable(); | |||
| for (Enumeration e = toAnalyze.keys(); e.hasMoreElements();) { | |||
| String classname = (String) e.nextElement(); | |||
| analyzedDeps = new Hashtable<String, String>(); | |||
| for (Enumeration<String> e = toAnalyze.keys(); e.hasMoreElements();) { | |||
| String classname = e.nextElement(); | |||
| dependencies.put(classname, classname); | |||
| try { | |||
| File container = getClassContainer(classname); | |||
| @@ -90,10 +90,7 @@ public class AntAnalyzer extends AbstractAnalyzer { | |||
| } | |||
| ClassFile classFile = new ClassFile(); | |||
| classFile.read(inStream); | |||
| Vector dependencyList = classFile.getClassRefs(); | |||
| Enumeration depEnum = dependencyList.elements(); | |||
| while (depEnum.hasMoreElements()) { | |||
| String dependency = (String) depEnum.nextElement(); | |||
| for (String dependency : classFile.getClassRefs()) { | |||
| analyzedDeps.put(dependency, dependency); | |||
| } | |||
| } finally { | |||
| @@ -110,9 +107,7 @@ public class AntAnalyzer extends AbstractAnalyzer { | |||
| toAnalyze.clear(); | |||
| // now recover all the dependencies collected and add to the list. | |||
| Enumeration depsEnum = analyzedDeps.elements(); | |||
| while (depsEnum.hasMoreElements()) { | |||
| String className = (String) depsEnum.nextElement(); | |||
| for (String className : analyzedDeps.values()) { | |||
| if (!dependencies.containsKey(className)) { | |||
| toAnalyze.put(className, className); | |||
| } | |||
| @@ -120,20 +115,18 @@ public class AntAnalyzer extends AbstractAnalyzer { | |||
| } | |||
| // pick up the last round of dependencies that were determined | |||
| Enumeration depsEnum = analyzedDeps.elements(); | |||
| while (depsEnum.hasMoreElements()) { | |||
| String className = (String) depsEnum.nextElement(); | |||
| for (String className : analyzedDeps.values()) { | |||
| dependencies.put(className, className); | |||
| } | |||
| files.removeAllElements(); | |||
| for (Enumeration e = containers.keys(); e.hasMoreElements();) { | |||
| files.addElement((File) e.nextElement()); | |||
| for (File f : containers.keySet()) { | |||
| files.add(f); | |||
| } | |||
| classes.removeAllElements(); | |||
| for (Enumeration e = dependencies.keys(); e.hasMoreElements();) { | |||
| classes.addElement((String) e.nextElement()); | |||
| for (String dependency :dependencies.keySet()) { | |||
| classes.add(dependency); | |||
| } | |||
| } | |||
| @@ -86,9 +86,9 @@ public class ClassFile { | |||
| * | |||
| * @return a vector of class names which this class references | |||
| */ | |||
| public Vector getClassRefs() { | |||
| public Vector<String> getClassRefs() { | |||
| Vector classRefs = new Vector(); | |||
| Vector<String> classRefs = new Vector<String>(); | |||
| final int size = constantPool.size(); | |||
| for (int i = 0; i < size; ++i) { | |||
| @@ -99,7 +99,7 @@ public class ClassFile { | |||
| ClassCPInfo classEntry = (ClassCPInfo) entry; | |||
| if (!classEntry.getClassName().equals(className)) { | |||
| classRefs.addElement( | |||
| classRefs.add( | |||
| ClassFileUtils.convertSlashName(classEntry.getClassName())); | |||
| } | |||
| } | |||
| @@ -19,9 +19,10 @@ package org.apache.tools.ant.taskdefs.optional.depend.constantpool; | |||
| import java.io.DataInputStream; | |||
| import java.io.IOException; | |||
| import java.util.Enumeration; | |||
| import java.util.Hashtable; | |||
| import java.util.Vector; | |||
| import java.util.ArrayList; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| /** | |||
| * The constant pool of a Java class. The constant pool is a collection of | |||
| @@ -34,23 +35,19 @@ import java.util.Vector; | |||
| public class ConstantPool { | |||
| /** The entries in the constant pool. */ | |||
| private Vector entries; | |||
| private final List<ConstantPoolEntry> entries = new ArrayList<ConstantPoolEntry>(); | |||
| /** | |||
| * A Hashtable of UTF8 entries - used to get constant pool indexes of | |||
| * the UTF8 values quickly | |||
| */ | |||
| private Hashtable utf8Indexes; | |||
| private final Map<String, Integer> utf8Indexes = new HashMap<String, Integer>(); | |||
| /** Initialise the constant pool. */ | |||
| public ConstantPool() { | |||
| entries = new Vector(); | |||
| // The zero index is never present in the constant pool itself so | |||
| // we add a null entry for it | |||
| entries.addElement(null); | |||
| utf8Indexes = new Hashtable(); | |||
| entries.add(null); | |||
| } | |||
| /** | |||
| @@ -92,13 +89,13 @@ public class ConstantPool { | |||
| public int addEntry(ConstantPoolEntry entry) { | |||
| int index = entries.size(); | |||
| entries.addElement(entry); | |||
| entries.add(entry); | |||
| int numSlots = entry.getNumEntries(); | |||
| // add null entries for any additional slots required. | |||
| for (int j = 0; j < numSlots - 1; ++j) { | |||
| entries.addElement(null); | |||
| entries.add(null); | |||
| } | |||
| if (entry instanceof Utf8CPInfo) { | |||
| @@ -116,9 +113,7 @@ public class ConstantPool { | |||
| * into the actual data for that entry. | |||
| */ | |||
| public void resolve() { | |||
| for (Enumeration i = entries.elements(); i.hasMoreElements();) { | |||
| ConstantPoolEntry poolInfo = (ConstantPoolEntry) i.nextElement(); | |||
| for (ConstantPoolEntry poolInfo : entries) { | |||
| if (poolInfo != null && !poolInfo.isResolved()) { | |||
| poolInfo.resolve(this); | |||
| } | |||
| @@ -133,7 +128,7 @@ public class ConstantPool { | |||
| * @return the constant pool entry at that index. | |||
| */ | |||
| public ConstantPoolEntry getEntry(int index) { | |||
| return (ConstantPoolEntry) entries.elementAt(index); | |||
| return entries.get(index); | |||
| } | |||
| /** | |||
| @@ -145,7 +140,7 @@ public class ConstantPool { | |||
| */ | |||
| public int getUTF8Entry(String value) { | |||
| int index = -1; | |||
| Integer indexInteger = (Integer) utf8Indexes.get(value); | |||
| Integer indexInteger = utf8Indexes.get(value); | |||
| if (indexInteger != null) { | |||
| index = indexInteger.intValue(); | |||
| @@ -167,7 +162,7 @@ public class ConstantPool { | |||
| final int size = entries.size(); | |||
| for (int i = 0; i < size && index == -1; ++i) { | |||
| Object element = entries.elementAt(i); | |||
| Object element = entries.get(i); | |||
| if (element instanceof ClassCPInfo) { | |||
| ClassCPInfo classinfo = (ClassCPInfo) element; | |||
| @@ -194,7 +189,7 @@ public class ConstantPool { | |||
| final int size = entries.size(); | |||
| for (int i = 0; i < size && index == -1; ++i) { | |||
| Object element = entries.elementAt(i); | |||
| Object element = entries.get(i); | |||
| if (element instanceof ConstantCPInfo) { | |||
| ConstantCPInfo constantEntry = (ConstantCPInfo) element; | |||
| @@ -225,7 +220,7 @@ public class ConstantPool { | |||
| final int size = entries.size(); | |||
| for (int i = 0; i < size && index == -1; ++i) { | |||
| Object element = entries.elementAt(i); | |||
| Object element = entries.get(i); | |||
| if (element instanceof MethodRefCPInfo) { | |||
| MethodRefCPInfo methodRefEntry = (MethodRefCPInfo) element; | |||
| @@ -260,7 +255,7 @@ public class ConstantPool { | |||
| final int size = entries.size(); | |||
| for (int i = 0; i < size && index == -1; ++i) { | |||
| Object element = entries.elementAt(i); | |||
| Object element = entries.get(i); | |||
| if (element instanceof InterfaceMethodRefCPInfo) { | |||
| InterfaceMethodRefCPInfo interfaceMethodRefEntry | |||
| @@ -297,7 +292,7 @@ public class ConstantPool { | |||
| final int size = entries.size(); | |||
| for (int i = 0; i < size && index == -1; ++i) { | |||
| Object element = entries.elementAt(i); | |||
| Object element = entries.get(i); | |||
| if (element instanceof FieldRefCPInfo) { | |||
| FieldRefCPInfo fieldRefEntry = (FieldRefCPInfo) element; | |||
| @@ -327,7 +322,7 @@ public class ConstantPool { | |||
| final int size = entries.size(); | |||
| for (int i = 0; i < size && index == -1; ++i) { | |||
| Object element = entries.elementAt(i); | |||
| Object element = entries.get(i); | |||
| if (element instanceof NameAndTypeCPInfo) { | |||
| NameAndTypeCPInfo nameAndTypeEntry | |||
| @@ -349,7 +344,7 @@ public class ConstantPool { | |||
| * @return the constant pool entries as strings | |||
| */ | |||
| public String toString() { | |||
| StringBuffer sb = new StringBuffer("\n"); | |||
| StringBuilder sb = new StringBuilder("\n"); | |||
| final int size = entries.size(); | |||
| for (int i = 0; i < size; ++i) { | |||
| @@ -18,10 +18,11 @@ | |||
| package org.apache.tools.ant.types; | |||
| import java.io.File; | |||
| import java.util.ArrayList; | |||
| import java.util.Collections; | |||
| import java.util.Enumeration; | |||
| import java.util.Iterator; | |||
| import java.util.List; | |||
| import java.util.Stack; | |||
| import java.util.Vector; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.FileScanner; | |||
| @@ -62,8 +63,8 @@ public abstract class AbstractFileSet extends DataType | |||
| implements Cloneable, SelectorContainer { | |||
| private PatternSet defaultPatterns = new PatternSet(); | |||
| private Vector additionalPatterns = new Vector(); | |||
| private Vector selectors = new Vector(); | |||
| private List<PatternSet> additionalPatterns = new ArrayList<PatternSet>(); | |||
| private List<FileSelector> selectors = new ArrayList<FileSelector>(); | |||
| private File dir; | |||
| private boolean useDefaultExcludes = true; | |||
| @@ -165,7 +166,7 @@ public abstract class AbstractFileSet extends DataType | |||
| throw noChildrenAllowed(); | |||
| } | |||
| PatternSet patterns = new PatternSet(); | |||
| additionalPatterns.addElement(patterns); | |||
| additionalPatterns.add(patterns); | |||
| directoryScanner = null; | |||
| return patterns; | |||
| } | |||
| @@ -579,9 +580,7 @@ public abstract class AbstractFileSet extends DataType | |||
| if (defaultPatterns.hasPatterns(getProject())) { | |||
| return true; | |||
| } | |||
| Enumeration e = additionalPatterns.elements(); | |||
| while (e.hasMoreElements()) { | |||
| PatternSet ps = (PatternSet) e.nextElement(); | |||
| for (PatternSet ps : additionalPatterns) { | |||
| if (ps.hasPatterns(getProject())) { | |||
| return true; | |||
| } | |||
| @@ -621,12 +620,12 @@ public abstract class AbstractFileSet extends DataType | |||
| * | |||
| * @return an <code>Enumeration</code> of selectors. | |||
| */ | |||
| public synchronized Enumeration selectorElements() { | |||
| public synchronized Enumeration<FileSelector> selectorElements() { | |||
| if (isReference()) { | |||
| return getRef(getProject()).selectorElements(); | |||
| } | |||
| dieOnCircularReference(); | |||
| return selectors.elements(); | |||
| return Collections.enumeration(selectors); | |||
| } | |||
| /** | |||
| @@ -638,7 +637,7 @@ public abstract class AbstractFileSet extends DataType | |||
| if (isReference()) { | |||
| throw noChildrenAllowed(); | |||
| } | |||
| selectors.addElement(selector); | |||
| selectors.add(selector); | |||
| directoryScanner = null; | |||
| setChecked(false); | |||
| } | |||
| @@ -844,13 +843,11 @@ public abstract class AbstractFileSet extends DataType | |||
| try { | |||
| AbstractFileSet fs = (AbstractFileSet) super.clone(); | |||
| fs.defaultPatterns = (PatternSet) defaultPatterns.clone(); | |||
| fs.additionalPatterns = new Vector(additionalPatterns.size()); | |||
| Enumeration e = additionalPatterns.elements(); | |||
| while (e.hasMoreElements()) { | |||
| fs.additionalPatterns | |||
| .addElement(((PatternSet) e.nextElement()).clone()); | |||
| fs.additionalPatterns = new ArrayList<PatternSet>(additionalPatterns.size()); | |||
| for (PatternSet ps : additionalPatterns) { | |||
| fs.additionalPatterns.add((PatternSet) ps.clone()); | |||
| } | |||
| fs.selectors = new Vector(selectors); | |||
| fs.selectors = new ArrayList<FileSelector>(selectors); | |||
| return fs; | |||
| } catch (CloneNotSupportedException e) { | |||
| throw new BuildException(e); | |||
| @@ -898,13 +895,12 @@ public abstract class AbstractFileSet extends DataType | |||
| PatternSet ps = (PatternSet) defaultPatterns.clone(); | |||
| final int count = additionalPatterns.size(); | |||
| for (int i = 0; i < count; i++) { | |||
| Object o = additionalPatterns.elementAt(i); | |||
| ps.append((PatternSet) o, p); | |||
| ps.append(additionalPatterns.get(i), p); | |||
| } | |||
| return ps; | |||
| } | |||
| protected synchronized void dieOnCircularReference(Stack stk, Project p) | |||
| protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) | |||
| throws BuildException { | |||
| if (isChecked()) { | |||
| return; | |||
| @@ -912,14 +908,12 @@ public abstract class AbstractFileSet extends DataType | |||
| if (isReference()) { | |||
| super.dieOnCircularReference(stk, p); | |||
| } else { | |||
| for (Iterator i = selectors.iterator(); i.hasNext(); ) { | |||
| Object o = i.next(); | |||
| if (o instanceof DataType) { | |||
| pushAndInvokeCircularReferenceCheck((DataType) o, stk, p); | |||
| for (FileSelector fileSelector : selectors) { | |||
| if (fileSelector instanceof DataType) { | |||
| pushAndInvokeCircularReferenceCheck((DataType) fileSelector, stk, p); | |||
| } | |||
| } | |||
| for (Iterator i = additionalPatterns.iterator(); i.hasNext(); ) { | |||
| PatternSet ps = (PatternSet) i.next(); | |||
| for (PatternSet ps : additionalPatterns) { | |||
| pushAndInvokeCircularReferenceCheck(ps, stk, p); | |||
| } | |||
| setChecked(true); | |||
| @@ -207,6 +207,7 @@ public abstract class ArchiveFileSet extends FileSet { | |||
| * @throws BuildException if the reference is invalid (circular ref, wrong class, etc). | |||
| * @since Ant 1.8 | |||
| */ | |||
| // TODO is the above true? AFAICT the calls look circular :/ | |||
| protected Object getCheckedRef(Project p) { | |||
| return getRef(p); | |||
| } | |||
| @@ -475,7 +476,7 @@ public abstract class ArchiveFileSet extends FileSet { | |||
| */ | |||
| public Object clone() { | |||
| if (isReference()) { | |||
| return ((ArchiveFileSet) getRef(getProject())).clone(); | |||
| return getCheckedRef(ArchiveFileSet.class, getDataTypeName(), getProject()).clone(); | |||
| } | |||
| return super.clone(); | |||
| } | |||
| @@ -545,7 +546,7 @@ public abstract class ArchiveFileSet extends FileSet { | |||
| } | |||
| } | |||
| protected synchronized void dieOnCircularReference(Stack stk, Project p) | |||
| protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) | |||
| throws BuildException { | |||
| if (isChecked()) { | |||
| return; | |||
| @@ -20,7 +20,6 @@ package org.apache.tools.ant.types; | |||
| import java.io.File; | |||
| import java.util.Map; | |||
| import java.util.Set; | |||
| import java.util.TreeMap; | |||
| import java.util.Iterator; | |||
| @@ -62,22 +61,22 @@ public abstract class ArchiveScanner extends DirectoryScanner { | |||
| /** | |||
| * record list of all file zip entries | |||
| */ | |||
| private TreeMap fileEntries = new TreeMap(); | |||
| private Map<String, Resource> fileEntries = new TreeMap<String, Resource>(); | |||
| /** | |||
| * record list of all directory zip entries | |||
| */ | |||
| private TreeMap dirEntries = new TreeMap(); | |||
| private Map<String, Resource> dirEntries = new TreeMap<String, Resource>(); | |||
| /** | |||
| * record list of matching file zip entries | |||
| */ | |||
| private TreeMap matchFileEntries = new TreeMap(); | |||
| private Map<String, Resource> matchFileEntries = new TreeMap<String, Resource>(); | |||
| /** | |||
| * record list of matching directory zip entries | |||
| */ | |||
| private TreeMap matchDirEntries = new TreeMap(); | |||
| private Map<String, Resource> matchDirEntries = new TreeMap<String, Resource>(); | |||
| /** | |||
| * encoding of file names. | |||
| @@ -159,8 +158,7 @@ public abstract class ArchiveScanner extends DirectoryScanner { | |||
| return super.getIncludedFiles(); | |||
| } | |||
| scanme(); | |||
| Set s = matchFileEntries.keySet(); | |||
| return (String[]) (s.toArray(new String[s.size()])); | |||
| return matchFileEntries.keySet().toArray(new String[matchFileEntries.size()]); | |||
| } | |||
| /** | |||
| @@ -189,8 +187,7 @@ public abstract class ArchiveScanner extends DirectoryScanner { | |||
| return super.getIncludedDirectories(); | |||
| } | |||
| scanme(); | |||
| Set s = matchDirEntries.keySet(); | |||
| return (String[]) (s.toArray(new String[s.size()])); | |||
| return matchDirEntries.keySet().toArray(new String[matchDirEntries.size()]); | |||
| } | |||
| /** | |||
| @@ -212,7 +209,7 @@ public abstract class ArchiveScanner extends DirectoryScanner { | |||
| * @return an Iterator of Resources. | |||
| * @since Ant 1.7 | |||
| */ | |||
| /* package-private for now */ Iterator getResourceFiles(Project project) { | |||
| /* package-private for now */ Iterator<Resource> getResourceFiles(Project project) { | |||
| if (src == null) { | |||
| return new FileResourceIterator(project, getBasedir(), getIncludedFiles()); | |||
| } | |||
| @@ -226,7 +223,7 @@ public abstract class ArchiveScanner extends DirectoryScanner { | |||
| * @return an Iterator of Resources. | |||
| * @since Ant 1.7 | |||
| */ | |||
| /* package-private for now */ Iterator getResourceDirectories(Project project) { | |||
| /* package-private for now */ Iterator<Resource> getResourceDirectories(Project project) { | |||
| if (src == null) { | |||
| return new FileResourceIterator(project, getBasedir(), getIncludedDirectories()); | |||
| } | |||
| @@ -280,12 +277,12 @@ public abstract class ArchiveScanner extends DirectoryScanner { | |||
| // first check if the archive needs to be scanned again | |||
| scanme(); | |||
| if (fileEntries.containsKey(name)) { | |||
| return (Resource) fileEntries.get(name); | |||
| return fileEntries.get(name); | |||
| } | |||
| name = trimSeparator(name); | |||
| if (dirEntries.containsKey(name)) { | |||
| return (Resource) dirEntries.get(name); | |||
| return dirEntries.get(name); | |||
| } | |||
| return new Resource(name); | |||
| } | |||
| @@ -308,10 +305,10 @@ public abstract class ArchiveScanner extends DirectoryScanner { | |||
| */ | |||
| protected abstract void fillMapsFromArchive(Resource archive, | |||
| String encoding, | |||
| Map fileEntries, | |||
| Map matchFileEntries, | |||
| Map dirEntries, | |||
| Map matchDirEntries); | |||
| Map<String, Resource> fileEntries, | |||
| Map<String, Resource> matchFileEntries, | |||
| Map<String, Resource> dirEntries, | |||
| Map<String, Resource> matchDirEntries); | |||
| /** | |||
| * if the datetime of the archive did not change since | |||
| @@ -22,7 +22,6 @@ import org.apache.tools.ant.BuildException; | |||
| import org.apache.tools.ant.Project; | |||
| import java.util.ArrayList; | |||
| import java.util.Iterator; | |||
| import java.util.List; | |||
| import java.util.ListIterator; | |||
| @@ -76,7 +75,7 @@ public class Assertions extends DataType implements Cloneable { | |||
| /** | |||
| * list of type BaseAssertion | |||
| */ | |||
| private ArrayList assertionList = new ArrayList(); | |||
| private ArrayList<BaseAssertion> assertionList = new ArrayList<BaseAssertion>(); | |||
| /** | |||
| @@ -163,7 +162,7 @@ public class Assertions extends DataType implements Cloneable { | |||
| * for adding to a command line | |||
| * @param commandList the command line to format | |||
| */ | |||
| public void applyAssertions(List commandList) { | |||
| public void applyAssertions(List<String> commandList) { | |||
| getProject().log("Applying assertions", Project.MSG_DEBUG); | |||
| Assertions clause = getFinalReference(); | |||
| //do the system assertions | |||
| @@ -176,9 +175,7 @@ public class Assertions extends DataType implements Cloneable { | |||
| } | |||
| //now any inner assertions | |||
| Iterator it = clause.assertionList.iterator(); | |||
| while (it.hasNext()) { | |||
| BaseAssertion assertion = (BaseAssertion) it.next(); | |||
| for (BaseAssertion assertion : clause.assertionList) { | |||
| String arg = assertion.toCommand(); | |||
| getProject().log("adding assertion " + arg, Project.MSG_DEBUG); | |||
| commandList.add(arg); | |||
| @@ -199,9 +196,7 @@ public class Assertions extends DataType implements Cloneable { | |||
| } | |||
| //now any inner assertions | |||
| Iterator it = clause.assertionList.iterator(); | |||
| while (it.hasNext()) { | |||
| BaseAssertion assertion = (BaseAssertion) it.next(); | |||
| for (BaseAssertion assertion : clause.assertionList) { | |||
| String arg = assertion.toCommand(); | |||
| addVmArgument(command, arg); | |||
| } | |||
| @@ -212,7 +207,7 @@ public class Assertions extends DataType implements Cloneable { | |||
| * for adding to a command line | |||
| * @param commandIterator list of commands | |||
| */ | |||
| public void applyAssertions(final ListIterator commandIterator) { | |||
| public void applyAssertions(final ListIterator<String> commandIterator) { | |||
| getProject().log("Applying assertions", Project.MSG_DEBUG); | |||
| Assertions clause = getFinalReference(); | |||
| //do the system assertions | |||
| @@ -225,9 +220,7 @@ public class Assertions extends DataType implements Cloneable { | |||
| } | |||
| //now any inner assertions | |||
| Iterator it = clause.assertionList.iterator(); | |||
| while (it.hasNext()) { | |||
| BaseAssertion assertion = (BaseAssertion) it.next(); | |||
| for (BaseAssertion assertion : clause.assertionList) { | |||
| String arg = assertion.toCommand(); | |||
| getProject().log("adding assertion " + arg, Project.MSG_DEBUG); | |||
| commandIterator.add(arg); | |||
| @@ -254,7 +247,7 @@ public class Assertions extends DataType implements Cloneable { | |||
| */ | |||
| public Object clone() throws CloneNotSupportedException { | |||
| Assertions that = (Assertions) super.clone(); | |||
| that.assertionList = (ArrayList) assertionList.clone(); | |||
| that.assertionList = new ArrayList<BaseAssertion>(assertionList); | |||
| return that; | |||
| } | |||
| @@ -20,7 +20,6 @@ package org.apache.tools.ant.types; | |||
| import java.io.File; | |||
| import java.util.StringTokenizer; | |||
| import java.util.Vector; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| import java.util.ListIterator; | |||
| @@ -59,7 +58,7 @@ public class Commandline implements Cloneable { | |||
| /** | |||
| * The arguments of the command | |||
| */ | |||
| private Vector arguments = new Vector(); | |||
| private List<Argument> arguments = new ArrayList<Argument>(); | |||
| /** | |||
| * the program to execute | |||
| @@ -232,7 +231,7 @@ public class Commandline implements Cloneable { | |||
| if (realPos == -1) { | |||
| realPos = (executable == null ? 0 : 1); | |||
| for (int i = 0; i < position; i++) { | |||
| Argument arg = (Argument) arguments.elementAt(i); | |||
| Argument arg = (Argument) arguments.get(i); | |||
| realPos += arg.getParts().length; | |||
| } | |||
| } | |||
| @@ -306,9 +305,9 @@ public class Commandline implements Cloneable { | |||
| public Argument createArgument(boolean insertAtStart) { | |||
| Argument argument = new Argument(); | |||
| if (insertAtStart) { | |||
| arguments.insertElementAt(argument, 0); | |||
| arguments.add(0, argument); | |||
| } else { | |||
| arguments.addElement(argument); | |||
| arguments.add(argument); | |||
| } | |||
| return argument; | |||
| } | |||
| @@ -349,11 +348,9 @@ public class Commandline implements Cloneable { | |||
| * @return the commandline as an array of strings. | |||
| */ | |||
| public String[] getCommandline() { | |||
| List commands = new LinkedList(); | |||
| ListIterator list = commands.listIterator(); | |||
| addCommandToList(list); | |||
| final String[] result = new String[commands.size()]; | |||
| return (String[]) commands.toArray(result); | |||
| final List<String> commands = new LinkedList<String>(); | |||
| addCommandToList(commands.listIterator()); | |||
| return commands.toArray(new String[commands.size()]); | |||
| } | |||
| /** | |||
| @@ -361,7 +358,7 @@ public class Commandline implements Cloneable { | |||
| * @param list the list to add to. | |||
| * @since Ant 1.6 | |||
| */ | |||
| public void addCommandToList(ListIterator list) { | |||
| public void addCommandToList(ListIterator<String> list) { | |||
| if (executable != null) { | |||
| list.add(executable); | |||
| } | |||
| @@ -374,10 +371,9 @@ public class Commandline implements Cloneable { | |||
| * @return the arguments as an array of strings. | |||
| */ | |||
| public String[] getArguments() { | |||
| List result = new ArrayList(arguments.size() * 2); | |||
| List<String> result = new ArrayList<String>(arguments.size() * 2); | |||
| addArgumentsToList(result.listIterator()); | |||
| String [] res = new String[result.size()]; | |||
| return (String[]) result.toArray(res); | |||
| return result.toArray(new String[result.size()]); | |||
| } | |||
| /** | |||
| @@ -385,10 +381,10 @@ public class Commandline implements Cloneable { | |||
| * @param list the list of arguments. | |||
| * @since Ant 1.6 | |||
| */ | |||
| public void addArgumentsToList(ListIterator list) { | |||
| public void addArgumentsToList(ListIterator<String> list) { | |||
| final int size = arguments.size(); | |||
| for (int i = 0; i < size; i++) { | |||
| Argument arg = (Argument) arguments.elementAt(i); | |||
| Argument arg = arguments.get(i); | |||
| String[] s = arg.getParts(); | |||
| if (s != null) { | |||
| for (int j = 0; j < s.length; j++) { | |||
| @@ -448,7 +444,7 @@ public class Commandline implements Cloneable { | |||
| return ""; | |||
| } | |||
| // path containing one or more elements | |||
| final StringBuffer result = new StringBuffer(); | |||
| final StringBuilder result = new StringBuilder(); | |||
| for (int i = 0; i < line.length; i++) { | |||
| if (i > 0) { | |||
| result.append(' '); | |||
| @@ -475,9 +471,9 @@ public class Commandline implements Cloneable { | |||
| final int inQuote = 1; | |||
| final int inDoubleQuote = 2; | |||
| int state = normal; | |||
| StringTokenizer tok = new StringTokenizer(toProcess, "\"\' ", true); | |||
| Vector v = new Vector(); | |||
| StringBuffer current = new StringBuffer(); | |||
| final StringTokenizer tok = new StringTokenizer(toProcess, "\"\' ", true); | |||
| final ArrayList<String> result = new ArrayList<String>(); | |||
| final StringBuilder current = new StringBuilder(); | |||
| boolean lastTokenHasBeenQuoted = false; | |||
| while (tok.hasMoreTokens()) { | |||
| @@ -506,8 +502,8 @@ public class Commandline implements Cloneable { | |||
| state = inDoubleQuote; | |||
| } else if (" ".equals(nextTok)) { | |||
| if (lastTokenHasBeenQuoted || current.length() != 0) { | |||
| v.addElement(current.toString()); | |||
| current = new StringBuffer(); | |||
| result.add(current.toString()); | |||
| current.setLength(0); | |||
| } | |||
| } else { | |||
| current.append(nextTok); | |||
| @@ -517,14 +513,12 @@ public class Commandline implements Cloneable { | |||
| } | |||
| } | |||
| if (lastTokenHasBeenQuoted || current.length() != 0) { | |||
| v.addElement(current.toString()); | |||
| result.add(current.toString()); | |||
| } | |||
| if (state == inQuote || state == inDoubleQuote) { | |||
| throw new BuildException("unbalanced quotes in " + toProcess); | |||
| } | |||
| String[] args = new String[v.size()]; | |||
| v.copyInto(args); | |||
| return args; | |||
| return result.toArray(new String[result.size()]); | |||
| } | |||
| /** | |||
| @@ -543,7 +537,7 @@ public class Commandline implements Cloneable { | |||
| public Object clone() { | |||
| try { | |||
| Commandline c = (Commandline) super.clone(); | |||
| c.arguments = (Vector) arguments.clone(); | |||
| c.arguments = new ArrayList<Argument>(arguments); | |||
| return c; | |||
| } catch (CloneNotSupportedException e) { | |||
| throw new BuildException(e); | |||
| @@ -555,7 +549,7 @@ public class Commandline implements Cloneable { | |||
| */ | |||
| public void clear() { | |||
| executable = null; | |||
| arguments.removeAllElements(); | |||
| arguments.clear(); | |||
| } | |||
| /** | |||
| @@ -563,7 +557,7 @@ public class Commandline implements Cloneable { | |||
| * another operation. | |||
| */ | |||
| public void clearArgs() { | |||
| arguments.removeAllElements(); | |||
| arguments.clear(); | |||
| } | |||
| /** | |||
| @@ -689,7 +683,7 @@ public class Commandline implements Cloneable { | |||
| * @since Ant 1.7 | |||
| * @return an Iterator. | |||
| */ | |||
| public Iterator iterator() { | |||
| public Iterator<Argument> iterator() { | |||
| return arguments.iterator(); | |||
| } | |||
| } | |||
| @@ -79,7 +79,7 @@ public class CommandlineJava implements Cloneable { | |||
| /** the system properties. */ | |||
| Properties sys = null; | |||
| // CheckStyle:VisibilityModifier ON | |||
| private Vector propertySets = new Vector(); | |||
| private Vector<PropertySet> propertySets = new Vector<PropertySet>(); | |||
| /** | |||
| * Get the properties as an array; this is an override of the | |||
| @@ -89,13 +89,12 @@ public class CommandlineJava implements Cloneable { | |||
| */ | |||
| public String[] getVariables() throws BuildException { | |||
| List definitions = new LinkedList(); | |||
| ListIterator list = definitions.listIterator(); | |||
| addDefinitionsToList(list); | |||
| List<String> definitions = new LinkedList<String>(); | |||
| addDefinitionsToList(definitions.listIterator()); | |||
| if (definitions.size() == 0) { | |||
| return null; | |||
| } else { | |||
| return (String[]) definitions.toArray(new String[definitions.size()]); | |||
| return definitions.toArray(new String[definitions.size()]); | |||
| } | |||
| } | |||
| @@ -103,7 +102,7 @@ public class CommandlineJava implements Cloneable { | |||
| * Add all definitions (including property sets) to a list. | |||
| * @param listIt list iterator supporting add method. | |||
| */ | |||
| public void addDefinitionsToList(ListIterator listIt) { | |||
| public void addDefinitionsToList(ListIterator<String> listIt) { | |||
| String[] props = super.getVariables(); | |||
| if (props != null) { | |||
| for (int i = 0; i < props.length; i++) { | |||
| @@ -111,7 +110,7 @@ public class CommandlineJava implements Cloneable { | |||
| } | |||
| } | |||
| Properties propertySetProperties = mergePropertySets(); | |||
| for (Enumeration e = propertySetProperties.keys(); | |||
| for (Enumeration<?> e = propertySetProperties.keys(); | |||
| e.hasMoreElements();) { | |||
| String key = (String) e.nextElement(); | |||
| String value = propertySetProperties.getProperty(key); | |||
| @@ -138,7 +137,7 @@ public class CommandlineJava implements Cloneable { | |||
| try { | |||
| sys = System.getProperties(); | |||
| Properties p = new Properties(); | |||
| for (Enumeration e = sys.propertyNames(); e.hasMoreElements();) { | |||
| for (Enumeration<?> e = sys.propertyNames(); e.hasMoreElements();) { | |||
| String name = (String) e.nextElement(); | |||
| String value = sys.getProperty(name); | |||
| if (name != null && value != null) { | |||
| @@ -146,8 +145,7 @@ public class CommandlineJava implements Cloneable { | |||
| } | |||
| } | |||
| p.putAll(mergePropertySets()); | |||
| for (Enumeration e = variables.elements(); e.hasMoreElements();) { | |||
| Environment.Variable v = (Environment.Variable) e.nextElement(); | |||
| for (Environment.Variable v : variables) { | |||
| v.validate(); | |||
| p.put(v.getKey(), v.getValue()); | |||
| } | |||
| @@ -180,11 +178,12 @@ public class CommandlineJava implements Cloneable { | |||
| * @return a cloned instance of SysProperties. | |||
| * @exception CloneNotSupportedException for signature. | |||
| */ | |||
| @SuppressWarnings("unchecked") | |||
| public Object clone() throws CloneNotSupportedException { | |||
| try { | |||
| SysProperties c = (SysProperties) super.clone(); | |||
| c.variables = (Vector) variables.clone(); | |||
| c.propertySets = (Vector) propertySets.clone(); | |||
| c.variables = (Vector<Environment.Variable>) variables.clone(); | |||
| c.propertySets = (Vector<PropertySet>) propertySets.clone(); | |||
| return c; | |||
| } catch (CloneNotSupportedException e) { | |||
| return null; | |||
| @@ -215,9 +214,7 @@ public class CommandlineJava implements Cloneable { | |||
| */ | |||
| private Properties mergePropertySets() { | |||
| Properties p = new Properties(); | |||
| for (Enumeration e = propertySets.elements(); | |||
| e.hasMoreElements();) { | |||
| PropertySet ps = (PropertySet) e.nextElement(); | |||
| for (PropertySet ps : propertySets) { | |||
| p.putAll(ps.getProperties()); | |||
| } | |||
| return p; | |||
| @@ -399,12 +396,11 @@ public class CommandlineJava implements Cloneable { | |||
| */ | |||
| public String[] getCommandline() { | |||
| //create the list | |||
| List commands = new LinkedList(); | |||
| final ListIterator listIterator = commands.listIterator(); | |||
| List<String> commands = new LinkedList<String>(); | |||
| //fill it | |||
| addCommandsToList(listIterator); | |||
| addCommandsToList(commands.listIterator()); | |||
| //convert to an array | |||
| return (String[]) commands.toArray(new String[commands.size()]); | |||
| return commands.toArray(new String[commands.size()]); | |||
| } | |||
| /** | |||
| @@ -412,7 +408,7 @@ public class CommandlineJava implements Cloneable { | |||
| * @param listIterator an iterator that supports the add method. | |||
| * @since Ant 1.6 | |||
| */ | |||
| private void addCommandsToList(final ListIterator listIterator) { | |||
| private void addCommandsToList(final ListIterator<String> listIterator) { | |||
| //create the command to run Java, including user specified options | |||
| getActualVMCommand().addCommandToList(listIterator); | |||
| // properties are part of the vm options... | |||
| @@ -25,7 +25,8 @@ import org.apache.tools.ant.UnknownElement; | |||
| import org.apache.tools.ant.Target; | |||
| import org.apache.tools.ant.helper.ProjectHelperImpl; | |||
| import java.util.Vector; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| /** | |||
| @@ -50,7 +51,7 @@ public class Description extends DataType { | |||
| */ | |||
| public void addText(String text) { | |||
| ProjectHelper ph = (ProjectHelper) getProject().getReference(ProjectHelper.PROJECTHELPER_REFERENCE); | |||
| ProjectHelper ph = getProject().getReference(ProjectHelper.PROJECTHELPER_REFERENCE); | |||
| if (!(ph instanceof ProjectHelperImpl)) { | |||
| // New behavior for delayed task creation. Description | |||
| // will be evaluated in Project.getDescription() | |||
| @@ -73,31 +74,23 @@ public class Description extends DataType { | |||
| * the targets. | |||
| */ | |||
| public static String getDescription(Project project) { | |||
| Vector targets = (Vector) project.getReference(ProjectHelper2.REFID_TARGETS); | |||
| List<Target> targets = project.getReference(ProjectHelper2.REFID_TARGETS); | |||
| if (targets == null) { | |||
| return null; | |||
| } | |||
| StringBuffer description = new StringBuffer(); | |||
| final int size = targets.size(); | |||
| for (int i = 0; i < size; i++) { | |||
| Target t = (Target) targets.elementAt(i); | |||
| StringBuilder description = new StringBuilder(); | |||
| for (Target t : targets) { | |||
| concatDescriptions(project, t, description); | |||
| } | |||
| return description.toString(); | |||
| } | |||
| private static void concatDescriptions(Project project, Target t, | |||
| StringBuffer description) { | |||
| StringBuilder description) { | |||
| if (t == null) { | |||
| return; | |||
| } | |||
| Vector tasks = findElementInTarget(project, t, "description"); | |||
| if (tasks == null) { | |||
| return; | |||
| } | |||
| final int size = tasks.size(); | |||
| for (int i = 0; i < size; i++) { | |||
| Task task = (Task) tasks.elementAt(i); | |||
| for (Task task : findElementInTarget(project, t, "description")) { | |||
| if (!(task instanceof UnknownElement)) { | |||
| continue; | |||
| } | |||
| @@ -109,13 +102,12 @@ public class Description extends DataType { | |||
| } | |||
| } | |||
| private static Vector findElementInTarget(Project project, | |||
| private static List<Task> findElementInTarget(Project project, | |||
| Target t, String name) { | |||
| Task[] tasks = t.getTasks(); | |||
| Vector elems = new Vector(); | |||
| for (int i = 0; i < tasks.length; i++) { | |||
| if (name.equals(tasks[i].getTaskName())) { | |||
| elems.addElement(tasks[i]); | |||
| final List<Task> elems = new ArrayList<Task>(); | |||
| for (Task task : t.getTasks()) { | |||
| if (name.equals(task.getTaskName())) { | |||
| elems.add(task); | |||
| } | |||
| } | |||
| return elems; | |||
| @@ -67,7 +67,7 @@ public abstract class EnumeratedAttribute { | |||
| * http://issues.apache.org/bugzilla/show_bug.cgi?id=14831</a> | |||
| */ | |||
| public static EnumeratedAttribute getInstance( | |||
| Class/*<? extends EnumeratedAttribute>*/ clazz, | |||
| Class<? extends EnumeratedAttribute> clazz, | |||
| String value) throws BuildException { | |||
| if (!EnumeratedAttribute.class.isAssignableFrom(clazz)) { | |||
| throw new BuildException( | |||
| @@ -75,7 +75,7 @@ public abstract class EnumeratedAttribute { | |||
| } | |||
| EnumeratedAttribute ea = null; | |||
| try { | |||
| ea = (EnumeratedAttribute) clazz.newInstance(); | |||
| ea = clazz.newInstance(); | |||
| } catch (Exception e) { | |||
| throw new BuildException(e); | |||
| } | |||
| @@ -19,8 +19,9 @@ | |||
| package org.apache.tools.ant.types; | |||
| import java.io.File; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| import java.util.StringTokenizer; | |||
| import java.util.Vector; | |||
| import java.util.Iterator; | |||
| import org.apache.tools.ant.Project; | |||
| @@ -36,7 +37,7 @@ import org.apache.tools.ant.types.resources.FileResourceIterator; | |||
| */ | |||
| public class FileList extends DataType implements ResourceCollection { | |||
| private Vector filenames = new Vector(); | |||
| private List<String> filenames = new ArrayList<String>(); | |||
| private File dir; | |||
| /** | |||
| @@ -108,7 +109,7 @@ public class FileList extends DataType implements ResourceCollection { | |||
| StringTokenizer tok = new StringTokenizer( | |||
| filenames, ", \t\n\r\f", false); | |||
| while (tok.hasMoreTokens()) { | |||
| this.filenames.addElement(tok.nextToken()); | |||
| this.filenames.add(tok.nextToken()); | |||
| } | |||
| } | |||
| } | |||
| @@ -131,9 +132,7 @@ public class FileList extends DataType implements ResourceCollection { | |||
| throw new BuildException("No files specified for filelist."); | |||
| } | |||
| String[] result = new String[filenames.size()]; | |||
| filenames.copyInto(result); | |||
| return result; | |||
| return filenames.toArray(new String[filenames.size()]); | |||
| } | |||
| /** | |||
| @@ -180,7 +179,7 @@ public class FileList extends DataType implements ResourceCollection { | |||
| throw new BuildException( | |||
| "No name specified in nested file element"); | |||
| } | |||
| filenames.addElement(name.getName()); | |||
| filenames.add(name.getName()); | |||
| } | |||
| /** | |||
| @@ -190,10 +189,10 @@ public class FileList extends DataType implements ResourceCollection { | |||
| */ | |||
| public Iterator<Resource> iterator() { | |||
| if (isReference()) { | |||
| return ((FileList) getRef(getProject())).iterator(); | |||
| return getRef(getProject()).iterator(); | |||
| } | |||
| return new FileResourceIterator(getProject(), dir, | |||
| (String[]) (filenames.toArray(new String[filenames.size()]))); | |||
| filenames.toArray(new String[filenames.size()])); | |||
| } | |||
| /** | |||
| @@ -17,18 +17,8 @@ | |||
| */ | |||
| package org.apache.tools.ant.types; | |||
| // java io classes | |||
| // java util classes | |||
| import java.util.Enumeration; | |||
| import java.util.Vector; | |||
| // ant classes | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| /** | |||
| @@ -38,7 +28,7 @@ import java.util.Vector; | |||
| */ | |||
| public class FilterSetCollection { | |||
| private Vector filterSets = new Vector(); | |||
| private List<FilterSet> filterSets = new ArrayList<FilterSet>(); | |||
| /** | |||
| * Constructor for a FilterSetCollection. | |||
| @@ -61,7 +51,7 @@ public class FilterSetCollection { | |||
| * @param filterSet a <code>FilterSet</code> value | |||
| */ | |||
| public void addFilterSet(FilterSet filterSet) { | |||
| filterSets.addElement(filterSet); | |||
| filterSets.add(filterSet); | |||
| } | |||
| /** | |||
| @@ -73,8 +63,7 @@ public class FilterSetCollection { | |||
| */ | |||
| public String replaceTokens(String line) { | |||
| String replacedLine = line; | |||
| for (Enumeration e = filterSets.elements(); e.hasMoreElements();) { | |||
| FilterSet filterSet = (FilterSet) e.nextElement(); | |||
| for (FilterSet filterSet : filterSets) { | |||
| replacedLine = filterSet.replaceTokens(replacedLine); | |||
| } | |||
| return replacedLine; | |||
| @@ -86,8 +75,7 @@ public class FilterSetCollection { | |||
| * @return Return true if there are filter in this set otherwise false. | |||
| */ | |||
| public boolean hasFilters() { | |||
| for (Enumeration e = filterSets.elements(); e.hasMoreElements();) { | |||
| FilterSet filterSet = (FilterSet) e.nextElement(); | |||
| for (FilterSet filterSet : filterSets) { | |||
| if (filterSet.hasFilters()) { | |||
| return true; | |||
| } | |||
| @@ -230,8 +230,7 @@ public class Mapper extends DataType implements Cloneable { | |||
| } | |||
| try { | |||
| FileNameMapper m | |||
| = (FileNameMapper) (getImplementationClass().newInstance()); | |||
| FileNameMapper m = getImplementationClass().newInstance(); | |||
| final Project p = getProject(); | |||
| if (p != null) { | |||
| p.setProjectReference(m); | |||
| @@ -252,7 +251,7 @@ public class Mapper extends DataType implements Cloneable { | |||
| * @return <code>Class</code>. | |||
| * @throws ClassNotFoundException if the class cannot be found | |||
| */ | |||
| protected Class getImplementationClass() throws ClassNotFoundException { | |||
| protected Class<? extends FileNameMapper> getImplementationClass() throws ClassNotFoundException { | |||
| String cName = this.classname; | |||
| if (type != null) { | |||
| @@ -264,7 +263,7 @@ public class Mapper extends DataType implements Cloneable { | |||
| // Memory leak in line below | |||
| : getProject().createClassLoader(classpath); | |||
| return Class.forName(cName, true, loader); | |||
| return Class.forName(cName, true, loader).asSubclass(FileNameMapper.class); | |||
| } | |||
| /** | |||
| @@ -275,7 +274,7 @@ public class Mapper extends DataType implements Cloneable { | |||
| * @return the referenced Mapper | |||
| */ | |||
| protected Mapper getRef() { | |||
| return (Mapper) getCheckedRef(); | |||
| return getCheckedRef(Mapper.class, getDataTypeName()); | |||
| } | |||
| /** | |||
| @@ -21,9 +21,9 @@ import java.io.BufferedReader; | |||
| import java.io.File; | |||
| import java.io.FileReader; | |||
| import java.io.IOException; | |||
| import java.util.Enumeration; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| import java.util.StringTokenizer; | |||
| import java.util.Vector; | |||
| import org.apache.tools.ant.BuildException; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.PropertyHelper; | |||
| @@ -37,10 +37,10 @@ import org.apache.tools.ant.util.FileUtils; | |||
| * | |||
| */ | |||
| public class PatternSet extends DataType implements Cloneable { | |||
| private Vector includeList = new Vector(); | |||
| private Vector excludeList = new Vector(); | |||
| private Vector includesFileList = new Vector(); | |||
| private Vector excludesFileList = new Vector(); | |||
| private List<NameEntry> includeList = new ArrayList<NameEntry>(); | |||
| private List<NameEntry> excludeList = new ArrayList<NameEntry>(); | |||
| private List<NameEntry> includesFileList = new ArrayList<NameEntry>(); | |||
| private List<NameEntry> excludesFileList = new ArrayList<NameEntry>(); | |||
| /** | |||
| * inner class to hold a name on list. "If" and "Unless" attributes | |||
| @@ -318,9 +318,9 @@ public class PatternSet extends DataType implements Cloneable { | |||
| /** | |||
| * add a name entry to the given list | |||
| */ | |||
| private NameEntry addPatternToList(Vector list) { | |||
| private NameEntry addPatternToList(List<NameEntry> list) { | |||
| NameEntry result = new NameEntry(); | |||
| list.addElement(result); | |||
| list.add(result); | |||
| return result; | |||
| } | |||
| @@ -354,7 +354,7 @@ public class PatternSet extends DataType implements Cloneable { | |||
| * Reads path matching patterns from a file and adds them to the | |||
| * includes or excludes list (as appropriate). | |||
| */ | |||
| private void readPatterns(File patternfile, Vector patternlist, Project p) | |||
| private void readPatterns(File patternfile, List<NameEntry> patternlist, Project p) | |||
| throws BuildException { | |||
| BufferedReader patternReader = null; | |||
| @@ -458,21 +458,18 @@ public class PatternSet extends DataType implements Cloneable { | |||
| /** | |||
| * Convert a vector of NameEntry elements into an array of Strings. | |||
| */ | |||
| private String[] makeArray(Vector list, Project p) { | |||
| private String[] makeArray(List<NameEntry> list, Project p) { | |||
| if (list.size() == 0) { | |||
| return null; | |||
| } | |||
| Vector tmpNames = new Vector(); | |||
| for (Enumeration e = list.elements(); e.hasMoreElements();) { | |||
| NameEntry ne = (NameEntry) e.nextElement(); | |||
| ArrayList<String> tmpNames = new ArrayList<String>(); | |||
| for (NameEntry ne : list) { | |||
| String pattern = ne.evalName(p); | |||
| if (pattern != null && pattern.length() > 0) { | |||
| tmpNames.addElement(pattern); | |||
| tmpNames.add(pattern); | |||
| } | |||
| } | |||
| String[] result = new String[tmpNames.size()]; | |||
| tmpNames.copyInto(result); | |||
| return result; | |||
| return tmpNames.toArray(new String[tmpNames.size()]); | |||
| } | |||
| /** | |||
| @@ -480,9 +477,7 @@ public class PatternSet extends DataType implements Cloneable { | |||
| */ | |||
| private void readFiles(Project p) { | |||
| if (includesFileList.size() > 0) { | |||
| Enumeration e = includesFileList.elements(); | |||
| while (e.hasMoreElements()) { | |||
| NameEntry ne = (NameEntry) e.nextElement(); | |||
| for (NameEntry ne : includesFileList) { | |||
| String fileName = ne.evalName(p); | |||
| if (fileName != null) { | |||
| File inclFile = p.resolveFile(fileName); | |||
| @@ -493,12 +488,10 @@ public class PatternSet extends DataType implements Cloneable { | |||
| readPatterns(inclFile, includeList, p); | |||
| } | |||
| } | |||
| includesFileList.removeAllElements(); | |||
| includesFileList.clear(); | |||
| } | |||
| if (excludesFileList.size() > 0) { | |||
| Enumeration e = excludesFileList.elements(); | |||
| while (e.hasMoreElements()) { | |||
| NameEntry ne = (NameEntry) e.nextElement(); | |||
| for (NameEntry ne : excludesFileList) { | |||
| String fileName = ne.evalName(p); | |||
| if (fileName != null) { | |||
| File exclFile = p.resolveFile(fileName); | |||
| @@ -509,7 +502,7 @@ public class PatternSet extends DataType implements Cloneable { | |||
| readPatterns(exclFile, excludeList, p); | |||
| } | |||
| } | |||
| excludesFileList.removeAllElements(); | |||
| excludesFileList.clear(); | |||
| } | |||
| } | |||
| @@ -527,10 +520,10 @@ public class PatternSet extends DataType implements Cloneable { | |||
| public Object clone() { | |||
| try { | |||
| PatternSet ps = (PatternSet) super.clone(); | |||
| ps.includeList = (Vector) includeList.clone(); | |||
| ps.excludeList = (Vector) excludeList.clone(); | |||
| ps.includesFileList = (Vector) includesFileList.clone(); | |||
| ps.excludesFileList = (Vector) excludesFileList.clone(); | |||
| ps.includeList = new ArrayList<NameEntry>(includeList); | |||
| ps.excludeList = new ArrayList<NameEntry>(excludeList); | |||
| ps.includesFileList = new ArrayList<NameEntry>(includesFileList); | |||
| ps.excludesFileList = new ArrayList<NameEntry>(excludesFileList); | |||
| return ps; | |||
| } catch (CloneNotSupportedException e) { | |||
| throw new BuildException(e); | |||
| @@ -21,7 +21,6 @@ package org.apache.tools.ant.types; | |||
| import java.lang.reflect.Constructor; | |||
| import java.security.UnresolvedPermission; | |||
| import java.util.HashSet; | |||
| import java.util.Iterator; | |||
| import java.util.LinkedList; | |||
| import java.util.List; | |||
| import java.util.Set; | |||
| @@ -45,15 +44,15 @@ import org.apache.tools.ant.ExitException; | |||
| */ | |||
| public class Permissions { | |||
| private List grantedPermissions = new LinkedList(); | |||
| private List revokedPermissions = new LinkedList(); | |||
| private List<Permission> grantedPermissions = new LinkedList<Permission>(); | |||
| private List<Permission> revokedPermissions = new LinkedList<Permission>(); | |||
| private java.security.Permissions granted = null; | |||
| private SecurityManager origSm = null; | |||
| private boolean active = false; | |||
| private boolean delegateToOldSM; | |||
| // Mandatory constructor for permission object. | |||
| private static final Class[] PARAMS = {String.class, String.class}; | |||
| private static final Class<?>[] PARAMS = {String.class, String.class}; | |||
| /** | |||
| * Create a set of Permissions. Equivalent to calling | |||
| @@ -108,14 +107,12 @@ public class Permissions { | |||
| */ | |||
| private void init() throws BuildException { | |||
| granted = new java.security.Permissions(); | |||
| for (Iterator i = revokedPermissions.listIterator(); i.hasNext();) { | |||
| Permissions.Permission p = (Permissions.Permission) i.next(); | |||
| for (Permissions.Permission p : revokedPermissions) { | |||
| if (p.getClassName() == null) { | |||
| throw new BuildException("Revoked permission " + p + " does not contain a class."); | |||
| } | |||
| } | |||
| for (Iterator i = grantedPermissions.listIterator(); i.hasNext();) { | |||
| Permissions.Permission p = (Permissions.Permission) i.next(); | |||
| for (Permissions.Permission p : grantedPermissions) { | |||
| if (p.getClassName() == null) { | |||
| throw new BuildException("Granted permission " + p | |||
| + " does not contain a class."); | |||
| @@ -153,12 +150,12 @@ public class Permissions { | |||
| try { | |||
| // First add explicitly already resolved permissions will not be | |||
| // resolved when added as unresolved permission. | |||
| Class clazz = Class.forName(permission.getClassName()); | |||
| Class<? extends java.security.Permission> clazz = Class.forName( | |||
| permission.getClassName()).asSubclass(java.security.Permission.class); | |||
| String name = permission.getName(); | |||
| String actions = permission.getActions(); | |||
| Constructor ctr = clazz.getConstructor(PARAMS); | |||
| return (java.security.Permission) ctr.newInstance(new Object[] { | |||
| name, actions }); | |||
| Constructor<? extends java.security.Permission> ctr = clazz.getConstructor(PARAMS); | |||
| return ctr.newInstance(new Object[] { name, actions }); | |||
| } catch (Exception e) { | |||
| // Let the UnresolvedPermission handle it. | |||
| return new UnresolvedPermission(permission.getClassName(), | |||
| @@ -232,12 +229,11 @@ public class Permissions { | |||
| * @param perm the permission being checked | |||
| */ | |||
| private void checkRevoked(java.security.Permission perm) { | |||
| for (Iterator i = revokedPermissions.listIterator(); i.hasNext();) { | |||
| if (((Permissions.Permission) i.next()).matches(perm)) { | |||
| for (Permissions.Permission revoked : revokedPermissions) { | |||
| if (revoked.matches(perm)) { | |||
| throw new SecurityException("Permission " + perm + " was revoked."); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -246,14 +242,14 @@ public class Permissions { | |||
| private String className; | |||
| private String name; | |||
| private String actionString; | |||
| private Set actions; | |||
| private Set<String> actions; | |||
| /** | |||
| * Set the class, mandatory. | |||
| * @param aClass The class name of the permission. | |||
| */ | |||
| public void setClass(String aClass) { | |||
| className = aClass.trim(); | |||
| className = aClass.trim(); | |||
| } | |||
| /** | |||
| @@ -319,7 +315,7 @@ public class Permissions { | |||
| } | |||
| } | |||
| if (actions != null) { | |||
| Set as = parseActions(perm.getActions()); | |||
| Set<String> as = parseActions(perm.getActions()); | |||
| int size = as.size(); | |||
| as.removeAll(actions); | |||
| if (as.size() == size) { | |||
| @@ -334,8 +330,8 @@ public class Permissions { | |||
| * Parses the actions into a set of separate strings. | |||
| * @param actions The actions to be parsed. | |||
| */ | |||
| private Set parseActions(String actions) { | |||
| Set result = new HashSet(); | |||
| private Set<String> parseActions(String actions) { | |||
| Set<String> result = new HashSet<String>(); | |||
| StringTokenizer tk = new StringTokenizer(actions, ","); | |||
| while (tk.hasMoreTokens()) { | |||
| String item = tk.nextToken().trim(); | |||
| @@ -18,16 +18,19 @@ | |||
| package org.apache.tools.ant.types; | |||
| import java.util.ArrayList; | |||
| import java.util.Enumeration; | |||
| import java.util.HashMap; | |||
| import java.util.Iterator; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| import java.util.HashSet; | |||
| import java.util.Map.Entry; | |||
| import java.util.Set; | |||
| import java.util.Stack; | |||
| import java.util.TreeMap; | |||
| import java.util.Hashtable; | |||
| import java.util.Properties; | |||
| import java.util.Vector; | |||
| import org.apache.tools.ant.BuildException; | |||
| import org.apache.tools.ant.Project; | |||
| @@ -46,9 +49,9 @@ public class PropertySet extends DataType implements ResourceCollection { | |||
| private boolean dynamic = true; | |||
| private boolean negate = false; | |||
| private Set cachedNames; | |||
| private Vector ptyRefs = new Vector(); | |||
| private Vector setRefs = new Vector(); | |||
| private Set<String> cachedNames; | |||
| private List<PropertyRef> ptyRefs = new ArrayList<PropertyRef>(); | |||
| private List<PropertySet> setRefs = new ArrayList<PropertySet>(); | |||
| private Mapper mapper; | |||
| /** | |||
| @@ -184,7 +187,7 @@ public class PropertySet extends DataType implements ResourceCollection { | |||
| public void addPropertyref(PropertyRef ref) { | |||
| assertNotReference(); | |||
| setChecked(false); | |||
| ptyRefs.addElement(ref); | |||
| ptyRefs.add(ref); | |||
| } | |||
| /** | |||
| @@ -194,7 +197,7 @@ public class PropertySet extends DataType implements ResourceCollection { | |||
| public void addPropertyset(PropertySet ref) { | |||
| assertNotReference(); | |||
| setChecked(false); | |||
| setRefs.addElement(ref); | |||
| setRefs.add(ref); | |||
| } | |||
| /** | |||
| @@ -274,9 +277,9 @@ public class PropertySet extends DataType implements ResourceCollection { | |||
| * Use propertynames to get the list of properties (including | |||
| * default ones). | |||
| */ | |||
| private Hashtable getAllSystemProperties() { | |||
| Hashtable ret = new Hashtable(); | |||
| for (Enumeration e = System.getProperties().propertyNames(); | |||
| private Hashtable<String, Object> getAllSystemProperties() { | |||
| Hashtable<String, Object> ret = new Hashtable<String, Object>(); | |||
| for (Enumeration<?> e = System.getProperties().propertyNames(); | |||
| e.hasMoreElements();) { | |||
| String name = (String) e.nextElement(); | |||
| ret.put(name, System.getProperties().getProperty(name)); | |||
| @@ -289,23 +292,33 @@ public class PropertySet extends DataType implements ResourceCollection { | |||
| * @return the properties for this propertyset. | |||
| */ | |||
| public Properties getProperties() { | |||
| final Properties result = new Properties(); | |||
| result.putAll(getPropertyMap()); | |||
| return result; | |||
| } | |||
| /** | |||
| * | |||
| * @return Map | |||
| * @since 1.9.0 | |||
| */ | |||
| private Map<String, Object> getPropertyMap() { | |||
| if (isReference()) { | |||
| return getRef().getProperties(); | |||
| return getRef().getPropertyMap(); | |||
| } | |||
| dieOnCircularReference(); | |||
| Hashtable props = getEffectiveProperties(); | |||
| Set names = getPropertyNames(props); | |||
| final Mapper myMapper = getMapper(); | |||
| final FileNameMapper m = myMapper == null ? null : myMapper.getImplementation(); | |||
| final Map<String, Object> effectiveProperties = getEffectiveProperties(); | |||
| final Set<String> propertyNames = getPropertyNames(effectiveProperties); | |||
| final Map<String, Object> result = new HashMap<String, Object>(); | |||
| FileNameMapper m = null; | |||
| Mapper myMapper = getMapper(); | |||
| if (myMapper != null) { | |||
| m = myMapper.getImplementation(); | |||
| } | |||
| Properties properties = new Properties(); | |||
| //iterate through the names, get the matching values | |||
| for (Iterator iter = names.iterator(); iter.hasNext();) { | |||
| String name = (String) iter.next(); | |||
| String value = (String) props.get(name); | |||
| for (String name : propertyNames) { | |||
| Object value = effectiveProperties.get(name); | |||
| // TODO should we include null properties? | |||
| // TODO should we query the PropertyHelper for property value to grab potentially shadowed values? | |||
| if (value != null) { | |||
| // may be null if a system property has been added | |||
| // after the project instance has been initialized | |||
| @@ -316,36 +329,35 @@ public class PropertySet extends DataType implements ResourceCollection { | |||
| name = newname[0]; | |||
| } | |||
| } | |||
| properties.setProperty(name, value); | |||
| result.put(name, value); | |||
| } | |||
| } | |||
| return properties; | |||
| return result; | |||
| } | |||
| private Hashtable getEffectiveProperties() { | |||
| Project prj = getProject(); | |||
| Hashtable result = prj == null ? getAllSystemProperties() : prj.getProperties(); | |||
| private Map<String, Object> getEffectiveProperties() { | |||
| final Project prj = getProject(); | |||
| final Map<String, Object> result = prj == null ? getAllSystemProperties() : prj.getProperties(); | |||
| //quick & dirty, to make nested mapped p-sets work: | |||
| for (Enumeration e = setRefs.elements(); e.hasMoreElements();) { | |||
| PropertySet set = (PropertySet) e.nextElement(); | |||
| result.putAll(set.getProperties()); | |||
| for (PropertySet set : setRefs) { | |||
| result.putAll(set.getPropertyMap()); | |||
| } | |||
| return result; | |||
| } | |||
| private Set getPropertyNames(Hashtable props) { | |||
| Set names; | |||
| private Set<String> getPropertyNames(Map<String, Object> props) { | |||
| Set<String> names; | |||
| if (getDynamic() || cachedNames == null) { | |||
| names = new HashSet(); | |||
| names = new HashSet<String>(); | |||
| addPropertyNames(names, props); | |||
| // Add this PropertySet's nested PropertySets' property names. | |||
| for (Enumeration e = setRefs.elements(); e.hasMoreElements();) { | |||
| PropertySet set = (PropertySet) e.nextElement(); | |||
| names.addAll(set.getProperties().keySet()); | |||
| for (PropertySet set : setRefs) { | |||
| names.addAll(set.getPropertyMap().keySet()); | |||
| } | |||
| if (negate) { | |||
| //make a copy... | |||
| HashSet complement = new HashSet(props.keySet()); | |||
| HashSet<String> complement = new HashSet<String>(props.keySet()); | |||
| complement.removeAll(names); | |||
| names = complement; | |||
| } | |||
| @@ -361,24 +373,22 @@ public class PropertySet extends DataType implements ResourceCollection { | |||
| /** | |||
| * @param names the output Set to fill with the property names | |||
| * matching this PropertySet selection criteria. | |||
| * @param properties the current Project properties, passed in to | |||
| * @param props the current Project properties, passed in to | |||
| * avoid needless duplication of the Hashtable during recursion. | |||
| */ | |||
| private void addPropertyNames(Set names, Hashtable properties) { | |||
| private void addPropertyNames(Set<String> names, Map<String, Object> props) { | |||
| if (isReference()) { | |||
| getRef().addPropertyNames(names, properties); | |||
| getRef().addPropertyNames(names, props); | |||
| } | |||
| dieOnCircularReference(); | |||
| // Add this PropertySet's property names. | |||
| for (Enumeration e = ptyRefs.elements(); e.hasMoreElements();) { | |||
| PropertyRef r = (PropertyRef) e.nextElement(); | |||
| for (PropertyRef r : ptyRefs) { | |||
| if (r.name != null) { | |||
| if (properties.get(r.name) != null) { | |||
| if (props.get(r.name) != null) { | |||
| names.add(r.name); | |||
| } | |||
| } else if (r.prefix != null) { | |||
| for (Enumeration p = properties.keys(); p.hasMoreElements();) { | |||
| String name = (String) p.nextElement(); | |||
| for (String name : props.keySet()) { | |||
| if (name.startsWith(r.prefix)) { | |||
| names.add(name); | |||
| } | |||
| @@ -387,8 +397,7 @@ public class PropertySet extends DataType implements ResourceCollection { | |||
| RegexpMatcherFactory matchMaker = new RegexpMatcherFactory(); | |||
| RegexpMatcher matcher = matchMaker.newRegexpMatcher(); | |||
| matcher.setPattern(r.regex); | |||
| for (Enumeration p = properties.keys(); p.hasMoreElements();) { | |||
| String name = (String) p.nextElement(); | |||
| for (String name : props.keySet()) { | |||
| if (matcher.matches(name)) { | |||
| names.add(name); | |||
| } | |||
| @@ -396,9 +405,9 @@ public class PropertySet extends DataType implements ResourceCollection { | |||
| } else if (r.builtin != null) { | |||
| if (r.builtin.equals(BuiltinPropertySetName.ALL)) { | |||
| names.addAll(properties.keySet()); | |||
| names.addAll(props.keySet()); | |||
| } else if (r.builtin.equals(BuiltinPropertySetName.SYSTEM)) { | |||
| names.addAll(System.getProperties().keySet()); | |||
| names.addAll(getAllSystemProperties().keySet()); | |||
| } else if (r.builtin.equals(BuiltinPropertySetName | |||
| .COMMANDLINE)) { | |||
| names.addAll(getProject().getUserProperties().keySet()); | |||
| @@ -483,16 +492,15 @@ public class PropertySet extends DataType implements ResourceCollection { | |||
| return getRef().toString(); | |||
| } | |||
| dieOnCircularReference(); | |||
| StringBuffer b = new StringBuffer(); | |||
| TreeMap sorted = new TreeMap(getProperties()); | |||
| for (Iterator i = sorted.entrySet().iterator(); i.hasNext();) { | |||
| Map.Entry e = (Map.Entry) i.next(); | |||
| StringBuilder b = new StringBuilder(); | |||
| TreeMap<String, Object> sorted = new TreeMap<String, Object>(getPropertyMap()); | |||
| for (Entry<String, Object> e : sorted.entrySet()) { | |||
| if (b.length() != 0) { | |||
| b.append(", "); | |||
| } | |||
| b.append(e.getKey().toString()); | |||
| b.append(e.getKey()); | |||
| b.append("="); | |||
| b.append(e.getValue().toString()); | |||
| b.append(e.getValue()); | |||
| } | |||
| return b.toString(); | |||
| } | |||
| @@ -507,19 +515,18 @@ public class PropertySet extends DataType implements ResourceCollection { | |||
| return getRef().iterator(); | |||
| } | |||
| dieOnCircularReference(); | |||
| Hashtable props = getEffectiveProperties(); | |||
| Set names = getPropertyNames(props); | |||
| final Set<String> names = getPropertyNames(getEffectiveProperties()); | |||
| Mapper myMapper = getMapper(); | |||
| final FileNameMapper m = myMapper == null ? null : myMapper.getImplementation(); | |||
| final Iterator iter = names.iterator(); | |||
| final Iterator<String> iter = names.iterator(); | |||
| return new Iterator<Resource>() { | |||
| public boolean hasNext() { | |||
| return iter.hasNext(); | |||
| } | |||
| public Resource next() { | |||
| PropertyResource p = new PropertyResource(getProject(), (String) iter.next()); | |||
| PropertyResource p = new PropertyResource(getProject(), iter.next()); | |||
| return m == null ? (Resource) p : new MappedResource(p, m); | |||
| } | |||
| public void remove() { | |||
| @@ -548,7 +555,7 @@ public class PropertySet extends DataType implements ResourceCollection { | |||
| return false; | |||
| } | |||
| protected synchronized void dieOnCircularReference(Stack stk, Project p) | |||
| protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) | |||
| throws BuildException { | |||
| if (isChecked()) { | |||
| return; | |||
| @@ -559,8 +566,8 @@ public class PropertySet extends DataType implements ResourceCollection { | |||
| if (mapper != null) { | |||
| pushAndInvokeCircularReferenceCheck(mapper, stk, p); | |||
| } | |||
| for (Iterator i = setRefs.iterator(); i.hasNext(); ) { | |||
| pushAndInvokeCircularReferenceCheck((PropertySet) i.next(), stk, | |||
| for (PropertySet propertySet : setRefs) { | |||
| pushAndInvokeCircularReferenceCheck(propertySet, stk, | |||
| p); | |||
| } | |||
| setChecked(true); | |||
| @@ -18,9 +18,10 @@ | |||
| package org.apache.tools.ant.types; | |||
| import java.io.File; | |||
| import java.util.Arrays; | |||
| import java.util.List; | |||
| import java.util.Stack; | |||
| import java.util.Vector; | |||
| import java.util.Iterator; | |||
| import java.util.ArrayList; | |||
| import org.apache.tools.ant.Project; | |||
| @@ -83,13 +84,13 @@ public class RedirectorElement extends DataType { | |||
| private Mapper errorMapper; | |||
| /** input filter chains. */ | |||
| private Vector inputFilterChains = new Vector(); | |||
| private Vector<FilterChain> inputFilterChains = new Vector<FilterChain>(); | |||
| /** output filter chains. */ | |||
| private Vector outputFilterChains = new Vector(); | |||
| private Vector<FilterChain> outputFilterChains = new Vector<FilterChain>(); | |||
| /** error filter chains. */ | |||
| private Vector errorFilterChains = new Vector(); | |||
| private Vector<FilterChain> errorFilterChains = new Vector<FilterChain>(); | |||
| /** The output encoding */ | |||
| private String outputEncoding; | |||
| @@ -554,7 +555,7 @@ public class RedirectorElement extends DataType { | |||
| return null; | |||
| } | |||
| //remove any null elements | |||
| ArrayList list = new ArrayList(name.length); | |||
| ArrayList<File> list = new ArrayList<File>(name.length); | |||
| for (int i = 0; i < name.length; i++) { | |||
| if (name[i] != null) { | |||
| list.add(getProject().resolveFile(name[i])); | |||
| @@ -570,7 +571,7 @@ public class RedirectorElement extends DataType { | |||
| * @param p the project to use to dereference the references. | |||
| * @throws BuildException on error. | |||
| */ | |||
| protected void dieOnCircularReference(Stack stk, Project p) | |||
| protected void dieOnCircularReference(Stack<Object> stk, Project p) | |||
| throws BuildException { | |||
| if (isChecked()) { | |||
| return; | |||
| @@ -586,12 +587,13 @@ public class RedirectorElement extends DataType { | |||
| stk.pop(); | |||
| } | |||
| } | |||
| Vector[] v = new Vector[] | |||
| {inputFilterChains, outputFilterChains, errorFilterChains}; | |||
| for (int i = 0; i < v.length; i++) { | |||
| if (v[i] != null) { | |||
| for (Iterator fci = v[i].iterator(); fci.hasNext();) { | |||
| FilterChain fc = (FilterChain) fci.next(); | |||
| @SuppressWarnings("unchecked") | |||
| final List<? extends List<FilterChain>> filterChainLists = Arrays | |||
| .<List<FilterChain>> asList(inputFilterChains, outputFilterChains, | |||
| errorFilterChains); | |||
| for (List<FilterChain> filterChains : filterChainLists) { | |||
| if (filterChains != null) { | |||
| for (FilterChain fc : filterChains) { | |||
| pushAndInvokeCircularReferenceCheck(fc, stk, p); | |||
| } | |||
| } | |||
| @@ -50,8 +50,9 @@ public class TarScanner extends ArchiveScanner { | |||
| * patterns and didn't match any exclude patterns. | |||
| */ | |||
| protected void fillMapsFromArchive(Resource src, String encoding, | |||
| Map fileEntries, Map matchFileEntries, | |||
| Map dirEntries, Map matchDirEntries) { | |||
| Map<String, Resource> fileEntries, Map<String, Resource> matchFileEntries, | |||
| Map<String, Resource> dirEntries, Map<String, Resource> matchDirEntries) { | |||
| TarEntry entry = null; | |||
| TarInputStream ti = null; | |||
| @@ -26,7 +26,6 @@ import java.io.IOException; | |||
| import java.io.InputStream; | |||
| import java.net.MalformedURLException; | |||
| import java.net.URL; | |||
| import java.util.Enumeration; | |||
| import java.util.Stack; | |||
| import java.util.Vector; | |||
| import javax.xml.parsers.ParserConfigurationException; | |||
| @@ -126,7 +125,7 @@ public class XMLCatalog extends DataType | |||
| //-- Fields ---------------------------------------------------------------- | |||
| /** Holds dtd/entity objects until needed. */ | |||
| private Vector elements = new Vector(); | |||
| private Vector<ResourceLocation> elements = new Vector<ResourceLocation>(); | |||
| /** | |||
| * Classpath in which to attempt to resolve resources. | |||
| @@ -166,7 +165,7 @@ public class XMLCatalog extends DataType | |||
| * | |||
| * @return the elements of the catalog - ResourceLocation objects | |||
| */ | |||
| private Vector getElements() { | |||
| private Vector<ResourceLocation> getElements() { | |||
| return getRef().elements; | |||
| } | |||
| @@ -331,12 +330,7 @@ public class XMLCatalog extends DataType | |||
| } | |||
| // Add all nested elements to our catalog | |||
| Vector newElements = catalog.getElements(); | |||
| Vector ourElements = getElements(); | |||
| Enumeration e = newElements.elements(); | |||
| while (e.hasMoreElements()) { | |||
| ourElements.addElement(e.nextElement()); | |||
| } | |||
| getElements().addAll(catalog.getElements()); | |||
| // Append the classpath of the nested catalog | |||
| Path nestedClasspath = catalog.getClasspath(); | |||
| @@ -452,7 +446,7 @@ public class XMLCatalog extends DataType | |||
| return source; | |||
| } | |||
| protected synchronized void dieOnCircularReference(Stack stk, Project p) | |||
| protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) | |||
| throws BuildException { | |||
| if (isChecked()) { | |||
| return; | |||
| @@ -477,7 +471,7 @@ public class XMLCatalog extends DataType | |||
| if (!isReference()) { | |||
| return this; | |||
| } | |||
| return (XMLCatalog) getCheckedRef(XMLCatalog.class, "xmlcatalog"); | |||
| return getCheckedRef(XMLCatalog.class, "xmlcatalog"); | |||
| } | |||
| /** | |||
| @@ -504,7 +498,7 @@ public class XMLCatalog extends DataType | |||
| loader = getProject().createClassLoader(Path.systemClasspath); | |||
| try { | |||
| Class clazz = Class.forName(APACHE_RESOLVER, true, loader); | |||
| Class<?> clazz = Class.forName(APACHE_RESOLVER, true, loader); | |||
| // The Apache resolver is present - Need to check if it can | |||
| // be seen by the catalog resolver class. Start by getting | |||
| @@ -512,7 +506,7 @@ public class XMLCatalog extends DataType | |||
| ClassLoader apacheResolverLoader = clazz.getClassLoader(); | |||
| // load the base class through this loader. | |||
| Class baseResolverClass | |||
| Class<?> baseResolverClass | |||
| = Class.forName(CATALOG_RESOLVER, true, apacheResolverLoader); | |||
| // and find its actual loader | |||
| @@ -594,15 +588,9 @@ public class XMLCatalog extends DataType | |||
| * of the Resource or null if no such information is available. | |||
| */ | |||
| private ResourceLocation findMatchingEntry(String publicId) { | |||
| Enumeration e = getElements().elements(); | |||
| ResourceLocation element = null; | |||
| while (e.hasMoreElements()) { | |||
| Object o = e.nextElement(); | |||
| if (o instanceof ResourceLocation) { | |||
| element = (ResourceLocation) o; | |||
| if (element.getPublicId().equals(publicId)) { | |||
| return element; | |||
| } | |||
| for (ResourceLocation element : getElements()) { | |||
| if (element.getPublicId().equals(publicId)) { | |||
| return element; | |||
| } | |||
| } | |||
| return null; | |||
| @@ -917,7 +905,7 @@ public class XMLCatalog extends DataType | |||
| private boolean externalCatalogsProcessed = false; | |||
| public ExternalResolver(Class resolverImplClass, | |||
| public ExternalResolver(Class<?> resolverImplClass, | |||
| Object resolverImpl) { | |||
| this.resolverImpl = resolverImpl; | |||
| @@ -53,8 +53,8 @@ public class ZipScanner extends ArchiveScanner { | |||
| * patterns and didn't match any exclude patterns. | |||
| */ | |||
| protected void fillMapsFromArchive(Resource src, String encoding, | |||
| Map fileEntries, Map matchFileEntries, | |||
| Map dirEntries, Map matchDirEntries) { | |||
| Map<String, Resource> fileEntries, Map<String, Resource> matchFileEntries, | |||
| Map<String, Resource> dirEntries, Map<String, Resource> matchDirEntries) { | |||
| ZipEntry entry = null; | |||
| ZipFile zf = null; | |||
| @@ -74,9 +74,9 @@ public class ZipScanner extends ArchiveScanner { | |||
| } catch (IOException ex) { | |||
| throw new BuildException("Problem opening " + srcFile, ex); | |||
| } | |||
| Enumeration e = zf.getEntries(); | |||
| Enumeration<ZipEntry> e = zf.getEntries(); | |||
| while (e.hasMoreElements()) { | |||
| entry = (ZipEntry) e.nextElement(); | |||
| entry = e.nextElement(); | |||
| Resource r = new ZipResource(srcFile, encoding, entry); | |||
| String name = entry.getName(); | |||
| if (entry.isDirectory()) { | |||
| @@ -70,7 +70,7 @@ public class FilterMapper extends FilterChain implements FileNameMapper { | |||
| helper.setBufferSize(BUFFER_SIZE); | |||
| helper.setPrimaryReader(stringReader); | |||
| helper.setProject(getProject()); | |||
| Vector filterChains = new Vector(); | |||
| Vector<FilterChain> filterChains = new Vector<FilterChain>(); | |||
| filterChains.add(this); | |||
| helper.setFilterChains(filterChains); | |||
| String result = FileUtils.safeReadFully(helper.getAssembledReader()); | |||
| @@ -27,9 +27,7 @@ import java.util.ArrayList; | |||
| */ | |||
| public class ScriptMapper extends AbstractScriptComponent implements FileNameMapper { | |||
| private ArrayList files; | |||
| static final String[] EMPTY_STRING_ARRAY = new String[0]; | |||
| private ArrayList<String> files; | |||
| /** | |||
| @@ -54,7 +52,7 @@ public class ScriptMapper extends AbstractScriptComponent implements FileNameMap | |||
| * Reset the list of files | |||
| */ | |||
| public void clear() { | |||
| files = new ArrayList(1); | |||
| files = new ArrayList<String>(1); | |||
| } | |||
| /** | |||
| @@ -87,7 +85,7 @@ public class ScriptMapper extends AbstractScriptComponent implements FileNameMap | |||
| if (files.size() == 0) { | |||
| return null; | |||
| } else { | |||
| return (String[]) files.toArray(EMPTY_STRING_ARRAY); | |||
| return files.toArray(new String[files.size()]); | |||
| } | |||
| } | |||
| } | |||
| @@ -17,7 +17,8 @@ | |||
| */ | |||
| package org.apache.tools.ant.types.optional.depend; | |||
| import java.util.Enumeration; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| import java.util.Stack; | |||
| import java.util.Vector; | |||
| import org.apache.tools.ant.Project; | |||
| @@ -39,12 +40,12 @@ public class ClassfileSet extends FileSet { | |||
| * classes which must be included in the fileset and which are the | |||
| * starting point for the dependency search. | |||
| */ | |||
| private Vector rootClasses = new Vector(); | |||
| private List<String> rootClasses = new ArrayList<String>(); | |||
| /** | |||
| * The list of filesets which contain root classes. | |||
| */ | |||
| private Vector rootFileSets = new Vector(); | |||
| private List<FileSet> rootFileSets = new ArrayList<FileSet>(); | |||
| /** | |||
| * Inner class used to contain info about root classes. | |||
| @@ -86,7 +87,7 @@ public class ClassfileSet extends FileSet { | |||
| * classes. | |||
| */ | |||
| public void addRootFileset(FileSet rootFileSet) { | |||
| rootFileSets.addElement(rootFileSet); | |||
| rootFileSets.add(rootFileSet); | |||
| setChecked(false); | |||
| } | |||
| @@ -97,7 +98,7 @@ public class ClassfileSet extends FileSet { | |||
| */ | |||
| protected ClassfileSet(ClassfileSet s) { | |||
| super(s); | |||
| rootClasses = (Vector) s.rootClasses.clone(); | |||
| rootClasses.addAll(s.rootClasses); | |||
| } | |||
| /** | |||
| @@ -106,7 +107,7 @@ public class ClassfileSet extends FileSet { | |||
| * @param rootClass the name of the root class. | |||
| */ | |||
| public void setRootClass(String rootClass) { | |||
| rootClasses.addElement(rootClass); | |||
| rootClasses.add(rootClass); | |||
| } | |||
| /** | |||
| @@ -123,9 +124,8 @@ public class ClassfileSet extends FileSet { | |||
| dieOnCircularReference(p); | |||
| DirectoryScanner parentScanner = super.getDirectoryScanner(p); | |||
| DependScanner scanner = new DependScanner(parentScanner); | |||
| Vector allRootClasses = (Vector) rootClasses.clone(); | |||
| for (Enumeration e = rootFileSets.elements(); e.hasMoreElements();) { | |||
| FileSet additionalRootSet = (FileSet) e.nextElement(); | |||
| final Vector<String> allRootClasses = new Vector<String>(rootClasses); | |||
| for (FileSet additionalRootSet : rootFileSets) { | |||
| DirectoryScanner additionalScanner | |||
| = additionalRootSet.getDirectoryScanner(p); | |||
| String[] files = additionalScanner.getIncludedFiles(); | |||
| @@ -151,7 +151,7 @@ public class ClassfileSet extends FileSet { | |||
| * @param root the configured class root. | |||
| */ | |||
| public void addConfiguredRoot(ClassRoot root) { | |||
| rootClasses.addElement(root.getClassname()); | |||
| rootClasses.add(root.getClassname()); | |||
| } | |||
| /** | |||
| @@ -164,7 +164,7 @@ public class ClassfileSet extends FileSet { | |||
| ? (ClassfileSet) (getRef(getProject())) : this); | |||
| } | |||
| protected synchronized void dieOnCircularReference(Stack stk, Project p) { | |||
| protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) { | |||
| if (isChecked()) { | |||
| return; | |||
| } | |||
| @@ -173,9 +173,7 @@ public class ClassfileSet extends FileSet { | |||
| super.dieOnCircularReference(stk, p); | |||
| if (!isReference()) { | |||
| for (Enumeration e = rootFileSets.elements(); | |||
| e.hasMoreElements();) { | |||
| FileSet additionalRootSet = (FileSet) e.nextElement(); | |||
| for (FileSet additionalRootSet : rootFileSets) { | |||
| pushAndInvokeCircularReferenceCheck(additionalRootSet, stk, p); | |||
| } | |||
| setChecked(true); | |||
| @@ -40,14 +40,14 @@ public class DependScanner extends DirectoryScanner { | |||
| /** | |||
| * The root classes to drive the search for dependent classes. | |||
| */ | |||
| private Vector rootClasses; | |||
| private Vector<String> rootClasses; | |||
| /** | |||
| * The names of the classes to include in the fileset. | |||
| */ | |||
| private Vector included; | |||
| private Vector<String> included; | |||
| private Vector additionalBaseDirs = new Vector(); | |||
| private Vector<File> additionalBaseDirs = new Vector<File>(); | |||
| /** | |||
| * The parent scanner which gives the basic set of files. Only files which | |||
| @@ -72,7 +72,7 @@ public class DependScanner extends DirectoryScanner { | |||
| * | |||
| * @param rootClasses the rootClasses to be used for this scan. | |||
| */ | |||
| public synchronized void setRootClasses(Vector rootClasses) { | |||
| public synchronized void setRootClasses(Vector<String> rootClasses) { | |||
| this.rootClasses = rootClasses; | |||
| } | |||
| @@ -103,30 +103,31 @@ public class DependScanner extends DirectoryScanner { | |||
| * @exception IllegalStateException when basedir was set incorrectly. | |||
| */ | |||
| public synchronized void scan() throws IllegalStateException { | |||
| included = new Vector(); | |||
| included = new Vector<String>(); | |||
| String analyzerClassName = DEFAULT_ANALYZER_CLASS; | |||
| DependencyAnalyzer analyzer = null; | |||
| try { | |||
| Class analyzerClass = Class.forName(analyzerClassName); | |||
| analyzer = (DependencyAnalyzer) analyzerClass.newInstance(); | |||
| Class<? extends DependencyAnalyzer> analyzerClass = Class.forName(analyzerClassName) | |||
| .asSubclass(DependencyAnalyzer.class); | |||
| analyzer = analyzerClass.newInstance(); | |||
| } catch (Exception e) { | |||
| throw new BuildException("Unable to load dependency analyzer: " | |||
| + analyzerClassName, e); | |||
| } | |||
| analyzer.addClassPath(new Path(null, basedir.getPath())); | |||
| for (Enumeration e = additionalBaseDirs.elements(); e.hasMoreElements();) { | |||
| File additionalBaseDir = (File) e.nextElement(); | |||
| for (Enumeration<File> e = additionalBaseDirs.elements(); e.hasMoreElements();) { | |||
| File additionalBaseDir = e.nextElement(); | |||
| analyzer.addClassPath(new Path(null, additionalBaseDir.getPath())); | |||
| } | |||
| for (Enumeration e = rootClasses.elements(); e.hasMoreElements();) { | |||
| String rootClass = (String) e.nextElement(); | |||
| for (Enumeration<String> e = rootClasses.elements(); e.hasMoreElements();) { | |||
| String rootClass = e.nextElement(); | |||
| analyzer.addRootClass(rootClass); | |||
| } | |||
| Enumeration e = analyzer.getClassDependencies(); | |||
| Enumeration<String> e = analyzer.getClassDependencies(); | |||
| String[] parentFiles = parentScanner.getIncludedFiles(); | |||
| Hashtable parentSet = new Hashtable(); | |||
| Hashtable<String, String> parentSet = new Hashtable<String, String>(); | |||
| for (int i = 0; i < parentFiles.length; ++i) { | |||
| parentSet.put(parentFiles[i], parentFiles[i]); | |||
| } | |||
| @@ -26,7 +26,7 @@ import java.util.Vector; | |||
| */ | |||
| public abstract class ImageOperation extends DataType { | |||
| // CheckStyle:VisibilityModifier OFF - bc | |||
| protected Vector instructions = new Vector(); | |||
| protected Vector<ImageOperation> instructions = new Vector<ImageOperation>(); | |||
| // CheckStyle:VisibilityModifier ON | |||
| /** | |||
| @@ -22,7 +22,6 @@ import javax.media.jai.InterpolationNearest; | |||
| import javax.media.jai.JAI; | |||
| import java.awt.image.renderable.ParameterBlock; | |||
| import java.awt.image.BufferedImage; | |||
| import java.awt.Graphics2D; | |||
| /** | |||
| * ImageOperation to rotate an image by a certain degree | |||
| @@ -69,7 +68,6 @@ public class Rotate extends TransformOperation implements DrawOperation { | |||
| */ | |||
| public PlanarImage executeTransformOperation(PlanarImage image) { | |||
| BufferedImage bi = null; | |||
| Graphics2D graphics = null; | |||
| final int size = instructions.size(); | |||
| for (int i = 0; i < size; i++) { | |||
| ImageOperation instr = ((ImageOperation) instructions.elementAt(i)); | |||
| @@ -82,7 +80,6 @@ public class Rotate extends TransformOperation implements DrawOperation { | |||
| return image; | |||
| } else if (instr instanceof TransformOperation) { | |||
| bi = image.getAsBufferedImage(); | |||
| graphics = (Graphics2D) bi.getGraphics(); | |||
| System.out.println("Execing Transforms"); | |||
| image = ((TransformOperation) instr) | |||
| .executeTransformOperation(PlanarImage.wrapRenderedImage(bi)); | |||
| @@ -232,7 +232,7 @@ public abstract class AbstractClasspathResource extends Resource { | |||
| */ | |||
| protected abstract InputStream openInputStream(ClassLoader cl) throws IOException; | |||
| protected synchronized void dieOnCircularReference(Stack stk, Project p) { | |||
| protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) { | |||
| if (isChecked()) { | |||
| return; | |||
| } | |||
| @@ -98,7 +98,7 @@ public abstract class AbstractResourceCollectionWrapper | |||
| * of the iterator is allowed to not be thread safe whereas the iterator | |||
| * itself should. The returned iterator will be wrapped into the FailFast | |||
| * one. | |||
| * | |||
| * | |||
| * @return the iterator on the resource collection | |||
| */ | |||
| protected abstract Iterator<Resource> createIterator(); | |||
| @@ -118,7 +118,7 @@ public abstract class AbstractResourceCollectionWrapper | |||
| /** | |||
| * Do compute the size of the resource collection. The implementation of | |||
| * this function is allowed to be not thread safe. | |||
| * | |||
| * | |||
| * @return size of resource collection. | |||
| */ | |||
| protected abstract int getSize(); | |||
| @@ -138,8 +138,7 @@ public abstract class AbstractResourceCollectionWrapper | |||
| } | |||
| /* now check each Resource in case the child only | |||
| lets through files from any children IT may have: */ | |||
| for (Iterator i = createIterator(); i.hasNext();) { | |||
| Resource r = (Resource) i.next(); | |||
| for (Resource r : this) { | |||
| if (r.as(FileProvider.class) == null) { | |||
| return false; | |||
| } | |||
| @@ -154,7 +153,7 @@ public abstract class AbstractResourceCollectionWrapper | |||
| * @param p the project to use to dereference the references. | |||
| * @throws BuildException on error. | |||
| */ | |||
| protected synchronized void dieOnCircularReference(Stack stk, Project p) | |||
| protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) | |||
| throws BuildException { | |||
| if (isChecked()) { | |||
| return; | |||
| @@ -193,12 +192,12 @@ public abstract class AbstractResourceCollectionWrapper | |||
| if (getSize() == 0) { | |||
| return ""; | |||
| } | |||
| StringBuffer sb = new StringBuffer(); | |||
| for (Iterator i = createIterator(); i.hasNext();) { | |||
| StringBuilder sb = new StringBuilder(); | |||
| for (Resource resource : this) { | |||
| if (sb.length() > 0) { | |||
| sb.append(File.pathSeparatorChar); | |||
| } | |||
| sb.append(i.next()); | |||
| sb.append(resource); | |||
| } | |||
| return sb.toString(); | |||
| } | |||
| @@ -244,7 +244,7 @@ public abstract class ArchiveResource extends Resource { | |||
| /** | |||
| * Validate settings and ensure that the represented "archive entry" | |||
| * has been established. | |||
| * has been established. | |||
| */ | |||
| protected final synchronized void checkEntry() throws BuildException { | |||
| dieOnCircularReference(); | |||
| @@ -277,7 +277,7 @@ public abstract class ArchiveResource extends Resource { | |||
| /** | |||
| * {@inheritDoc} | |||
| */ | |||
| protected synchronized void dieOnCircularReference(Stack stk, Project p) { | |||
| protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) { | |||
| if (isChecked()) { | |||
| return; | |||
| } | |||
| @@ -77,8 +77,8 @@ public class Archives extends DataType | |||
| } | |||
| dieOnCircularReference(); | |||
| int total = 0; | |||
| for (Iterator i = grabArchives(); i.hasNext(); ) { | |||
| total += ((ResourceCollection) i.next()).size(); | |||
| for (Iterator<ArchiveFileSet> i = grabArchives(); i.hasNext(); ) { | |||
| total += i.next().size(); | |||
| } | |||
| return total; | |||
| } | |||
| @@ -173,7 +173,7 @@ public class Archives extends DataType | |||
| * @param p the project to use to dereference the references. | |||
| * @throws BuildException on error. | |||
| */ | |||
| protected synchronized void dieOnCircularReference(Stack stk, Project p) | |||
| protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) | |||
| throws BuildException { | |||
| if (isChecked()) { | |||
| return; | |||
| @@ -47,7 +47,7 @@ public abstract class BaseResourceCollectionContainer | |||
| public BaseResourceCollectionContainer() { | |||
| // TODO Auto-generated constructor stub | |||
| } | |||
| /** | |||
| * Create a new BaseResourceCollectionContainer. | |||
| * @since Ant 1.8 | |||
| @@ -115,13 +115,13 @@ public abstract class BaseResourceCollectionContainer | |||
| * @param c the Collection whose elements to add. | |||
| * @throws BuildException on error. | |||
| */ | |||
| public synchronized void addAll(Collection c) throws BuildException { | |||
| public synchronized void addAll(Collection<? extends ResourceCollection> c) throws BuildException { | |||
| if (isReference()) { | |||
| throw noChildrenAllowed(); | |||
| } | |||
| try { | |||
| for (Iterator i = c.iterator(); i.hasNext();) { | |||
| add((ResourceCollection) i.next()); | |||
| for (ResourceCollection resourceCollection : c) { | |||
| add(resourceCollection); | |||
| } | |||
| } catch (ClassCastException e) { | |||
| throw new BuildException(e); | |||
| @@ -148,7 +148,7 @@ public abstract class BaseResourceCollectionContainer | |||
| */ | |||
| public synchronized int size() { | |||
| if (isReference()) { | |||
| return ((BaseResourceCollectionContainer) getCheckedRef()).size(); | |||
| return getCheckedRef(BaseResourceCollectionContainer.class, getDataTypeName()).size(); | |||
| } | |||
| dieOnCircularReference(); | |||
| return cacheCollection().size(); | |||
| @@ -165,16 +165,15 @@ public abstract class BaseResourceCollectionContainer | |||
| dieOnCircularReference(); | |||
| //first the easy way, if all children are filesystem-only, return true: | |||
| boolean goEarly = true; | |||
| for (Iterator i = rc.iterator(); goEarly && i.hasNext();) { | |||
| goEarly = ((ResourceCollection) i.next()).isFilesystemOnly(); | |||
| for (Iterator<ResourceCollection> i = rc.iterator(); goEarly && i.hasNext();) { | |||
| goEarly = i.next().isFilesystemOnly(); | |||
| } | |||
| if (goEarly) { | |||
| return true; | |||
| } | |||
| /* now check each Resource in case the child only | |||
| lets through files from any children IT may have: */ | |||
| for (Iterator i = cacheCollection().iterator(); i.hasNext();) { | |||
| Resource r = (Resource) i.next(); | |||
| for (Resource r : cacheCollection()) { | |||
| if (r.as(FileProvider.class) == null) { | |||
| return false; | |||
| } | |||
| @@ -189,7 +188,7 @@ public abstract class BaseResourceCollectionContainer | |||
| * @param p the project to use to dereference the references. | |||
| * @throws BuildException on error. | |||
| */ | |||
| protected synchronized void dieOnCircularReference(Stack stk, Project p) | |||
| protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) | |||
| throws BuildException { | |||
| if (isChecked()) { | |||
| return; | |||
| @@ -197,10 +196,9 @@ public abstract class BaseResourceCollectionContainer | |||
| if (isReference()) { | |||
| super.dieOnCircularReference(stk, p); | |||
| } else { | |||
| for (Iterator i = rc.iterator(); i.hasNext();) { | |||
| Object o = i.next(); | |||
| if (o instanceof DataType) { | |||
| pushAndInvokeCircularReferenceCheck((DataType) o, stk, p); | |||
| for (ResourceCollection resourceCollection : rc) { | |||
| if (resourceCollection instanceof DataType) { | |||
| pushAndInvokeCircularReferenceCheck((DataType) resourceCollection, stk, p); | |||
| } | |||
| } | |||
| setChecked(true); | |||
| @@ -231,7 +229,7 @@ public abstract class BaseResourceCollectionContainer | |||
| try { | |||
| BaseResourceCollectionContainer c | |||
| = (BaseResourceCollectionContainer) super.clone(); | |||
| c.rc = new ArrayList(rc); | |||
| c.rc = new ArrayList<ResourceCollection>(rc); | |||
| c.coll = null; | |||
| return c; | |||
| } catch (CloneNotSupportedException e) { | |||
| @@ -250,12 +248,12 @@ public abstract class BaseResourceCollectionContainer | |||
| if (cacheCollection().size() == 0) { | |||
| return ""; | |||
| } | |||
| StringBuffer sb = new StringBuffer(); | |||
| for (Iterator i = coll.iterator(); i.hasNext();) { | |||
| StringBuilder sb = new StringBuilder(); | |||
| for (Resource resource : coll) { | |||
| if (sb.length() > 0) { | |||
| sb.append(File.pathSeparatorChar); | |||
| } | |||
| sb.append(i.next()); | |||
| sb.append(resource); | |||
| } | |||
| return sb.toString(); | |||
| } | |||
| @@ -31,43 +31,43 @@ import org.apache.tools.ant.types.Resource; | |||
| * @since Ant 1.7 | |||
| */ | |||
| /*package-private*/ class FailFast implements Iterator<Resource> { | |||
| private static final WeakHashMap MAP = new WeakHashMap(); | |||
| private static final WeakHashMap<Object, Set<FailFast>> MAP = new WeakHashMap<Object, Set<FailFast>>(); | |||
| /** | |||
| * Invalidate any in-use Iterators from the specified Object. | |||
| * @param o the parent Object. | |||
| */ | |||
| static synchronized void invalidate(Object o) { | |||
| Set s = (Set) (MAP.get(o)); | |||
| Set<FailFast> s = MAP.get(o); | |||
| if (s != null) { | |||
| s.clear(); | |||
| } | |||
| } | |||
| private static synchronized void add(FailFast f) { | |||
| Set s = (Set) (MAP.get(f.parent)); | |||
| Set<FailFast> s = MAP.get(f.parent); | |||
| if (s == null) { | |||
| s = new HashSet(); | |||
| s = new HashSet<FailFast>(); | |||
| MAP.put(f.parent, s); | |||
| } | |||
| s.add(f); | |||
| } | |||
| private static synchronized void remove(FailFast f) { | |||
| Set s = (Set) (MAP.get(f.parent)); | |||
| Set<FailFast> s = MAP.get(f.parent); | |||
| if (s != null) { | |||
| s.remove(f); | |||
| } | |||
| } | |||
| private static synchronized void failFast(FailFast f) { | |||
| Set s = (Set) (MAP.get(f.parent)); | |||
| Set<FailFast> s = MAP.get(f.parent); | |||
| if (!s.contains(f)) { | |||
| throw new ConcurrentModificationException(); | |||
| } | |||
| } | |||
| private Object parent; | |||
| private final Object parent; | |||
| private Iterator<Resource> wrapped; | |||
| /** | |||
| @@ -43,7 +43,7 @@ public class Files extends AbstractSelectorContainer | |||
| = Collections.<Resource>emptySet().iterator(); | |||
| private PatternSet defaultPatterns = new PatternSet(); | |||
| private Vector additionalPatterns = new Vector(); | |||
| private Vector<PatternSet> additionalPatterns = new Vector<PatternSet>(); | |||
| private boolean useDefaultExcludes = true; | |||
| private boolean caseSensitive = true; | |||
| @@ -357,8 +357,8 @@ public class Files extends AbstractSelectorContainer | |||
| if (hasPatterns(defaultPatterns)) { | |||
| return true; | |||
| } | |||
| for (Iterator i = additionalPatterns.iterator(); i.hasNext();) { | |||
| if (hasPatterns((PatternSet) i.next())) { | |||
| for (PatternSet patternSet : additionalPatterns) { | |||
| if (hasPatterns(patternSet)) { | |||
| return true; | |||
| } | |||
| } | |||
| @@ -411,10 +411,9 @@ public class Files extends AbstractSelectorContainer | |||
| } | |||
| Files f = (Files) super.clone(); | |||
| f.defaultPatterns = (PatternSet) defaultPatterns.clone(); | |||
| f.additionalPatterns = new Vector(additionalPatterns.size()); | |||
| for (Iterator iter = additionalPatterns.iterator(); iter.hasNext();) { | |||
| PatternSet ps = (PatternSet) iter.next(); | |||
| f.additionalPatterns.add(ps.clone()); | |||
| f.additionalPatterns = new Vector<PatternSet>(additionalPatterns.size()); | |||
| for (PatternSet ps : additionalPatterns) { | |||
| f.additionalPatterns.add((PatternSet) ps.clone()); | |||
| } | |||
| return f; | |||
| } | |||
| @@ -26,6 +26,7 @@ import java.io.IOException; | |||
| * @since Ant 1.7 | |||
| */ | |||
| public class ImmutableResourceException extends IOException { | |||
| private static final long serialVersionUID = 1L; | |||
| /** | |||
| * Default constructor. | |||
| @@ -37,7 +37,7 @@ public class JavaConstantResource extends AbstractClasspathResource { | |||
| * @throws IOException if an error occurs. | |||
| */ | |||
| protected InputStream openInputStream(ClassLoader cl) throws IOException { | |||
| Class clazz; | |||
| Class<?> clazz; | |||
| String constant = getName(); | |||
| int index1 = constant.lastIndexOf('.'); | |||
| if (index1 < 0) { | |||
| @@ -185,7 +185,7 @@ public class MappedResourceCollection | |||
| * @param p the project to use to dereference the references. | |||
| * @throws BuildException on error. | |||
| */ | |||
| protected synchronized void dieOnCircularReference(Stack stk, Project p) | |||
| protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) | |||
| throws BuildException { | |||
| if (isChecked()) { | |||
| return; | |||
| @@ -203,7 +203,7 @@ public abstract class ResourceDecorator extends Resource { | |||
| /** | |||
| * {@inheritDoc} | |||
| */ | |||
| protected void dieOnCircularReference(final Stack stack, | |||
| protected void dieOnCircularReference(final Stack<Object> stack, | |||
| final Project project) | |||
| throws BuildException { | |||
| if (isChecked()) { | |||
| @@ -44,8 +44,8 @@ import org.apache.tools.ant.util.FileUtils; | |||
| * @since Ant 1.8.0 | |||
| */ | |||
| public class ResourceList extends DataType implements ResourceCollection { | |||
| private final Vector filterChains = new Vector(); | |||
| private final ArrayList textDocuments = new ArrayList(); | |||
| private final Vector<FilterChain> filterChains = new Vector<FilterChain>(); | |||
| private final ArrayList<ResourceCollection> textDocuments = new ArrayList<ResourceCollection>(); | |||
| private final Union cachedResources = new Union(); | |||
| private volatile boolean cached = false; | |||
| private String encoding = null; | |||
| @@ -148,7 +148,7 @@ public class ResourceList extends DataType implements ResourceCollection { | |||
| * @param p the project to use to dereference the references. | |||
| * @throws BuildException on error. | |||
| */ | |||
| protected synchronized void dieOnCircularReference(Stack stk, Project p) | |||
| protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) | |||
| throws BuildException { | |||
| if (isChecked()) { | |||
| return; | |||
| @@ -156,25 +156,22 @@ public class ResourceList extends DataType implements ResourceCollection { | |||
| if (isReference()) { | |||
| super.dieOnCircularReference(stk, p); | |||
| } else { | |||
| for (Iterator iter = textDocuments.iterator(); iter.hasNext(); ) { | |||
| Object o = (Object) iter.next(); | |||
| if (o instanceof DataType) { | |||
| pushAndInvokeCircularReferenceCheck((DataType) o, stk, p); | |||
| for (ResourceCollection resourceCollection : textDocuments) { | |||
| if (resourceCollection instanceof DataType) { | |||
| pushAndInvokeCircularReferenceCheck((DataType) resourceCollection, stk, p); | |||
| } | |||
| } | |||
| for (Iterator iter = filterChains.iterator(); iter.hasNext(); ) { | |||
| FilterChain fc = (FilterChain) iter.next(); | |||
| pushAndInvokeCircularReferenceCheck(fc, stk, p); | |||
| for (FilterChain filterChain : filterChains) { | |||
| pushAndInvokeCircularReferenceCheck(filterChain, stk, p); | |||
| } | |||
| setChecked(true); | |||
| } | |||
| } | |||
| private synchronized ResourceCollection cache() { | |||
| if (!cached) { | |||
| dieOnCircularReference(); | |||
| for (Iterator iter = textDocuments.iterator(); iter.hasNext(); ) { | |||
| ResourceCollection rc = (ResourceCollection) iter.next(); | |||
| for (ResourceCollection rc : textDocuments) { | |||
| for (Resource r : rc) { | |||
| cachedResources.add(read(r)); | |||
| } | |||
| @@ -40,8 +40,8 @@ public class Restrict | |||
| * Restrict the nested ResourceCollection based on the nested selectors. | |||
| */ | |||
| protected boolean filterResource(Resource r) { | |||
| for (Iterator i = getSelectors(); i.hasNext();) { | |||
| if (!((ResourceSelector) (i.next())).isSelected(r)) { | |||
| for (Iterator<ResourceSelector> i = getSelectors(); i.hasNext();) { | |||
| if (!i.next().isSelected(r)) { | |||
| return true; | |||
| } | |||
| } | |||
| @@ -140,7 +140,7 @@ public class Restrict | |||
| return w.toString(); | |||
| } | |||
| protected synchronized void dieOnCircularReference(Stack stk, Project p) { | |||
| protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) { | |||
| if (isChecked()) { | |||
| return; | |||
| } | |||
| @@ -80,12 +80,12 @@ public class Sort extends BaseResourceCollectionWrapper { | |||
| * @param p the project to use to dereference the references. | |||
| * @throws BuildException on error. | |||
| */ | |||
| protected synchronized void dieOnCircularReference(Stack stk, Project p) | |||
| protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) | |||
| throws BuildException { | |||
| if (isChecked()) { | |||
| return; | |||
| } | |||
| // check nested collection | |||
| super.dieOnCircularReference(stk, p); | |||
| @@ -28,8 +28,10 @@ import java.util.Collections; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.BuildException; | |||
| import org.apache.tools.ant.types.DataType; | |||
| import org.apache.tools.ant.types.Resource; | |||
| import org.apache.tools.ant.types.ResourceCollection; | |||
| import org.apache.tools.ant.util.ConcatResourceInputStream; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| import org.apache.tools.ant.util.LineTokenizer; | |||
| import org.apache.tools.ant.util.Tokenizer; | |||
| @@ -47,10 +49,10 @@ public class Tokens extends BaseResourceCollectionWrapper { | |||
| * Sort the contained elements. | |||
| * @return a Collection of Resources. | |||
| */ | |||
| protected synchronized Collection getCollection() { | |||
| protected synchronized Collection<Resource> getCollection() { | |||
| ResourceCollection rc = getResourceCollection(); | |||
| if (rc.size() == 0) { | |||
| return Collections.EMPTY_SET; | |||
| return Collections.emptySet(); | |||
| } | |||
| if (tokenizer == null) { | |||
| tokenizer = new LineTokenizer(); | |||
| @@ -58,27 +60,29 @@ public class Tokens extends BaseResourceCollectionWrapper { | |||
| ConcatResourceInputStream cat = new ConcatResourceInputStream(rc); | |||
| cat.setManagingComponent(this); | |||
| InputStreamReader rdr = null; | |||
| if (encoding == null) { | |||
| rdr = new InputStreamReader(cat); | |||
| } else { | |||
| try { | |||
| rdr = new InputStreamReader(cat, encoding); | |||
| } catch (UnsupportedEncodingException e) { | |||
| throw new BuildException(e); | |||
| } | |||
| } | |||
| ArrayList result = new ArrayList(); | |||
| try { | |||
| InputStreamReader rdr = null; | |||
| if (encoding == null) { | |||
| rdr = new InputStreamReader(cat); | |||
| } else { | |||
| try { | |||
| rdr = new InputStreamReader(cat, encoding); | |||
| } catch (UnsupportedEncodingException e) { | |||
| throw new BuildException(e); | |||
| } | |||
| } | |||
| ArrayList<Resource> result = new ArrayList<Resource>(); | |||
| for (String s = tokenizer.getToken(rdr); s != null; s = tokenizer.getToken(rdr)) { | |||
| StringResource resource = new StringResource(s); | |||
| resource.setProject(getProject()); | |||
| result.add(resource); | |||
| } | |||
| return result; | |||
| } catch (IOException e) { | |||
| throw new BuildException("Error reading tokens", e); | |||
| } finally { | |||
| FileUtils.close(cat); | |||
| } | |||
| return result; | |||
| } | |||
| /** | |||
| @@ -112,7 +116,7 @@ public class Tokens extends BaseResourceCollectionWrapper { | |||
| * @param p the project to use to dereference the references. | |||
| * @throws BuildException on error. | |||
| */ | |||
| protected synchronized void dieOnCircularReference(Stack stk, Project p) | |||
| protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) | |||
| throws BuildException { | |||
| if (isChecked()) { | |||
| return; | |||
| @@ -17,11 +17,12 @@ | |||
| */ | |||
| package org.apache.tools.ant.types.resources; | |||
| import java.util.ArrayList; | |||
| import java.util.Collection; | |||
| import java.util.Collections; | |||
| import java.util.Iterator; | |||
| import java.util.LinkedHashSet; | |||
| import java.util.List; | |||
| import java.util.Set; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.types.Resource; | |||
| @@ -63,7 +64,7 @@ public class Union extends BaseResourceCollectionContainer { | |||
| public Union(ResourceCollection rc) { | |||
| this(Project.getProject(rc), rc); | |||
| } | |||
| /** | |||
| * Convenience constructor. | |||
| * @param project owning Project | |||
| @@ -81,10 +82,10 @@ public class Union extends BaseResourceCollectionContainer { | |||
| */ | |||
| public String[] list() { | |||
| if (isReference()) { | |||
| return ((Union) getCheckedRef()).list(); | |||
| return getCheckedRef(Union.class, getDataTypeName()).list(); | |||
| } | |||
| Collection result = getCollection(true); | |||
| return (String[]) (result.toArray(new String[result.size()])); | |||
| final Collection<String> result = getAllToStrings(); | |||
| return result.toArray(new String[result.size()]); | |||
| } | |||
| /** | |||
| @@ -93,18 +94,18 @@ public class Union extends BaseResourceCollectionContainer { | |||
| */ | |||
| public Resource[] listResources() { | |||
| if (isReference()) { | |||
| return ((Union) getCheckedRef()).listResources(); | |||
| return getCheckedRef(Union.class, getDataTypeName()).listResources(); | |||
| } | |||
| Collection result = getCollection(); | |||
| return (Resource[]) (result.toArray(new Resource[result.size()])); | |||
| final Collection<Resource> result = getAllResources(); | |||
| return result.toArray(new Resource[result.size()]); | |||
| } | |||
| /** | |||
| * Unify the contained Resources. | |||
| * @return a Collection of Resources. | |||
| */ | |||
| protected Collection getCollection() { | |||
| return getCollection(false); | |||
| protected Collection<Resource> getCollection() { | |||
| return getAllResources(); | |||
| } | |||
| /** | |||
| @@ -113,26 +114,43 @@ public class Union extends BaseResourceCollectionContainer { | |||
| * should contain Strings instead of Resources. | |||
| * @return a Collection of Resources. | |||
| */ | |||
| protected Collection getCollection(boolean asString) { // XXX untypable | |||
| List rc = getResourceCollections(); | |||
| if (rc.isEmpty()) { | |||
| return Collections.EMPTY_LIST; | |||
| @Deprecated | |||
| @SuppressWarnings("unchecked") | |||
| protected <T> Collection<T> getCollection(boolean asString) { // XXX untypable | |||
| return asString ? (Collection<T>) getAllToStrings() : (Collection<T>) getAllResources(); | |||
| } | |||
| /** | |||
| * Get a collection of strings representing the unified resource set (strings may duplicate). | |||
| * @return Collection<String> | |||
| */ | |||
| protected Collection<String> getAllToStrings() { | |||
| final Set<Resource> allResources = getAllResources(); | |||
| final ArrayList<String> result = new ArrayList<String>(allResources.size()); | |||
| for (Resource r : allResources) { | |||
| result.add(r.toString()); | |||
| } | |||
| LinkedHashSet set = new LinkedHashSet(rc.size() * 2); | |||
| for (Iterator rcIter = rc.iterator(); rcIter.hasNext();) { | |||
| for (Iterator r = nextRC(rcIter).iterator(); r.hasNext();) { | |||
| Object o = r.next(); | |||
| if (asString) { | |||
| o = o.toString(); | |||
| } | |||
| set.add(o); | |||
| return result; | |||
| } | |||
| /** | |||
| * Get the unified set of contained Resources. | |||
| * @return Set<Resource> | |||
| */ | |||
| protected Set<Resource> getAllResources() { | |||
| final List<ResourceCollection> resourceCollections = getResourceCollections(); | |||
| if (resourceCollections.isEmpty()) { | |||
| return Collections.emptySet(); | |||
| } | |||
| final LinkedHashSet<Resource> result = new LinkedHashSet<Resource>( | |||
| resourceCollections.size() * 2); | |||
| for (ResourceCollection resourceCollection : resourceCollections) { | |||
| for (Resource r : resourceCollection) { | |||
| result.add(r); | |||
| } | |||
| } | |||
| return set; | |||
| return result; | |||
| } | |||
| private static ResourceCollection nextRC(Iterator i) { | |||
| return (ResourceCollection) i.next(); | |||
| } | |||
| } | |||
| @@ -17,6 +17,7 @@ | |||
| */ | |||
| package org.apache.tools.ant.types.resources.comparators; | |||
| import java.util.List; | |||
| import java.util.Stack; | |||
| import java.util.Vector; | |||
| import java.util.Iterator; | |||
| @@ -33,7 +34,7 @@ import org.apache.tools.ant.types.Resource; | |||
| */ | |||
| public class DelegatedResourceComparator extends ResourceComparator { | |||
| private Vector v = null; | |||
| private List<ResourceComparator> resourceComparators = null; | |||
| /** | |||
| * Add a delegate ResourceComparator. | |||
| @@ -46,8 +47,8 @@ public class DelegatedResourceComparator extends ResourceComparator { | |||
| if (c == null) { | |||
| return; | |||
| } | |||
| v = (v == null) ? new Vector() : v; | |||
| v.add(c); | |||
| resourceComparators = (resourceComparators == null) ? new Vector<ResourceComparator>() : resourceComparators; | |||
| resourceComparators.add(c); | |||
| setChecked(false); | |||
| } | |||
| @@ -67,8 +68,8 @@ public class DelegatedResourceComparator extends ResourceComparator { | |||
| if (!(o instanceof DelegatedResourceComparator)) { | |||
| return false; | |||
| } | |||
| Vector ov = ((DelegatedResourceComparator) o).v; | |||
| return v == null ? ov == null : v.equals(ov); | |||
| List<ResourceComparator> ov = ((DelegatedResourceComparator) o).resourceComparators; | |||
| return resourceComparators == null ? ov == null : resourceComparators.equals(ov); | |||
| } | |||
| /** | |||
| @@ -79,18 +80,18 @@ public class DelegatedResourceComparator extends ResourceComparator { | |||
| if (isReference()) { | |||
| return getCheckedRef().hashCode(); | |||
| } | |||
| return v == null ? 0 : v.hashCode(); | |||
| return resourceComparators == null ? 0 : resourceComparators.hashCode(); | |||
| } | |||
| /** {@inheritDoc} */ | |||
| protected synchronized int resourceCompare(Resource foo, Resource bar) { | |||
| //if no nested, natural order: | |||
| if (v == null || v.isEmpty()) { | |||
| if (resourceComparators == null || resourceComparators.isEmpty()) { | |||
| return foo.compareTo(bar); | |||
| } | |||
| int result = 0; | |||
| for (Iterator i = v.iterator(); result == 0 && i.hasNext();) { | |||
| result = ((ResourceComparator) i.next()).resourceCompare(foo, bar); | |||
| for (Iterator<ResourceComparator> i = resourceComparators.iterator(); result == 0 && i.hasNext();) { | |||
| result = i.next().resourceCompare(foo, bar); | |||
| } | |||
| return result; | |||
| } | |||
| @@ -102,7 +103,7 @@ s. | |||
| * @param p the Project to resolve against. | |||
| * @throws BuildException on error. | |||
| */ | |||
| protected void dieOnCircularReference(Stack stk, Project p) | |||
| protected void dieOnCircularReference(Stack<Object> stk, Project p) | |||
| throws BuildException { | |||
| if (isChecked()) { | |||
| return; | |||
| @@ -110,11 +111,10 @@ s. | |||
| if (isReference()) { | |||
| super.dieOnCircularReference(stk, p); | |||
| } else { | |||
| if (!(v == null || v.isEmpty())) { | |||
| for (Iterator i = v.iterator(); i.hasNext();) { | |||
| Object o = i.next(); | |||
| if (o instanceof DataType) { | |||
| pushAndInvokeCircularReferenceCheck((DataType) o, stk, | |||
| if (!(resourceComparators == null || resourceComparators.isEmpty())) { | |||
| for (ResourceComparator resourceComparator : resourceComparators) { | |||
| if (resourceComparator instanceof DataType) { | |||
| pushAndInvokeCircularReferenceCheck((DataType) resourceComparator, stk, | |||
| p); | |||
| } | |||
| } | |||
| @@ -72,7 +72,7 @@ public class Reverse extends ResourceComparator { | |||
| ? foo.compareTo(bar) : nested.compare(foo, bar)); | |||
| } | |||
| protected void dieOnCircularReference(Stack stk, Project p) | |||
| protected void dieOnCircularReference(Stack<Object> stk, Project p) | |||
| throws BuildException { | |||
| if (isChecked()) { | |||
| return; | |||
| @@ -47,8 +47,8 @@ public class And extends ResourceSelectorContainer implements ResourceSelector { | |||
| * @return whether the Resource was selected. | |||
| */ | |||
| public boolean isSelected(Resource r) { | |||
| for (Iterator i = getSelectors(); i.hasNext();) { | |||
| if (!((ResourceSelector) i.next()).isSelected(r)) { | |||
| for (Iterator<ResourceSelector> i = getSelectors(); i.hasNext();) { | |||
| if (!i.next().isSelected(r)) { | |||
| return false; | |||
| } | |||
| } | |||
| @@ -18,7 +18,6 @@ | |||
| package org.apache.tools.ant.types.resources.selectors; | |||
| import java.util.Stack; | |||
| import java.util.Iterator; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.BuildException; | |||
| @@ -128,7 +127,7 @@ public class Compare extends DataType implements ResourceSelector { | |||
| * @param p the project to use to dereference the references. | |||
| * @throws BuildException on error. | |||
| */ | |||
| protected synchronized void dieOnCircularReference(Stack stk, Project p) | |||
| protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) | |||
| throws BuildException { | |||
| if (isChecked()) { | |||
| return; | |||
| @@ -33,7 +33,7 @@ public class InstanceOf implements ResourceSelector { | |||
| private static final String ONE_ONLY = "Exactly one of class|type must be set."; | |||
| private Project project; | |||
| private Class clazz; | |||
| private Class<?> clazz; | |||
| private String type; | |||
| private String uri; | |||
| @@ -49,7 +49,7 @@ public class InstanceOf implements ResourceSelector { | |||
| * Set the class to compare against. | |||
| * @param c the class. | |||
| */ | |||
| public void setClass(Class c) { | |||
| public void setClass(Class<?> c) { | |||
| if (clazz != null) { | |||
| throw new BuildException("The class attribute has already been set."); | |||
| } | |||
| @@ -76,7 +76,7 @@ public class InstanceOf implements ResourceSelector { | |||
| * Get the comparison class. | |||
| * @return the Class object. | |||
| */ | |||
| public Class getCheckClass() { | |||
| public Class<?> getCheckClass() { | |||
| return clazz; | |||
| } | |||
| @@ -106,7 +106,7 @@ public class InstanceOf implements ResourceSelector { | |||
| if ((clazz == null) == (type == null)) { | |||
| throw new BuildException(ONE_ONLY); | |||
| } | |||
| Class c = clazz; | |||
| Class<?> c = clazz; | |||
| if (type != null) { | |||
| if (project == null) { | |||
| throw new BuildException( | |||
| @@ -64,8 +64,8 @@ public class Majority | |||
| boolean even = count % 2 == 0; | |||
| int threshold = count / 2; | |||
| for (Iterator i = getSelectors(); i.hasNext();) { | |||
| if (((ResourceSelector) i.next()).isSelected(r)) { | |||
| for (Iterator<ResourceSelector> i = getSelectors(); i.hasNext();) { | |||
| if (i.next().isSelected(r)) { | |||
| ++passed; | |||
| if (passed > threshold || (even && tie && passed == threshold)) { | |||
| return true; | |||
| @@ -48,11 +48,12 @@ public class None | |||
| * @return whether the Resource was selected. | |||
| */ | |||
| public boolean isSelected(Resource r) { | |||
| boolean none = true; | |||
| for (Iterator i = getSelectors(); none && i.hasNext();) { | |||
| none = !((ResourceSelector) i.next()).isSelected(r); | |||
| for (Iterator<ResourceSelector> i = getSelectors(); i.hasNext();) { | |||
| if (i.next().isSelected(r)) { | |||
| return false; | |||
| } | |||
| } | |||
| return none; | |||
| return true; | |||
| } | |||
| } | |||
| @@ -47,8 +47,8 @@ public class Or extends ResourceSelectorContainer implements ResourceSelector { | |||
| * @return whether the Resource was selected. | |||
| */ | |||
| public boolean isSelected(Resource r) { | |||
| for (Iterator i = getSelectors(); i.hasNext();) { | |||
| if (((ResourceSelector) i.next()).isSelected(r)) { | |||
| for (Iterator<ResourceSelector> i = getSelectors(); i.hasNext();) { | |||
| if (i.next().isSelected(r)) { | |||
| return true; | |||
| } | |||
| } | |||
| @@ -17,8 +17,9 @@ | |||
| */ | |||
| package org.apache.tools.ant.types.resources.selectors; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| import java.util.Stack; | |||
| import java.util.Vector; | |||
| import java.util.Iterator; | |||
| import java.util.Collections; | |||
| @@ -32,7 +33,7 @@ import org.apache.tools.ant.types.DataType; | |||
| */ | |||
| public class ResourceSelectorContainer extends DataType { | |||
| private Vector v = new Vector(); | |||
| private final List<ResourceSelector> resourceSelectors = new ArrayList<ResourceSelector>(); | |||
| /** | |||
| * Default constructor. | |||
| @@ -61,7 +62,7 @@ public class ResourceSelectorContainer extends DataType { | |||
| if (s == null) { | |||
| return; | |||
| } | |||
| v.add(s); | |||
| resourceSelectors.add(s); | |||
| setChecked(false); | |||
| } | |||
| @@ -74,7 +75,7 @@ public class ResourceSelectorContainer extends DataType { | |||
| return ((ResourceSelectorContainer) getCheckedRef()).hasSelectors(); | |||
| } | |||
| dieOnCircularReference(); | |||
| return !v.isEmpty(); | |||
| return !resourceSelectors.isEmpty(); | |||
| } | |||
| /** | |||
| @@ -86,19 +87,19 @@ public class ResourceSelectorContainer extends DataType { | |||
| return ((ResourceSelectorContainer) getCheckedRef()).selectorCount(); | |||
| } | |||
| dieOnCircularReference(); | |||
| return v.size(); | |||
| return resourceSelectors.size(); | |||
| } | |||
| /** | |||
| * Return an Iterator over the nested selectors. | |||
| * @return Iterator of ResourceSelectors. | |||
| */ | |||
| public Iterator getSelectors() { | |||
| public Iterator<ResourceSelector> getSelectors() { | |||
| if (isReference()) { | |||
| return ((ResourceSelectorContainer) getCheckedRef()).getSelectors(); | |||
| } | |||
| dieOnCircularReference(); | |||
| return Collections.unmodifiableList(v).iterator(); | |||
| return Collections.unmodifiableList(resourceSelectors).iterator(); | |||
| } | |||
| /** | |||
| @@ -107,7 +108,7 @@ public class ResourceSelectorContainer extends DataType { | |||
| * @param p the Project to resolve against. | |||
| * @throws BuildException on error. | |||
| */ | |||
| protected void dieOnCircularReference(Stack stk, Project p) | |||
| protected void dieOnCircularReference(Stack<Object> stk, Project p) | |||
| throws BuildException { | |||
| if (isChecked()) { | |||
| return; | |||
| @@ -115,10 +116,9 @@ public class ResourceSelectorContainer extends DataType { | |||
| if (isReference()) { | |||
| super.dieOnCircularReference(stk, p); | |||
| } else { | |||
| for (Iterator i = v.iterator(); i.hasNext();) { | |||
| Object o = i.next(); | |||
| if (o instanceof DataType) { | |||
| pushAndInvokeCircularReferenceCheck((DataType) o, stk, p); | |||
| for (ResourceSelector resourceSelector : resourceSelectors) { | |||
| if (resourceSelector instanceof DataType) { | |||
| pushAndInvokeCircularReferenceCheck((DataType) resourceSelector, stk, p); | |||
| } | |||
| } | |||
| setChecked(true); | |||
| @@ -19,7 +19,6 @@ | |||
| package org.apache.tools.ant.types.selectors; | |||
| import java.util.Enumeration; | |||
| import java.util.Iterator; | |||
| import java.util.Stack; | |||
| import java.util.Vector; | |||
| @@ -37,7 +36,7 @@ import org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector; | |||
| public abstract class AbstractSelectorContainer extends DataType | |||
| implements Cloneable, SelectorContainer { | |||
| private Vector selectorsList = new Vector(); | |||
| private Vector<FileSelector> selectorsList = new Vector<FileSelector>(); | |||
| /** | |||
| * Indicates whether there are any selectors here. | |||
| @@ -83,7 +82,7 @@ public abstract class AbstractSelectorContainer extends DataType | |||
| * Returns an enumerator for accessing the set of selectors. | |||
| * @return an enumerator for the selectors | |||
| */ | |||
| public Enumeration selectorElements() { | |||
| public Enumeration<FileSelector> selectorElements() { | |||
| if (isReference()) { | |||
| return ((AbstractSelectorContainer) getCheckedRef()) | |||
| .selectorElements(); | |||
| @@ -100,8 +99,8 @@ public abstract class AbstractSelectorContainer extends DataType | |||
| * @return comma separated list of Selectors contained in this one | |||
| */ | |||
| public String toString() { | |||
| StringBuffer buf = new StringBuffer(); | |||
| Enumeration e = selectorElements(); | |||
| StringBuilder buf = new StringBuilder(); | |||
| Enumeration<FileSelector> e = selectorElements(); | |||
| if (e.hasMoreElements()) { | |||
| while (e.hasMoreElements()) { | |||
| buf.append(e.nextElement().toString()); | |||
| @@ -148,7 +147,7 @@ public abstract class AbstractSelectorContainer extends DataType | |||
| ((AbstractSelectorContainer) getCheckedRef()).validate(); | |||
| } | |||
| dieOnCircularReference(); | |||
| Enumeration e = selectorElements(); | |||
| Enumeration<FileSelector> e = selectorElements(); | |||
| while (e.hasMoreElements()) { | |||
| Object o = e.nextElement(); | |||
| if (o instanceof BaseSelector) { | |||
| @@ -322,17 +321,16 @@ public abstract class AbstractSelectorContainer extends DataType | |||
| appendSelector(selector); | |||
| } | |||
| protected synchronized void dieOnCircularReference(Stack stk, Project p) { | |||
| protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) { | |||
| if (isChecked()) { | |||
| return; | |||
| } | |||
| if (isReference()) { | |||
| super.dieOnCircularReference(stk, p); | |||
| } else { | |||
| for (Iterator i = selectorsList.iterator(); i.hasNext(); ) { | |||
| Object o = i.next(); | |||
| if (o instanceof DataType) { | |||
| pushAndInvokeCircularReferenceCheck((DataType) o, stk, p); | |||
| for (FileSelector fileSelector : selectorsList) { | |||
| if (fileSelector instanceof DataType) { | |||
| pushAndInvokeCircularReferenceCheck((DataType) fileSelector, stk, p); | |||
| } | |||
| } | |||
| setChecked(true); | |||
| @@ -346,7 +344,7 @@ public abstract class AbstractSelectorContainer extends DataType | |||
| try { | |||
| AbstractSelectorContainer sc = | |||
| (AbstractSelectorContainer) super.clone(); | |||
| sc.selectorsList = new Vector(selectorsList); | |||
| sc.selectorsList = new Vector<FileSelector>(selectorsList); | |||
| return sc; | |||
| } catch (CloneNotSupportedException e) { | |||
| throw new BuildException(e); | |||
| @@ -39,7 +39,7 @@ public class AndSelector extends BaseSelectorContainer { | |||
| * @return a string representation of the selector | |||
| */ | |||
| public String toString() { | |||
| StringBuffer buf = new StringBuffer(); | |||
| StringBuilder buf = new StringBuilder(); | |||
| if (hasSelectors()) { | |||
| buf.append("{andselect: "); | |||
| buf.append(super.toString()); | |||
| @@ -60,13 +60,10 @@ public class AndSelector extends BaseSelectorContainer { | |||
| */ | |||
| public boolean isSelected(File basedir, String filename, File file) { | |||
| validate(); | |||
| Enumeration e = selectorElements(); | |||
| boolean result; | |||
| Enumeration<FileSelector> e = selectorElements(); | |||
| while (e.hasMoreElements()) { | |||
| result = ((FileSelector) e.nextElement()).isSelected(basedir, | |||
| filename, file); | |||
| if (!result) { | |||
| if (!e.nextElement().isSelected(basedir, filename, file)) { | |||
| return false; | |||
| } | |||
| } | |||
| @@ -20,7 +20,6 @@ package org.apache.tools.ant.types.selectors; | |||
| import java.io.File; | |||
| import java.util.Enumeration; | |||
| import java.util.Iterator; | |||
| import java.util.Stack; | |||
| import java.util.Vector; | |||
| @@ -37,7 +36,7 @@ import org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector; | |||
| public abstract class BaseSelectorContainer extends BaseSelector | |||
| implements SelectorContainer { | |||
| private Vector selectorsList = new Vector(); | |||
| private Vector<FileSelector> selectorsList = new Vector<FileSelector>(); | |||
| /** | |||
| * Default constructor. | |||
| @@ -79,7 +78,7 @@ public abstract class BaseSelectorContainer extends BaseSelector | |||
| * Returns an enumerator for accessing the set of selectors. | |||
| * @return an enumerator for the selectors | |||
| */ | |||
| public Enumeration selectorElements() { | |||
| public Enumeration<FileSelector> selectorElements() { | |||
| dieOnCircularReference(); | |||
| return selectorsList.elements(); | |||
| } | |||
| @@ -93,17 +92,14 @@ public abstract class BaseSelectorContainer extends BaseSelector | |||
| */ | |||
| public String toString() { | |||
| dieOnCircularReference(); | |||
| StringBuffer buf = new StringBuffer(); | |||
| Enumeration e = selectorElements(); | |||
| if (e.hasMoreElements()) { | |||
| while (e.hasMoreElements()) { | |||
| buf.append(e.nextElement().toString()); | |||
| if (e.hasMoreElements()) { | |||
| buf.append(", "); | |||
| } | |||
| StringBuilder buf = new StringBuilder(); | |||
| Enumeration<FileSelector> e = selectorElements(); | |||
| while (e.hasMoreElements()) { | |||
| buf.append(e.nextElement().toString()); | |||
| if (e.hasMoreElements()) { | |||
| buf.append(", "); | |||
| } | |||
| } | |||
| return buf.toString(); | |||
| } | |||
| @@ -140,7 +136,7 @@ public abstract class BaseSelectorContainer extends BaseSelector | |||
| if (errmsg != null) { | |||
| throw new BuildException(errmsg); | |||
| } | |||
| Enumeration e = selectorElements(); | |||
| Enumeration<FileSelector> e = selectorElements(); | |||
| while (e.hasMoreElements()) { | |||
| Object o = e.nextElement(); | |||
| if (o instanceof BaseSelector) { | |||
| @@ -328,7 +324,7 @@ public abstract class BaseSelectorContainer extends BaseSelector | |||
| appendSelector(selector); | |||
| } | |||
| protected synchronized void dieOnCircularReference(Stack stk, Project p) | |||
| protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) | |||
| throws BuildException { | |||
| if (isChecked()) { | |||
| return; | |||
| @@ -336,10 +332,9 @@ public abstract class BaseSelectorContainer extends BaseSelector | |||
| if (isReference()) { | |||
| super.dieOnCircularReference(stk, p); | |||
| } else { | |||
| for (Iterator i = selectorsList.iterator(); i.hasNext();) { | |||
| Object o = i.next(); | |||
| if (o instanceof DataType) { | |||
| pushAndInvokeCircularReferenceCheck((DataType) o, stk, p); | |||
| for (FileSelector fileSelector : selectorsList) { | |||
| if (fileSelector instanceof DataType) { | |||
| pushAndInvokeCircularReferenceCheck((DataType) fileSelector, stk, p); | |||
| } | |||
| } | |||
| setChecked(true); | |||
| @@ -66,7 +66,7 @@ public class ContainsRegexpSelector extends BaseExtendSelector | |||
| * @return a string describing this object | |||
| */ | |||
| public String toString() { | |||
| StringBuffer buf = new StringBuffer( | |||
| StringBuilder buf = new StringBuilder( | |||
| "{containsregexpselector expression: "); | |||
| buf.append(userProvidedExpression); | |||
| buf.append("}"); | |||
| @@ -63,7 +63,7 @@ public class ContainsSelector extends BaseExtendSelector implements ResourceSele | |||
| * @return a string describing this object | |||
| */ | |||
| public String toString() { | |||
| StringBuffer buf = new StringBuffer("{containsselector text: "); | |||
| StringBuilder buf = new StringBuilder("{containsselector text: "); | |||
| buf.append('"').append(contains).append('"'); | |||
| buf.append(" casesensitive: "); | |||
| buf.append(casesensitive ? "true" : "false"); | |||
| @@ -71,7 +71,7 @@ public class DateSelector extends BaseExtendSelector { | |||
| * @return a string describing this object | |||
| */ | |||
| public String toString() { | |||
| StringBuffer buf = new StringBuffer("{dateselector date: "); | |||
| StringBuilder buf = new StringBuilder("{dateselector date: "); | |||
| buf.append(dateTime); | |||
| buf.append(" compare: ").append(when.getValue()); | |||
| buf.append(" granularity: "); | |||
| @@ -42,7 +42,7 @@ public class DependSelector extends MappingSelector { | |||
| * @return a string describing this object | |||
| */ | |||
| public String toString() { | |||
| StringBuffer buf = new StringBuffer("{dependselector targetdir: "); | |||
| StringBuilder buf = new StringBuilder("{dependselector targetdir: "); | |||
| if (targetdir == null) { | |||
| buf.append("NOT YET SET"); | |||
| } else { | |||
| @@ -57,7 +57,7 @@ public class DepthSelector extends BaseExtendSelector { | |||
| * @return a string describing this object | |||
| */ | |||
| public String toString() { | |||
| StringBuffer buf = new StringBuffer("{depthselector min: "); | |||
| StringBuilder buf = new StringBuilder("{depthselector min: "); | |||
| buf.append(min); | |||
| buf.append(" max: "); | |||
| buf.append(max); | |||
| @@ -37,7 +37,7 @@ public class ExtendSelector extends BaseSelector { | |||
| private String classname = null; | |||
| private FileSelector dynselector = null; | |||
| private Vector paramVec = new Vector(); | |||
| private Vector<Parameter> paramVec = new Vector<Parameter>(); | |||
| private Path classpath = null; | |||
| /** | |||
| @@ -61,7 +61,7 @@ public class ExtendSelector extends BaseSelector { | |||
| public void selectorCreate() { | |||
| if (classname != null && classname.length() > 0) { | |||
| try { | |||
| Class c = null; | |||
| Class<?> c = null; | |||
| if (classpath == null) { | |||
| c = Class.forName(classname); | |||
| } else { | |||
| @@ -70,7 +70,7 @@ public class ExtendSelector extends BaseSelector { | |||
| = getProject().createClassLoader(classpath); | |||
| c = Class.forName(classname, true, al); | |||
| } | |||
| dynselector = (FileSelector) c.newInstance(); | |||
| dynselector = c.asSubclass(FileSelector.class).newInstance(); | |||
| final Project p = getProject(); | |||
| if (p != null) { | |||
| p.setProjectReference(dynselector); | |||
| @@ -62,7 +62,7 @@ public class FilenameSelector extends BaseExtendSelector { | |||
| * @return a string describing this object | |||
| */ | |||
| public String toString() { | |||
| StringBuffer buf = new StringBuffer("{filenameselector name: "); | |||
| StringBuilder buf = new StringBuilder("{filenameselector name: "); | |||
| if (pattern != null) { | |||
| buf.append(pattern); | |||
| } | |||
| @@ -46,7 +46,7 @@ public class MajoritySelector extends BaseSelectorContainer { | |||
| * @return a string describing this object | |||
| */ | |||
| public String toString() { | |||
| StringBuffer buf = new StringBuffer(); | |||
| StringBuilder buf = new StringBuilder(); | |||
| if (hasSelectors()) { | |||
| buf.append("{majorityselect: "); | |||
| buf.append(super.toString()); | |||
| @@ -81,16 +81,14 @@ public class MajoritySelector extends BaseSelectorContainer { | |||
| validate(); | |||
| int yesvotes = 0; | |||
| int novotes = 0; | |||
| Enumeration e = selectorElements(); | |||
| boolean result; | |||
| Enumeration<FileSelector> e = selectorElements(); | |||
| while (e.hasMoreElements()) { | |||
| result = ((FileSelector) e.nextElement()).isSelected(basedir, | |||
| filename, file); | |||
| if (result) { | |||
| yesvotes = yesvotes + 1; | |||
| if (e.nextElement().isSelected(basedir, | |||
| filename, file)) { | |||
| yesvotes++; | |||
| } else { | |||
| novotes = novotes + 1; | |||
| novotes++; | |||
| } | |||
| } | |||
| if (yesvotes > novotes) { | |||
| @@ -40,7 +40,7 @@ public class NoneSelector extends BaseSelectorContainer { | |||
| * @return a string representation of the selector | |||
| */ | |||
| public String toString() { | |||
| StringBuffer buf = new StringBuffer(); | |||
| StringBuilder buf = new StringBuilder(); | |||
| if (hasSelectors()) { | |||
| buf.append("{noneselect: "); | |||
| buf.append(super.toString()); | |||
| @@ -61,13 +61,10 @@ public class NoneSelector extends BaseSelectorContainer { | |||
| */ | |||
| public boolean isSelected(File basedir, String filename, File file) { | |||
| validate(); | |||
| Enumeration e = selectorElements(); | |||
| boolean result; | |||
| Enumeration<FileSelector> e = selectorElements(); | |||
| while (e.hasMoreElements()) { | |||
| result = ((FileSelector) e.nextElement()).isSelected(basedir, | |||
| filename, file); | |||
| if (result) { | |||
| if (e.nextElement().isSelected(basedir, filename, file)) { | |||
| return false; | |||
| } | |||
| } | |||
| @@ -49,7 +49,7 @@ public class NotSelector extends NoneSelector { | |||
| * @return a string representation of the selector | |||
| */ | |||
| public String toString() { | |||
| StringBuffer buf = new StringBuffer(); | |||
| StringBuilder buf = new StringBuilder(); | |||
| if (hasSelectors()) { | |||
| buf.append("{notselect: "); | |||
| buf.append(super.toString()); | |||
| @@ -39,7 +39,7 @@ public class OrSelector extends BaseSelectorContainer { | |||
| * @return a string representation of the selector | |||
| */ | |||
| public String toString() { | |||
| StringBuffer buf = new StringBuffer(); | |||
| StringBuilder buf = new StringBuilder(); | |||
| if (hasSelectors()) { | |||
| buf.append("{orselect: "); | |||
| buf.append(super.toString()); | |||
| @@ -60,14 +60,11 @@ public class OrSelector extends BaseSelectorContainer { | |||
| */ | |||
| public boolean isSelected(File basedir, String filename, File file) { | |||
| validate(); | |||
| Enumeration e = selectorElements(); | |||
| boolean result; | |||
| Enumeration<FileSelector> e = selectorElements(); | |||
| // First, check that all elements are correctly configured | |||
| while (e.hasMoreElements()) { | |||
| result = ((FileSelector) e.nextElement()).isSelected(basedir, | |||
| filename, file); | |||
| if (result) { | |||
| if (e.nextElement().isSelected(basedir, filename, file)) { | |||
| return true; | |||
| } | |||
| } | |||
| @@ -52,7 +52,7 @@ public class PresentSelector extends BaseSelector { | |||
| * @return a string describing this object | |||
| */ | |||
| public String toString() { | |||
| StringBuffer buf = new StringBuffer("{presentselector targetdir: "); | |||
| StringBuilder buf = new StringBuilder("{presentselector targetdir: "); | |||
| if (targetdir == null) { | |||
| buf.append("NOT YET SET"); | |||
| } else { | |||
| @@ -108,7 +108,7 @@ public class PresentSelector extends BaseSelector { | |||
| } | |||
| this.map = fileNameMapper; | |||
| } | |||
| /** | |||
| * This sets whether to select a file if its dest file is present. | |||
| * It could be a <code>negate</code> boolean, but by doing things | |||
| @@ -114,7 +114,7 @@ public class SelectSelector extends BaseSelectorContainer { | |||
| * Returns an enumerator for accessing the set of selectors. | |||
| * @return an enumerator that goes through each of the selectors | |||
| */ | |||
| public Enumeration selectorElements() { | |||
| public Enumeration<FileSelector> selectorElements() { | |||
| if (isReference()) { | |||
| return getRef().selectorElements(); | |||
| } | |||
| @@ -220,11 +220,11 @@ public class SelectSelector extends BaseSelectorContainer { | |||
| return false; | |||
| } | |||
| Enumeration e = selectorElements(); | |||
| if (!(e.hasMoreElements())) { | |||
| Enumeration<FileSelector> e = selectorElements(); | |||
| if (!e.hasMoreElements()) { | |||
| return true; | |||
| } | |||
| FileSelector f = (FileSelector) e.nextElement(); | |||
| FileSelector f = e.nextElement(); | |||
| return f.isSelected(basedir, filename, file); | |||
| } | |||
| } | |||
| @@ -55,7 +55,7 @@ public interface SelectorContainer { | |||
| * | |||
| * @return an enumerator that goes through each of the selectors | |||
| */ | |||
| Enumeration selectorElements(); | |||
| Enumeration<FileSelector> selectorElements(); | |||
| /** | |||
| * Add a new selector into this container. | |||
| @@ -172,11 +172,11 @@ public final class SelectorUtils { | |||
| /** | |||
| * Tests whether or not a given path matches a given pattern. | |||
| * | |||
| * If you need to call this method multiple times with the same | |||
| * If you need to call this method multiple times with the same | |||
| * pattern you should rather use TokenizedPath | |||
| * | |||
| * @see TokenizedPath | |||
| * | |||
| * | |||
| * @param pattern The pattern to match against. Must not be | |||
| * <code>null</code>. | |||
| * @param str The path to match, as a String. Must not be | |||
| @@ -192,12 +192,12 @@ public final class SelectorUtils { | |||
| /** | |||
| * Tests whether or not a given path matches a given pattern. | |||
| * | |||
| * If you need to call this method multiple times with the same | |||
| * | |||
| * If you need to call this method multiple times with the same | |||
| * pattern you should rather use TokenizedPattern | |||
| * | |||
| * @see TokenizedPattern | |||
| * | |||
| * | |||
| * @param pattern The pattern to match against. Must not be | |||
| * <code>null</code>. | |||
| * @param str The path to match, as a String. Must not be | |||
| @@ -509,7 +509,7 @@ public final class SelectorUtils { | |||
| * | |||
| * @return a Vector of path elements from the tokenized path | |||
| */ | |||
| public static Vector tokenizePath (String path) { | |||
| public static Vector<String> tokenizePath(String path) { | |||
| return tokenizePath(path, File.separator); | |||
| } | |||
| @@ -522,8 +522,8 @@ public final class SelectorUtils { | |||
| * @return a Vector of path elements from the tokenized path | |||
| * @since Ant 1.6 | |||
| */ | |||
| public static Vector tokenizePath (String path, String separator) { | |||
| Vector ret = new Vector(); | |||
| public static Vector<String> tokenizePath(String path, String separator) { | |||
| Vector<String> ret = new Vector<String>(); | |||
| if (FileUtils.isAbsolutePath(path)) { | |||
| String[] s = FILE_UTILS.dissect(path); | |||
| ret.add(s[0]); | |||
| @@ -75,7 +75,7 @@ public class SizeSelector extends BaseExtendSelector { | |||
| * @return a string describing this object | |||
| */ | |||
| public String toString() { | |||
| StringBuffer buf = new StringBuffer("{sizeselector value: "); | |||
| StringBuilder buf = new StringBuilder("{sizeselector value: "); | |||
| buf.append(sizelimit); | |||
| buf.append("compare: ").append(when.getValue()); | |||
| buf.append("}"); | |||
| @@ -41,14 +41,14 @@ public class TokenizedPattern { | |||
| private final String tokenizedPattern[]; | |||
| /** | |||
| * Initialize the PathPattern by parsing it. | |||
| * Initialize the PathPattern by parsing it. | |||
| * @param pattern The pattern to match against. Must not be | |||
| * <code>null</code>. | |||
| */ | |||
| public TokenizedPattern(String pattern) { | |||
| this(pattern, SelectorUtils.tokenizePathAsArray(pattern)); | |||
| } | |||
| TokenizedPattern(String pattern, String[] tokens) { | |||
| this.pattern = pattern; | |||
| this.tokenizedPattern = tokens; | |||
| @@ -69,7 +69,7 @@ public class TokenizedPattern { | |||
| return SelectorUtils.matchPath(tokenizedPattern, path.getTokens(), | |||
| isCaseSensitive); | |||
| } | |||
| /** | |||
| * Tests whether or not this pattern matches the start of | |||
| * a path. | |||
| @@ -86,7 +86,7 @@ public class TokenizedPattern { | |||
| public String toString() { | |||
| return pattern; | |||
| } | |||
| public String getPattern() { | |||
| return pattern; | |||
| } | |||
| @@ -128,7 +128,7 @@ public class TokenizedPattern { | |||
| * @return the leftmost part of the pattern without wildcards | |||
| */ | |||
| public TokenizedPath rtrimWildcardTokens() { | |||
| StringBuffer sb = new StringBuffer(); | |||
| StringBuilder sb = new StringBuilder(); | |||
| int newLen = 0; | |||
| for (; newLen < tokenizedPattern.length; newLen++) { | |||
| if (SelectorUtils.hasWildcards(tokenizedPattern[newLen])) { | |||
| @@ -173,5 +173,5 @@ public class TokenizedPattern { | |||
| return new TokenizedPattern(pattern.substring(0, index), tokens); | |||
| } | |||
| } | |||
| } | |||
| @@ -46,7 +46,7 @@ public class TypeSelector extends BaseExtendSelector { | |||
| * @return a string describing this object | |||
| */ | |||
| public String toString() { | |||
| StringBuffer buf = new StringBuffer("{typeselector type: "); | |||
| StringBuilder buf = new StringBuilder("{typeselector type: "); | |||
| buf.append(type); | |||
| buf.append("}"); | |||
| return buf.toString(); | |||
| @@ -40,9 +40,6 @@ public class WritableSelector implements FileSelector, ResourceSelector { | |||
| public boolean isSelected(Resource r) { | |||
| FileProvider fp = r.as(FileProvider.class); | |||
| if (fp != null) { | |||
| return isSelected(null, null, fp.getFile()); | |||
| } | |||
| return false; | |||
| return fp != null && isSelected(null, null, fp.getFile()); | |||
| } | |||
| } | |||
| @@ -68,5 +68,5 @@ public interface Cache { | |||
| * Returns an iterator over the keys in the cache. | |||
| * @return An iterator over the keys. | |||
| */ | |||
| Iterator iterator(); | |||
| Iterator<String> iterator(); | |||
| } | |||
| @@ -141,7 +141,7 @@ public class ChecksumAlgorithm implements Algorithm { | |||
| * @return some information about this algorithm. | |||
| */ | |||
| public String toString() { | |||
| StringBuffer buf = new StringBuffer(); | |||
| StringBuilder buf = new StringBuilder(); | |||
| buf.append("<ChecksumAlgorithm:"); | |||
| buf.append("algorithm=").append(algorithm); | |||
| buf.append(">"); | |||
| @@ -197,7 +197,7 @@ public class DigestAlgorithm implements Algorithm { | |||
| * @return some information about this algorithm. | |||
| */ | |||
| public String toString() { | |||
| StringBuffer buf = new StringBuffer(); | |||
| StringBuilder buf = new StringBuilder(); | |||
| buf.append("<DigestAlgorithm:"); | |||
| buf.append("algorithm=").append(algorithm); | |||
| buf.append(";provider=").append(provider); | |||
| @@ -30,7 +30,7 @@ import java.util.Comparator; | |||
| * @version 2003-09-13 | |||
| * @since Ant 1.6 | |||
| */ | |||
| public class EqualComparator implements Comparator { | |||
| public class EqualComparator implements Comparator<Object> { | |||
| /** | |||
| * Implements Comparator.compare(). | |||
| @@ -191,7 +191,7 @@ public class ModifiedSelector extends BaseExtendSelector | |||
| /** How should the cached value and the new one compared? */ | |||
| private Comparator comparator = null; | |||
| private Comparator<? super String> comparator = null; | |||
| /** Algorithm for computing new values and updating the cache. */ | |||
| private Algorithm algorithm = null; | |||
| @@ -209,7 +209,7 @@ public class ModifiedSelector extends BaseExtendSelector | |||
| * Parameter vector with parameters for later initialization. | |||
| * @see #configure | |||
| */ | |||
| private Vector configParameter = new Vector(); | |||
| private Vector<Parameter> configParameter = new Vector<Parameter>(); | |||
| /** | |||
| * Parameter vector with special parameters for later initialization. | |||
| @@ -217,7 +217,7 @@ public class ModifiedSelector extends BaseExtendSelector | |||
| * These parameters are used <b>after</b> the parameters with the pattern '*'. | |||
| * @see #configure | |||
| */ | |||
| private Vector specialParameter = new Vector(); | |||
| private Vector<Parameter> specialParameter = new Vector<Parameter>(); | |||
| /** The classloader of this class. */ | |||
| private ClassLoader myClassLoader = null; | |||
| @@ -297,21 +297,20 @@ public class ModifiedSelector extends BaseExtendSelector | |||
| } | |||
| Cache defaultCache = new PropertiesfileCache(cachefile); | |||
| Algorithm defaultAlgorithm = new DigestAlgorithm(); | |||
| Comparator defaultComparator = new EqualComparator(); | |||
| Comparator<? super String> defaultComparator = new EqualComparator(); | |||
| // | |||
| // ----- Set the main attributes, pattern '*' ----- | |||
| // | |||
| for (Iterator itConfig = configParameter.iterator(); itConfig.hasNext();) { | |||
| Parameter par = (Parameter) itConfig.next(); | |||
| if (par.getName().indexOf(".") > 0) { | |||
| for (Parameter parameter : configParameter) { | |||
| if (parameter.getName().indexOf(".") > 0) { | |||
| // this is a *.* parameter for later use | |||
| specialParameter.add(par); | |||
| specialParameter.add(parameter); | |||
| } else { | |||
| useParameter(par); | |||
| useParameter(parameter); | |||
| } | |||
| } | |||
| configParameter = new Vector(); | |||
| configParameter = new Vector<Parameter>(); | |||
| // specify the algorithm classname | |||
| if (algoName != null) { | |||
| @@ -368,10 +367,9 @@ public class ModifiedSelector extends BaseExtendSelector | |||
| } else { | |||
| if (comparatorClass != null) { | |||
| // use Algorithm specified by classname | |||
| comparator = (Comparator) loadClass( | |||
| comparatorClass, | |||
| "is not a Comparator.", | |||
| Comparator.class); | |||
| @SuppressWarnings("unchecked") | |||
| Comparator<? super String> localComparator = loadClass(comparatorClass, "is not a Comparator.", Comparator.class); | |||
| comparator = localComparator; | |||
| } else { | |||
| // nothing specified - use default | |||
| comparator = defaultComparator; | |||
| @@ -381,11 +379,11 @@ public class ModifiedSelector extends BaseExtendSelector | |||
| // | |||
| // ----- Set the special attributes, pattern '*.*' ----- | |||
| // | |||
| for (Iterator itSpecial = specialParameter.iterator(); itSpecial.hasNext();) { | |||
| Parameter par = (Parameter) itSpecial.next(); | |||
| for (Iterator<Parameter> itSpecial = specialParameter.iterator(); itSpecial.hasNext();) { | |||
| Parameter par = itSpecial.next(); | |||
| useParameter(par); | |||
| } | |||
| specialParameter = new Vector(); | |||
| specialParameter = new Vector<Parameter>(); | |||
| } | |||
| @@ -398,18 +396,18 @@ public class ModifiedSelector extends BaseExtendSelector | |||
| * @param type the type to check against | |||
| * @return a castable object | |||
| */ | |||
| protected Object loadClass(String classname, String msg, Class type) { | |||
| protected <T> T loadClass(String classname, String msg, Class<? extends T> type) { | |||
| try { | |||
| // load the specified class | |||
| ClassLoader cl = getClassLoader(); | |||
| Class clazz = null; | |||
| Class<?> clazz = null; | |||
| if (cl != null) { | |||
| clazz = cl.loadClass(classname); | |||
| } else { | |||
| clazz = Class.forName(classname); | |||
| } | |||
| Object rv = clazz.newInstance(); | |||
| T rv = clazz.asSubclass(type).newInstance(); | |||
| if (!type.isInstance(rv)) { | |||
| throw new BuildException("Specified class (" + classname + ") " + msg); | |||
| @@ -944,7 +942,7 @@ public class ModifiedSelector extends BaseExtendSelector | |||
| * Get the comparator type to use. | |||
| * @return the enumerated comparator type | |||
| */ | |||
| public Comparator getComparator() { | |||
| public Comparator<? super String> getComparator() { | |||
| return comparator; | |||
| } | |||
| @@ -208,11 +208,11 @@ public class PropertiesfileCache implements Cache { | |||
| * Returns an iterator over the keys in the cache. | |||
| * @return An iterator over the keys. | |||
| */ | |||
| public Iterator iterator() { | |||
| Vector v = new java.util.Vector(); | |||
| Enumeration en = cache.propertyNames(); | |||
| public Iterator<String> iterator() { | |||
| Vector<String> v = new Vector<String>(); | |||
| Enumeration<?> en = cache.propertyNames(); | |||
| while (en.hasMoreElements()) { | |||
| v.add(en.nextElement()); | |||
| v.add(en.nextElement().toString()); | |||
| } | |||
| return v.iterator(); | |||
| } | |||
| @@ -40,15 +40,15 @@ public abstract class AbstractAnalyzer implements DependencyAnalyzer { | |||
| private Path classPath = new Path(null); | |||
| /** The list of root classes */ | |||
| private final Vector rootClasses = new VectorSet(); | |||
| private final Vector<String> rootClasses = new VectorSet<String>(); | |||
| /** true if dependencies have been determined */ | |||
| private boolean determined = false; | |||
| /** the list of File objects that the root classes depend upon */ | |||
| private Vector fileDependencies; | |||
| private Vector<File> fileDependencies; | |||
| /** the list of java classes the root classes depend upon */ | |||
| private Vector classDependencies; | |||
| private Vector<String> classDependencies; | |||
| /** true if indirect dependencies should be gathered */ | |||
| private boolean closure = true; | |||
| @@ -77,7 +77,7 @@ public abstract class AbstractAnalyzer implements DependencyAnalyzer { | |||
| * | |||
| * @return an enumeration of File instances. | |||
| */ | |||
| public Enumeration getFileDependencies() { | |||
| public Enumeration<File> getFileDependencies() { | |||
| if (!supportsFileDependencies()) { | |||
| throw new RuntimeException("File dependencies are not supported " | |||
| + "by this analyzer"); | |||
| @@ -95,7 +95,7 @@ public abstract class AbstractAnalyzer implements DependencyAnalyzer { | |||
| * @return an enumeration of Strings, each being the name of a Java | |||
| * class in dot notation. | |||
| */ | |||
| public Enumeration getClassDependencies() { | |||
| public Enumeration<String> getClassDependencies() { | |||
| if (!determined) { | |||
| determineDependencies(fileDependencies, classDependencies); | |||
| } | |||
| @@ -201,8 +201,8 @@ public abstract class AbstractAnalyzer implements DependencyAnalyzer { | |||
| public void reset() { | |||
| rootClasses.removeAllElements(); | |||
| determined = false; | |||
| fileDependencies = new Vector(); | |||
| classDependencies = new Vector(); | |||
| fileDependencies = new Vector<File>(); | |||
| classDependencies = new Vector<String>(); | |||
| } | |||
| /** | |||
| @@ -211,7 +211,7 @@ public abstract class AbstractAnalyzer implements DependencyAnalyzer { | |||
| * @return an enumeration of Strings, each of which is a class name | |||
| * for a root class. | |||
| */ | |||
| protected Enumeration getRootClasses() { | |||
| protected Enumeration<String> getRootClasses() { | |||
| return rootClasses.elements(); | |||
| } | |||
| @@ -233,7 +233,7 @@ public abstract class AbstractAnalyzer implements DependencyAnalyzer { | |||
| * @param classes a vector of Strings into which the names of classes | |||
| * upon which the root classes depend should be placed. | |||
| */ | |||
| protected abstract void determineDependencies(Vector files, Vector classes); | |||
| protected abstract void determineDependencies(Vector<File> files, Vector<String> classes); | |||
| /** | |||
| * Indicate if the particular subclass supports file dependency | |||
| @@ -68,7 +68,7 @@ public interface DependencyAnalyzer { | |||
| * | |||
| * @return an enumeration of File instances. | |||
| */ | |||
| Enumeration getFileDependencies(); | |||
| Enumeration<File> getFileDependencies(); | |||
| /** | |||
| * Get the list of classes upon which root classes depend. This is a | |||
| @@ -77,7 +77,7 @@ public interface DependencyAnalyzer { | |||
| * @return an enumeration of Strings, each being the name of a Java | |||
| * class in dot notation. | |||
| */ | |||
| Enumeration getClassDependencies(); | |||
| Enumeration<String> getClassDependencies(); | |||
| /** | |||
| @@ -61,15 +61,16 @@ public class AncestorAnalyzer extends AbstractAnalyzer { | |||
| * @param classes a vector to be populated with the names of the | |||
| * dependency classes. | |||
| */ | |||
| protected void determineDependencies(Vector files, Vector classes) { | |||
| protected void determineDependencies(Vector<File> files, Vector<String> classes) { | |||
| // we get the root classes and build up a set of | |||
| // classes upon which they depend | |||
| Hashtable dependencies = new Hashtable(); | |||
| Hashtable containers = new Hashtable(); | |||
| Hashtable toAnalyze = new Hashtable(); | |||
| Hashtable nextAnalyze = new Hashtable(); | |||
| for (Enumeration e = getRootClasses(); e.hasMoreElements();) { | |||
| String classname = (String) e.nextElement(); | |||
| Hashtable<String, String> dependencies = new Hashtable<String, String>(); | |||
| Hashtable<File, File> containers = new Hashtable<File, File>(); | |||
| Hashtable<String, String> toAnalyze = new Hashtable<String, String>(); | |||
| Hashtable<String, String> nextAnalyze = new Hashtable<String, String>(); | |||
| for (Enumeration<String> e = getRootClasses(); e.hasMoreElements();) { | |||
| String classname = e.nextElement(); | |||
| toAnalyze.put(classname, classname); | |||
| } | |||
| @@ -77,8 +78,7 @@ public class AncestorAnalyzer extends AbstractAnalyzer { | |||
| int maxCount = isClosureRequired() ? MAX_LOOPS : 2; | |||
| while (toAnalyze.size() != 0 && count++ < maxCount) { | |||
| nextAnalyze.clear(); | |||
| for (Enumeration e = toAnalyze.keys(); e.hasMoreElements();) { | |||
| String classname = (String) e.nextElement(); | |||
| for (String classname : toAnalyze.keySet()) { | |||
| dependencies.put(classname, classname); | |||
| try { | |||
| File container = getClassContainer(classname); | |||
| @@ -115,19 +115,19 @@ public class AncestorAnalyzer extends AbstractAnalyzer { | |||
| } | |||
| } | |||
| Hashtable temp = toAnalyze; | |||
| Hashtable<String, String> temp = toAnalyze; | |||
| toAnalyze = nextAnalyze; | |||
| nextAnalyze = temp; | |||
| } | |||
| files.removeAllElements(); | |||
| for (Enumeration e = containers.keys(); e.hasMoreElements();) { | |||
| files.addElement((File) e.nextElement()); | |||
| for (File f : containers.keySet()) { | |||
| files.add(f); | |||
| } | |||
| classes.removeAllElements(); | |||
| for (Enumeration e = dependencies.keys(); e.hasMoreElements();) { | |||
| classes.addElement((String) e.nextElement()); | |||
| for (String dependency : dependencies.keySet()) { | |||
| classes.add(dependency); | |||
| } | |||
| } | |||
| @@ -33,8 +33,8 @@ import org.apache.bcel.classfile.ConstantNameAndType; | |||
| * | |||
| */ | |||
| public class DependencyVisitor extends EmptyVisitor { | |||
| /** The collectd dependencies */ | |||
| private Hashtable dependencies = new Hashtable(); | |||
| /** The collected dependencies */ | |||
| private Hashtable<String, String> dependencies = new Hashtable<String, String>(); | |||
| /** | |||
| * The current class's constant pool - used to determine class names | |||
| * from class references. | |||
| @@ -47,7 +47,7 @@ public class DependencyVisitor extends EmptyVisitor { | |||
| * @return a Enumeration of classnames, being the classes upon which the | |||
| * visited classes depend. | |||
| */ | |||
| public Enumeration getDependencies() { | |||
| public Enumeration<String> getDependencies() { | |||
| return dependencies.keys(); | |||
| } | |||
| @@ -60,14 +60,14 @@ public class FullAnalyzer extends AbstractAnalyzer { | |||
| * @param classes a vector to be populated with the names of the | |||
| * dependency classes. | |||
| */ | |||
| protected void determineDependencies(Vector files, Vector classes) { | |||
| protected void determineDependencies(Vector<File> files, Vector<String> classes) { | |||
| // we get the root classes and build up a set of | |||
| // classes upon which they depend | |||
| Hashtable dependencies = new Hashtable(); | |||
| Hashtable containers = new Hashtable(); | |||
| Hashtable toAnalyze = new Hashtable(); | |||
| for (Enumeration e = getRootClasses(); e.hasMoreElements();) { | |||
| String classname = (String) e.nextElement(); | |||
| Hashtable<String, String> dependencies = new Hashtable<String, String>(); | |||
| Hashtable<File, File> containers = new Hashtable<File, File>(); | |||
| Hashtable<String, String> toAnalyze = new Hashtable<String, String>(); | |||
| for (Enumeration<String> e = getRootClasses(); e.hasMoreElements();) { | |||
| String classname = e.nextElement(); | |||
| toAnalyze.put(classname, classname); | |||
| } | |||
| @@ -75,8 +75,7 @@ public class FullAnalyzer extends AbstractAnalyzer { | |||
| int maxCount = isClosureRequired() ? MAX_LOOPS : 2; | |||
| while (toAnalyze.size() != 0 && count++ < maxCount) { | |||
| DependencyVisitor dependencyVisitor = new DependencyVisitor(); | |||
| for (Enumeration e = toAnalyze.keys(); e.hasMoreElements();) { | |||
| String classname = (String) e.nextElement(); | |||
| for (String classname : toAnalyze.keySet()) { | |||
| dependencies.put(classname, classname); | |||
| try { | |||
| File container = getClassContainer(classname); | |||
| @@ -105,9 +104,9 @@ public class FullAnalyzer extends AbstractAnalyzer { | |||
| toAnalyze.clear(); | |||
| // now recover all the dependencies collected and add to the list. | |||
| Enumeration depsEnum = dependencyVisitor.getDependencies(); | |||
| Enumeration<String> depsEnum = dependencyVisitor.getDependencies(); | |||
| while (depsEnum.hasMoreElements()) { | |||
| String className = (String) depsEnum.nextElement(); | |||
| String className = depsEnum.nextElement(); | |||
| if (!dependencies.containsKey(className)) { | |||
| toAnalyze.put(className, className); | |||
| } | |||
| @@ -115,13 +114,13 @@ public class FullAnalyzer extends AbstractAnalyzer { | |||
| } | |||
| files.removeAllElements(); | |||
| for (Enumeration e = containers.keys(); e.hasMoreElements();) { | |||
| files.addElement((File) e.nextElement()); | |||
| for (File f : containers.keySet()) { | |||
| files.add(f); | |||
| } | |||
| classes.removeAllElements(); | |||
| for (Enumeration e = dependencies.keys(); e.hasMoreElements();) { | |||
| classes.addElement((String) e.nextElement()); | |||
| for (String dependency : dependencies.keySet()) { | |||
| classes.add(dependency); | |||
| } | |||
| } | |||