git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1375571 13f79535-47bb-0310-9956-ffa450edef68master
@@ -843,17 +843,19 @@ public class Main implements AntMain { | |||
project.init(); | |||
// resolve properties | |||
PropertyHelper propertyHelper = (PropertyHelper) PropertyHelper | |||
.getPropertyHelper(project); | |||
HashMap<Object, Object> props = new HashMap<Object, Object>(definedProps); | |||
PropertyHelper propertyHelper = PropertyHelper.getPropertyHelper(project); | |||
@SuppressWarnings({ "rawtypes", "unchecked" }) | |||
Map raw = new HashMap(definedProps); | |||
@SuppressWarnings("unchecked") | |||
Map<String, Object> props = raw; | |||
ResolvePropertyMap resolver = new ResolvePropertyMap(project, | |||
NOPROPERTIES, propertyHelper.getExpanders()); | |||
resolver.resolveAllProperties(props, null, false); | |||
// set user-define properties | |||
for (Entry<Object, Object> ent : props.entrySet()) { | |||
String arg = (String) ent.getKey(); | |||
for (Entry<String, Object> ent : props.entrySet()) { | |||
String arg = ent.getKey(); | |||
Object value = ent.getValue(); | |||
project.setUserProperty(arg, String.valueOf(value)); | |||
} | |||
@@ -2022,7 +2022,7 @@ public class Project implements ResourceFactory { | |||
* Must not be <code>null</code>. | |||
* | |||
* @return the reference with the specified ID, or <code>null</code> if | |||
* there is no such reference in the project. | |||
* there is no such reference in the project, with type inference. | |||
*/ | |||
public <T> T getReference(String key) { | |||
@SuppressWarnings("unchecked") | |||
@@ -58,7 +58,7 @@ public class DispatchUtils { | |||
if (name.length() > 1) { | |||
mName += name.substring(1); | |||
} | |||
final Class c = dispatchable.getClass(); | |||
final Class<? extends Dispatchable> c = dispatchable.getClass(); | |||
final Method actionM = c.getMethod(mName, new Class[0]); | |||
if (actionM != null) { | |||
final Object o = actionM.invoke(dispatchable, (Object[]) null); | |||
@@ -106,10 +106,10 @@ public final class ClassConstants | |||
} else { | |||
final byte[] bytes = clazz.getBytes(ResourceUtils.ISO_8859_1); | |||
try { | |||
final Class javaClassHelper = | |||
final Class<?> javaClassHelper = | |||
Class.forName(JAVA_CLASS_HELPER); | |||
if (javaClassHelper != null) { | |||
final Class[] params = { | |||
final Class<?>[] params = { | |||
byte[].class | |||
}; | |||
final Method getConstants = | |||
@@ -435,10 +435,6 @@ public final class FixCrLfFilter extends BaseParamFilterReader implements Chaina | |||
push(cs, 0, cs.length); | |||
} | |||
public void push(String s) { | |||
push(s.toCharArray()); | |||
} | |||
/** | |||
* Does this filter want to block edits on the last character returned | |||
* by read()? | |||
@@ -55,7 +55,7 @@ public final class LineContains | |||
private static final String NEGATE_KEY = "negate"; | |||
/** Vector that holds the strings that input lines must contain. */ | |||
private Vector contains = new Vector(); | |||
private Vector<String> contains = new Vector<String>(); | |||
/** | |||
* Remaining line to be read from this filter, or <code>null</code> if | |||
@@ -163,7 +163,7 @@ public final class LineContains | |||
* @param contains A vector of words which must be contained within a line | |||
* in order for it to match in this filter. Must not be <code>null</code>. | |||
*/ | |||
private void setContains(final Vector contains) { | |||
private void setContains(final Vector<String> contains) { | |||
this.contains = contains; | |||
} | |||
@@ -176,7 +176,7 @@ public final class LineContains | |||
* returned object is "live" - in other words, changes made to the | |||
* returned object are mirrored in the filter. | |||
*/ | |||
private Vector getContains() { | |||
private Vector<String> getContains() { | |||
return contains; | |||
} | |||
@@ -57,7 +57,7 @@ public final class LineContainsRegExp | |||
private static final String CS_KEY = "casesensitive"; | |||
/** Vector that holds the expressions that input lines must contain. */ | |||
private Vector regexps = new Vector(); | |||
private Vector<RegularExpression> regexps = new Vector<RegularExpression>(); | |||
/** | |||
* Remaining line to be read from this filter, or <code>null</code> if | |||
@@ -155,7 +155,7 @@ public final class LineContainsRegExp | |||
* within a line in order for it to match in this filter. Must not be | |||
* <code>null</code>. | |||
*/ | |||
private void setRegexps(final Vector regexps) { | |||
private void setRegexps(final Vector<RegularExpression> regexps) { | |||
this.regexps = regexps; | |||
} | |||
@@ -169,7 +169,7 @@ public final class LineContainsRegExp | |||
* filter. The returned object is "live" - in other words, changes made to | |||
* the returned object are mirrored in the filter. | |||
*/ | |||
private Vector getRegexps() { | |||
private Vector<RegularExpression> getRegexps() { | |||
return regexps; | |||
} | |||
@@ -70,7 +70,7 @@ public final class ReplaceTokens | |||
private int queueIndex = -1; | |||
/** Hashtable to hold the replacee-replacer pairs (String to String). */ | |||
private Hashtable hash = new Hashtable(); | |||
private Hashtable<String, String> hash = new Hashtable<String, String>(); | |||
/** Character marking the beginning of a token. */ | |||
private char beginToken = DEFAULT_BEGIN_TOKEN; | |||
@@ -266,7 +266,7 @@ public final class ReplaceTokens | |||
* @param hash A map (String->String) of token keys to replacement | |||
* values. Must not be <code>null</code>. | |||
*/ | |||
private void setTokens(final Hashtable hash) { | |||
private void setTokens(final Hashtable<String, String> hash) { | |||
this.hash = hash; | |||
} | |||
@@ -276,7 +276,7 @@ public final class ReplaceTokens | |||
* @return a map (String->String) of token keys to replacement | |||
* values | |||
*/ | |||
private Hashtable getTokens() { | |||
private Hashtable<String, String> getTokens() { | |||
return hash; | |||
} | |||
@@ -339,7 +339,7 @@ public final class ReplaceTokens | |||
private void makeTokensFromProperties(Resource r) { | |||
Properties props = getProperties(r); | |||
for (Enumeration e = props.keys(); e.hasMoreElements();) { | |||
for (Enumeration<?> e = props.keys(); e.hasMoreElements();) { | |||
String key = (String) e.nextElement(); | |||
String value = props.getProperty(key); | |||
hash.put(key, value); | |||
@@ -32,11 +32,11 @@ import org.apache.tools.ant.types.Parameter; | |||
* <p> | |||
* Sort a file before and/or after the file. | |||
* </p> | |||
* | |||
* | |||
* <p> | |||
* Examples: | |||
* </p> | |||
* | |||
* | |||
* <pre> | |||
* <copy todir="build"> | |||
* <fileset dir="input" includes="*.txt"/> | |||
@@ -45,14 +45,14 @@ import org.apache.tools.ant.types.Parameter; | |||
* </filterchain> | |||
* </copy> | |||
* </pre> | |||
* | |||
* | |||
* <p> | |||
* Sort all files <code>*.txt</code> from <i>src</i> location and copy | |||
* them into <i>build</i> location. The lines of each file are sorted | |||
* in ascendant order comparing the lines via the | |||
* <code>String.compareTo(Object o)</code> method. | |||
* </p> | |||
* | |||
* | |||
* <pre> | |||
* <copy todir="build"> | |||
* <fileset dir="input" includes="*.txt"/> | |||
@@ -61,14 +61,14 @@ import org.apache.tools.ant.types.Parameter; | |||
* </filterchain> | |||
* </copy> | |||
* </pre> | |||
* | |||
* | |||
* <p> | |||
* Sort all files <code>*.txt</code> from <i>src</i> location into reverse | |||
* order and copy them into <i>build</i> location. If reverse parameter has | |||
* value <code>true</code> (default value), then the output line of the files | |||
* will be in ascendant order. | |||
* </p> | |||
* | |||
* | |||
* <pre> | |||
* <copy todir="build"> | |||
* <fileset dir="input" includes="*.txt"/> | |||
@@ -79,7 +79,7 @@ import org.apache.tools.ant.types.Parameter; | |||
* </filterchain> | |||
* </copy> | |||
* </pre> | |||
* | |||
* | |||
* <p> | |||
* Sort all files <code>*.txt</code> from <i>src</i> location using as | |||
* sorting criterium <code>EvenFirstCmp</code> class, that sorts the file | |||
@@ -89,7 +89,7 @@ import org.apache.tools.ant.types.Parameter; | |||
* therefore in case of inner class has to be <em>static</em>. It also has to | |||
* implement <code>java.util.Comparator</code> interface, for example: | |||
* </p> | |||
* | |||
* | |||
* <pre> | |||
* package org.apache.tools.ant.filters; | |||
* ...(omitted) | |||
@@ -99,9 +99,9 @@ import org.apache.tools.ant.types.Parameter; | |||
* } | |||
* } | |||
* </pre> | |||
* | |||
* | |||
* <p>The example above is equivalent to:</p> | |||
* | |||
* | |||
* <blockquote><pre> | |||
* <componentdef name="evenfirst" | |||
* classname="org.apache.tools.ant.filters.EvenFirstCmp"/> | |||
@@ -114,10 +114,10 @@ import org.apache.tools.ant.types.Parameter; | |||
* </filterchain> | |||
* </copy> | |||
* </pre></blockquote> | |||
* | |||
* | |||
* <p> If parameter <code>comparator</code> is present, then | |||
* <code>reverse</code> parameter will not be taken into account. </p> | |||
* | |||
* | |||
* @since Ant 1.8.0 | |||
*/ | |||
public final class SortFilter extends BaseParamFilterReader | |||
@@ -135,7 +135,7 @@ public final class SortFilter extends BaseParamFilterReader | |||
/** | |||
* Instance of comparator class to be used for sorting. | |||
*/ | |||
private Comparator comparator = null; | |||
private Comparator<? super String> comparator = null; | |||
/** | |||
* Controls if the sorting process will be in ascendant/descendant order. If | |||
@@ -148,7 +148,7 @@ public final class SortFilter extends BaseParamFilterReader | |||
/** | |||
* Stores the lines to be sorted. | |||
*/ | |||
private List lines; | |||
private List<String> lines; | |||
/** | |||
* Remaining line to be read from this filter, or <code>null</code> if the | |||
@@ -157,11 +157,11 @@ public final class SortFilter extends BaseParamFilterReader | |||
*/ | |||
private String line = null; | |||
private Iterator iterator = null; | |||
private Iterator<String> iterator = null; | |||
/** | |||
* Constructor for "dummy" instances. | |||
* | |||
* | |||
* @see BaseFilterReader#BaseFilterReader() | |||
*/ | |||
public SortFilter() { | |||
@@ -170,7 +170,7 @@ public final class SortFilter extends BaseParamFilterReader | |||
/** | |||
* Creates a new filtered reader. | |||
* | |||
* | |||
* @param in | |||
* A Reader object providing the underlying stream. Must not be | |||
* <code>null</code>. | |||
@@ -184,10 +184,10 @@ public final class SortFilter extends BaseParamFilterReader | |||
* of lines have already been read, the resulting stream is effectively at | |||
* an end. Otherwise, the next character from the underlying stream is read | |||
* and returned. | |||
* | |||
* | |||
* @return the next character in the resulting stream, or -1 if the end of | |||
* the resulting stream has been reached | |||
* | |||
* | |||
* @exception IOException | |||
* if the underlying stream throws an IOException during | |||
* reading | |||
@@ -213,7 +213,7 @@ public final class SortFilter extends BaseParamFilterReader | |||
} else { | |||
if (lines == null) { | |||
// We read all lines and sort them | |||
lines = new ArrayList(); | |||
lines = new ArrayList<String>(); | |||
for (line = readLine(); line != null; line = readLine()) { | |||
lines.add(line); | |||
} | |||
@@ -237,11 +237,11 @@ public final class SortFilter extends BaseParamFilterReader | |||
/** | |||
* Creates a new SortReader using the passed in Reader for instantiation. | |||
* | |||
* | |||
* @param rdr | |||
* A Reader object providing the underlying stream. Must not be | |||
* <code>null</code>. | |||
* | |||
* | |||
* @return a new filter based on this configuration, but filtering the | |||
* specified reader | |||
*/ | |||
@@ -256,7 +256,7 @@ public final class SortFilter extends BaseParamFilterReader | |||
/** | |||
* Returns <code>true</code> if the sorting process will be in reverse | |||
* order, otherwise the sorting process will be in ascendant order. | |||
* | |||
* | |||
* @return <code>true</code> if the sorting process will be in reverse | |||
* order, otherwise the sorting process will be in ascendant order. | |||
*/ | |||
@@ -267,7 +267,7 @@ public final class SortFilter extends BaseParamFilterReader | |||
/** | |||
* Sets the sorting process will be in ascendant (<code>reverse=false</code>) | |||
* or to descendant (<code>reverse=true</code>). | |||
* | |||
* | |||
* @param reverse | |||
* Boolean representing reverse ordering process. | |||
*/ | |||
@@ -277,30 +277,30 @@ public final class SortFilter extends BaseParamFilterReader | |||
/** | |||
* Returns the comparator to be used for sorting. | |||
* | |||
* | |||
* @return the comparator | |||
*/ | |||
public Comparator getComparator() { | |||
public Comparator<? super String> getComparator() { | |||
return comparator; | |||
} | |||
/** | |||
* Set the comparator to be used as sorting criterium. | |||
* | |||
* | |||
* @param comparator | |||
* the comparator to set | |||
*/ | |||
public void setComparator(Comparator comparator) { | |||
public void setComparator(Comparator<? super String> comparator) { | |||
this.comparator = comparator; | |||
} | |||
/** | |||
* Set the comparator to be used as sorting criterium as nested element. | |||
* | |||
* Set the comparator to be used as sorting criterion as nested element. | |||
* | |||
* @param comparator | |||
* the comparator to set | |||
*/ | |||
public void add(Comparator comparator) { | |||
public void add(Comparator<? super String> comparator) { | |||
if (this.comparator != null && comparator != null) { | |||
throw new BuildException("can't have more than one comparator"); | |||
} | |||
@@ -324,8 +324,10 @@ public final class SortFilter extends BaseParamFilterReader | |||
if (COMPARATOR_KEY.equals(paramName)) { | |||
try { | |||
String className = (String) params[i].getValue(); | |||
setComparator((Comparator) (Class.forName(className) | |||
.newInstance())); | |||
@SuppressWarnings("unchecked") | |||
final Comparator<? super String> comparatorInstance = (Comparator<? super String>) (Class | |||
.forName(className).newInstance()); | |||
setComparator(comparatorInstance); | |||
continue; | |||
} catch (InstantiationException e) { | |||
throw new BuildException(e); | |||
@@ -353,15 +355,13 @@ public final class SortFilter extends BaseParamFilterReader | |||
/** | |||
* Sorts the read lines (<code>lines</code>)acording to the sorting | |||
* criteria defined by the user. | |||
* | |||
* | |||
*/ | |||
private void sort() { | |||
if (comparator == null) { | |||
if (reverse) { | |||
Collections.sort(lines, new Comparator() { | |||
public int compare(Object o1, Object o2) { | |||
String s1 = (String) o1; | |||
String s2 = (String) o2; | |||
Collections.sort(lines, new Comparator<String>() { | |||
public int compare(String s1, String s2) { | |||
return (-s1.compareTo(s2)); | |||
} | |||
}); | |||
@@ -54,7 +54,7 @@ public final class StripLineComments | |||
private static final String COMMENTS_KEY = "comment"; | |||
/** Vector that holds the comment prefixes. */ | |||
private Vector comments = new Vector(); | |||
private Vector<String> comments = new Vector<String>(); | |||
/** The line that has been read ahead. */ | |||
private String line = null; | |||
@@ -110,7 +110,7 @@ public final class StripLineComments | |||
while (line != null) { | |||
for (int i = 0; i < commentsSize; i++) { | |||
String comment = (String) comments.elementAt(i); | |||
String comment = comments.elementAt(i); | |||
if (line.startsWith(comment)) { | |||
line = null; | |||
break; | |||
@@ -149,7 +149,7 @@ public final class StripLineComments | |||
* @param comments A list of strings, each of which is a prefix | |||
* for a comment line. Must not be <code>null</code>. | |||
*/ | |||
private void setComments(final Vector comments) { | |||
private void setComments(final Vector<String> comments) { | |||
this.comments = comments; | |||
} | |||
@@ -158,7 +158,7 @@ public final class StripLineComments | |||
* | |||
* @return the list of comment prefixes to strip. | |||
*/ | |||
private Vector getComments() { | |||
private Vector<String> getComments() { | |||
return comments; | |||
} | |||
@@ -65,7 +65,7 @@ public final class TailFilter extends BaseParamFilterReader | |||
/** the position in the current line */ | |||
private int linePos = 0; | |||
private LinkedList lineList = new LinkedList(); | |||
private LinkedList<String> lineList = new LinkedList<String>(); | |||
/** | |||
* Constructor for "dummy" instances. | |||
@@ -212,7 +212,7 @@ public final class TailFilter extends BaseParamFilterReader | |||
lineList.add(line); | |||
if (lines == -1) { | |||
if (lineList.size() > skip) { | |||
return (String) lineList.removeFirst(); | |||
return lineList.removeFirst(); | |||
} | |||
} else { | |||
long linesToKeep = lines + (skip > 0 ? skip : 0); | |||
@@ -235,7 +235,7 @@ public final class TailFilter extends BaseParamFilterReader | |||
} | |||
} | |||
if (lineList.size() > 0) { | |||
return (String) lineList.removeFirst(); | |||
return lineList.removeFirst(); | |||
} | |||
return null; | |||
} | |||
@@ -58,7 +58,7 @@ public class TokenFilter extends BaseFilterReader | |||
/** string filters */ | |||
private Vector filters = new Vector(); | |||
private Vector<Filter> filters = new Vector<Filter>(); | |||
/** the tokenizer to use on the input stream */ | |||
private Tokenizer tokenizer = null; | |||
/** the output token termination */ | |||
@@ -109,8 +109,8 @@ public class TokenFilter extends BaseFilterReader | |||
if (line == null) { | |||
return -1; | |||
} | |||
for (Enumeration e = filters.elements(); e.hasMoreElements();) { | |||
Filter filter = (Filter) e.nextElement(); | |||
for (Enumeration<Filter> e = filters.elements(); e.hasMoreElements();) { | |||
Filter filter = e.nextElement(); | |||
line = filter.filter(line); | |||
if (line == null) { | |||
break; | |||
@@ -60,7 +60,7 @@ public final class ChainReaderHelper { | |||
/** | |||
* Chain of filters | |||
*/ | |||
public Vector filterChains = new Vector(); | |||
public Vector<FilterChain> filterChains = new Vector<FilterChain>(); | |||
/** The Ant project */ | |||
private Project project = null; | |||
@@ -106,7 +106,7 @@ public final class ChainReaderHelper { | |||
* | |||
* @param fchain the filter chains collection | |||
*/ | |||
public void setFilterChains(Vector fchain) { | |||
public void setFilterChains(Vector<FilterChain> fchain) { | |||
filterChains = fchain; | |||
} | |||
@@ -122,14 +122,14 @@ public final class ChainReaderHelper { | |||
Reader instream = primaryReader; | |||
final int filterReadersCount = filterChains.size(); | |||
final Vector finalFilters = new Vector(); | |||
final ArrayList/*<AntClassLoader>*/ classLoadersToCleanUp = | |||
new ArrayList/*<AntClassLoader>*/(); | |||
final Vector<Object> finalFilters = new Vector<Object>(); | |||
final ArrayList<AntClassLoader> classLoadersToCleanUp = | |||
new ArrayList<AntClassLoader>(); | |||
for (int i = 0; i < filterReadersCount; i++) { | |||
final FilterChain filterchain = | |||
(FilterChain) filterChains.elementAt(i); | |||
final Vector filterReaders = filterchain.getFilterReaders(); | |||
filterChains.elementAt(i); | |||
final Vector<Object> filterReaders = filterchain.getFilterReaders(); | |||
final int readerCount = filterReaders.size(); | |||
for (int j = 0; j < readerCount; j++) { | |||
finalFilters.addElement(filterReaders.elementAt(j)); | |||
@@ -197,9 +197,9 @@ public final class ChainReaderHelper { | |||
/** | |||
* Deregisters Classloaders from the project so GC can remove them later. | |||
*/ | |||
private static void cleanUpClassLoaders(List/*<AntClassLoader>*/ loaders) { | |||
for (Iterator it = loaders.iterator(); it.hasNext(); ) { | |||
((AntClassLoader) it.next()).cleanup(); | |||
private static void cleanUpClassLoaders(List<AntClassLoader> loaders) { | |||
for (Iterator<AntClassLoader> it = loaders.iterator(); it.hasNext(); ) { | |||
it.next().cleanup(); | |||
} | |||
} | |||
@@ -223,13 +223,13 @@ public final class ChainReaderHelper { | |||
*/ | |||
private Reader expandReader(final AntFilterReader filter, | |||
final Reader ancestor, | |||
final List/*<AntClassLoader>*/ classLoadersToCleanUp) { | |||
final List<AntClassLoader> classLoadersToCleanUp) { | |||
final String className = filter.getClassName(); | |||
final Path classpath = filter.getClasspath(); | |||
final Project pro = filter.getProject(); | |||
if (className != null) { | |||
try { | |||
Class clazz = null; | |||
Class<?> clazz = null; | |||
if (classpath == null) { | |||
clazz = Class.forName(className); | |||
} else { | |||
@@ -242,11 +242,11 @@ public final class ChainReaderHelper { | |||
throw new BuildException(className + " does not extend" | |||
+ " java.io.FilterReader"); | |||
} | |||
final Constructor[] constructors = clazz.getConstructors(); | |||
final Constructor<?>[] constructors = clazz.getConstructors(); | |||
int j = 0; | |||
boolean consPresent = false; | |||
for (; j < constructors.length; j++) { | |||
Class[] types = constructors[j].getParameterTypes(); | |||
Class<?>[] types = constructors[j].getParameterTypes(); | |||
if (types.length == 1 | |||
&& types[0].isAssignableFrom(Reader.class)) { | |||
consPresent = true; | |||
@@ -54,7 +54,7 @@ public class AntXMLContext { | |||
* defined. Project maintains a Hashtable, which is not ordered. | |||
* This will allow description to know the original order. | |||
*/ | |||
private Vector targetVector = new Vector(); | |||
private Vector<Target> targetVector = new Vector<Target>(); | |||
/** | |||
* Parent directory of the build file. Used for resolving entities | |||
@@ -92,7 +92,7 @@ public class AntXMLContext { | |||
/** The stack of RuntimeConfigurable2 wrapping the | |||
objects. | |||
*/ | |||
private Vector wStack = new Vector(); | |||
private Vector<RuntimeConfigurable> wStack = new Vector<RuntimeConfigurable>(); | |||
/** | |||
* Indicates whether the project tag attributes are to be ignored | |||
@@ -101,11 +101,11 @@ public class AntXMLContext { | |||
private boolean ignoreProjectTag = false; | |||
/** Keeps track of prefix -> uri mapping during parsing */ | |||
private Map prefixMapping = new HashMap(); | |||
private Map<String, List<String>> prefixMapping = new HashMap<String, List<String>>(); | |||
/** Keeps track of targets in files */ | |||
private Map currentTargets = null; | |||
private Map<String, Target> currentTargets = null; | |||
/** | |||
* constructor | |||
@@ -253,7 +253,7 @@ public class AntXMLContext { | |||
* access the stack of wrappers | |||
* @return the stack of wrappers | |||
*/ | |||
public Vector getWrapperStack() { | |||
public Vector<RuntimeConfigurable> getWrapperStack() { | |||
return wStack; | |||
} | |||
@@ -302,7 +302,7 @@ public class AntXMLContext { | |||
* access the vector of targets | |||
* @return vector of targets | |||
*/ | |||
public Vector getTargets() { | |||
public Vector<Target> getTargets() { | |||
return targetVector; | |||
} | |||
@@ -362,9 +362,9 @@ public class AntXMLContext { | |||
* @param uri a namespace uri | |||
*/ | |||
public void startPrefixMapping(String prefix, String uri) { | |||
List list = (List) prefixMapping.get(prefix); | |||
List<String> list = prefixMapping.get(prefix); | |||
if (list == null) { | |||
list = new ArrayList(); | |||
list = new ArrayList<String>(); | |||
prefixMapping.put(prefix, list); | |||
} | |||
list.add(uri); | |||
@@ -376,7 +376,7 @@ public class AntXMLContext { | |||
* @param prefix the namespace prefix | |||
*/ | |||
public void endPrefixMapping(String prefix) { | |||
List list = (List) prefixMapping.get(prefix); | |||
List<String> list = prefixMapping.get(prefix); | |||
if (list == null || list.size() == 0) { | |||
return; // Should not happen | |||
} | |||
@@ -390,7 +390,7 @@ public class AntXMLContext { | |||
* @return the uri for this prefix, null if not present | |||
*/ | |||
public String getPrefixMapping(String prefix) { | |||
List list = (List) prefixMapping.get(prefix); | |||
List<String> list = prefixMapping.get(prefix); | |||
if (list == null || list.size() == 0) { | |||
return null; | |||
} | |||
@@ -401,7 +401,7 @@ public class AntXMLContext { | |||
* Get the targets in the current source file. | |||
* @return the current targets. | |||
*/ | |||
public Map getCurrentTargets() { | |||
public Map<String, Target> getCurrentTargets() { | |||
return currentTargets; | |||
} | |||
@@ -409,7 +409,7 @@ public class AntXMLContext { | |||
* Set the map of the targets in the current source file. | |||
* @param currentTargets a map of targets. | |||
*/ | |||
public void setCurrentTargets(Map currentTargets) { | |||
public void setCurrentTargets(Map<String, Target> currentTargets) { | |||
this.currentTargets = currentTargets; | |||
} | |||
@@ -40,11 +40,11 @@ public class IgnoreDependenciesExecutor implements Executor { | |||
/** {@inheritDoc}. */ | |||
public void executeTargets(Project project, String[] targetNames) | |||
throws BuildException { | |||
Hashtable targets = project.getTargets(); | |||
Hashtable<String, Target> targets = project.getTargets(); | |||
BuildException thrownException = null; | |||
for (int i = 0; i < targetNames.length; i++) { | |||
try { | |||
Target t = (Target) targets.get(targetNames[i]); | |||
Target t = targets.get(targetNames[i]); | |||
if (t == null) { | |||
throw new BuildException("Unknown target " + targetNames[i]); | |||
} | |||
@@ -50,7 +50,6 @@ import java.io.UnsupportedEncodingException; | |||
import java.net.URL; | |||
import java.util.HashMap; | |||
import java.util.Hashtable; | |||
import java.util.Iterator; | |||
import java.util.Map; | |||
import java.util.Stack; | |||
@@ -157,13 +156,13 @@ public class ProjectHelper2 extends ProjectHelper { | |||
context.setIgnoreProjectTag(true); | |||
Target currentTarget = context.getCurrentTarget(); | |||
Target currentImplicit = context.getImplicitTarget(); | |||
Map currentTargets = context.getCurrentTargets(); | |||
Map<String, Target> currentTargets = context.getCurrentTargets(); | |||
try { | |||
Target newCurrent = new Target(); | |||
newCurrent.setProject(project); | |||
newCurrent.setName(""); | |||
context.setCurrentTarget(newCurrent); | |||
context.setCurrentTargets(new HashMap()); | |||
context.setCurrentTargets(new HashMap<String, Target>()); | |||
context.setImplicitTarget(newCurrent); | |||
parse(project, source, new RootHandler(context, mainHandler)); | |||
newCurrent.execute(); | |||
@@ -174,7 +173,7 @@ public class ProjectHelper2 extends ProjectHelper { | |||
} | |||
} else { | |||
// top level file | |||
context.setCurrentTargets(new HashMap()); | |||
context.setCurrentTargets(new HashMap<String, Target>()); | |||
parse(project, source, new RootHandler(context, mainHandler)); | |||
// Execute the top-level target | |||
context.getImplicitTarget().execute(); | |||
@@ -485,7 +484,7 @@ public class ProjectHelper2 extends ProjectHelper { | |||
* with the implicit execution stack ) | |||
*/ | |||
public static class RootHandler extends DefaultHandler { | |||
private Stack antHandlers = new Stack(); | |||
private Stack<AntHandler> antHandlers = new Stack<AntHandler>(); | |||
private AntHandler currentHandler = null; | |||
private AntXMLContext context; | |||
@@ -962,7 +961,7 @@ public class ProjectHelper2 extends ProjectHelper { | |||
throw new BuildException("Duplicate target '" + name + "'", | |||
target.getLocation()); | |||
} | |||
Hashtable projectTargets = project.getTargets(); | |||
Hashtable<String, Target> projectTargets = project.getTargets(); | |||
boolean usedTarget = false; | |||
// If the name has not already been defined define it | |||
if (projectTargets.containsKey(name)) { | |||
@@ -979,12 +978,9 @@ public class ProjectHelper2 extends ProjectHelper { | |||
if (!isInIncludeMode) { | |||
target.setDepends(depends); | |||
} else { | |||
for (Iterator iter = | |||
Target.parseDepends(depends, name, "depends") | |||
.iterator(); | |||
iter.hasNext(); ) { | |||
target.addDependency(prefix + sep + iter.next()); | |||
} | |||
for (String string : Target.parseDepends(depends, name, "depends")) { | |||
target.addDependency(prefix + sep + string); | |||
} | |||
} | |||
} | |||
if (!isInIncludeMode && context.isIgnoringProjectTag() | |||
@@ -1003,7 +999,7 @@ public class ProjectHelper2 extends ProjectHelper { | |||
} | |||
if (extensionPointMissing != null && extensionPoint == null) { | |||
throw new BuildException("onMissingExtensionPoint attribute cannot " + | |||
"be specified unless extensionOf is specified", | |||
"be specified unless extensionOf is specified", | |||
target.getLocation()); | |||
} | |||
@@ -855,7 +855,7 @@ public class ProjectHelperImpl extends ProjectHelper { | |||
* BuildException being thrown during configuration. | |||
*/ | |||
public void init(String propType, AttributeList attrs) throws SAXParseException { | |||
Class parentClass = parent.getClass(); | |||
Class<?> parentClass = parent.getClass(); | |||
IntrospectionHelper ih = IntrospectionHelper.getHelper(helperImpl.project, parentClass); | |||
try { | |||
@@ -22,7 +22,6 @@ import java.io.BufferedReader; | |||
import java.io.IOException; | |||
import java.io.InputStream; | |||
import java.io.InputStreamReader; | |||
import java.util.Enumeration; | |||
import org.apache.tools.ant.BuildException; | |||
import org.apache.tools.ant.util.KeepAliveInputStream; | |||
@@ -86,16 +85,12 @@ public class DefaultInputHandler implements InputHandler { | |||
String prompt = request.getPrompt(); | |||
String def = request.getDefaultValue(); | |||
if (request instanceof MultipleChoiceInputRequest) { | |||
StringBuffer sb = new StringBuffer(prompt); | |||
sb.append(" ("); | |||
Enumeration e = | |||
((MultipleChoiceInputRequest) request).getChoices().elements(); | |||
StringBuilder sb = new StringBuilder(prompt).append(" ("); | |||
boolean first = true; | |||
while (e.hasMoreElements()) { | |||
for (String next : ((MultipleChoiceInputRequest) request).getChoices()) { | |||
if (!first) { | |||
sb.append(", "); | |||
} | |||
String next = (String) e.nextElement(); | |||
if (next.equals(def)) { | |||
sb.append('['); | |||
} | |||
@@ -27,26 +27,26 @@ import java.util.Vector; | |||
* @since Ant 1.5 | |||
*/ | |||
public class MultipleChoiceInputRequest extends InputRequest { | |||
private final LinkedHashSet choices; | |||
private final LinkedHashSet<String> choices; | |||
/** | |||
* @param prompt The prompt to show to the user. Must not be null. | |||
* @param choices holds all input values that are allowed. | |||
* Must not be null. | |||
*/ | |||
public MultipleChoiceInputRequest(String prompt, Vector choices) { | |||
public MultipleChoiceInputRequest(String prompt, Vector<String> choices) { | |||
super(prompt); | |||
if (choices == null) { | |||
throw new IllegalArgumentException("choices must not be null"); | |||
} | |||
this.choices = new LinkedHashSet(choices); | |||
this.choices = new LinkedHashSet<String>(choices); | |||
} | |||
/** | |||
* @return The possible values. | |||
*/ | |||
public Vector getChoices() { | |||
return new Vector(choices); | |||
public Vector<String> getChoices() { | |||
return new Vector<String>(choices); | |||
} | |||
/** | |||
@@ -42,8 +42,7 @@ public class SecureInputHandler extends DefaultInputHandler { | |||
public void handleInput(InputRequest request) throws BuildException { | |||
String prompt = getPrompt(request); | |||
try { | |||
Class system = Class.forName("java.lang.System"); | |||
Object console = ReflectUtil.invokeStatic(system, "console"); | |||
Object console = ReflectUtil.invokeStatic(System.class, "console"); | |||
do { | |||
char[] input = (char[]) ReflectUtil.invoke( | |||
console, "readPassword", String.class, prompt, | |||
@@ -23,6 +23,7 @@ package org.apache.tools.ant.launch; | |||
* @since Ant 1.6 | |||
*/ | |||
public class LaunchException extends Exception { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* Constructs an exception with the given descriptive message. | |||
@@ -24,7 +24,6 @@ import java.io.File; | |||
import java.util.StringTokenizer; | |||
import java.util.List; | |||
import java.util.ArrayList; | |||
import java.util.Iterator; | |||
@@ -133,7 +132,7 @@ public class Launcher { | |||
* @param libPathURLs the list of paths to add to | |||
* @throws MalformedURLException if we can't create a URL | |||
*/ | |||
private void addPath(String path, boolean getJars, List libPathURLs) | |||
private void addPath(String path, boolean getJars, List<URL> libPathURLs) | |||
throws MalformedURLException { | |||
StringTokenizer tokenizer = new StringTokenizer(path, File.pathSeparator); | |||
while (tokenizer.hasMoreElements()) { | |||
@@ -190,9 +189,9 @@ public class Launcher { | |||
+ "ant could not be located (estimated value="+antHome.getAbsolutePath()+")"); | |||
} | |||
List libPaths = new ArrayList(); | |||
List<String> libPaths = new ArrayList<String>(); | |||
String cpString = null; | |||
List argList = new ArrayList(); | |||
List<String> argList = new ArrayList<String>(); | |||
String[] newArgs; | |||
boolean noUserLib = false; | |||
boolean noClassPath = false; | |||
@@ -271,7 +270,7 @@ public class Launcher { | |||
URLClassLoader loader = new URLClassLoader(jars, Launcher.class.getClassLoader()); | |||
Thread.currentThread().setContextClassLoader(loader); | |||
Class mainClass = null; | |||
Class<?> mainClass = null; | |||
int exitCode = 0; | |||
Throwable thrown=null; | |||
try { | |||
@@ -311,20 +310,19 @@ public class Launcher { | |||
* @return an array of URLs. | |||
* @throws MalformedURLException if the URLs cannot be created. | |||
*/ | |||
private URL[] getLibPathURLs(String cpString, List libPaths) | |||
private URL[] getLibPathURLs(String cpString, List<String> libPaths) | |||
throws MalformedURLException { | |||
List libPathURLs = new ArrayList(); | |||
List<URL> libPathURLs = new ArrayList<URL>(); | |||
if (cpString != null) { | |||
addPath(cpString, false, libPathURLs); | |||
} | |||
for (Iterator i = libPaths.iterator(); i.hasNext();) { | |||
String libPath = (String) i.next(); | |||
for (String libPath : libPaths) { | |||
addPath(libPath, true, libPathURLs); | |||
} | |||
return (URL[]) libPathURLs.toArray(new URL[libPathURLs.size()]); | |||
return libPathURLs.toArray(new URL[libPathURLs.size()]); | |||
} | |||
/** | |||
@@ -113,7 +113,7 @@ public final class Locator { | |||
* | |||
* @since Ant 1.6 | |||
*/ | |||
public static File getClassSource(Class c) { | |||
public static File getClassSource(Class<?> c) { | |||
String classResource = c.getName().replace('.', '/') + ".class"; | |||
return getResourceSource(c.getClassLoader(), classResource); | |||
} | |||
@@ -17,6 +17,7 @@ | |||
*/ | |||
package org.apache.tools.ant.listener; | |||
import java.io.File; | |||
import java.io.FileInputStream; | |||
import java.io.IOException; | |||
import java.io.InputStream; | |||
@@ -32,6 +33,7 @@ import org.apache.tools.ant.BuildException; | |||
import org.apache.tools.ant.DefaultLogger; | |||
import org.apache.tools.ant.Project; | |||
import org.apache.tools.ant.taskdefs.email.EmailAddress; | |||
import org.apache.tools.ant.taskdefs.email.Header; | |||
import org.apache.tools.ant.taskdefs.email.Message; | |||
import org.apache.tools.ant.taskdefs.email.Mailer; | |||
import org.apache.tools.ant.util.ClasspathUtils; | |||
@@ -100,7 +102,7 @@ public class MailLogger extends DefaultLogger { | |||
super.buildFinished(event); | |||
Project project = event.getProject(); | |||
Hashtable properties = project.getProperties(); | |||
Hashtable<String, Object> properties = project.getProperties(); | |||
// overlay specified properties file (if any), which overrides project | |||
// settings | |||
@@ -118,7 +120,7 @@ public class MailLogger extends DefaultLogger { | |||
} | |||
} | |||
for (Enumeration e = fileProperties.keys(); e.hasMoreElements();) { | |||
for (Enumeration<?> e = fileProperties.keys(); e.hasMoreElements();) { | |||
String key = (String) e.nextElement(); | |||
String value = fileProperties.getProperty(key); | |||
properties.put(key, project.replaceProperties(value)); | |||
@@ -298,7 +300,7 @@ public class MailLogger extends DefaultLogger { | |||
* @exception Exception thrown if no default value is specified and the | |||
* property is not present in properties. | |||
*/ | |||
private String getValue(Hashtable properties, String name, | |||
private String getValue(Hashtable<String, Object> properties, String name, | |||
String defaultValue) throws Exception { | |||
String propertyName = "MailLogger." + name; | |||
String value = (String) properties.get(propertyName); | |||
@@ -371,7 +373,7 @@ public class MailLogger extends DefaultLogger { | |||
return; | |||
} | |||
// convert the replyTo string into a vector of emailaddresses | |||
Vector replyToList = vectorizeEmailAddresses(values.replytoList()); | |||
Vector<EmailAddress> replyToList = vectorizeEmailAddresses(values.replytoList()); | |||
mailer.setHost(values.mailhost()); | |||
mailer.setPort(values.port()); | |||
mailer.setUser(values.user()); | |||
@@ -388,17 +390,17 @@ public class MailLogger extends DefaultLogger { | |||
mailer.setMessage(mymessage); | |||
mailer.setFrom(new EmailAddress(values.from())); | |||
mailer.setReplyToList(replyToList); | |||
Vector toList = vectorizeEmailAddresses(values.toList()); | |||
Vector<EmailAddress> toList = vectorizeEmailAddresses(values.toList()); | |||
mailer.setToList(toList); | |||
mailer.setCcList(new Vector()); | |||
mailer.setBccList(new Vector()); | |||
mailer.setFiles(new Vector()); | |||
mailer.setCcList(new Vector<EmailAddress>()); | |||
mailer.setBccList(new Vector<EmailAddress>()); | |||
mailer.setFiles(new Vector<File>()); | |||
mailer.setSubject(values.subject()); | |||
mailer.setHeaders(new Vector()); | |||
mailer.setHeaders(new Vector<Header>()); | |||
mailer.send(); | |||
} | |||
private Vector vectorizeEmailAddresses(String listString) { | |||
Vector emailList = new Vector(); | |||
private Vector<EmailAddress> vectorizeEmailAddresses(String listString) { | |||
Vector<EmailAddress> emailList = new Vector<EmailAddress>(); | |||
StringTokenizer tokens = new StringTokenizer(listString, ","); | |||
while (tokens.hasMoreTokens()) { | |||
emailList.addElement(new EmailAddress(tokens.nextToken())); | |||
@@ -32,7 +32,7 @@ import org.apache.tools.ant.util.StringUtils; | |||
*/ | |||
public class ProfileLogger extends DefaultLogger { | |||
private Map profileData = new HashMap(); // <Object, Date> | |||
private Map<Object, Date> profileData = new HashMap<Object, Date>(); | |||
/** | |||
* Logs a message to say that the target has started. | |||
@@ -21,6 +21,8 @@ package org.apache.tools.ant.loader; | |||
import java.util.Enumeration; | |||
import java.io.Closeable; | |||
import java.io.IOException; | |||
import java.net.URL; | |||
import org.apache.tools.ant.AntClassLoader; | |||
import org.apache.tools.ant.Project; | |||
import org.apache.tools.ant.types.Path; | |||
@@ -52,7 +54,7 @@ public class AntClassLoader5 extends AntClassLoader implements Closeable { | |||
} | |||
/** {@inheritDoc} */ | |||
public Enumeration getResources(String name) throws IOException { | |||
public Enumeration<URL> getResources(String name) throws IOException { | |||
return getNamedResources(name); | |||
} | |||
@@ -19,7 +19,6 @@ package org.apache.tools.ant.property; | |||
import java.text.ParsePosition; | |||
import java.util.Collection; | |||
import java.util.Iterator; | |||
import org.apache.tools.ant.Project; | |||
/** | |||
@@ -31,7 +30,7 @@ public class ParseProperties implements ParseNextProperty { | |||
private final Project project; | |||
private final GetProperty getProperty; | |||
private final Collection expanders; | |||
private final Collection<PropertyExpander> expanders; | |||
/** | |||
* Constructor with a getProperty. | |||
@@ -39,7 +38,7 @@ public class ParseProperties implements ParseNextProperty { | |||
* @param expanders a sequence of expanders | |||
* @param getProperty property resolver. | |||
*/ | |||
public ParseProperties(Project project, Collection expanders, GetProperty getProperty) { | |||
public ParseProperties(Project project, Collection<PropertyExpander> expanders, GetProperty getProperty) { | |||
this.project = project; | |||
this.expanders = expanders; | |||
this.getProperty = getProperty; | |||
@@ -183,9 +182,8 @@ public class ParseProperties implements ParseNextProperty { | |||
} | |||
private String parsePropertyName(String value, ParsePosition pos) { | |||
for (Iterator iter = expanders.iterator(); iter.hasNext();) { | |||
String propertyName = ((PropertyExpander) iter.next()) | |||
.parsePropertyName(value, pos, this); | |||
for (PropertyExpander propertyExpander : expanders) { | |||
String propertyName = propertyExpander.parsePropertyName(value, pos, this); | |||
if (propertyName == null) { | |||
continue; | |||
} | |||
@@ -17,7 +17,6 @@ | |||
*/ | |||
package org.apache.tools.ant.property; | |||
import java.util.Iterator; | |||
import java.util.Map; | |||
import java.util.Set; | |||
import java.util.HashSet; | |||
@@ -31,10 +30,10 @@ import org.apache.tools.ant.BuildException; | |||
* @since Ant 1.8.0 | |||
*/ | |||
public class ResolvePropertyMap implements GetProperty { | |||
private final Set seen = new HashSet(); | |||
private final Set<String> seen = new HashSet<String>(); | |||
private final ParseProperties parseProperties; | |||
private final GetProperty master; | |||
private Map map; | |||
private Map<String, Object> map; | |||
private String prefix; | |||
// whether properties of the value side of the map should be | |||
// expanded | |||
@@ -49,7 +48,7 @@ public class ResolvePropertyMap implements GetProperty { | |||
* @param master the master property holder (usually PropertyHelper) | |||
* @param expanders a collection of expanders (usually from PropertyHelper). | |||
*/ | |||
public ResolvePropertyMap(Project project, GetProperty master, Collection expanders) { | |||
public ResolvePropertyMap(Project project, GetProperty master, Collection<PropertyExpander> expanders) { | |||
this.master = master; | |||
this.parseProperties = new ParseProperties(project, expanders, this); | |||
} | |||
@@ -102,7 +101,7 @@ public class ResolvePropertyMap implements GetProperty { | |||
* @param map the map to resolve properties in. | |||
* @deprecated since Ant 1.8.2, use the three-arg method instead. | |||
*/ | |||
public void resolveAllProperties(Map map) { | |||
public void resolveAllProperties(Map<String, Object> map) { | |||
resolveAllProperties(map, null, false); | |||
} | |||
@@ -113,7 +112,7 @@ public class ResolvePropertyMap implements GetProperty { | |||
* will finally receive - may be null. | |||
* @deprecated since Ant 1.8.2, use the three-arg method instead. | |||
*/ | |||
public void resolveAllProperties(Map map, String prefix) { | |||
public void resolveAllProperties(Map<String, Object> map, String prefix) { | |||
resolveAllProperties(map, null, false); | |||
} | |||
@@ -125,7 +124,7 @@ public class ResolvePropertyMap implements GetProperty { | |||
* @param prefixValues - whether the prefix will be applied | |||
* to properties on the value side of the map as well. | |||
*/ | |||
public void resolveAllProperties(Map map, String prefix, | |||
public void resolveAllProperties(Map<String, Object> map, String prefix, | |||
boolean prefixValues) { | |||
// The map, prefix and prefixValues flag get used in the | |||
// getProperty callback | |||
@@ -133,9 +132,8 @@ public class ResolvePropertyMap implements GetProperty { | |||
this.prefix = prefix; | |||
this.prefixValues = prefixValues; | |||
for (Iterator i = map.keySet().iterator(); i.hasNext();) { | |||
for (String key : map.keySet()) { | |||
expandingLHS = true; | |||
String key = (String) i.next(); | |||
Object result = getProperty(key); | |||
String value = result == null ? "" : result.toString(); | |||
map.put(key, value); | |||
@@ -25,7 +25,6 @@ import java.io.IOException; | |||
import java.io.OutputStream; | |||
import java.io.PrintStream; | |||
import java.util.ArrayList; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import java.util.Vector; | |||
import org.apache.tools.ant.BuildException; | |||
@@ -55,10 +54,10 @@ public abstract class AbstractCvsTask extends Task { | |||
private Commandline cmd = new Commandline(); | |||
private ArrayList modules = new ArrayList(); | |||
private ArrayList<Module> modules = new ArrayList<Module>(); | |||
/** list of Commandline children */ | |||
private Vector vecCommandlines = new Vector(); | |||
private Vector<Commandline> vecCommandlines = new Vector<Commandline>(); | |||
/** | |||
* the CVSROOT variable. | |||
@@ -769,8 +768,7 @@ public abstract class AbstractCvsTask extends Task { | |||
if (cvsPackage != null) { | |||
c.createArgument().setLine(cvsPackage); | |||
} | |||
for (Iterator iter = modules.iterator(); iter.hasNext(); ) { | |||
Module m = (Module) iter.next(); | |||
for (Module m : modules) { | |||
c.createArgument().setValue(m.getName()); | |||
} | |||
if (this.compression > 0 | |||
@@ -855,8 +853,10 @@ public abstract class AbstractCvsTask extends Task { | |||
modules.add(m); | |||
} | |||
protected List getModules() { | |||
return (List) modules.clone(); | |||
protected List<Module> getModules() { | |||
@SuppressWarnings("unchecked") | |||
final List<Module> clone = (List<Module>) modules.clone(); | |||
return clone; | |||
} | |||
public static final class Module { | |||
@@ -19,7 +19,6 @@ | |||
package org.apache.tools.ant.taskdefs; | |||
import java.io.File; | |||
import java.util.Enumeration; | |||
import java.util.Vector; | |||
import org.apache.tools.ant.BuildException; | |||
@@ -74,7 +73,7 @@ public abstract class AbstractJarSignerTask extends Task { | |||
/** | |||
* the filesets of the jars to sign | |||
*/ | |||
protected Vector filesets = new Vector(); | |||
protected Vector<FileSet> filesets = new Vector<FileSet>(); | |||
/** | |||
* name of JDK program we are looking for | |||
*/ | |||
@@ -291,10 +290,7 @@ public abstract class AbstractJarSignerTask extends Task { | |||
} | |||
//now patch in all system properties | |||
Vector props = sysProperties.getVariablesVector(); | |||
Enumeration e = props.elements(); | |||
while (e.hasMoreElements()) { | |||
Environment.Variable variable = (Environment.Variable) e.nextElement(); | |||
for (Environment.Variable variable : sysProperties.getVariablesVector()) { | |||
declareSysProperty(cmd, variable); | |||
} | |||
} | |||
@@ -358,8 +354,9 @@ public abstract class AbstractJarSignerTask extends Task { | |||
* fileset, if is defined | |||
* @return a vector of FileSet instances | |||
*/ | |||
protected Vector createUnifiedSources() { | |||
Vector sources = (Vector) filesets.clone(); | |||
protected Vector<FileSet> createUnifiedSources() { | |||
@SuppressWarnings("unchecked") | |||
Vector<FileSet> sources = (Vector<FileSet>) filesets.clone(); | |||
if (jar != null) { | |||
//we create a fileset with the source file. | |||
//this lets us combine our logic for handling output directories, | |||
@@ -382,10 +379,8 @@ public abstract class AbstractJarSignerTask extends Task { | |||
*/ | |||
protected Path createUnifiedSourcePath() { | |||
Path p = path == null ? new Path(getProject()) : (Path) path.clone(); | |||
Vector s = createUnifiedSources(); | |||
Enumeration e = s.elements(); | |||
while (e.hasMoreElements()) { | |||
p.add((FileSet) e.nextElement()); | |||
for (FileSet fileSet : createUnifiedSources()) { | |||
p.add(fileSet); | |||
} | |||
return p; | |||
} | |||
@@ -87,10 +87,10 @@ public class Ant extends Task { | |||
private boolean inheritRefs = false; | |||
/** the properties to pass to the new project */ | |||
private Vector properties = new Vector(); | |||
private Vector<Property> properties = new Vector<Property>(); | |||
/** the references to pass to the new project */ | |||
private Vector references = new Vector(); | |||
private Vector<Reference> references = new Vector<Reference>(); | |||
/** the temporary project created to run the build file */ | |||
private Project newProject; | |||
@@ -99,10 +99,10 @@ public class Ant extends Task { | |||
private PrintStream out = null; | |||
/** the sets of properties to pass to the new project */ | |||
private Vector propertySets = new Vector(); | |||
private Vector<PropertySet> propertySets = new Vector<PropertySet>(); | |||
/** the targets to call on the new project */ | |||
private Vector targets = new Vector(); | |||
private Vector<String> targets = new Vector<String>(); | |||
/** whether the target attribute was specified **/ | |||
private boolean targetAttributeSet = false; | |||
@@ -192,7 +192,7 @@ public class Ant extends Task { | |||
private void initializeProject() { | |||
newProject.setInputHandler(getProject().getInputHandler()); | |||
Iterator iter = getBuildListeners(); | |||
Iterator<BuildListener> iter = getBuildListeners(); | |||
while (iter.hasNext()) { | |||
newProject.addBuildListener((BuildListener) iter.next()); | |||
} | |||
@@ -232,9 +232,7 @@ public class Ant extends Task { | |||
addAlmostAll(getProject().getProperties(), PropertyType.PLAIN); | |||
} | |||
Enumeration e = propertySets.elements(); | |||
while (e.hasMoreElements()) { | |||
PropertySet ps = (PropertySet) e.nextElement(); | |||
for (PropertySet ps : propertySets) { | |||
addAlmostAll(ps.getProperties(), PropertyType.PLAIN); | |||
} | |||
} | |||
@@ -334,7 +332,7 @@ public class Ant extends Task { | |||
public void execute() throws BuildException { | |||
File savedDir = dir; | |||
String savedAntFile = antFile; | |||
Vector locals = new VectorSet(targets); | |||
Vector<String> locals = new VectorSet<String>(targets); | |||
try { | |||
getNewProject(); | |||
@@ -414,10 +412,10 @@ public class Ant extends Task { | |||
+ "its own parent target."); | |||
} | |||
boolean circular = false; | |||
for (Iterator it = locals.iterator(); | |||
for (Iterator<String> it = locals.iterator(); | |||
!circular && it.hasNext();) { | |||
Target other = | |||
(Target) (getProject().getTargets().get(it.next())); | |||
getProject().getTargets().get(it.next()); | |||
circular |= (other != null | |||
&& other.dependsOn(owningTargetName)); | |||
} | |||
@@ -452,9 +450,7 @@ public class Ant extends Task { | |||
} finally { | |||
// help the gc | |||
newProject = null; | |||
Enumeration e = properties.elements(); | |||
while (e.hasMoreElements()) { | |||
Property p = (Property) e.nextElement(); | |||
for (Property p : properties) { | |||
p.setProject(null); | |||
} | |||
@@ -475,7 +471,7 @@ public class Ant extends Task { | |||
* <p> | |||
* This function may be overrided by providers of custom ProjectHelper so they can implement easily their sub | |||
* launcher. | |||
* | |||
* | |||
* @return the name of the default file | |||
* @since Ant 1.8.0 | |||
*/ | |||
@@ -491,9 +487,9 @@ public class Ant extends Task { | |||
private void overrideProperties() throws BuildException { | |||
// remove duplicate properties - last property wins | |||
// Needed for backward compatibility | |||
Set set = new HashSet(); | |||
Set<String> set = new HashSet<String>(); | |||
for (int i = properties.size() - 1; i >= 0; --i) { | |||
Property p = (Property) properties.get(i); | |||
Property p = properties.get(i); | |||
if (p.getName() != null && !p.getName().equals("")) { | |||
if (set.contains(p.getName())) { | |||
properties.remove(i); | |||
@@ -502,9 +498,9 @@ public class Ant extends Task { | |||
} | |||
} | |||
} | |||
Enumeration e = properties.elements(); | |||
Enumeration<Property> e = properties.elements(); | |||
while (e.hasMoreElements()) { | |||
Property p = (Property) e.nextElement(); | |||
Property p = e.nextElement(); | |||
p.setProject(newProject); | |||
p.execute(); | |||
} | |||
@@ -524,39 +520,35 @@ public class Ant extends Task { | |||
* @throws BuildException if a reference does not have a refid. | |||
*/ | |||
private void addReferences() throws BuildException { | |||
Hashtable thisReferences | |||
= (Hashtable) getProject().getReferences().clone(); | |||
Hashtable newReferences = newProject.getReferences(); | |||
Enumeration e; | |||
if (references.size() > 0) { | |||
for (e = references.elements(); e.hasMoreElements();) { | |||
Reference ref = (Reference) e.nextElement(); | |||
String refid = ref.getRefId(); | |||
if (refid == null) { | |||
throw new BuildException("the refid attribute is required" | |||
+ " for reference elements"); | |||
} | |||
if (!thisReferences.containsKey(refid)) { | |||
log("Parent project doesn't contain any reference '" | |||
+ refid + "'", | |||
Project.MSG_WARN); | |||
continue; | |||
} | |||
@SuppressWarnings("unchecked") | |||
Hashtable<String, Object> thisReferences | |||
= (Hashtable<String, Object>) getProject().getReferences().clone(); | |||
for (Reference ref : references) { | |||
String refid = ref.getRefId(); | |||
if (refid == null) { | |||
throw new BuildException("the refid attribute is required" | |||
+ " for reference elements"); | |||
} | |||
if (!thisReferences.containsKey(refid)) { | |||
log("Parent project doesn't contain any reference '" | |||
+ refid + "'", | |||
Project.MSG_WARN); | |||
continue; | |||
} | |||
thisReferences.remove(refid); | |||
String toRefid = ref.getToRefid(); | |||
if (toRefid == null) { | |||
toRefid = refid; | |||
} | |||
copyReference(refid, toRefid); | |||
thisReferences.remove(refid); | |||
String toRefid = ref.getToRefid(); | |||
if (toRefid == null) { | |||
toRefid = refid; | |||
} | |||
copyReference(refid, toRefid); | |||
} | |||
// Now add all references that are not defined in the | |||
// subproject, if inheritRefs is true | |||
if (inheritRefs) { | |||
for (e = thisReferences.keys(); e.hasMoreElements();) { | |||
String key = (String) e.nextElement(); | |||
Hashtable<String, Object> newReferences = newProject.getReferences(); | |||
for (String key : thisReferences.keySet()) { | |||
if (newReferences.containsKey(key)) { | |||
continue; | |||
} | |||
@@ -584,7 +576,7 @@ public class Ant extends Task { | |||
return; | |||
} | |||
Class c = orig.getClass(); | |||
Class<?> c = orig.getClass(); | |||
Object copy = orig; | |||
try { | |||
Method cloneM = c.getMethod("clone", new Class[0]); | |||
@@ -628,8 +620,8 @@ public class Ant extends Task { | |||
* user property or an inherited property). | |||
* @since Ant 1.8.0 | |||
*/ | |||
private void addAlmostAll(Hashtable props, PropertyType type) { | |||
Enumeration e = props.keys(); | |||
private void addAlmostAll(Hashtable<?, ?> props, PropertyType type) { | |||
Enumeration<?> e = props.keys(); | |||
while (e.hasMoreElements()) { | |||
String key = e.nextElement().toString(); | |||
if (MagicNames.PROJECT_BASEDIR.equals(key) | |||
@@ -763,7 +755,7 @@ public class Ant extends Task { | |||
/** | |||
* @since Ant 1.6.2 | |||
*/ | |||
private Iterator getBuildListeners() { | |||
private Iterator<BuildListener> getBuildListeners() { | |||
return getProject().getBuildListeners().iterator(); | |||
} | |||
@@ -776,7 +768,7 @@ public class Ant extends Task { | |||
/** Creates a reference to be configured by Ant. */ | |||
public Reference() { | |||
super(); | |||
super(); | |||
} | |||
private String targetid = null; | |||
@@ -27,7 +27,6 @@ import java.io.PrintWriter; | |||
import java.io.UnsupportedEncodingException; | |||
import java.util.Enumeration; | |||
import java.util.Hashtable; | |||
import java.util.Iterator; | |||
import java.util.Vector; | |||
import org.apache.tools.ant.BuildException; | |||
import org.apache.tools.ant.IntrospectionHelper; | |||
@@ -96,26 +95,21 @@ public class AntStructure extends Task { | |||
} | |||
printer.printHead(out, getProject(), | |||
new Hashtable(getProject().getTaskDefinitions()), | |||
new Hashtable(getProject().getDataTypeDefinitions())); | |||
new Hashtable<String, Class<?>>(getProject().getTaskDefinitions()), | |||
new Hashtable<String, Class<?>>(getProject().getDataTypeDefinitions())); | |||
printer.printTargetDecl(out); | |||
Iterator dataTypes = getProject().getCopyOfDataTypeDefinitions() | |||
.keySet().iterator(); | |||
while (dataTypes.hasNext()) { | |||
String typeName = (String) dataTypes.next(); | |||
for (String typeName : getProject().getCopyOfDataTypeDefinitions() | |||
.keySet()) { | |||
printer.printElementDecl( | |||
out, getProject(), typeName, | |||
(Class) getProject().getDataTypeDefinitions().get(typeName)); | |||
out, getProject(), typeName, | |||
getProject().getDataTypeDefinitions().get(typeName)); | |||
} | |||
Iterator tasks = getProject().getCopyOfTaskDefinitions().keySet() | |||
.iterator(); | |||
while (tasks.hasNext()) { | |||
String tName = (String) tasks.next(); | |||
for (String tName : getProject().getCopyOfTaskDefinitions().keySet()) { | |||
printer.printElementDecl(out, getProject(), tName, | |||
(Class) getProject().getTaskDefinitions().get(tName)); | |||
getProject().getTaskDefinitions().get(tName)); | |||
} | |||
printer.printTail(out); | |||
@@ -151,8 +145,8 @@ public class AntStructure extends Task { | |||
* @param types map (name to implementing class) | |||
* data types. | |||
*/ | |||
void printHead(PrintWriter out, Project p, Hashtable tasks, | |||
Hashtable types); | |||
void printHead(PrintWriter out, Project p, Hashtable<String, Class<?>> tasks, | |||
Hashtable<String, Class<?>> types); | |||
/** | |||
* Prints the definition for the target element. | |||
@@ -169,7 +163,7 @@ public class AntStructure extends Task { | |||
* @param element class of the defined element. | |||
*/ | |||
void printElementDecl(PrintWriter out, Project p, String name, | |||
Class element); | |||
Class<?> element); | |||
/** | |||
* Prints the trailer. | |||
@@ -184,13 +178,14 @@ public class AntStructure extends Task { | |||
private static final String TASKS = "%tasks;"; | |||
private static final String TYPES = "%types;"; | |||
private Hashtable visited = new Hashtable(); | |||
private Hashtable<String, String> visited = new Hashtable<String, String>(); | |||
public void printTail(PrintWriter out) { | |||
visited.clear(); | |||
} | |||
public void printHead(PrintWriter out, Project p, Hashtable tasks, Hashtable types) { | |||
public void printHead(PrintWriter out, Project p, Hashtable<String, Class<?>> tasks, | |||
Hashtable<String, Class<?>> types) { | |||
printHead(out, tasks.keys(), types.keys()); | |||
} | |||
@@ -201,14 +196,14 @@ public class AntStructure extends Task { | |||
* <p>Basically this prints the XML declaration, defines some | |||
* entities and the project element.</p> | |||
*/ | |||
private void printHead(PrintWriter out, Enumeration tasks, | |||
Enumeration types) { | |||
private void printHead(PrintWriter out, Enumeration<String> tasks, | |||
Enumeration<String> types) { | |||
out.println("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"); | |||
out.println("<!ENTITY % boolean \"(true|false|on|off|yes|no)\">"); | |||
out.print("<!ENTITY % tasks \""); | |||
boolean first = true; | |||
while (tasks.hasMoreElements()) { | |||
String tName = (String) tasks.nextElement(); | |||
String tName = tasks.nextElement(); | |||
if (!first) { | |||
out.print(" | "); | |||
} else { | |||
@@ -220,7 +215,7 @@ public class AntStructure extends Task { | |||
out.print("<!ENTITY % types \""); | |||
first = true; | |||
while (types.hasMoreElements()) { | |||
String typeName = (String) types.nextElement(); | |||
String typeName = types.nextElement(); | |||
if (!first) { | |||
out.print(" | "); | |||
} else { | |||
@@ -281,7 +276,7 @@ public class AntStructure extends Task { | |||
* Print the definition for a given element. | |||
*/ | |||
public void printElementDecl(PrintWriter out, Project p, | |||
String name, Class element) { | |||
String name, Class<?> element) { | |||
if (visited.containsKey(name)) { | |||
return; | |||
@@ -313,7 +308,7 @@ public class AntStructure extends Task { | |||
return; | |||
} | |||
Vector v = new Vector(); | |||
Vector<String> v = new Vector<String>(); | |||
if (ih.supportsCharacters()) { | |||
v.addElement("#PCDATA"); | |||
} | |||
@@ -322,7 +317,7 @@ public class AntStructure extends Task { | |||
v.addElement(TASKS); | |||
} | |||
Enumeration e = ih.getNestedElements(); | |||
Enumeration<String> e = ih.getNestedElements(); | |||
while (e.hasMoreElements()) { | |||
v.addElement(e.nextElement()); | |||
} | |||
@@ -359,7 +354,7 @@ public class AntStructure extends Task { | |||
sb.append(LINE_SEP).append(" ") | |||
.append(attrName).append(" "); | |||
Class type = ih.getAttributeType(attrName); | |||
Class<?> type = ih.getAttributeType(attrName); | |||
if (type.equals(java.lang.Boolean.class) | |||
|| type.equals(java.lang.Boolean.TYPE)) { | |||
sb.append(BOOLEAN).append(" "); | |||
@@ -113,7 +113,7 @@ public class Antlib extends Task implements TaskContainer { | |||
// | |||
private ClassLoader classLoader; | |||
private String uri = ""; | |||
private List tasks = new ArrayList(); | |||
private List<Object> tasks = new ArrayList<Object>(); | |||
/** | |||
* Set the class loader for this antlib. | |||
@@ -155,7 +155,8 @@ public class Antlib extends Task implements TaskContainer { | |||
* any tasks that derive from Definer. | |||
*/ | |||
public void execute() { | |||
for (Iterator i = tasks.iterator(); i.hasNext();) { | |||
//TODO handle tasks added via #addTask() | |||
for (Iterator<Object> i = tasks.iterator(); i.hasNext();) { | |||
UnknownElement ue = (UnknownElement) i.next(); | |||
setLocation(ue.getLocation()); | |||
ue.maybeConfigure(); | |||
@@ -41,7 +41,7 @@ public class Apt | |||
private boolean compile = true; | |||
private String factory; | |||
private Path factoryPath; | |||
private Vector options = new Vector(); | |||
private Vector<Option> options = new Vector<Option>(); | |||
private File preprocessDir; | |||
/** The name of the apt tool. */ | |||
public static final String EXECUTABLE_NAME = "apt"; | |||
@@ -234,7 +234,7 @@ public class Apt | |||
* Each option will use '"-E" name ["=" value]' argument. | |||
* @return the options. | |||
*/ | |||
public Vector getOptions() { | |||
public Vector<Option> getOptions() { | |||
return options; | |||
} | |||
@@ -32,7 +32,7 @@ public class AugmentReference extends Task implements TypeAdapter { | |||
/** | |||
* {@inheritDoc} | |||
*/ | |||
public void checkProxyClass(Class proxyClass) { | |||
public void checkProxyClass(Class<?> proxyClass) { | |||
} | |||
/** | |||
@@ -33,7 +33,7 @@ public class BindTargets extends Task { | |||
private String extensionPoint; | |||
private List/* <String> */targets = new ArrayList(); | |||
private List<String> targets = new ArrayList<String>(); | |||
private OnMissingExtensionPoint onMissingExtensionPoint; | |||
@@ -80,10 +80,9 @@ public class BindTargets extends Task { | |||
ProjectHelper helper = (ProjectHelper) getProject().getReference( | |||
ProjectHelper.PROJECTHELPER_REFERENCE); | |||
Iterator itTarget = targets.iterator(); | |||
while (itTarget.hasNext()) { | |||
for (Iterator<String> itTarget = targets.iterator(); itTarget.hasNext();) { | |||
helper.getExtensionStack().add( | |||
new String[] { extensionPoint, (String) itTarget.next(), | |||
new String[] { extensionPoint, itTarget.next(), | |||
onMissingExtensionPoint.name() }); | |||
} | |||
@@ -31,8 +31,6 @@ import java.util.Comparator; | |||
import java.util.HashMap; | |||
import java.util.Map; | |||
import java.util.Hashtable; | |||
import java.util.Enumeration; | |||
import java.util.Set; | |||
import java.util.Arrays; | |||
import java.text.MessageFormat; | |||
import java.text.ParseException; | |||
@@ -60,7 +58,6 @@ import org.apache.tools.ant.util.StringUtils; | |||
*/ | |||
public class Checksum extends MatchingTask implements Condition { | |||
private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||
private static final int NIBBLE = 4; | |||
private static final int WORD = 16; | |||
private static final int BUFFER_SIZE = 8 * 1024; | |||
@@ -112,14 +109,14 @@ public class Checksum extends MatchingTask implements Condition { | |||
* Key: java.util.File (source file) | |||
* Value: java.lang.String (digest) | |||
*/ | |||
private Map allDigests = new HashMap(); | |||
private Map<File, byte[]> allDigests = new HashMap<File, byte[]>(); | |||
/** | |||
* Holds relative file names for all files (always with a forward slash). | |||
* This is used to calculate the total hash. | |||
* Key: java.util.File (source file) | |||
* Value: java.lang.String (relative file name) | |||
*/ | |||
private Map relativeFilePaths = new HashMap(); | |||
private Map<File, String> relativeFilePaths = new HashMap<File, String>(); | |||
/** | |||
* Property where totalChecksum gets set. | |||
*/ | |||
@@ -140,7 +137,7 @@ public class Checksum extends MatchingTask implements Condition { | |||
/** | |||
* Stores SourceFile, DestFile pairs and SourceFile, Property String pairs. | |||
*/ | |||
private Hashtable includeFileMap = new Hashtable(); | |||
private Hashtable<File, Object> includeFileMap = new Hashtable<File, Object>(); | |||
/** | |||
* Message Digest instance | |||
*/ | |||
@@ -478,9 +475,9 @@ public class Checksum extends MatchingTask implements Condition { | |||
FileOutputStream fos = null; | |||
byte[] buf = new byte[readBufferSize]; | |||
try { | |||
for (Enumeration e = includeFileMap.keys(); e.hasMoreElements();) { | |||
for (Map.Entry<File, Object> e : includeFileMap.entrySet()) { | |||
messageDigest.reset(); | |||
File src = (File) e.nextElement(); | |||
File src = e.getKey(); | |||
if (!isCondition) { | |||
log("Calculating " + algorithm + " checksum for " + src, Project.MSG_VERBOSE); | |||
} | |||
@@ -499,7 +496,7 @@ public class Checksum extends MatchingTask implements Condition { | |||
} | |||
String checksum = createDigestString(fileDigest); | |||
//can either be a property name string or a file | |||
Object destination = includeFileMap.get(src); | |||
Object destination = e.getValue(); | |||
if (destination instanceof java.lang.String) { | |||
String prop = (String) destination; | |||
if (isCondition) { | |||
@@ -549,14 +546,11 @@ public class Checksum extends MatchingTask implements Condition { | |||
if (totalproperty != null) { | |||
// Calculate the total checksum | |||
// Convert the keys (source files) into a sorted array. | |||
Set keys = allDigests.keySet(); | |||
Object[] keyArray = keys.toArray(); | |||
File[] keyArray = allDigests.keySet().toArray(new File[allDigests.size()]); | |||
// File is Comparable, but sort-order is platform | |||
// dependent (case-insensitive on Windows) | |||
Arrays.sort(keyArray, new Comparator() { | |||
public int compare(Object o1, Object o2) { | |||
File f1 = (File) o1; | |||
File f2 = (File) o2; | |||
Arrays.sort(keyArray, new Comparator<File>() { | |||
public int compare(File f1, File f2) { | |||
return f1 == null ? (f2 == null ? 0 : -1) | |||
: (f2 == null ? 1 | |||
: getRelativeFilePath(f1) | |||
@@ -565,11 +559,9 @@ public class Checksum extends MatchingTask implements Condition { | |||
}); | |||
// Loop over the checksums and generate a total hash. | |||
messageDigest.reset(); | |||
for (int i = 0; i < keyArray.length; i++) { | |||
File src = (File) keyArray[i]; | |||
for (File src : keyArray) { | |||
// Add the digest for the file content | |||
byte[] digest = (byte[]) allDigests.get(src); | |||
byte[] digest = allDigests.get(src); | |||
messageDigest.update(digest); | |||
// Add the file path | |||
@@ -675,7 +667,7 @@ public class Checksum extends MatchingTask implements Condition { | |||
* @since 1.7 | |||
*/ | |||
public static class FormatElement extends EnumeratedAttribute { | |||
private static HashMap formatMap = new HashMap(); | |||
private static HashMap<String, MessageFormat> formatMap = new HashMap<String, MessageFormat>(); | |||
private static final String CHECKSUM = "CHECKSUM"; | |||
private static final String MD5SUM = "MD5SUM"; | |||
private static final String SVF = "SVF"; | |||
@@ -211,8 +211,8 @@ public class Concat extends Task implements ResourceCollection { | |||
} | |||
} | |||
private interface ReaderFactory { | |||
Reader getReader(Object o) throws IOException; | |||
private interface ReaderFactory<S> { | |||
Reader getReader(S s) throws IOException; | |||
} | |||
/** | |||
@@ -220,15 +220,15 @@ public class Concat extends Task implements ResourceCollection { | |||
* The concatentated result can then be filtered as | |||
* a single stream. | |||
*/ | |||
private final class MultiReader extends Reader { | |||
private final class MultiReader<S> extends Reader { | |||
private Reader reader = null; | |||
private int lastPos = 0; | |||
private char[] lastChars = new char[eolString.length()]; | |||
private boolean needAddSeparator = false; | |||
private Iterator readerSources; | |||
private ReaderFactory factory; | |||
private Iterator<S> readerSources; | |||
private ReaderFactory<S> factory; | |||
private MultiReader(Iterator readerSources, ReaderFactory factory) { | |||
private MultiReader(Iterator<S> readerSources, ReaderFactory<S> factory) { | |||
this.readerSources = readerSources; | |||
this.factory = factory; | |||
} | |||
@@ -389,7 +389,7 @@ public class Concat extends Task implements ResourceCollection { | |||
return result; | |||
} | |||
Reader resourceReader = getFilteredReader( | |||
new MultiReader(c.iterator(), resourceReaderFactory)); | |||
new MultiReader<Resource>(c.iterator(), resourceReaderFactory)); | |||
Reader rdr; | |||
if (header == null && footer == null) { | |||
rdr = resourceReader; | |||
@@ -417,7 +417,7 @@ public class Concat extends Task implements ResourceCollection { | |||
readers[pos] = getFilteredReader(readers[pos]); | |||
} | |||
} | |||
rdr = new MultiReader(Arrays.asList(readers).iterator(), | |||
rdr = new MultiReader<Reader>(Arrays.asList(readers).iterator(), | |||
identityReaderFactory); | |||
} | |||
return outputEncoding == null ? new ReaderInputStream(rdr) | |||
@@ -469,7 +469,7 @@ public class Concat extends Task implements ResourceCollection { | |||
private Resources rc; | |||
/** for filtering the concatenated */ | |||
private Vector filterChains; | |||
private Vector<FilterChain> filterChains; | |||
/** ignore dates on input files */ | |||
private boolean forceOverwrite = true; | |||
/** overwrite read-only files */ | |||
@@ -490,18 +490,18 @@ public class Concat extends Task implements ResourceCollection { | |||
/** exposed resource name */ | |||
private String resourceName; | |||
private ReaderFactory resourceReaderFactory = new ReaderFactory() { | |||
public Reader getReader(Object o) throws IOException { | |||
InputStream is = ((Resource) o).getInputStream(); | |||
private ReaderFactory<Resource> resourceReaderFactory = new ReaderFactory<Resource>() { | |||
public Reader getReader(Resource o) throws IOException { | |||
InputStream is = o.getInputStream(); | |||
return new BufferedReader(encoding == null | |||
? new InputStreamReader(is) | |||
: new InputStreamReader(is, encoding)); | |||
} | |||
}; | |||
private ReaderFactory identityReaderFactory = new ReaderFactory() { | |||
public Reader getReader(Object o) { | |||
return (Reader) o; | |||
private ReaderFactory<Reader> identityReaderFactory = new ReaderFactory<Reader>() { | |||
public Reader getReader(Reader o) { | |||
return o; | |||
} | |||
}; | |||
@@ -691,7 +691,7 @@ public class Concat extends Task implements ResourceCollection { | |||
*/ | |||
public void addFilterChain(FilterChain filterChain) { | |||
if (filterChains == null) { | |||
filterChains = new Vector(); | |||
filterChains = new Vector<FilterChain>(); | |||
} | |||
filterChains.addElement(filterChain); | |||
} | |||
@@ -21,11 +21,9 @@ package org.apache.tools.ant.taskdefs; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.util.ArrayList; | |||
import java.util.Enumeration; | |||
import java.util.HashMap; | |||
import java.util.HashSet; | |||
import java.util.Hashtable; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.Vector; | |||
@@ -76,9 +74,9 @@ public class Copy extends Task { | |||
protected File file = null; // the source file | |||
protected File destFile = null; // the destination file | |||
protected File destDir = null; // the destination directory | |||
protected Vector rcs = new Vector(); | |||
protected Vector<ResourceCollection> rcs = new Vector<ResourceCollection>(); | |||
// here to provide API backwards compatibility | |||
protected Vector filesets = rcs; | |||
protected Vector<ResourceCollection> filesets = rcs; | |||
private boolean enableMultipleMappings = false; | |||
protected boolean filtering = false; | |||
@@ -89,15 +87,15 @@ public class Copy extends Task { | |||
protected boolean includeEmpty = true; | |||
protected boolean failonerror = true; | |||
protected Hashtable fileCopyMap = new LinkedHashtable(); | |||
protected Hashtable dirCopyMap = new LinkedHashtable(); | |||
protected Hashtable completeDirMap = new LinkedHashtable(); | |||
protected Hashtable<String, String[]> fileCopyMap = new LinkedHashtable<String, String[]>(); | |||
protected Hashtable<String, String[]> dirCopyMap = new LinkedHashtable<String, String[]>(); | |||
protected Hashtable<File, File> completeDirMap = new LinkedHashtable<File, File>(); | |||
protected Mapper mapperElement = null; | |||
protected FileUtils fileUtils; | |||
//CheckStyle:VisibilityModifier ON | |||
private Vector filterChains = new Vector(); | |||
private Vector filterSets = new Vector(); | |||
private Vector<FilterChain> filterChains = new Vector<FilterChain>(); | |||
private Vector<FilterSet> filterSets = new Vector<FilterSet>(); | |||
private String inputEncoding = null; | |||
private String outputEncoding = null; | |||
private long granularity = 0; | |||
@@ -204,7 +202,7 @@ public class Copy extends Task { | |||
* | |||
* @return a vector of FilterSet objects. | |||
*/ | |||
protected Vector getFilterSets() { | |||
protected Vector<FilterSet> getFilterSets() { | |||
return filterSets; | |||
} | |||
@@ -213,7 +211,7 @@ public class Copy extends Task { | |||
* | |||
* @return a vector of FilterChain objects. | |||
*/ | |||
protected Vector getFilterChains() { | |||
protected Vector<FilterChain> getFilterChains() { | |||
return filterChains; | |||
} | |||
@@ -288,7 +286,7 @@ public class Copy extends Task { | |||
/** | |||
* Set quiet mode. Used to hide messages when a file or directory to be | |||
* copied does not exist. | |||
* | |||
* | |||
* @param quiet | |||
* whether or not to display error messages when a file or | |||
* directory does not exist. Default is false. | |||
@@ -473,13 +471,13 @@ public class Copy extends Task { | |||
separate lists and then each list is handled in one go. | |||
*/ | |||
HashMap filesByBasedir = new HashMap(); | |||
HashMap dirsByBasedir = new HashMap(); | |||
HashSet baseDirs = new HashSet(); | |||
ArrayList nonFileResources = new ArrayList(); | |||
HashMap<File, List<String>> filesByBasedir = new HashMap<File, List<String>>(); | |||
HashMap<File, List<String>> dirsByBasedir = new HashMap<File, List<String>>(); | |||
HashSet<File> baseDirs = new HashSet<File>(); | |||
ArrayList<Resource> nonFileResources = new ArrayList<Resource>(); | |||
final int size = rcs.size(); | |||
for (int i = 0; i < size; i++) { | |||
ResourceCollection rc = (ResourceCollection) rcs.elementAt(i); | |||
ResourceCollection rc = rcs.elementAt(i); | |||
// Step (1) - beware of the ZipFileSet | |||
if (rc instanceof FileSet && rc.isFilesystemOnly()) { | |||
@@ -577,7 +575,7 @@ public class Copy extends Task { | |||
Resource[] nonFiles = | |||
(Resource[]) nonFileResources.toArray(new Resource[nonFileResources.size()]); | |||
// restrict to out-of-date resources | |||
Map map = scan(nonFiles, destDir); | |||
Map<Resource, String[]> map = scan(nonFiles, destDir); | |||
if (singleResource != null) { | |||
map.put(singleResource, | |||
new String[] { destFile.getAbsolutePath() }); | |||
@@ -645,21 +643,19 @@ public class Copy extends Task { | |||
} | |||
private void iterateOverBaseDirs( | |||
HashSet baseDirs, HashMap dirsByBasedir, HashMap filesByBasedir) { | |||
HashSet<File> baseDirs, HashMap<File, List<String>> dirsByBasedir, HashMap<File, List<String>> filesByBasedir) { | |||
Iterator iter = baseDirs.iterator(); | |||
while (iter.hasNext()) { | |||
File f = (File) iter.next(); | |||
List files = (List) filesByBasedir.get(f); | |||
List dirs = (List) dirsByBasedir.get(f); | |||
for (File f : baseDirs) { | |||
List<String> files = filesByBasedir.get(f); | |||
List<String> dirs = dirsByBasedir.get(f); | |||
String[] srcFiles = new String[0]; | |||
if (files != null) { | |||
srcFiles = (String[]) files.toArray(srcFiles); | |||
srcFiles = files.toArray(srcFiles); | |||
} | |||
String[] srcDirs = new String[0]; | |||
if (dirs != null) { | |||
srcDirs = (String[]) dirs.toArray(srcDirs); | |||
srcDirs = dirs.toArray(srcDirs); | |||
} | |||
scan(f == NULL_FILE_PLACEHOLDER ? null : f, destDir, srcFiles, | |||
srcDirs); | |||
@@ -755,7 +751,7 @@ public class Copy extends Task { | |||
* | |||
* @since Ant 1.7 | |||
*/ | |||
protected Map scan(Resource[] fromResources, File toDir) { | |||
protected Map<Resource, String[]> scan(Resource[] fromResources, File toDir) { | |||
return buildMap(fromResources, toDir, getMapper()); | |||
} | |||
@@ -769,10 +765,10 @@ public class Copy extends Task { | |||
* @param map a map of source file to array of destination files. | |||
*/ | |||
protected void buildMap(File fromDir, File toDir, String[] names, | |||
FileNameMapper mapper, Hashtable map) { | |||
FileNameMapper mapper, Hashtable<String, String[]> map) { | |||
String[] toCopy = null; | |||
if (forceOverwrite) { | |||
Vector v = new Vector(); | |||
Vector<String> v = new Vector<String>(); | |||
for (int i = 0; i < names.length; i++) { | |||
if (mapper.mapFileName(names[i]) != null) { | |||
v.addElement(names[i]); | |||
@@ -810,12 +806,12 @@ public class Copy extends Task { | |||
* @return a map of source resource to array of destination files. | |||
* @since Ant 1.7 | |||
*/ | |||
protected Map buildMap(Resource[] fromResources, final File toDir, | |||
protected Map<Resource, String[]> buildMap(Resource[] fromResources, final File toDir, | |||
FileNameMapper mapper) { | |||
HashMap map = new HashMap(); | |||
HashMap<Resource, String[]> map = new HashMap<Resource, String[]>(); | |||
Resource[] toCopy = null; | |||
if (forceOverwrite) { | |||
Vector v = new Vector(); | |||
Vector<Resource> v = new Vector<Resource>(); | |||
for (int i = 0; i < fromResources.length; i++) { | |||
if (mapper.mapFileName(fromResources[i].getName()) != null) { | |||
v.addElement(fromResources[i]); | |||
@@ -868,10 +864,9 @@ public class Copy extends Task { | |||
+ " file" + (fileCopyMap.size() == 1 ? "" : "s") | |||
+ " to " + destDir.getAbsolutePath()); | |||
Enumeration e = fileCopyMap.keys(); | |||
while (e.hasMoreElements()) { | |||
String fromFile = (String) e.nextElement(); | |||
String[] toFiles = (String[]) fileCopyMap.get(fromFile); | |||
for (Map.Entry<String, String[]> e : fileCopyMap.entrySet()) { | |||
String fromFile = e.getKey(); | |||
String[] toFiles = e.getValue(); | |||
for (int i = 0; i < toFiles.length; i++) { | |||
String toFile = toFiles[i]; | |||
@@ -889,10 +884,8 @@ public class Copy extends Task { | |||
executionFilters | |||
.addFilterSet(getProject().getGlobalFilterSet()); | |||
} | |||
for (Enumeration filterEnum = filterSets.elements(); | |||
filterEnum.hasMoreElements();) { | |||
executionFilters | |||
.addFilterSet((FilterSet) filterEnum.nextElement()); | |||
for (FilterSet filterSet : filterSets) { | |||
executionFilters.addFilterSet(filterSet); | |||
} | |||
fileUtils.copyFile(new File(fromFile), new File(toFile), | |||
executionFilters, | |||
@@ -917,10 +910,8 @@ public class Copy extends Task { | |||
} | |||
} | |||
if (includeEmpty) { | |||
Enumeration e = dirCopyMap.elements(); | |||
int createCount = 0; | |||
while (e.hasMoreElements()) { | |||
String[] dirs = (String[]) e.nextElement(); | |||
for (String[] dirs : dirCopyMap.values()) { | |||
for (int i = 0; i < dirs.length; i++) { | |||
File d = new File(dirs[i]); | |||
if (!d.exists()) { | |||
@@ -951,34 +942,26 @@ public class Copy extends Task { | |||
* @param map a map of source resource to array of destination files. | |||
* @since Ant 1.7 | |||
*/ | |||
protected void doResourceOperations(Map map) { | |||
protected void doResourceOperations(Map<Resource, String[]> map) { | |||
if (map.size() > 0) { | |||
log("Copying " + map.size() | |||
+ " resource" + (map.size() == 1 ? "" : "s") | |||
+ " to " + destDir.getAbsolutePath()); | |||
Iterator iter = map.keySet().iterator(); | |||
while (iter.hasNext()) { | |||
Resource fromResource = (Resource) iter.next(); | |||
String[] toFiles = (String[]) map.get(fromResource); | |||
for (int i = 0; i < toFiles.length; i++) { | |||
String toFile = toFiles[i]; | |||
for (Map.Entry<Resource, String[]> e : map.entrySet()) { | |||
Resource fromResource = e.getKey(); | |||
for (String toFile : e.getValue()) { | |||
try { | |||
log("Copying " + fromResource + " to " + toFile, | |||
verbosity); | |||
FilterSetCollection executionFilters = | |||
new FilterSetCollection(); | |||
FilterSetCollection executionFilters = new FilterSetCollection(); | |||
if (filtering) { | |||
executionFilters | |||
.addFilterSet(getProject().getGlobalFilterSet()); | |||
} | |||
for (Enumeration filterEnum = filterSets.elements(); | |||
filterEnum.hasMoreElements();) { | |||
executionFilters | |||
.addFilterSet((FilterSet) filterEnum.nextElement()); | |||
for (FilterSet filterSet : filterSets) { | |||
executionFilters.addFilterSet(filterSet); | |||
} | |||
ResourceUtils.copyResource(fromResource, | |||
new FileResource(destDir, | |||
@@ -1032,12 +1015,12 @@ public class Copy extends Task { | |||
* Adds the given strings to a list contained in the given map. | |||
* The file is the key into the map. | |||
*/ | |||
private static void add(File baseDir, String[] names, Map m) { | |||
private static void add(File baseDir, String[] names, Map<File, List<String>> m) { | |||
if (names != null) { | |||
baseDir = getKeyFile(baseDir); | |||
List l = (List) m.get(baseDir); | |||
List<String> l = m.get(baseDir); | |||
if (l == null) { | |||
l = new ArrayList(names.length); | |||
l = new ArrayList<String>(names.length); | |||
m.put(baseDir, l); | |||
} | |||
l.addAll(java.util.Arrays.asList(names)); | |||
@@ -1048,7 +1031,7 @@ public class Copy extends Task { | |||
* Adds the given string to a list contained in the given map. | |||
* The file is the key into the map. | |||
*/ | |||
private static void add(File baseDir, String name, Map m) { | |||
private static void add(File baseDir, String name, Map<File, List<String>> m) { | |||
if (name != null) { | |||
add(baseDir, new String[] {name}, m); | |||
} | |||
@@ -20,8 +20,9 @@ package org.apache.tools.ant.taskdefs; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.util.Enumeration; | |||
import java.util.Hashtable; | |||
import java.util.Map; | |||
import org.apache.tools.ant.BuildException; | |||
import org.apache.tools.ant.DirectoryScanner; | |||
import org.apache.tools.ant.Project; | |||
@@ -41,7 +42,7 @@ public class Copydir extends MatchingTask { | |||
private boolean filtering = false; | |||
private boolean flatten = false; | |||
private boolean forceOverwrite = false; | |||
private Hashtable filecopyList = new Hashtable(); | |||
private Hashtable<String, String> filecopyList = new Hashtable<String, String>(); | |||
/** | |||
* The src attribute | |||
@@ -124,10 +125,9 @@ public class Copydir extends MatchingTask { | |||
log("Copying " + filecopyList.size() + " file" | |||
+ (filecopyList.size() == 1 ? "" : "s") | |||
+ " to " + destDir.getAbsolutePath()); | |||
Enumeration e = filecopyList.keys(); | |||
while (e.hasMoreElements()) { | |||
String fromFile = (String) e.nextElement(); | |||
String toFile = (String) filecopyList.get(fromFile); | |||
for (Map.Entry<String, String> e : filecopyList.entrySet()) { | |||
String fromFile = e.getKey(); | |||
String toFile = e.getValue(); | |||
try { | |||
getProject().copyFile(fromFile, toFile, filtering, | |||
forceOverwrite); | |||
@@ -22,16 +22,17 @@ import java.io.File; | |||
import java.io.IOException; | |||
import java.io.InputStream; | |||
import java.net.URL; | |||
import java.util.Collections; | |||
import java.util.Enumeration; | |||
import java.util.HashMap; | |||
import java.util.Locale; | |||
import java.util.Map; | |||
import java.util.NoSuchElementException; | |||
import java.util.Properties; | |||
import org.apache.tools.ant.AntTypeDefinition; | |||
import org.apache.tools.ant.ComponentHelper; | |||
import org.apache.tools.ant.BuildException; | |||
import org.apache.tools.ant.Location; | |||
import org.apache.tools.ant.Project; | |||
import org.apache.tools.ant.ProjectHelper; | |||
import org.apache.tools.ant.MagicNames; | |||
@@ -53,15 +54,12 @@ public abstract class Definer extends DefBase { | |||
*/ | |||
private static final String ANTLIB_XML = "/antlib.xml"; | |||
private static class ResourceStack extends ThreadLocal { | |||
public Object initialValue() { | |||
return new HashMap(); | |||
private static final ThreadLocal<Map<URL, Location>> RESOURCE_STACK = new ThreadLocal<Map<URL, Location>>() { | |||
protected Map<URL, Location> initialValue() { | |||
return new HashMap<URL, Location>(); | |||
} | |||
Map getStack() { | |||
return (Map) get(); | |||
} | |||
} | |||
private static ResourceStack resourceStack = new ResourceStack(); | |||
}; | |||
private String name; | |||
private String classname; | |||
private File file; | |||
@@ -74,8 +72,8 @@ public abstract class Definer extends DefBase { | |||
private String adapter; | |||
private String adaptTo; | |||
private Class adapterClass; | |||
private Class adaptToClass; | |||
private Class<?> adapterClass; | |||
private Class<?> adaptToClass; | |||
/** | |||
* Enumerated type for onError attribute | |||
@@ -243,32 +241,19 @@ public abstract class Definer extends DefBase { | |||
+ "together with file or resource."; | |||
throw new BuildException(msg, getLocation()); | |||
} | |||
Enumeration/*<URL>*/ urls = null; | |||
if (file != null) { | |||
final Enumeration<URL> urls; | |||
if (file == null) { | |||
urls = resourceToURLs(al); | |||
} else { | |||
final URL url = fileToURL(); | |||
if (url == null) { | |||
return; | |||
} | |||
urls = new Enumeration() { | |||
private boolean more = true; | |||
public boolean hasMoreElements() { | |||
return more; | |||
} | |||
public Object nextElement() throws NoSuchElementException { | |||
if (more) { | |||
more = false; | |||
return url; | |||
} else { | |||
throw new NoSuchElementException(); | |||
} | |||
} | |||
}; | |||
} else { | |||
urls = resourceToURLs(al); | |||
urls = Collections.enumeration(Collections.singleton(url)); | |||
} | |||
while (urls.hasMoreElements()) { | |||
URL url = (URL) urls.nextElement(); | |||
URL url = urls.nextElement(); | |||
int fmt = this.format; | |||
if (url.toString().toLowerCase(Locale.ENGLISH).endsWith(".xml")) { | |||
@@ -279,19 +264,19 @@ public abstract class Definer extends DefBase { | |||
loadProperties(al, url); | |||
break; | |||
} else { | |||
if (resourceStack.getStack().get(url) != null) { | |||
if (RESOURCE_STACK.get().get(url) != null) { | |||
log("Warning: Recursive loading of " + url | |||
+ " ignored" | |||
+ " at " + getLocation() | |||
+ " originally loaded at " | |||
+ resourceStack.getStack().get(url), | |||
+ RESOURCE_STACK.get().get(url), | |||
Project.MSG_WARN); | |||
} else { | |||
try { | |||
resourceStack.getStack().put(url, getLocation()); | |||
RESOURCE_STACK.get().put(url, getLocation()); | |||
loadAntlib(al, url); | |||
} finally { | |||
resourceStack.getStack().remove(url); | |||
RESOURCE_STACK.get().remove(url); | |||
} | |||
} | |||
} | |||
@@ -369,8 +354,8 @@ public abstract class Definer extends DefBase { | |||
return null; | |||
} | |||
private Enumeration/*<URL>*/ resourceToURLs(ClassLoader classLoader) { | |||
Enumeration ret; | |||
private Enumeration<URL> resourceToURLs(ClassLoader classLoader) { | |||
Enumeration<URL> ret; | |||
try { | |||
ret = classLoader.getResources(resource); | |||
} catch (IOException e) { | |||
@@ -416,7 +401,7 @@ public abstract class Definer extends DefBase { | |||
} | |||
Properties props = new Properties(); | |||
props.load(is); | |||
Enumeration keys = props.keys(); | |||
Enumeration<?> keys = props.keys(); | |||
while (keys.hasMoreElements()) { | |||
name = ((String) keys.nextElement()); | |||
classname = props.getProperty(name); | |||
@@ -548,7 +533,7 @@ public abstract class Definer extends DefBase { | |||
* | |||
* @param adapterClass the class to use to adapt the definition class | |||
*/ | |||
protected void setAdapterClass(Class adapterClass) { | |||
protected void setAdapterClass(Class<?> adapterClass) { | |||
this.adapterClass = adapterClass; | |||
} | |||
@@ -570,7 +555,7 @@ public abstract class Definer extends DefBase { | |||
* | |||
* @param adaptToClass the class for adaptor. | |||
*/ | |||
protected void setAdaptToClass(Class adaptToClass) { | |||
protected void setAdaptToClass(Class<?> adaptToClass) { | |||
this.adaptToClass = adaptToClass; | |||
} | |||
@@ -585,7 +570,7 @@ public abstract class Definer extends DefBase { | |||
*/ | |||
protected void addDefinition(ClassLoader al, String name, String classname) | |||
throws BuildException { | |||
Class cl = null; | |||
Class<?> cl = null; | |||
try { | |||
try { | |||
name = ProjectHelper.genComponentName(getURI(), name); | |||
@@ -81,8 +81,8 @@ public class Delete extends MatchingTask { | |||
private static final ResourceSelector EXISTS = new Exists(); | |||
private static class ReverseDirs implements ResourceCollection { | |||
static final Comparator REVERSE = new Comparator() { | |||
public int compare(Object foo, Object bar) { | |||
static final Comparator<Comparable<?>> REVERSE = new Comparator<Comparable<?>>() { | |||
public int compare(Comparable<?> foo, Comparable<?> bar) { | |||
return ((Comparable) foo).compareTo(bar) * -1; | |||
} | |||
}; | |||
@@ -105,7 +105,7 @@ public class Delete extends MatchingTask { | |||
// CheckStyle:VisibilityModifier OFF - bc | |||
protected File file = null; | |||
protected File dir = null; | |||
protected Vector filesets = new Vector(); | |||
protected Vector<FileSet> filesets = new Vector<FileSet>(); | |||
protected boolean usedMatchingTask = false; | |||
// by default, remove matching empty dirs | |||
protected boolean includeEmpty = false; | |||
@@ -20,11 +20,8 @@ package org.apache.tools.ant.taskdefs; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.util.Enumeration; | |||
import java.util.Locale; | |||
import java.util.Map; | |||
import java.util.Vector; | |||
import org.apache.tools.ant.BuildException; | |||
import org.apache.tools.ant.Project; | |||
import org.apache.tools.ant.Task; | |||
@@ -721,8 +718,8 @@ public class ExecTask extends Task { | |||
return line.substring("PATH=".length()); | |||
} | |||
private String getPath(Map/*<String, String>*/ map) { | |||
String p = (String) map.get("PATH"); | |||
return p != null ? p : (String) map.get("Path"); | |||
private String getPath(Map<String, String> map) { | |||
String p = map.get("PATH"); | |||
return p != null ? p : map.get("Path"); | |||
} | |||
} |
@@ -26,9 +26,9 @@ import java.io.OutputStream; | |||
import java.io.StringReader; | |||
import java.util.ArrayList; | |||
import java.util.HashMap; | |||
import java.util.Iterator; | |||
import java.util.LinkedHashMap; | |||
import java.util.Map; | |||
import java.util.Map.Entry; | |||
import java.util.Vector; | |||
import org.apache.tools.ant.BuildException; | |||
@@ -43,7 +43,7 @@ import org.apache.tools.ant.util.StringUtils; | |||
/** | |||
* Runs an external program. | |||
* | |||
* | |||
* @since Ant 1.2 | |||
*/ | |||
public class Execute { | |||
@@ -68,7 +68,7 @@ public class Execute { | |||
private boolean useVMLauncher = true; | |||
private static String antWorkingDirectory = System.getProperty("user.dir"); | |||
private static Map/*<String, String>*/ procEnvironment = null; | |||
private static Map<String, String> procEnvironment = null; | |||
/** Used to destroy processes when the VM exits. */ | |||
private static ProcessDestroyer processDestroyer = new ProcessDestroyer(); | |||
@@ -85,7 +85,7 @@ public class Execute { | |||
/** | |||
* Set whether or not you want the process to be spawned. | |||
* Default is not spawned. | |||
* | |||
* | |||
* @param spawn if true you do not want Ant | |||
* to wait for the end of the process. | |||
* Has no influence in here, the calling task contains | |||
@@ -101,27 +101,29 @@ public class Execute { | |||
/** | |||
* Find the list of environment variables for this process. | |||
* | |||
* | |||
* @return a map containing the environment variables. | |||
* @since Ant 1.8.2 | |||
*/ | |||
public static synchronized Map/*<String,String>*/ getEnvironmentVariables() { | |||
public static synchronized Map<String,String> getEnvironmentVariables() { | |||
if (procEnvironment != null) { | |||
return procEnvironment; | |||
} | |||
if (JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_1_5) | |||
&& !Os.isFamily("openvms")) { | |||
try { | |||
procEnvironment = (Map) System.class | |||
@SuppressWarnings("unchecked") | |||
final Map<String, String> cast = (Map<String, String>) System.class | |||
.getMethod("getenv", new Class[0]) | |||
.invoke(null, new Object[0]); | |||
procEnvironment = cast; | |||
return procEnvironment; | |||
} catch (Exception x) { | |||
x.printStackTrace(); | |||
} | |||
} | |||
procEnvironment = new LinkedHashMap(); | |||
procEnvironment = new LinkedHashMap<String, String>(); | |||
try { | |||
ByteArrayOutputStream out = new ByteArrayOutputStream(); | |||
Execute exe = new Execute(new PumpStreamHandler(out)); | |||
@@ -174,17 +176,15 @@ public class Execute { | |||
/** | |||
* Find the list of environment variables for this process. | |||
* | |||
* | |||
* @return a vector containing the environment variables. | |||
* The vector elements are strings formatted like variable = value. | |||
* @deprecated use #getEnvironmentVariables instead | |||
*/ | |||
@Deprecated | |||
public static synchronized Vector getProcEnvironment() { | |||
Vector v = new Vector(); | |||
Iterator it = getEnvironmentVariables().entrySet().iterator(); | |||
while (it.hasNext()) { | |||
Map.Entry entry = (Map.Entry) it.next(); | |||
public static synchronized Vector<String> getProcEnvironment() { | |||
Vector<String> v = new Vector<String>(); | |||
for (Entry<String, String> entry : getEnvironmentVariables().entrySet()) { | |||
v.add(entry.getKey() + "=" + entry.getValue()); | |||
} | |||
return v; | |||
@@ -194,7 +194,7 @@ public class Execute { | |||
* This is the operation to get our environment. | |||
* It is a notorious troublespot pre-Java1.5, and should be approached | |||
* with extreme caution. | |||
* | |||
* | |||
* @return | |||
*/ | |||
private static String[] getProcEnvCommand() { | |||
@@ -240,7 +240,7 @@ public class Execute { | |||
* ByteArrayOutputStream#toString doesn't seem to work reliably on | |||
* OS/390, at least not the way we use it in the execution | |||
* context. | |||
* | |||
* | |||
* @param bos the output stream that one wants to read. | |||
* @return the output stream as a string, read with | |||
* special encodings in the case of z/os and os/400. | |||
@@ -273,7 +273,7 @@ public class Execute { | |||
/** | |||
* Creates a new execute object. | |||
* | |||
* | |||
* @param streamHandler the stream handler used to handle the input and | |||
* output streams of the subprocess. | |||
*/ | |||
@@ -283,7 +283,7 @@ public class Execute { | |||
/** | |||
* Creates a new execute object. | |||
* | |||
* | |||
* @param streamHandler the stream handler used to handle the input and | |||
* output streams of the subprocess. | |||
* @param watchdog a watchdog for the subprocess or <code>null</code> | |||
@@ -302,7 +302,7 @@ public class Execute { | |||
/** | |||
* Set the stream handler to use. | |||
* | |||
* | |||
* @param streamHandler ExecuteStreamHandler. | |||
* @since Ant 1.6 | |||
*/ | |||
@@ -312,7 +312,7 @@ public class Execute { | |||
/** | |||
* Returns the commandline used to create a subprocess. | |||
* | |||
* | |||
* @return the commandline used to create a subprocess. | |||
*/ | |||
public String[] getCommandline() { | |||
@@ -321,7 +321,7 @@ public class Execute { | |||
/** | |||
* Sets the commandline of the subprocess to launch. | |||
* | |||
* | |||
* @param commandline the commandline of the subprocess to launch. | |||
*/ | |||
public void setCommandline(String[] commandline) { | |||
@@ -330,7 +330,7 @@ public class Execute { | |||
/** | |||
* Set whether to propagate the default environment or not. | |||
* | |||
* | |||
* @param newenv whether to propagate the process environment. | |||
*/ | |||
public void setNewenvironment(boolean newenv) { | |||
@@ -339,7 +339,7 @@ public class Execute { | |||
/** | |||
* Returns the environment used to create a subprocess. | |||
* | |||
* | |||
* @return the environment used to create a subprocess. | |||
*/ | |||
public String[] getEnvironment() { | |||
@@ -349,7 +349,7 @@ public class Execute { | |||
/** | |||
* Sets the environment variables for the subprocess to launch. | |||
* | |||
* | |||
* @param env array of Strings, each element of which has | |||
* an environment variable settings in format <em>key=value</em>. | |||
*/ | |||
@@ -364,7 +364,7 @@ public class Execute { | |||
* Windows NT in which case a cmd.exe is spawned, | |||
* or MRJ and setting user.dir works, or JDK 1.3 and there is | |||
* official support in java.lang.Runtime. | |||
* | |||
* | |||
* @param wd the working directory of the process. | |||
*/ | |||
public void setWorkingDirectory(File wd) { | |||
@@ -375,7 +375,7 @@ public class Execute { | |||
/** | |||
* Return the working directory. | |||
* | |||
* | |||
* @return the directory as a File. | |||
* @since Ant 1.7 | |||
*/ | |||
@@ -386,7 +386,7 @@ public class Execute { | |||
/** | |||
* Set the name of the antRun script using the project's value. | |||
* | |||
* | |||
* @param project the current project. | |||
* @throws BuildException not clear when it is going to throw an exception, but | |||
* it is the method's signature. | |||
@@ -400,7 +400,7 @@ public class Execute { | |||
* the OS's shell. In some cases and operating systems using the shell will | |||
* allow the shell to perform additional processing such as associating an | |||
* executable with a script, etc. | |||
* | |||
* | |||
* @param useVMLauncher true if exec should launch through the VM, | |||
* false if the shell should be used to launch the | |||
* command. | |||
@@ -411,7 +411,7 @@ public class Execute { | |||
/** | |||
* Creates a process that runs a command. | |||
* | |||
* | |||
* @param project the Project, only used for logging purposes, may be null. | |||
* @param command the command to run. | |||
* @param env the environment for the command. | |||
@@ -436,7 +436,7 @@ public class Execute { | |||
/** | |||
* Runs a process defined by the command line and returns its exit status. | |||
* | |||
* | |||
* @return the exit status of the subprocess or <code>INVALID</code>. | |||
* @exception java.io.IOException The exception is thrown, if launching | |||
* of the subprocess failed. | |||
@@ -493,7 +493,7 @@ public class Execute { | |||
/** | |||
* Starts a process defined by the command line. | |||
* Ant will not wait for this process, nor log its output. | |||
* | |||
* | |||
* @throws java.io.IOException The exception is thrown, if launching | |||
* of the subprocess failed. | |||
* @since Ant 1.6 | |||
@@ -532,7 +532,7 @@ public class Execute { | |||
/** | |||
* Wait for a given process. | |||
* | |||
* | |||
* @param process the process one wants to wait for. | |||
*/ | |||
protected void waitFor(Process process) { | |||
@@ -546,7 +546,7 @@ public class Execute { | |||
/** | |||
* Set the exit value. | |||
* | |||
* | |||
* @param value exit value of the process. | |||
*/ | |||
protected void setExitValue(int value) { | |||
@@ -555,7 +555,7 @@ public class Execute { | |||
/** | |||
* Query the exit value of the process. | |||
* | |||
* | |||
* @return the exit value or Execute.INVALID if no exit value has | |||
* been received. | |||
*/ | |||
@@ -574,7 +574,7 @@ public class Execute { | |||
* return 0 if successful (like on any other platform), but this | |||
* signals a failure on OpenVMS. So if you execute a new Java VM | |||
* on OpenVMS, you cannot trust this method.</p> | |||
* | |||
* | |||
* @param exitValue the exit value (return code) to be checked. | |||
* @return <code>true</code> if <code>exitValue</code> signals a failure. | |||
*/ | |||
@@ -587,7 +587,7 @@ public class Execute { | |||
/** | |||
* Did this execute return in a failure. | |||
* | |||
* | |||
* @see #isFailure(int) | |||
* @return true if and only if the exit code is interpreted as a failure | |||
* @since Ant1.7 | |||
@@ -598,7 +598,7 @@ public class Execute { | |||
/** | |||
* Test for an untimely death of the process. | |||
* | |||
* | |||
* @return true if a watchdog had to kill the process. | |||
* @since Ant 1.5 | |||
*/ | |||
@@ -608,7 +608,7 @@ public class Execute { | |||
/** | |||
* Patch the current environment with the new values from the user. | |||
* | |||
* | |||
* @return the patched environment. | |||
*/ | |||
private String[] patchEnvironment() { | |||
@@ -618,8 +618,8 @@ public class Execute { | |||
if (Os.isFamily("openvms")) { | |||
return env; | |||
} | |||
Map/*<String, String>*/ osEnv = | |||
new LinkedHashMap(getEnvironmentVariables()); | |||
Map<String, String> osEnv = | |||
new LinkedHashMap<String, String>(getEnvironmentVariables()); | |||
for (int i = 0; i < env.length; i++) { | |||
String keyValue = env[i]; | |||
String key = keyValue.substring(0, keyValue.indexOf('=')); | |||
@@ -630,8 +630,7 @@ public class Execute { | |||
if (osEnv.remove(key) == null && environmentCaseInSensitive) { | |||
// not found, maybe perform a case insensitive search | |||
for (Iterator it = osEnv.keySet().iterator(); it.hasNext();) { | |||
String osEnvItem = (String) it.next(); | |||
for (String osEnvItem : osEnv.keySet()) { | |||
// Nb: using default locale as key is a env name | |||
if (osEnvItem.toLowerCase().equals(key.toLowerCase())) { | |||
// Use the original casiness of the key | |||
@@ -645,18 +644,17 @@ public class Execute { | |||
osEnv.put(key, keyValue.substring(key.length() + 1)); | |||
} | |||
ArrayList l = new ArrayList(); | |||
for (Iterator it = osEnv.entrySet().iterator(); it.hasNext();) { | |||
Map.Entry entry = (Map.Entry) it.next(); | |||
ArrayList<String> l = new ArrayList<String>(); | |||
for (Entry<String, String> entry : osEnv.entrySet()) { | |||
l.add(entry.getKey() + "=" + entry.getValue()); | |||
} | |||
return (String[]) (l.toArray(new String[osEnv.size()])); | |||
return l.toArray(new String[osEnv.size()]); | |||
} | |||
/** | |||
* A utility method that runs an external command. Writes the output and | |||
* error streams of the command to the project log. | |||
* | |||
* | |||
* @param task The task that the command is part of. Used for logging | |||
* @param cmdline The command to execute. | |||
* @throws BuildException if the command does not exit successfully. | |||
@@ -683,7 +681,7 @@ public class Execute { | |||
/** | |||
* Close the streams belonging to the given Process. | |||
* | |||
* | |||
* @param process the <code>Process</code>. | |||
*/ | |||
public static void closeStreams(Process process) { | |||
@@ -703,9 +701,9 @@ public class Execute { | |||
* multiple equivalence names are mapped to a variable with multiple | |||
* values separated by a comma (,). | |||
*/ | |||
private static Map getVMSLogicals(BufferedReader in) | |||
private static Map<String, String> getVMSLogicals(BufferedReader in) | |||
throws IOException { | |||
HashMap logicals = new HashMap(); | |||
HashMap<String, String> logicals = new HashMap<String, String>(); | |||
String logName = null, logValue = null, newLogName; | |||
String line = null; | |||
// CheckStyle:MagicNumber OFF | |||
@@ -120,7 +120,7 @@ public class ExecuteJava implements Runnable, TimeoutObserver { | |||
if (sysProperties != null) { | |||
sysProperties.setSystem(); | |||
} | |||
Class target = null; | |||
Class<?> target = null; | |||
try { | |||
if (classpath == null) { | |||
target = Class.forName(classname); | |||
@@ -59,7 +59,7 @@ public class ExecuteOn extends ExecTask { | |||
// switching type to "dir" when we encounter a DirSet that would | |||
// be more difficult to achieve otherwise. | |||
protected Vector filesets = new Vector(); // contains AbstractFileSet | |||
protected Vector<AbstractFileSet> filesets = new Vector<AbstractFileSet>(); // contains AbstractFileSet | |||
// (both DirSet and FileSet) | |||
private Union resources = null; | |||
private boolean relative = false; | |||
@@ -349,12 +349,12 @@ public class ExecuteOn extends ExecTask { | |||
int totalDirs = 0; | |||
boolean haveExecuted = false; | |||
try { | |||
Vector fileNames = new Vector(); | |||
Vector baseDirs = new Vector(); | |||
Vector<String> fileNames = new Vector<String>(); | |||
Vector<File> baseDirs = new Vector<File>(); | |||
final int size = filesets.size(); | |||
for (int i = 0; i < size; i++) { | |||
String currentType = type; | |||
AbstractFileSet fs = (AbstractFileSet) filesets.elementAt(i); | |||
AbstractFileSet fs = filesets.elementAt(i); | |||
if (fs instanceof DirSet) { | |||
if (!FileDirBoth.DIR.equals(type)) { | |||
log("Found a nested dirset but type is " + type + ". " | |||
@@ -523,16 +523,16 @@ public class ExecuteOn extends ExecTask { | |||
*/ | |||
protected String[] getCommandline(String[] srcFiles, File[] baseDirs) { | |||
final char fileSeparator = File.separatorChar; | |||
Vector targets = new Vector(); | |||
Vector<String> targets = new Vector<String>(); | |||
if (targetFilePos != null) { | |||
HashSet addedFiles = new HashSet(); | |||
HashSet<String> addedFiles = new HashSet<String>(); | |||
for (int i = 0; i < srcFiles.length; i++) { | |||
String[] subTargets = mapper.mapFileName(srcFiles[i]); | |||
if (subTargets != null) { | |||
for (int j = 0; j < subTargets.length; j++) { | |||
String name = null; | |||
if (!relative) { | |||
name = (new File(destDir, subTargets[j])).getAbsolutePath(); | |||
name = new File(destDir, subTargets[j]).getAbsolutePath(); | |||
} else { | |||
name = subTargets[j]; | |||
} | |||
@@ -693,8 +693,8 @@ public class ExecuteOn extends ExecTask { | |||
* @throws BuildException on other errors. | |||
* @since Ant 1.6 | |||
*/ | |||
protected void runParallel(Execute exe, Vector fileNames, | |||
Vector baseDirs) | |||
protected void runParallel(Execute exe, Vector<String> fileNames, | |||
Vector<File> baseDirs) | |||
throws IOException, BuildException { | |||
String[] s = new String[fileNames.size()]; | |||
fileNames.copyInto(s); | |||
@@ -63,7 +63,7 @@ public class Expand extends Task { | |||
private File source; // req | |||
private boolean overwrite = true; | |||
private Mapper mapperElement = null; | |||
private Vector patternsets = new Vector(); | |||
private Vector<PatternSet> patternsets = new Vector<PatternSet>(); | |||
private Union resources = new Union(); | |||
private boolean resourcesSpecified = false; | |||
private boolean failOnEmptyArchive = false; | |||
@@ -167,10 +167,10 @@ public class Expand extends Task { | |||
try { | |||
zf = new ZipFile(srcF, encoding, scanForUnicodeExtraFields); | |||
boolean empty = true; | |||
Enumeration e = zf.getEntries(); | |||
Enumeration<ZipEntry> e = zf.getEntries(); | |||
while (e.hasMoreElements()) { | |||
empty = false; | |||
ZipEntry ze = (ZipEntry) e.nextElement(); | |||
ZipEntry ze = e.nextElement(); | |||
InputStream is = null; | |||
log("extracting " + ze.getName(), Project.MSG_DEBUG); | |||
try { | |||
@@ -254,11 +254,11 @@ public class Expand extends Task { | |||
.replace('\\', File.separatorChar); | |||
boolean included = false; | |||
Set includePatterns = new HashSet(); | |||
Set excludePatterns = new HashSet(); | |||
Set<String> includePatterns = new HashSet<String>(); | |||
Set<String> excludePatterns = new HashSet<String>(); | |||
final int size = patternsets.size(); | |||
for (int v = 0; v < size; v++) { | |||
PatternSet p = (PatternSet) patternsets.elementAt(v); | |||
PatternSet p = patternsets.elementAt(v); | |||
String[] incls = p.getIncludePatterns(getProject()); | |||
if (incls == null || incls.length == 0) { | |||
// no include pattern implicitly means includes="**" | |||
@@ -288,15 +288,15 @@ public class Expand extends Task { | |||
} | |||
} | |||
for (Iterator iter = includePatterns.iterator(); | |||
for (Iterator<String> iter = includePatterns.iterator(); | |||
!included && iter.hasNext();) { | |||
String pattern = (String) iter.next(); | |||
String pattern = iter.next(); | |||
included = SelectorUtils.matchPath(pattern, name); | |||
} | |||
for (Iterator iter = excludePatterns.iterator(); | |||
for (Iterator<String> iter = excludePatterns.iterator(); | |||
included && iter.hasNext();) { | |||
String pattern = (String) iter.next(); | |||
String pattern = iter.next(); | |||
included = !SelectorUtils.matchPath(pattern, name); | |||
} | |||
@@ -95,7 +95,7 @@ public class FixCRLF extends MatchingTask implements ChainableReader { | |||
private File destDir = null; | |||
private File file; | |||
private FixCrLfFilter filter = new FixCrLfFilter(); | |||
private Vector fcv = null; | |||
private Vector<FilterChain> fcv = null; | |||
/** | |||
* Encoding to assume for the files | |||
@@ -349,7 +349,7 @@ public class FixCRLF extends MatchingTask implements ChainableReader { | |||
if (fcv == null) { | |||
FilterChain fc = new FilterChain(); | |||
fc.add(filter); | |||
fcv = new Vector(1); | |||
fcv = new Vector<FilterChain>(1); | |||
fcv.add(fc); | |||
} | |||
File tmpFile = FILE_UTILS.createTempFile("fixcrlf", "", null, true, false); | |||
@@ -390,7 +390,7 @@ public class FixCRLF extends MatchingTask implements ChainableReader { | |||
* Deprecated, the functionality has been moved to filters.FixCrLfFilter. | |||
* @deprecated since 1.7.0. | |||
*/ | |||
protected class OneLiner implements Enumeration { | |||
protected class OneLiner implements Enumeration<Object> { | |||
private static final int UNDEF = -1; | |||
private static final int NOTJAVA = 0; | |||
private static final int LOOKING = 1; | |||
@@ -78,7 +78,7 @@ public class GenerateKey extends Task { | |||
* A class corresponding to the dname nested element. | |||
*/ | |||
public static class DistinguishedName { | |||
private Vector params = new Vector(); | |||
private Vector<DnameParam> params = new Vector<DnameParam>(); | |||
/** | |||
* Create a param nested element. | |||
@@ -95,7 +95,7 @@ public class GenerateKey extends Task { | |||
* Get the nested parameters. | |||
* @return an enumeration of the nested parameters. | |||
*/ | |||
public Enumeration getParams() { | |||
public Enumeration<DnameParam> getParams() { | |||
return params.elements(); | |||
} | |||
@@ -24,7 +24,6 @@ import java.net.InetAddress; | |||
import java.net.NetworkInterface; | |||
import java.util.Arrays; | |||
import java.util.Enumeration; | |||
import java.util.Iterator; | |||
import java.util.LinkedList; | |||
import java.util.List; | |||
@@ -35,7 +34,7 @@ import org.apache.tools.ant.Task; | |||
/** | |||
* Sets properties to the host provided, or localhost if no information is | |||
* provided. The default properties are NAME, FQDN, ADDR4, ADDR6; | |||
* | |||
* | |||
* @since Ant 1.8 | |||
* @ant.task category="utility" | |||
*/ | |||
@@ -71,12 +70,12 @@ public class HostInfo extends Task { | |||
private InetAddress best4; | |||
private List inetAddrs; | |||
private List<InetAddress> inetAddrs; | |||
/** | |||
* Set a prefix for the properties. If the prefix does not end with a "." | |||
* one is automatically added. | |||
* | |||
* | |||
* @param aPrefix | |||
* the prefix to use. | |||
* @since Ant 1.8 | |||
@@ -90,7 +89,7 @@ public class HostInfo extends Task { | |||
/** | |||
* Set the host to be retrieved. | |||
* | |||
* | |||
* @param aHost | |||
* the name or the address of the host, data for the local host | |||
* will be retrieved if omitted. | |||
@@ -102,7 +101,7 @@ public class HostInfo extends Task { | |||
/** | |||
* set the properties. | |||
* | |||
* | |||
* @throws BuildException | |||
* on error. | |||
*/ | |||
@@ -116,12 +115,11 @@ public class HostInfo extends Task { | |||
private void executeLocal() { | |||
try { | |||
Enumeration interfaces = NetworkInterface.getNetworkInterfaces(); | |||
inetAddrs = new LinkedList(); | |||
inetAddrs = new LinkedList<InetAddress>(); | |||
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); | |||
while (interfaces.hasMoreElements()) { | |||
NetworkInterface currentif = (NetworkInterface) interfaces | |||
.nextElement(); | |||
Enumeration addrs = currentif.getInetAddresses(); | |||
NetworkInterface currentif = interfaces.nextElement(); | |||
Enumeration<InetAddress> addrs = currentif.getInetAddresses(); | |||
while (addrs.hasMoreElements()) | |||
{ | |||
inetAddrs.add(addrs.nextElement()); | |||
@@ -153,16 +151,14 @@ public class HostInfo extends Task { | |||
setProperty(ADDR6, DEF_LOCAL_ADDR6); | |||
} | |||
} | |||
private boolean hasHostName(InetAddress addr) | |||
{ | |||
{ | |||
return !addr.getHostAddress().equals(addr.getCanonicalHostName()); | |||
} | |||
private void selectAddresses() { | |||
Iterator i = inetAddrs.iterator(); | |||
while (i.hasNext()) { | |||
InetAddress current = (InetAddress) i.next(); | |||
for (InetAddress current : inetAddrs) { | |||
if (!current.isMulticastAddress()) { | |||
if (current instanceof Inet4Address) { | |||
best4 = selectBestAddress(best4, current); | |||
@@ -171,7 +167,7 @@ public class HostInfo extends Task { | |||
} | |||
} | |||
} | |||
nameAddr = selectBestAddress(best4, best6); | |||
} | |||
@@ -199,7 +195,7 @@ public class HostInfo extends Task { | |||
best = current; | |||
} | |||
} else { | |||
// current is a "Global address", considered better than | |||
// current is a "Global address", considered better than | |||
// site local (and better than link local, loopback) | |||
// address with hostname resolved considered better than | |||
// address without hostname | |||
@@ -34,7 +34,6 @@ import org.apache.tools.ant.util.FileUtils; | |||
import java.io.File; | |||
import java.net.MalformedURLException; | |||
import java.net.URL; | |||
import java.util.Iterator; | |||
import java.util.Vector; | |||
/** | |||
@@ -142,7 +141,7 @@ public class ImportTask extends Task { | |||
throw new BuildException("import requires support in ProjectHelper"); | |||
} | |||
Vector importStack = helper.getImportStack(); | |||
Vector<Object> importStack = helper.getImportStack(); | |||
if (importStack.size() == 0) { | |||
// this happens if ant is used with a project | |||
@@ -166,7 +165,7 @@ public class ImportTask extends Task { | |||
private void importResource(ProjectHelper helper, | |||
Resource importedResource) { | |||
Vector importStack = helper.getImportStack(); | |||
Vector<Object> importStack = helper.getImportStack(); | |||
getProject().log("Importing file " + importedResource + " from " | |||
+ getLocation().getFileName(), Project.MSG_VERBOSE); | |||
@@ -290,7 +289,7 @@ public class ImportTask extends Task { | |||
/** | |||
* Sets a bunch of Thread-local ProjectHelper properties. | |||
* | |||
* | |||
* @since Ant 1.8.0 | |||
*/ | |||
private static void setProjectHelperProps(String prefix, | |||
@@ -218,7 +218,7 @@ public class Input extends Task { | |||
InputRequest request = null; | |||
if (validargs != null) { | |||
Vector accept = StringUtils.split(validargs, ','); | |||
Vector<String> accept = StringUtils.split(validargs, ','); | |||
request = new MultipleChoiceInputRequest(message, accept); | |||
} else { | |||
request = new InputRequest(message); | |||
@@ -102,7 +102,7 @@ public abstract class JDBCTask extends Task { | |||
* getting an OutOfMemoryError when calling this task | |||
* multiple times in a row. | |||
*/ | |||
private static Hashtable loaderMap = new Hashtable(HASH_TABLE_SIZE); | |||
private static Hashtable<String, AntClassLoader> LOADER_MAP = new Hashtable<String, AntClassLoader>(HASH_TABLE_SIZE); | |||
private boolean caching = true; | |||
@@ -156,7 +156,7 @@ public abstract class JDBCTask extends Task { | |||
* | |||
* @since Ant 1.8.0 | |||
*/ | |||
private List/*<Property>*/ connectionProperties = new ArrayList(); | |||
private List<Property> connectionProperties = new ArrayList<Property>(); | |||
/** | |||
* Sets the classpath for loading the driver. | |||
@@ -303,8 +303,8 @@ public abstract class JDBCTask extends Task { | |||
* Get the cache of loaders and drivers. | |||
* @return a hashtable | |||
*/ | |||
protected static Hashtable getLoaderMap() { | |||
return loaderMap; | |||
protected static Hashtable<String, AntClassLoader> getLoaderMap() { | |||
return LOADER_MAP; | |||
} | |||
/** | |||
@@ -352,9 +352,9 @@ public abstract class JDBCTask extends Task { | |||
info.put("user", getUserId()); | |||
info.put("password", getPassword()); | |||
for (Iterator props = connectionProperties.iterator(); | |||
for (Iterator<Property> props = connectionProperties.iterator(); | |||
props.hasNext(); ) { | |||
Property p = (Property) props.next(); | |||
Property p = props.next(); | |||
String name = p.getName(); | |||
String value = p.getValue(); | |||
if (name == null || value == null) { | |||
@@ -401,7 +401,7 @@ public abstract class JDBCTask extends Task { | |||
Driver driverInstance = null; | |||
try { | |||
Class dc; | |||
Class<?> dc; | |||
if (classpath != null) { | |||
// check first that it is not already loaded otherwise | |||
// consecutive runs seems to end into an OutOfMemoryError | |||
@@ -409,9 +409,9 @@ public abstract class JDBCTask extends Task { | |||
// several times. | |||
// this is far from being perfect but should work | |||
// in most cases. | |||
synchronized (loaderMap) { | |||
synchronized (LOADER_MAP) { | |||
if (caching) { | |||
loader = (AntClassLoader) loaderMap.get(driver); | |||
loader = (AntClassLoader) LOADER_MAP.get(driver); | |||
} | |||
if (loader == null) { | |||
log("Loading " + driver | |||
@@ -419,7 +419,7 @@ public abstract class JDBCTask extends Task { | |||
+ classpath, Project.MSG_VERBOSE); | |||
loader = getProject().createClassLoader(classpath); | |||
if (caching) { | |||
loaderMap.put(driver, loader); | |||
LOADER_MAP.put(driver, loader); | |||
} | |||
} else { | |||
log("Loading " + driver | |||
@@ -35,7 +35,6 @@ import java.util.Collections; | |||
import java.util.Comparator; | |||
import java.util.Enumeration; | |||
import java.util.HashSet; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import java.util.StringTokenizer; | |||
import java.util.TreeMap; | |||
@@ -76,7 +75,7 @@ public class Jar extends Zip { | |||
/** | |||
* List of all known SPI Services | |||
*/ | |||
private List serviceList = new ArrayList(); | |||
private List<Service> serviceList = new ArrayList<Service>(); | |||
/** merged manifests added through addConfiguredManifest */ | |||
private Manifest configuredManifest; | |||
@@ -140,7 +139,7 @@ public class Jar extends Zip { | |||
* | |||
* @since Ant 1.6 | |||
*/ | |||
private Vector rootEntries; | |||
private Vector<String> rootEntries; | |||
/** | |||
* Path containing jars that shall be indexed in addition to this archive. | |||
@@ -183,7 +182,7 @@ public class Jar extends Zip { | |||
archiveType = "jar"; | |||
emptyBehavior = "create"; | |||
setEncoding("UTF8"); | |||
rootEntries = new Vector(); | |||
rootEntries = new Vector<String>(); | |||
} | |||
/** | |||
@@ -339,9 +338,9 @@ public class Jar extends Zip { | |||
// must not use getEntry as "well behaving" applications | |||
// must accept the manifest in any capitalization | |||
Enumeration e = zf.entries(); | |||
Enumeration<? extends ZipEntry> e = zf.entries(); | |||
while (e.hasMoreElements()) { | |||
ZipEntry ze = (ZipEntry) e.nextElement(); | |||
ZipEntry ze = e.nextElement(); | |||
if (ze.getName().equalsIgnoreCase(MANIFEST_NAME)) { | |||
InputStreamReader isr = | |||
new InputStreamReader(zf.getInputStream(ze), "UTF-8"); | |||
@@ -380,9 +379,9 @@ public class Jar extends Zip { | |||
ZipFile zf = null; | |||
try { | |||
zf = new ZipFile(jarFile); | |||
Enumeration e = zf.entries(); | |||
Enumeration<? extends ZipEntry> e = zf.entries(); | |||
while (e.hasMoreElements()) { | |||
ZipEntry ze = (ZipEntry) e.nextElement(); | |||
ZipEntry ze = e.nextElement(); | |||
if (ze.getName().equalsIgnoreCase(INDEX_NAME)) { | |||
return true; | |||
} | |||
@@ -398,7 +397,7 @@ public class Jar extends Zip { | |||
} | |||
} | |||
} | |||
/** | |||
* Behavior when a Manifest is found in a zipfileset or zipgroupfileset file. | |||
* Valid values are "skip", "merge", and "mergewithoutmain". | |||
@@ -461,13 +460,7 @@ public class Jar extends Zip { | |||
* Write SPI Information to JAR | |||
*/ | |||
private void writeServices(ZipOutputStream zOut) throws IOException { | |||
Iterator serviceIterator; | |||
Service service; | |||
serviceIterator = serviceList.iterator(); | |||
while (serviceIterator.hasNext()) { | |||
service = (Service) serviceIterator.next(); | |||
for (Service service : serviceList) { | |||
InputStream is = null; | |||
try { | |||
is = service.getAsStream(); | |||
@@ -560,7 +553,7 @@ public class Jar extends Zip { | |||
private void writeManifest(ZipOutputStream zOut, Manifest manifest) | |||
throws IOException { | |||
for (Enumeration e = manifest.getWarnings(); | |||
for (Enumeration<String> e = manifest.getWarnings(); | |||
e.hasMoreElements();) { | |||
log("Manifest warning: " + e.nextElement(), | |||
Project.MSG_WARN); | |||
@@ -629,7 +622,7 @@ public class Jar extends Zip { | |||
// header newline | |||
writer.println(zipFile.getName()); | |||
writeIndexLikeList(new ArrayList(addedDirs.keySet()), | |||
writeIndexLikeList(new ArrayList<String>(addedDirs.keySet()), | |||
rootEntries, writer); | |||
writer.println(); | |||
@@ -651,8 +644,8 @@ public class Jar extends Zip { | |||
for (int i = 0; i < indexJarEntries.length; i++) { | |||
String name = findJarName(indexJarEntries[i], cpEntries); | |||
if (name != null) { | |||
ArrayList dirs = new ArrayList(); | |||
ArrayList files = new ArrayList(); | |||
ArrayList<String> dirs = new ArrayList<String>(); | |||
ArrayList<String> files = new ArrayList<String>(); | |||
grabFilesAndDirs(indexJarEntries[i], dirs, files); | |||
if (dirs.size() + files.size() > 0) { | |||
writer.println(name); | |||
@@ -1022,7 +1015,7 @@ public class Jar extends Zip { | |||
* @throws IOException on error | |||
* @since Ant 1.6.2 | |||
*/ | |||
protected final void writeIndexLikeList(List dirs, List files, | |||
protected final void writeIndexLikeList(List<String> dirs, List<String> files, | |||
PrintWriter writer) | |||
throws IOException { | |||
// JarIndex is sorting the directories by ascending order. | |||
@@ -1030,10 +1023,7 @@ public class Jar extends Zip { | |||
// hashtable by the classloader, but we'll do so anyway. | |||
Collections.sort(dirs); | |||
Collections.sort(files); | |||
Iterator iter = dirs.iterator(); | |||
while (iter.hasNext()) { | |||
String dir = (String) iter.next(); | |||
for (String dir : dirs) { | |||
// try to be smart, not to be fooled by a weird directory name | |||
dir = dir.replace('\\', '/'); | |||
if (dir.startsWith("./")) { | |||
@@ -1050,7 +1040,7 @@ public class Jar extends Zip { | |||
// looks like nothing from META-INF should be added | |||
// and the check is not case insensitive. | |||
// see sun.misc.JarIndex | |||
// see also | |||
// see also | |||
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4408526 | |||
if (!indexMetaInf && dir.startsWith("META-INF")) { | |||
continue; | |||
@@ -1059,9 +1049,8 @@ public class Jar extends Zip { | |||
writer.println(dir); | |||
} | |||
iter = files.iterator(); | |||
while (iter.hasNext()) { | |||
writer.println(iter.next()); | |||
for (String file : files) { | |||
writer.println(file); | |||
} | |||
} | |||
@@ -1091,7 +1080,7 @@ public class Jar extends Zip { | |||
return (new File(fileName)).getName(); | |||
} | |||
fileName = fileName.replace(File.separatorChar, '/'); | |||
TreeMap matches = new TreeMap(new Comparator() { | |||
TreeMap<String, String> matches = new TreeMap<String, String>(new Comparator<Object>() { | |||
// longest match comes first | |||
public int compare(Object o1, Object o2) { | |||
if (o1 instanceof String && o2 instanceof String) { | |||
@@ -1132,17 +1121,17 @@ public class Jar extends Zip { | |||
* @since Ant 1.7 | |||
* @throws IOException on error | |||
*/ | |||
protected static void grabFilesAndDirs(String file, List dirs, | |||
List files) | |||
protected static void grabFilesAndDirs(String file, List<String> dirs, | |||
List<String> files) | |||
throws IOException { | |||
org.apache.tools.zip.ZipFile zf = null; | |||
try { | |||
zf = new org.apache.tools.zip.ZipFile(file, "utf-8"); | |||
Enumeration entries = zf.getEntries(); | |||
HashSet dirSet = new HashSet(); | |||
Enumeration<org.apache.tools.zip.ZipEntry> entries = zf.getEntries(); | |||
HashSet<String> dirSet = new HashSet<String>(); | |||
while (entries.hasMoreElements()) { | |||
org.apache.tools.zip.ZipEntry ze = | |||
(org.apache.tools.zip.ZipEntry) entries.nextElement(); | |||
entries.nextElement(); | |||
String name = ze.getName(); | |||
if (ze.isDirectory()) { | |||
dirSet.add(name); | |||
@@ -76,7 +76,7 @@ public class Java extends Task { | |||
private boolean spawn = false; | |||
private boolean incompatibleWithSpawn = false; | |||
private static final String TIMEOUT_MESSAGE = | |||
private static final String TIMEOUT_MESSAGE = | |||
"Timeout: killed the sub-process"; | |||
/** | |||
@@ -896,12 +896,12 @@ public class Java extends Task { | |||
* @param args arguments for the class. | |||
* @throws BuildException in case of IOException in the execution. | |||
*/ | |||
protected void run(String classname, Vector args) throws BuildException { | |||
protected void run(String classname, Vector<String> args) throws BuildException { | |||
CommandlineJava cmdj = new CommandlineJava(); | |||
cmdj.setClassname(classname); | |||
final int size = args.size(); | |||
for (int i = 0; i < size; i++) { | |||
cmdj.createArgument().setValue((String) args.elementAt(i)); | |||
cmdj.createArgument().setValue(args.elementAt(i)); | |||
} | |||
run(cmdj); | |||
} | |||
@@ -23,8 +23,8 @@ import java.io.FileOutputStream; | |||
import java.io.IOException; | |||
import java.io.OutputStream; | |||
import java.util.HashMap; | |||
import java.util.Iterator; | |||
import java.util.Map; | |||
import java.util.Map.Entry; | |||
import org.apache.tools.ant.BuildException; | |||
import org.apache.tools.ant.DirectoryScanner; | |||
@@ -120,7 +120,7 @@ public class Javac extends MatchingTask { | |||
protected boolean failOnError = true; | |||
protected boolean listFiles = false; | |||
protected File[] compileList = new File[0]; | |||
private Map/*<String,Long>*/ packageInfos = new HashMap(); | |||
private Map<String, Long> packageInfos = new HashMap<String, Long>(); | |||
// CheckStyle:VisibilityModifier ON | |||
private String source; | |||
@@ -940,7 +940,7 @@ public class Javac extends MatchingTask { | |||
*/ | |||
protected void resetFileLists() { | |||
compileList = new File[0]; | |||
packageInfos = new HashMap(); | |||
packageInfos = new HashMap<String, Long>(); | |||
} | |||
/** | |||
@@ -984,7 +984,7 @@ public class Javac extends MatchingTask { | |||
if (adapter instanceof CompilerAdapterExtension) { | |||
extensions = | |||
((CompilerAdapterExtension) adapter).getSupportedFileExtensions(); | |||
} | |||
} | |||
if (extensions == null) { | |||
extensions = new String[] { "java" }; | |||
@@ -997,7 +997,7 @@ public class Javac extends MatchingTask { | |||
extensions[i] = "*." + extensions[i]; | |||
} | |||
} | |||
return extensions; | |||
return extensions; | |||
} | |||
/** | |||
@@ -1219,10 +1219,9 @@ public class Javac extends MatchingTask { | |||
* @see <a href="https://issues.apache.org/bugzilla/show_bug.cgi?id=43114">Bug #43114</a> | |||
*/ | |||
private void generateMissingPackageInfoClasses(File dest) throws IOException { | |||
for (Iterator i = packageInfos.entrySet().iterator(); i.hasNext(); ) { | |||
Map.Entry entry = (Map.Entry) i.next(); | |||
String pkg = (String) entry.getKey(); | |||
Long sourceLastMod = (Long) entry.getValue(); | |||
for (Entry<String, Long> entry : packageInfos.entrySet()) { | |||
String pkg = entry.getKey(); | |||
Long sourceLastMod = entry.getValue(); | |||
File pkgBinDir = new File(dest, pkg.replace('/', File.separatorChar)); | |||
pkgBinDir.mkdirs(); | |||
File pkgInfoClass = new File(pkgBinDir, "package-info.class"); | |||
@@ -78,7 +78,7 @@ import org.apache.tools.ant.util.JavaEnvUtils; | |||
public class Javadoc extends Task { | |||
// Whether *this VM* is 1.4+ (but also check executable != null). | |||
private static final boolean JAVADOC_5 = | |||
private static final boolean JAVADOC_5 = | |||
!JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_4); | |||
/** | |||
@@ -214,7 +214,7 @@ public class Javadoc extends Task { | |||
public class DocletInfo extends ExtensionInfo { | |||
/** Collection of doclet parameters. */ | |||
private Vector params = new Vector(); | |||
private Vector<DocletParam> params = new Vector<DocletParam>(); | |||
/** | |||
* Create a doclet parameter to be configured by Ant. | |||
@@ -233,7 +233,7 @@ public class Javadoc extends Task { | |||
* | |||
* @return an Enumeration of DocletParam instances. | |||
*/ | |||
public Enumeration getParams() { | |||
public Enumeration<DocletParam> getParams() { | |||
return params.elements(); | |||
} | |||
} | |||
@@ -366,7 +366,7 @@ public class Javadoc extends Task { | |||
* task runtime.</p> | |||
*/ | |||
public class ResourceCollectionContainer { | |||
private ArrayList rcs = new ArrayList(); | |||
private ArrayList<ResourceCollection> rcs = new ArrayList<ResourceCollection>(); | |||
/** | |||
* Add a resource collection to the container. | |||
* @param rc the collection to add. | |||
@@ -379,7 +379,7 @@ public class Javadoc extends Task { | |||
* Get an iterator on the collection. | |||
* @return an iterator. | |||
*/ | |||
private Iterator iterator() { | |||
private Iterator<ResourceCollection> iterator() { | |||
return rcs.iterator(); | |||
} | |||
} | |||
@@ -425,9 +425,9 @@ public class Javadoc extends Task { | |||
private boolean failOnError = false; | |||
private Path sourcePath = null; | |||
private File destDir = null; | |||
private Vector sourceFiles = new Vector(); | |||
private Vector packageNames = new Vector(); | |||
private Vector excludePackageNames = new Vector(1); | |||
private Vector<SourceFile> sourceFiles = new Vector<SourceFile>(); | |||
private Vector<PackageName> packageNames = new Vector<PackageName>(); | |||
private Vector<PackageName> excludePackageNames = new Vector<PackageName>(1); | |||
private boolean author = true; | |||
private boolean version = true; | |||
private DocletInfo doclet = null; | |||
@@ -435,9 +435,9 @@ public class Javadoc extends Task { | |||
private Path bootclasspath = null; | |||
private String group = null; | |||
private String packageList = null; | |||
private Vector links = new Vector(); | |||
private Vector groups = new Vector(); | |||
private Vector tags = new Vector(); | |||
private Vector<LinkArgument> links = new Vector<LinkArgument>(); | |||
private Vector<GroupArgument> groups = new Vector<GroupArgument>(); | |||
private Vector<Object> tags = new Vector<Object>(); | |||
private boolean useDefaultExcludes = true; | |||
private Html doctitle = null; | |||
private Html header = null; | |||
@@ -455,7 +455,7 @@ public class Javadoc extends Task { | |||
private ResourceCollectionContainer nestedSourceFiles | |||
= new ResourceCollectionContainer(); | |||
private Vector packageSets = new Vector(); | |||
private Vector<DirSet> packageSets = new Vector<DirSet>(); | |||
/** | |||
* Work around command line length limit by using an external file | |||
@@ -1450,7 +1450,7 @@ public class Javadoc extends Task { | |||
*/ | |||
public class GroupArgument { | |||
private Html title; | |||
private Vector packages = new Vector(); | |||
private Vector<PackageName> packages = new Vector<PackageName>(); | |||
/** Constructor for GroupArgument */ | |||
public GroupArgument() { | |||
@@ -1662,7 +1662,7 @@ public class Javadoc extends Task { | |||
public void execute() throws BuildException { | |||
checkTaskName(); | |||
Vector packagesToDoc = new Vector(); | |||
Vector<String> packagesToDoc = new Vector<String>(); | |||
Path sourceDirs = new Path(getProject()); | |||
checkPackageAndSourcePath(); | |||
@@ -1674,7 +1674,8 @@ public class Javadoc extends Task { | |||
parsePackages(packagesToDoc, sourceDirs); | |||
checkPackages(packagesToDoc, sourceDirs); | |||
Vector sourceFilesToDoc = (Vector) sourceFiles.clone(); | |||
@SuppressWarnings("unchecked") | |||
Vector<SourceFile> sourceFilesToDoc = (Vector<SourceFile>) sourceFiles.clone(); | |||
addSourceFiles(sourceFilesToDoc); | |||
checkPackagesToDoc(packagesToDoc, sourceFilesToDoc); | |||
@@ -1799,7 +1800,7 @@ public class Javadoc extends Task { | |||
} | |||
} | |||
private void checkPackages(Vector packagesToDoc, Path sourceDirs) { | |||
private void checkPackages(Vector<String> packagesToDoc, Path sourceDirs) { | |||
if (packagesToDoc.size() != 0 && sourceDirs.size() == 0) { | |||
String msg = "sourcePath attribute must be set when " | |||
+ "specifying package names."; | |||
@@ -1808,7 +1809,7 @@ public class Javadoc extends Task { | |||
} | |||
private void checkPackagesToDoc( | |||
Vector packagesToDoc, Vector sourceFilesToDoc) { | |||
Vector<String> packagesToDoc, Vector<SourceFile> sourceFilesToDoc) { | |||
if (packageList == null && packagesToDoc.size() == 0 | |||
&& sourceFilesToDoc.size() == 0) { | |||
throw new BuildException("No source files and no packages have " | |||
@@ -1880,9 +1881,9 @@ public class Javadoc extends Task { | |||
toExecute.createArgument().setPath(docletPath); | |||
} | |||
} | |||
for (Enumeration e = doclet.getParams(); | |||
for (Enumeration<DocletParam> e = doclet.getParams(); | |||
e.hasMoreElements();) { | |||
DocletParam param = (DocletParam) e.nextElement(); | |||
DocletParam param = e.nextElement(); | |||
if (param.getName() == null) { | |||
throw new BuildException("Doclet parameters must " | |||
+ "have a name"); | |||
@@ -1952,8 +1953,8 @@ public class Javadoc extends Task { | |||
private void doLinks(Commandline toExecute) { | |||
if (links.size() != 0) { | |||
for (Enumeration e = links.elements(); e.hasMoreElements();) { | |||
LinkArgument la = (LinkArgument) e.nextElement(); | |||
for (Enumeration<LinkArgument> e = links.elements(); e.hasMoreElements();) { | |||
LinkArgument la = e.nextElement(); | |||
if (la.getHref() == null || la.getHref().length() == 0) { | |||
log("No href was given for the link - skipping", | |||
@@ -2065,8 +2066,8 @@ public class Javadoc extends Task { | |||
// add the group arguments | |||
private void doGroups(Commandline toExecute) { | |||
if (groups.size() != 0) { | |||
for (Enumeration e = groups.elements(); e.hasMoreElements();) { | |||
GroupArgument ga = (GroupArgument) e.nextElement(); | |||
for (Enumeration<GroupArgument> e = groups.elements(); e.hasMoreElements();) { | |||
GroupArgument ga = e.nextElement(); | |||
String title = ga.getTitle(); | |||
String packages = ga.getPackages(); | |||
if (title == null || packages == null) { | |||
@@ -2083,7 +2084,7 @@ public class Javadoc extends Task { | |||
// Do java1.4 arguments | |||
private void doJava14(Commandline toExecute) { | |||
for (Enumeration e = tags.elements(); e.hasMoreElements();) { | |||
for (Enumeration<Object> e = tags.elements(); e.hasMoreElements();) { | |||
Object element = e.nextElement(); | |||
if (element instanceof TagArgument) { | |||
TagArgument ta = (TagArgument) element; | |||
@@ -2170,15 +2171,13 @@ public class Javadoc extends Task { | |||
private void doSourceAndPackageNames( | |||
Commandline toExecute, | |||
Vector packagesToDoc, | |||
Vector sourceFilesToDoc, | |||
Vector<String> packagesToDoc, | |||
Vector<SourceFile> sourceFilesToDoc, | |||
boolean useExternalFile, | |||
File tmpList, | |||
BufferedWriter srcListWriter) | |||
throws IOException { | |||
Enumeration e = packagesToDoc.elements(); | |||
while (e.hasMoreElements()) { | |||
String packageName = (String) e.nextElement(); | |||
for (String packageName : packagesToDoc) { | |||
if (useExternalFile) { | |||
srcListWriter.write(packageName); | |||
srcListWriter.newLine(); | |||
@@ -2187,9 +2186,7 @@ public class Javadoc extends Task { | |||
} | |||
} | |||
e = sourceFilesToDoc.elements(); | |||
while (e.hasMoreElements()) { | |||
SourceFile sf = (SourceFile) e.nextElement(); | |||
for (SourceFile sf : sourceFilesToDoc) { | |||
String sourceFileName = sf.getFile().getAbsolutePath(); | |||
if (useExternalFile) { | |||
// XXX what is the following doing? | |||
@@ -2288,10 +2285,10 @@ public class Javadoc extends Task { | |||
* | |||
* @since 1.7 | |||
*/ | |||
private void addSourceFiles(Vector sf) { | |||
Iterator e = nestedSourceFiles.iterator(); | |||
private void addSourceFiles(Vector<SourceFile> sf) { | |||
Iterator<ResourceCollection> e = nestedSourceFiles.iterator(); | |||
while (e.hasNext()) { | |||
ResourceCollection rc = (ResourceCollection) e.next(); | |||
ResourceCollection rc = e.next(); | |||
if (!rc.isFilesystemOnly()) { | |||
throw new BuildException("only file system based resources are" | |||
+ " supported by javadoc"); | |||
@@ -2321,9 +2318,10 @@ public class Javadoc extends Task { | |||
* | |||
* @since 1.5 | |||
*/ | |||
private void parsePackages(Vector pn, Path sp) { | |||
HashSet addedPackages = new HashSet(); | |||
Vector dirSets = (Vector) packageSets.clone(); | |||
private void parsePackages(Vector<String> pn, Path sp) { | |||
HashSet<String> addedPackages = new HashSet<String>(); | |||
@SuppressWarnings("unchecked") | |||
Vector<DirSet> dirSets = (Vector<DirSet>) packageSets.clone(); | |||
// for each sourcePath entry, add a directoryset with includes | |||
// taken from packagenames attribute and nested package | |||
@@ -2333,9 +2331,9 @@ public class Javadoc extends Task { | |||
PatternSet ps = new PatternSet(); | |||
ps.setProject(getProject()); | |||
if (packageNames.size() > 0) { | |||
Enumeration e = packageNames.elements(); | |||
Enumeration<PackageName> e = packageNames.elements(); | |||
while (e.hasMoreElements()) { | |||
PackageName p = (PackageName) e.nextElement(); | |||
PackageName p = e.nextElement(); | |||
String pkg = p.getName().replace('.', '/'); | |||
if (pkg.endsWith("*")) { | |||
pkg += "*"; | |||
@@ -2346,9 +2344,9 @@ public class Javadoc extends Task { | |||
ps.createInclude().setName("**"); | |||
} | |||
Enumeration e = excludePackageNames.elements(); | |||
Enumeration<PackageName> e = excludePackageNames.elements(); | |||
while (e.hasMoreElements()) { | |||
PackageName p = (PackageName) e.nextElement(); | |||
PackageName p = e.nextElement(); | |||
String pkg = p.getName().replace('.', '/'); | |||
if (pkg.endsWith("*")) { | |||
pkg += "*"; | |||
@@ -2374,9 +2372,9 @@ public class Javadoc extends Task { | |||
} | |||
} | |||
Enumeration e = dirSets.elements(); | |||
Enumeration<DirSet> e = dirSets.elements(); | |||
while (e.hasMoreElements()) { | |||
DirSet ds = (DirSet) e.nextElement(); | |||
DirSet ds = e.nextElement(); | |||
File baseDir = ds.getDir(getProject()); | |||
log("scanning " + baseDir + " for packages.", Project.MSG_DEBUG); | |||
DirectoryScanner dsc = ds.getDirectoryScanner(getProject()); | |||
@@ -44,7 +44,7 @@ public class KeySubst extends Task { | |||
private File source = null; | |||
private File dest = null; | |||
private String sep = "*"; | |||
private Hashtable replacements = new Hashtable(); | |||
private Hashtable<String, String> replacements = new Hashtable<String, String>(); | |||
/** | |||
* Do the execution. | |||
@@ -146,7 +146,7 @@ public class KeySubst extends Task { | |||
*/ | |||
public static void main(String[] args) { | |||
try { | |||
Hashtable hash = new Hashtable(); | |||
Hashtable<String, String> hash = new Hashtable<String, String>(); | |||
hash.put("VERSION", "1.0.3"); | |||
hash.put("b", "ffff"); | |||
System.out.println(KeySubst.replace("$f ${VERSION} f ${b} jj $", | |||
@@ -163,7 +163,7 @@ public class KeySubst extends Task { | |||
* @return the string with the replacements in it. | |||
* @throws BuildException on error | |||
*/ | |||
public static String replace(String origString, Hashtable keys) | |||
public static String replace(String origString, Hashtable<String, String> keys) | |||
throws BuildException { | |||
StringBuffer finalString = new StringBuffer(); | |||
int index = 0; | |||
@@ -21,7 +21,6 @@ package org.apache.tools.ant.taskdefs; | |||
import java.io.File; | |||
import java.io.PrintStream; | |||
import java.io.OutputStream; | |||
import java.util.Iterator; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.tools.ant.Project; | |||
@@ -55,13 +55,13 @@ public class LoadProperties extends Task { | |||
/** | |||
* Holds filterchains | |||
*/ | |||
private final Vector filterChains = new Vector(); | |||
private final Vector<FilterChain> filterChains = new Vector<FilterChain>(); | |||
/** | |||
* Encoding to use for input; defaults to the platform's default encoding. | |||
*/ | |||
private String encoding = null; | |||
/** | |||
* Prefix for loaded properties. | |||
*/ | |||
@@ -69,7 +69,7 @@ public class LoadResource extends Task { | |||
/** | |||
* Holds FilterChains | |||
*/ | |||
private final Vector filterChains = new Vector(); | |||
private final Vector<FilterChain> filterChains = new Vector<FilterChain>(); | |||
/** | |||
* Encoding to use for input, defaults to the platform's default | |||
@@ -23,6 +23,7 @@ import java.util.List; | |||
import java.util.Iterator; | |||
import java.util.Locale; | |||
import java.util.Map; | |||
import java.util.Map.Entry; | |||
import java.util.Set; | |||
import java.util.HashSet; | |||
import java.util.HashMap; | |||
@@ -38,6 +39,7 @@ import org.apache.tools.ant.Task; | |||
import org.apache.tools.ant.TaskContainer; | |||
import org.apache.tools.ant.UnknownElement; | |||
import org.apache.tools.ant.property.LocalProperties; | |||
import org.apache.tools.ant.taskdefs.MacroDef.Attribute; | |||
/** | |||
* The class to be placed in the ant type definition. | |||
@@ -48,13 +50,13 @@ import org.apache.tools.ant.property.LocalProperties; | |||
*/ | |||
public class MacroInstance extends Task implements DynamicAttribute, TaskContainer { | |||
private MacroDef macroDef; | |||
private Map map = new HashMap(); | |||
private Map nsElements = null; | |||
private Map presentElements; | |||
private Hashtable localAttributes; | |||
private Map<String, String> map = new HashMap<String, String>(); | |||
private Map<String, MacroDef.TemplateElement> nsElements = null; | |||
private Map<String, UnknownElement> presentElements; | |||
private Hashtable<String, String> localAttributes; | |||
private String text = null; | |||
private String implicitTag = null; | |||
private List unknownElements = new ArrayList(); | |||
private List<Task> unknownElements = new ArrayList<Task>(); | |||
/** | |||
* Called from MacroDef.MyAntTypeDefinition#create() | |||
@@ -93,20 +95,18 @@ public class MacroInstance extends Task implements DynamicAttribute, TaskContain | |||
throw new BuildException("Not implemented any more"); | |||
} | |||
private Map getNsElements() { | |||
private Map<String, MacroDef.TemplateElement> getNsElements() { | |||
if (nsElements == null) { | |||
nsElements = new HashMap(); | |||
for (Iterator i = macroDef.getElements().entrySet().iterator(); | |||
i.hasNext();) { | |||
Map.Entry entry = (Map.Entry) i.next(); | |||
nsElements.put((String) entry.getKey(), | |||
entry.getValue()); | |||
MacroDef.TemplateElement te = (MacroDef.TemplateElement) | |||
entry.getValue(); | |||
if (te.isImplicit()) { | |||
implicitTag = te.getName(); | |||
} | |||
nsElements = new HashMap<String, MacroDef.TemplateElement>(); | |||
for (Entry<String, MacroDef.TemplateElement> entry : macroDef.getElements().entrySet()) { | |||
nsElements.put((String) entry.getKey(), | |||
entry.getValue()); | |||
MacroDef.TemplateElement te = (MacroDef.TemplateElement) | |||
entry.getValue(); | |||
if (te.isImplicit()) { | |||
implicitTag = te.getName(); | |||
} | |||
} | |||
} | |||
return nsElements; | |||
} | |||
@@ -124,7 +124,7 @@ public class MacroInstance extends Task implements DynamicAttribute, TaskContain | |||
if (implicitTag != null) { | |||
return; | |||
} | |||
for (Iterator i = unknownElements.iterator(); i.hasNext();) { | |||
for (Iterator<Task> i = unknownElements.iterator(); i.hasNext();) { | |||
UnknownElement ue = (UnknownElement) i.next(); | |||
String name = ProjectHelper.extractNameFromComponentName( | |||
ue.getTag()).toLowerCase(Locale.ENGLISH); | |||
@@ -142,7 +142,7 @@ public class MacroInstance extends Task implements DynamicAttribute, TaskContain | |||
* Embedded element in macro instance | |||
*/ | |||
public static class Element implements TaskContainer { | |||
private List unknownElements = new ArrayList(); | |||
private List<Task> unknownElements = new ArrayList<Task>(); | |||
/** | |||
* Add an unknown element (to be snipped into the macroDef instance) | |||
@@ -156,7 +156,7 @@ public class MacroInstance extends Task implements DynamicAttribute, TaskContain | |||
/** | |||
* @return the list of unknown elements | |||
*/ | |||
public List getUnknownElements() { | |||
public List<Task> getUnknownElements() { | |||
return unknownElements; | |||
} | |||
} | |||
@@ -165,7 +165,7 @@ public class MacroInstance extends Task implements DynamicAttribute, TaskContain | |||
private static final int STATE_EXPECT_BRACKET = 1; | |||
private static final int STATE_EXPECT_NAME = 2; | |||
private String macroSubs(String s, Map macroMapping) { | |||
private String macroSubs(String s, Map<String, String> macroMapping) { | |||
if (s == null) { | |||
return null; | |||
} | |||
@@ -262,26 +262,25 @@ public class MacroInstance extends Task implements DynamicAttribute, TaskContain | |||
RuntimeConfigurable rc = new RuntimeConfigurable( | |||
ret, ue.getTaskName()); | |||
rc.setPolyType(ue.getWrapper().getPolyType()); | |||
Map m = ue.getWrapper().getAttributeMap(); | |||
for (Iterator i = m.entrySet().iterator(); i.hasNext();) { | |||
Map.Entry entry = (Map.Entry) i.next(); | |||
Map<String, Object> m = ue.getWrapper().getAttributeMap(); | |||
for (Map.Entry<String, Object> entry : m.entrySet()) { | |||
rc.setAttribute( | |||
(String) entry.getKey(), | |||
entry.getKey(), | |||
macroSubs((String) entry.getValue(), localAttributes)); | |||
} | |||
rc.addText(macroSubs(ue.getWrapper().getText().toString(), | |||
localAttributes)); | |||
Enumeration e = ue.getWrapper().getChildren(); | |||
Enumeration<RuntimeConfigurable> e = ue.getWrapper().getChildren(); | |||
while (e.hasMoreElements()) { | |||
RuntimeConfigurable r = (RuntimeConfigurable) e.nextElement(); | |||
RuntimeConfigurable r = e.nextElement(); | |||
UnknownElement unknownElement = (UnknownElement) r.getProxy(); | |||
String tag = unknownElement.getTaskType(); | |||
if (tag != null) { | |||
tag = tag.toLowerCase(Locale.ENGLISH); | |||
} | |||
MacroDef.TemplateElement templateElement = | |||
(MacroDef.TemplateElement) getNsElements().get(tag); | |||
getNsElements().get(tag); | |||
if (templateElement == null || nested) { | |||
UnknownElement child = copy(unknownElement, nested); | |||
rc.addChild(child.getWrapper()); | |||
@@ -292,7 +291,7 @@ public class MacroInstance extends Task implements DynamicAttribute, TaskContain | |||
"Missing nested elements for implicit element " | |||
+ templateElement.getName()); | |||
} | |||
for (Iterator i = unknownElements.iterator(); | |||
for (Iterator<Task> i = unknownElements.iterator(); | |||
i.hasNext();) { | |||
UnknownElement child | |||
= copy((UnknownElement) i.next(), true); | |||
@@ -315,12 +314,12 @@ public class MacroInstance extends Task implements DynamicAttribute, TaskContain | |||
if (!"".equals(presentText)) { | |||
rc.addText(macroSubs(presentText, localAttributes)); | |||
} | |||
List list = presentElement.getChildren(); | |||
List<UnknownElement> list = presentElement.getChildren(); | |||
if (list != null) { | |||
for (Iterator i = list.iterator(); | |||
for (Iterator<UnknownElement> i = list.iterator(); | |||
i.hasNext();) { | |||
UnknownElement child | |||
= copy((UnknownElement) i.next(), true); | |||
= copy(i.next(), true); | |||
rc.addChild(child.getWrapper()); | |||
ret.addChild(child); | |||
} | |||
@@ -337,13 +336,12 @@ public class MacroInstance extends Task implements DynamicAttribute, TaskContain | |||
* | |||
*/ | |||
public void execute() { | |||
presentElements = new HashMap(); | |||
presentElements = new HashMap<String, UnknownElement>(); | |||
getNsElements(); | |||
processTasks(); | |||
localAttributes = new Hashtable(); | |||
Set copyKeys = new HashSet(map.keySet()); | |||
for (Iterator i = macroDef.getAttributes().iterator(); i.hasNext();) { | |||
MacroDef.Attribute attribute = (MacroDef.Attribute) i.next(); | |||
localAttributes = new Hashtable<String, String>(); | |||
Set<String> copyKeys = new HashSet<String>(map.keySet()); | |||
for (Attribute attribute : macroDef.getAttributes()) { | |||
String value = (String) map.get(attribute.getName()); | |||
if (value == null && "description".equals(attribute.getName())) { | |||
value = getDescription(); | |||
@@ -61,12 +61,12 @@ public class MakeUrl extends Task { | |||
/** | |||
* filesets of nested files to add to this url | |||
*/ | |||
private List filesets = new LinkedList(); | |||
private List<FileSet> filesets = new LinkedList<FileSet>(); | |||
/** | |||
* paths to add | |||
*/ | |||
private List paths = new LinkedList(); | |||
private List<Path> paths = new LinkedList<Path>(); | |||
/** | |||
* validation flag | |||
@@ -148,8 +148,8 @@ public class MakeUrl extends Task { | |||
return ""; | |||
} | |||
int count = 0; | |||
StringBuffer urls = new StringBuffer(); | |||
ListIterator list = filesets.listIterator(); | |||
StringBuilder urls = new StringBuilder(); | |||
ListIterator<FileSet> list = filesets.listIterator(); | |||
while (list.hasNext()) { | |||
FileSet set = (FileSet) list.next(); | |||
DirectoryScanner scanner = set.getDirectoryScanner(getProject()); | |||
@@ -176,7 +176,7 @@ public class MakeUrl extends Task { | |||
* @param count number of URL entries | |||
* @return trimmed string, or empty string | |||
*/ | |||
private String stripTrailingSeparator(StringBuffer urls, | |||
private String stripTrailingSeparator(StringBuilder urls, | |||
int count) { | |||
if (count > 0) { | |||
urls.delete(urls.length() - separator.length(), urls.length()); | |||
@@ -197,8 +197,8 @@ public class MakeUrl extends Task { | |||
return ""; | |||
} | |||
int count = 0; | |||
StringBuffer urls = new StringBuffer(); | |||
ListIterator list = paths.listIterator(); | |||
StringBuilder urls = new StringBuilder(); | |||
ListIterator<Path> list = paths.listIterator(); | |||
while (list.hasNext()) { | |||
Path path = (Path) list.next(); | |||
String[] elements = path.list(); | |||
@@ -27,7 +27,6 @@ import java.io.Reader; | |||
import java.io.StringWriter; | |||
import java.io.UnsupportedEncodingException; | |||
import java.util.Enumeration; | |||
import java.util.Iterator; | |||
import java.util.LinkedHashMap; | |||
import java.util.Locale; | |||
import java.util.Map; | |||
@@ -127,7 +126,7 @@ public class Manifest { | |||
private String name = null; | |||
/** The attribute's value */ | |||
private Vector values = new Vector(); | |||
private Vector<String> values = new Vector<String>(); | |||
/** | |||
* For multivalued attributes, this is the index of the attribute | |||
@@ -276,8 +275,8 @@ public class Manifest { | |||
} | |||
String fullValue = ""; | |||
for (Enumeration e = getValues(); e.hasMoreElements();) { | |||
String value = (String) e.nextElement(); | |||
for (Enumeration<String> e = getValues(); e.hasMoreElements();) { | |||
String value = e.nextElement(); | |||
fullValue += value + " "; | |||
} | |||
return fullValue.trim(); | |||
@@ -298,7 +297,7 @@ public class Manifest { | |||
* | |||
* @return an enumeration of the attributes values | |||
*/ | |||
public Enumeration getValues() { | |||
public Enumeration<String> getValues() { | |||
return values.elements(); | |||
} | |||
@@ -342,8 +341,8 @@ public class Manifest { | |||
public void write(PrintWriter writer, boolean flatten) | |||
throws IOException { | |||
if (!flatten) { | |||
for (Enumeration e = getValues(); e.hasMoreElements();) { | |||
writeValue(writer, (String) e.nextElement()); | |||
for (Enumeration<String> e = getValues(); e.hasMoreElements();) { | |||
writeValue(writer, e.nextElement()); | |||
} | |||
} else { | |||
writeValue(writer, getValue()); | |||
@@ -402,7 +401,7 @@ public class Manifest { | |||
*/ | |||
public static class Section { | |||
/** Warnings for this section */ | |||
private Vector warnings = new Vector(); | |||
private Vector<String> warnings = new Vector<String>(); | |||
/** | |||
* The section's name if any. The main section in a | |||
@@ -411,7 +410,7 @@ public class Manifest { | |||
private String name = null; | |||
/** The section's attributes.*/ | |||
private Map attributes = new LinkedHashMap(); | |||
private Map<String, Attribute> attributes = new LinkedHashMap<String, Attribute>(); | |||
/** | |||
* The name of the section; optional -default is the main section. | |||
@@ -509,19 +508,19 @@ public class Manifest { | |||
+ "with different names"); | |||
} | |||
Enumeration e = section.getAttributeKeys(); | |||
Enumeration<String> e = section.getAttributeKeys(); | |||
Attribute classpathAttribute = null; | |||
while (e.hasMoreElements()) { | |||
String attributeName = (String) e.nextElement(); | |||
String attributeName = e.nextElement(); | |||
Attribute attribute = section.getAttribute(attributeName); | |||
if (attributeName.equalsIgnoreCase(ATTRIBUTE_CLASSPATH)) { | |||
if (classpathAttribute == null) { | |||
classpathAttribute = new Attribute(); | |||
classpathAttribute.setName(ATTRIBUTE_CLASSPATH); | |||
} | |||
Enumeration cpe = attribute.getValues(); | |||
Enumeration<String> cpe = attribute.getValues(); | |||
while (cpe.hasMoreElements()) { | |||
String value = (String) cpe.nextElement(); | |||
String value = cpe.nextElement(); | |||
classpathAttribute.addValue(value); | |||
} | |||
} else { | |||
@@ -534,9 +533,9 @@ public class Manifest { | |||
if (mergeClassPaths) { | |||
Attribute currentCp = getAttribute(ATTRIBUTE_CLASSPATH); | |||
if (currentCp != null) { | |||
for (Enumeration attribEnum = currentCp.getValues(); | |||
for (Enumeration<String> attribEnum = currentCp.getValues(); | |||
attribEnum.hasMoreElements(); ) { | |||
String value = (String) attribEnum.nextElement(); | |||
String value = attribEnum.nextElement(); | |||
classpathAttribute.addValue(value); | |||
} | |||
} | |||
@@ -545,7 +544,7 @@ public class Manifest { | |||
} | |||
// add in the warnings | |||
Enumeration warnEnum = section.warnings.elements(); | |||
Enumeration<String> warnEnum = section.warnings.elements(); | |||
while (warnEnum.hasMoreElements()) { | |||
warnings.addElement(warnEnum.nextElement()); | |||
} | |||
@@ -580,9 +579,9 @@ public class Manifest { | |||
Attribute nameAttr = new Attribute(ATTRIBUTE_NAME, name); | |||
nameAttr.write(writer); | |||
} | |||
Enumeration e = getAttributeKeys(); | |||
Enumeration<String> e = getAttributeKeys(); | |||
while (e.hasMoreElements()) { | |||
String key = (String) e.nextElement(); | |||
String key = e.nextElement(); | |||
Attribute attribute = getAttribute(key); | |||
attribute.write(writer, flatten); | |||
} | |||
@@ -607,7 +606,7 @@ public class Manifest { | |||
* @return an Enumeration of Strings, each string being the lower case | |||
* key of an attribute of the section. | |||
*/ | |||
public Enumeration getAttributeKeys() { | |||
public Enumeration<String> getAttributeKeys() { | |||
return CollectionUtils.asEnumeration(attributes.keySet().iterator()); | |||
} | |||
@@ -695,9 +694,9 @@ public class Manifest { | |||
+ "are supported but violate the Jar " | |||
+ "specification and may not be correctly " | |||
+ "processed in all environments"); | |||
Enumeration e = attribute.getValues(); | |||
Enumeration<String> e = attribute.getValues(); | |||
while (e.hasMoreElements()) { | |||
String value = (String) e.nextElement(); | |||
String value = e.nextElement(); | |||
classpathAttribute.addValue(value); | |||
} | |||
} | |||
@@ -721,9 +720,9 @@ public class Manifest { | |||
public Object clone() { | |||
Section cloned = new Section(); | |||
cloned.setName(name); | |||
Enumeration e = getAttributeKeys(); | |||
Enumeration<String> e = getAttributeKeys(); | |||
while (e.hasMoreElements()) { | |||
String key = (String) e.nextElement(); | |||
String key = e.nextElement(); | |||
Attribute attribute = getAttribute(key); | |||
cloned.storeAttribute(new Attribute(attribute.getName(), | |||
attribute.getValue())); | |||
@@ -749,7 +748,7 @@ public class Manifest { | |||
* | |||
* @return an Enumeration of warning strings. | |||
*/ | |||
public Enumeration getWarnings() { | |||
public Enumeration<String> getWarnings() { | |||
return warnings.elements(); | |||
} | |||
@@ -789,7 +788,7 @@ public class Manifest { | |||
private Section mainSection = new Section(); | |||
/** The named sections of this manifest */ | |||
private Map sections = new LinkedHashMap(); | |||
private Map<String, Section> sections = new LinkedHashMap<String, Section>(); | |||
/** | |||
* Construct a manifest from Ant's default manifest file. | |||
@@ -981,12 +980,12 @@ public class Manifest { | |||
manifestVersion = other.manifestVersion; | |||
} | |||
Enumeration e = other.getSectionNames(); | |||
Enumeration<String> e = other.getSectionNames(); | |||
while (e.hasMoreElements()) { | |||
String sectionName = (String) e.nextElement(); | |||
Section ourSection = (Section) sections.get(sectionName); | |||
String sectionName = e.nextElement(); | |||
Section ourSection = sections.get(sectionName); | |||
Section otherSection | |||
= (Section) other.sections.get(sectionName); | |||
= other.sections.get(sectionName); | |||
if (ourSection == null) { | |||
if (otherSection != null) { | |||
addConfiguredSection((Section) otherSection.clone()); | |||
@@ -1043,9 +1042,7 @@ public class Manifest { | |||
} | |||
} | |||
Iterator e = sections.keySet().iterator(); | |||
while (e.hasNext()) { | |||
String sectionName = (String) e.next(); | |||
for (String sectionName : sections.keySet()) { | |||
Section section = getSection(sectionName); | |||
section.write(writer, flatten); | |||
} | |||
@@ -1072,19 +1069,17 @@ public class Manifest { | |||
* | |||
* @return an enumeration of warning strings | |||
*/ | |||
public Enumeration getWarnings() { | |||
Vector warnings = new Vector(); | |||
public Enumeration<String> getWarnings() { | |||
Vector<String> warnings = new Vector<String>(); | |||
Enumeration warnEnum = mainSection.getWarnings(); | |||
Enumeration<String> warnEnum = mainSection.getWarnings(); | |||
while (warnEnum.hasMoreElements()) { | |||
warnings.addElement(warnEnum.nextElement()); | |||
} | |||
// create a vector and add in the warnings for all the sections | |||
Iterator e = sections.values().iterator(); | |||
while (e.hasNext()) { | |||
Section section = (Section) e.next(); | |||
Enumeration e2 = section.getWarnings(); | |||
for (Section section : sections.values()) { | |||
Enumeration<String> e2 = section.getWarnings(); | |||
while (e2.hasMoreElements()) { | |||
warnings.addElement(e2.nextElement()); | |||
} | |||
@@ -1173,7 +1168,7 @@ public class Manifest { | |||
* | |||
* @return an Enumeration of section names | |||
*/ | |||
public Enumeration getSectionNames() { | |||
public Enumeration<String> getSectionNames() { | |||
return CollectionUtils.asEnumeration(sections.keySet().iterator()); | |||
} | |||
} |
@@ -32,7 +32,6 @@ import java.util.Comparator; | |||
import java.util.Enumeration; | |||
import java.util.HashMap; | |||
import java.util.Hashtable; | |||
import java.util.Iterator; | |||
import java.util.Map; | |||
import java.util.Stack; | |||
import java.util.Vector; | |||
@@ -67,6 +66,7 @@ import org.apache.tools.zip.ZipEntry; | |||
import org.apache.tools.zip.ZipExtraField; | |||
import org.apache.tools.zip.ZipFile; | |||
import org.apache.tools.zip.ZipOutputStream; | |||
import org.apache.tools.zip.ZipOutputStream.UnicodeExtraFieldPolicy; | |||
/** | |||
* Create a Zip file. | |||
@@ -84,9 +84,9 @@ public class Zip extends MatchingTask { | |||
// use to scan own archive | |||
private ZipScanner zs; | |||
private File baseDir; | |||
protected Hashtable entries = new Hashtable(); | |||
private Vector groupfilesets = new Vector(); | |||
private Vector filesetsFromGroupfilesets = new Vector(); | |||
protected Hashtable<String, String> entries = new Hashtable<String, String>(); | |||
private Vector<FileSet> groupfilesets = new Vector<FileSet>(); | |||
private Vector<ZipFileSet> filesetsFromGroupfilesets = new Vector<ZipFileSet>(); | |||
protected String duplicate = "add"; | |||
private boolean doCompress = true; | |||
private boolean doUpdate = false; | |||
@@ -98,9 +98,9 @@ public class Zip extends MatchingTask { | |||
// For directories: | |||
private static final long EMPTY_CRC = new CRC32 ().getValue (); | |||
protected String emptyBehavior = "skip"; | |||
private Vector resources = new Vector(); | |||
protected Hashtable addedDirs = new Hashtable(); | |||
private Vector addedFiles = new Vector(); | |||
private Vector<ResourceCollection> resources = new Vector<ResourceCollection>(); | |||
protected Hashtable<String, String> addedDirs = new Hashtable<String, String>(); | |||
private Vector<String> addedFiles = new Vector<String>(); | |||
private static final ResourceSelector MISSING_SELECTOR = | |||
new ResourceSelector() { | |||
@@ -596,7 +596,7 @@ public class Zip extends MatchingTask { | |||
processGroupFilesets(); | |||
// collect filesets to pass them to getResourcesToAdd | |||
Vector vfss = new Vector(); | |||
Vector<ResourceCollection> vfss = new Vector<ResourceCollection>(); | |||
if (baseDir != null) { | |||
FileSet fs = (FileSet) getImplicitFileSet().clone(); | |||
fs.setDir(baseDir); | |||
@@ -1204,8 +1204,8 @@ public class Zip extends MatchingTask { | |||
File zipFile, | |||
boolean needsUpdate) | |||
throws BuildException { | |||
ArrayList filesets = new ArrayList(); | |||
ArrayList rest = new ArrayList(); | |||
ArrayList<ResourceCollection> filesets = new ArrayList<ResourceCollection>(); | |||
ArrayList<ResourceCollection> rest = new ArrayList<ResourceCollection>(); | |||
for (int i = 0; i < rcs.length; i++) { | |||
if (rcs[i] instanceof FileSet) { | |||
filesets.add(rcs[i]); | |||
@@ -1213,7 +1213,7 @@ public class Zip extends MatchingTask { | |||
rest.add(rcs[i]); | |||
} | |||
} | |||
ResourceCollection[] rc = (ResourceCollection[]) | |||
ResourceCollection[] rc = | |||
rest.toArray(new ResourceCollection[rest.size()]); | |||
ArchiveState as = getNonFileSetResourcesToAdd(rc, zipFile, | |||
needsUpdate); | |||
@@ -1253,8 +1253,8 @@ public class Zip extends MatchingTask { | |||
* to move the withEmpty behavior checks (since either would break | |||
* subclasses in several ways). | |||
*/ | |||
private static ThreadLocal haveNonFileSetResourcesToAdd = new ThreadLocal() { | |||
protected Object initialValue() { | |||
private static final ThreadLocal<Boolean> HAVE_NON_FILE_SET_RESOURCES_TO_ADD = new ThreadLocal<Boolean>() { | |||
protected Boolean initialValue() { | |||
return Boolean.FALSE; | |||
} | |||
}; | |||
@@ -1288,7 +1288,7 @@ public class Zip extends MatchingTask { | |||
Resource[][] initialResources = grabResources(filesets); | |||
if (isEmpty(initialResources)) { | |||
if (Boolean.FALSE.equals(haveNonFileSetResourcesToAdd.get())) { | |||
if (Boolean.FALSE.equals(HAVE_NON_FILE_SET_RESOURCES_TO_ADD.get())) { | |||
if (needsUpdate && doUpdate) { | |||
/* | |||
* This is a rather hairy case. | |||
@@ -1453,7 +1453,7 @@ public class Zip extends MatchingTask { | |||
Resource[][] initialResources = grabNonFileSetResources(rcs); | |||
boolean empty = isEmpty(initialResources); | |||
haveNonFileSetResourcesToAdd.set(Boolean.valueOf(!empty)); | |||
HAVE_NON_FILE_SET_RESOURCES_TO_ADD.set(Boolean.valueOf(!empty)); | |||
if (empty) { | |||
// no emptyBehavior handling since the FileSet version | |||
// will take care of it. | |||
@@ -1521,10 +1521,10 @@ public class Zip extends MatchingTask { | |||
getZipScanner(), | |||
MISSING_DIR_PROVIDER); | |||
if (rc.size() > 0) { | |||
ArrayList newer = new ArrayList(); | |||
ArrayList<Resource> newer = new ArrayList<Resource>(); | |||
newer.addAll(Arrays.asList(((Union) rc).listResources())); | |||
newer.addAll(Arrays.asList(result)); | |||
result = (Resource[]) newer.toArray(result); | |||
result = newer.toArray(result); | |||
} | |||
} | |||
return result; | |||
@@ -1552,7 +1552,7 @@ public class Zip extends MatchingTask { | |||
if (rs instanceof ZipScanner) { | |||
((ZipScanner) rs).setEncoding(encoding); | |||
} | |||
Vector resources = new Vector(); | |||
Vector<Resource> resources = new Vector<Resource>(); | |||
if (!doFilesonly) { | |||
String[] directories = rs.getIncludedDirectories(); | |||
for (int j = 0; j < directories.length; j++) { | |||
@@ -1585,8 +1585,8 @@ public class Zip extends MatchingTask { | |||
protected Resource[][] grabNonFileSetResources(ResourceCollection[] rcs) { | |||
Resource[][] result = new Resource[rcs.length][]; | |||
for (int i = 0; i < rcs.length; i++) { | |||
ArrayList dirs = new ArrayList(); | |||
ArrayList files = new ArrayList(); | |||
ArrayList<Resource> dirs = new ArrayList<Resource>(); | |||
ArrayList<Resource> files = new ArrayList<Resource>(); | |||
for (Resource r : rcs[i]) { | |||
if (r.isExists()) { | |||
if (r.isDirectory()) { | |||
@@ -1598,16 +1598,14 @@ public class Zip extends MatchingTask { | |||
} | |||
// make sure directories are in alpha-order - this also | |||
// ensures parents come before their children | |||
Collections.sort(dirs, new Comparator() { | |||
public int compare(Object o1, Object o2) { | |||
Resource r1 = (Resource) o1; | |||
Resource r2 = (Resource) o2; | |||
Collections.sort(dirs, new Comparator<Resource>() { | |||
public int compare(Resource r1, Resource r2) { | |||
return r1.getName().compareTo(r2.getName()); | |||
} | |||
}); | |||
ArrayList rs = new ArrayList(dirs); | |||
ArrayList<Resource> rs = new ArrayList<Resource>(dirs); | |||
rs.addAll(files); | |||
result[i] = (Resource[]) rs.toArray(new Resource[rs.size()]); | |||
result[i] = rs.toArray(new Resource[rs.size()]); | |||
} | |||
return result; | |||
} | |||
@@ -1702,11 +1700,7 @@ public class Zip extends MatchingTask { | |||
* support a new parameter (extra fields to preserve) without | |||
* breaking subclasses that override the old method signature. | |||
*/ | |||
private static ThreadLocal currentZipExtra = new ThreadLocal() { | |||
protected Object initialValue() { | |||
return null; | |||
} | |||
}; | |||
private static final ThreadLocal<ZipExtraField[]> CURRENT_ZIP_EXTRA = new ThreadLocal<ZipExtraField[]>(); | |||
/** | |||
* Provides the extra fields for the zip entry currently being | |||
@@ -1714,7 +1708,7 @@ public class Zip extends MatchingTask { | |||
* @since Ant 1.8.0 | |||
*/ | |||
protected final ZipExtraField[] getCurrentExtraFields() { | |||
return (ZipExtraField[]) currentZipExtra.get(); | |||
return (ZipExtraField[]) CURRENT_ZIP_EXTRA.get(); | |||
} | |||
/** | |||
@@ -1723,7 +1717,7 @@ public class Zip extends MatchingTask { | |||
* @since Ant 1.8.0 | |||
*/ | |||
protected final void setCurrentExtraFields(ZipExtraField[] extra) { | |||
currentZipExtra.set(extra); | |||
CURRENT_ZIP_EXTRA.set(extra); | |||
} | |||
/** | |||
@@ -1907,7 +1901,7 @@ public class Zip extends MatchingTask { | |||
int dirMode) | |||
throws IOException { | |||
if (!doFilesonly) { | |||
Stack directories = new Stack(); | |||
Stack<String> directories = new Stack<String>(); | |||
int slashPos = entry.length(); | |||
while ((slashPos = entry.lastIndexOf('/', slashPos - 1)) != -1) { | |||
@@ -1919,7 +1913,7 @@ public class Zip extends MatchingTask { | |||
} | |||
while (!directories.isEmpty()) { | |||
String dir = (String) directories.pop(); | |||
String dir = directories.pop(); | |||
File f = null; | |||
if (baseDir != null) { | |||
f = new File(baseDir, dir); | |||
@@ -1951,13 +1945,13 @@ public class Zip extends MatchingTask { | |||
entries.clear(); | |||
addingNewFiles = false; | |||
doUpdate = savedDoUpdate; | |||
Enumeration e = filesetsFromGroupfilesets.elements(); | |||
Enumeration<ZipFileSet> e = filesetsFromGroupfilesets.elements(); | |||
while (e.hasMoreElements()) { | |||
ZipFileSet zf = (ZipFileSet) e.nextElement(); | |||
ZipFileSet zf = e.nextElement(); | |||
resources.removeElement(zf); | |||
} | |||
filesetsFromGroupfilesets.removeAllElements(); | |||
haveNonFileSetResourcesToAdd.set(Boolean.FALSE); | |||
HAVE_NON_FILE_SET_RESOURCES_TO_ADD.set(Boolean.FALSE); | |||
} | |||
/** | |||
@@ -2049,7 +2043,7 @@ public class Zip extends MatchingTask { | |||
return orig; | |||
} | |||
ArrayList v = new ArrayList(orig.length); | |||
ArrayList<Resource> v = new ArrayList<Resource>(orig.length); | |||
for (int i = 0; i < orig.length; i++) { | |||
if (selector.isSelected(orig[i])) { | |||
v.add(orig[i]); | |||
@@ -2057,8 +2051,7 @@ public class Zip extends MatchingTask { | |||
} | |||
if (v.size() != orig.length) { | |||
Resource[] r = new Resource[v.size()]; | |||
return (Resource[]) v.toArray(r); | |||
return v.toArray(new Resource[v.size()]); | |||
} | |||
return orig; | |||
} | |||
@@ -2146,7 +2139,7 @@ public class Zip extends MatchingTask { | |||
* @since Ant 1.8.0 | |||
*/ | |||
public static final class UnicodeExtraField extends EnumeratedAttribute { | |||
private static final Map POLICIES = new HashMap(); | |||
private static final Map<String, UnicodeExtraFieldPolicy> POLICIES = new HashMap<String, UnicodeExtraFieldPolicy>(); | |||
private static final String NEVER_KEY = "never"; | |||
private static final String ALWAYS_KEY = "always"; | |||
private static final String N_E_KEY = "not-encodeable"; | |||
@@ -446,7 +446,7 @@ public class EmailTask extends Task { | |||
if (encoding.equals(MIME) | |||
|| (encoding.equals(AUTO) && !autoFound)) { | |||
try { | |||
//check to make sure that activation.jar | |||
//check to make sure that activation.jar | |||
//and mail.jar are available - see bug 31969 | |||
Class.forName("javax.activation.DataHandler"); | |||
Class.forName("javax.mail.internet.MimeMessage"); | |||
@@ -529,7 +529,7 @@ public class EmailTask extends Task { | |||
} | |||
// identify which files should be attached | |||
Vector files = new Vector(); | |||
Vector<File> files = new Vector<File>(); | |||
if (attachments != null) { | |||
for (Resource r : attachments) { | |||
files.addElement(r.as(FileProvider.class) | |||
@@ -17,6 +17,7 @@ | |||
*/ | |||
package org.apache.tools.ant.taskdefs.email; | |||
import java.io.File; | |||
import java.util.Vector; | |||
import org.apache.tools.ant.BuildException; | |||
import org.apache.tools.ant.Task; | |||
@@ -38,15 +39,15 @@ public abstract class Mailer { | |||
// CheckStyle:MemberNameCheck ON | |||
protected Message message; | |||
protected EmailAddress from; | |||
protected Vector replyToList = null; | |||
protected Vector toList = null; | |||
protected Vector ccList = null; | |||
protected Vector bccList = null; | |||
protected Vector files = null; | |||
protected Vector<EmailAddress> replyToList = null; | |||
protected Vector<EmailAddress> toList = null; | |||
protected Vector<EmailAddress> ccList = null; | |||
protected Vector<EmailAddress> bccList = null; | |||
protected Vector<File> files = null; | |||
protected String subject = null; | |||
protected Task task; | |||
protected boolean includeFileNames = false; | |||
protected Vector headers = null; | |||
protected Vector<Header> headers = null; | |||
// CheckStyle:VisibilityModifier ON | |||
private boolean ignoreInvalidRecipients = false; | |||
private boolean starttls = false; | |||
@@ -71,7 +72,7 @@ public abstract class Mailer { | |||
} | |||
/** | |||
* Whether the port has been explicitly specified by the user. | |||
* Whether the port has been explicitly specified by the user. | |||
* @since Ant 1.8.2 | |||
*/ | |||
public void setPortExplicitlySpecified(boolean explicit) { | |||
@@ -79,7 +80,7 @@ public abstract class Mailer { | |||
} | |||
/** | |||
* Whether the port has been explicitly specified by the user. | |||
* Whether the port has been explicitly specified by the user. | |||
* @since Ant 1.8.2 | |||
*/ | |||
protected boolean isPortExplicitlySpecified() { | |||
@@ -154,7 +155,7 @@ public abstract class Mailer { | |||
* @param list a vector of reployTo addresses. | |||
* @since Ant 1.6 | |||
*/ | |||
public void setReplyToList(Vector list) { | |||
public void setReplyToList(Vector<EmailAddress> list) { | |||
this.replyToList = list; | |||
} | |||
@@ -163,7 +164,7 @@ public abstract class Mailer { | |||
* | |||
* @param list a vector of recipient addresses. | |||
*/ | |||
public void setToList(Vector list) { | |||
public void setToList(Vector<EmailAddress> list) { | |||
this.toList = list; | |||
} | |||
@@ -172,7 +173,7 @@ public abstract class Mailer { | |||
* | |||
* @param list a vector of cc addresses. | |||
*/ | |||
public void setCcList(Vector list) { | |||
public void setCcList(Vector<EmailAddress> list) { | |||
this.ccList = list; | |||
} | |||
@@ -181,7 +182,7 @@ public abstract class Mailer { | |||
* | |||
* @param list a vector of the bcc addresses. | |||
*/ | |||
public void setBccList(Vector list) { | |||
public void setBccList(Vector<EmailAddress> list) { | |||
this.bccList = list; | |||
} | |||
@@ -190,7 +191,7 @@ public abstract class Mailer { | |||
* | |||
* @param files list of files to attach to the email. | |||
*/ | |||
public void setFiles(Vector files) { | |||
public void setFiles(Vector<File> files) { | |||
this.files = files; | |||
} | |||
@@ -226,7 +227,7 @@ public abstract class Mailer { | |||
* @param v a Vector presumed to contain Header objects. | |||
* @since Ant 1.7 | |||
*/ | |||
public void setHeaders(Vector v) { | |||
public void setHeaders(Vector<Header> v) { | |||
this.headers = v; | |||
} | |||
@@ -31,7 +31,7 @@ public final class AntFilterReader | |||
private String className; | |||
private final Vector parameters = new Vector(); | |||
private final Vector<Parameter> parameters = new Vector<Parameter>(); | |||
private Path classpath; | |||
@@ -160,7 +160,7 @@ public final class AntFilterReader | |||
super.setRefid(r); | |||
} | |||
protected synchronized void dieOnCircularReference(Stack stk, Project p) | |||
protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) | |||
throws BuildException { | |||
if (isChecked()) { | |||
return; | |||
@@ -112,7 +112,7 @@ public abstract class DataType extends ProjectComponent implements Cloneable { | |||
if (checked || !isReference()) { | |||
return; | |||
} | |||
dieOnCircularReference(new IdentityStack(this), p); | |||
dieOnCircularReference(new IdentityStack<Object>(this), p); | |||
} | |||
/** | |||
@@ -134,7 +134,7 @@ public abstract class DataType extends ProjectComponent implements Cloneable { | |||
* @param project the project to use to dereference the references. | |||
* @throws BuildException on error. | |||
*/ | |||
protected void dieOnCircularReference(final Stack stack, | |||
protected void dieOnCircularReference(final Stack<Object> stack, | |||
final Project project) | |||
throws BuildException { | |||
@@ -144,7 +144,7 @@ public abstract class DataType extends ProjectComponent implements Cloneable { | |||
Object o = ref.getReferencedObject(project); | |||
if (o instanceof DataType) { | |||
IdentityStack id = IdentityStack.getInstance(stack); | |||
IdentityStack<Object> id = IdentityStack.getInstance(stack); | |||
if (id.contains(o)) { | |||
throw circularReference(); | |||
@@ -166,7 +166,7 @@ public abstract class DataType extends ProjectComponent implements Cloneable { | |||
* @throws BuildException on error. | |||
* @since Ant 1.7 | |||
*/ | |||
public static void invokeCircularReferenceCheck(DataType dt, Stack stk, | |||
public static void invokeCircularReferenceCheck(DataType dt, Stack<Object> stk, | |||
Project p) { | |||
dt.dieOnCircularReference(stk, p); | |||
} | |||
@@ -184,7 +184,7 @@ public abstract class DataType extends ProjectComponent implements Cloneable { | |||
* @since Ant 1.8.0 | |||
*/ | |||
public static void pushAndInvokeCircularReferenceCheck(DataType dt, | |||
Stack stk, | |||
Stack<Object> stk, | |||
Project p) { | |||
stk.push(dt); | |||
dt.dieOnCircularReference(stk, p); | |||
@@ -223,7 +223,7 @@ public abstract class DataType extends ProjectComponent implements Cloneable { | |||
* @return the dereferenced object. | |||
* @throws BuildException if the reference is invalid (circular ref, wrong class, etc). | |||
*/ | |||
protected Object getCheckedRef(final Class requiredClass, | |||
protected <T> T getCheckedRef(final Class<T> requiredClass, | |||
final String dataTypeName) { | |||
return getCheckedRef(requiredClass, dataTypeName, getProject()); | |||
} | |||
@@ -240,7 +240,7 @@ public abstract class DataType extends ProjectComponent implements Cloneable { | |||
* or if <code>project</code> is <code>null</code>. | |||
* @since Ant 1.7 | |||
*/ | |||
protected Object getCheckedRef(final Class requiredClass, | |||
protected <T> T getCheckedRef(final Class<T> requiredClass, | |||
final String dataTypeName, final Project project) { | |||
if (project == null) { | |||
throw new BuildException("No Project specified"); | |||
@@ -253,7 +253,9 @@ public abstract class DataType extends ProjectComponent implements Cloneable { | |||
String msg = ref.getRefId() + " doesn\'t denote a " + dataTypeName; | |||
throw new BuildException(msg); | |||
} | |||
return o; | |||
@SuppressWarnings("unchecked") | |||
final T result = (T) o; | |||
return result; | |||
} | |||
/** | |||
@@ -32,7 +32,7 @@ public class Environment { | |||
* a vector of type Environment.Variable | |||
* @see Variable | |||
*/ | |||
protected Vector variables; | |||
protected Vector<Variable> variables; | |||
// CheckStyle:VisibilityModifier ON | |||
@@ -135,7 +135,7 @@ public class Environment { | |||
* constructor | |||
*/ | |||
public Environment() { | |||
variables = new Vector(); | |||
variables = new Vector<Variable>(); | |||
} | |||
/** | |||
@@ -170,7 +170,7 @@ public class Environment { | |||
* Variable | |||
* @since Ant 1.7 | |||
*/ | |||
public Vector getVariablesVector() { | |||
public Vector<Variable> getVariablesVector() { | |||
return variables; | |||
} | |||
} |
@@ -48,7 +48,7 @@ import org.apache.tools.ant.filters.TokenFilter; | |||
public class FilterChain extends DataType | |||
implements Cloneable { | |||
private Vector filterReaders = new Vector(); | |||
private Vector<Object> filterReaders = new Vector<Object>(); | |||
/** | |||
* Add an AntFilterReader filter. | |||
@@ -68,7 +68,7 @@ public class FilterChain extends DataType | |||
* | |||
* @return a <code>Vector</code> value containing the filters | |||
*/ | |||
public Vector getFilterReaders() { | |||
public Vector<Object> getFilterReaders() { | |||
if (isReference()) { | |||
return ((FilterChain) getCheckedRef()).getFilterReaders(); | |||
} | |||
@@ -396,7 +396,7 @@ public class FilterChain extends DataType | |||
filterReaders.addElement(filter); | |||
} | |||
protected synchronized void dieOnCircularReference(Stack stk, Project p) | |||
protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) | |||
throws BuildException { | |||
if (isChecked()) { | |||
return; | |||
@@ -404,7 +404,7 @@ public class FilterChain extends DataType | |||
if (isReference()) { | |||
super.dieOnCircularReference(stk, p); | |||
} else { | |||
for (Iterator i = filterReaders.iterator(); i.hasNext(); ) { | |||
for (Iterator<Object> i = filterReaders.iterator(); i.hasNext(); ) { | |||
Object o = i.next(); | |||
if (o instanceof DataType) { | |||
pushAndInvokeCircularReferenceCheck((DataType) o, stk, p); | |||
@@ -79,9 +79,6 @@ public class Path extends DataType implements Cloneable, ResourceCollection { | |||
public static final Path systemBootClasspath = | |||
new Path(null, System.getProperty("sun.boot.class.path")); | |||
private static final Iterator EMPTY_ITERATOR | |||
= Collections.EMPTY_SET.iterator(); | |||
// CheckStyle:VisibilityModifier OFF - bc | |||
/** | |||
@@ -397,7 +394,7 @@ public class Path extends DataType implements Cloneable, ResourceCollection { | |||
* @return an array of strings, one for each path element | |||
*/ | |||
public static String[] translatePath(Project project, String source) { | |||
final Vector result = new Vector(); | |||
final Vector<String> result = new Vector<String>(); | |||
if (source == null) { | |||
return new String[0]; | |||
} | |||
@@ -418,9 +415,7 @@ public class Path extends DataType implements Cloneable, ResourceCollection { | |||
result.addElement(element.toString()); | |||
element = new StringBuffer(); | |||
} | |||
String[] res = new String[result.size()]; | |||
result.copyInto(res); | |||
return res; | |||
return result.toArray(new String[result.size()]); | |||
} | |||
/** | |||
@@ -489,7 +484,7 @@ public class Path extends DataType implements Cloneable, 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; | |||
@@ -553,7 +548,7 @@ public class Path extends DataType implements Cloneable, ResourceCollection { | |||
Path result = new Path(getProject()); | |||
String order = defValue; | |||
String o = getProject() != null | |||
String o = getProject() != null | |||
? getProject().getProperty(MagicNames.BUILD_SYSCLASSPATH) | |||
: System.getProperty(MagicNames.BUILD_SYSCLASSPATH); | |||
if (o != null) { | |||
@@ -709,7 +704,7 @@ public class Path extends DataType implements Cloneable, ResourceCollection { | |||
if (getPreserveBC()) { | |||
return new FileResourceIterator(getProject(), null, list()); | |||
} | |||
return union == null ? EMPTY_ITERATOR | |||
return union == null ? Collections.<Resource> emptySet().iterator() | |||
: assertFilesystemOnly(union).iterator(); | |||
} | |||
@@ -89,7 +89,7 @@ public class Resources extends DataType implements ResourceCollection { | |||
return coll; | |||
} | |||
private class MyIterator implements Iterator<Resource> { | |||
private Iterator rci = getNested().iterator(); | |||
private Iterator<ResourceCollection> rci = getNested().iterator(); | |||
private Iterator<Resource> ri = null; | |||
public boolean hasNext() { | |||
@@ -112,7 +112,7 @@ public class Resources extends DataType implements ResourceCollection { | |||
} | |||
} | |||
private Vector rc; | |||
private Vector<ResourceCollection> rc; | |||
private Collection<Resource> coll; | |||
private boolean cache = false; | |||
@@ -151,7 +151,7 @@ public class Resources extends DataType implements ResourceCollection { | |||
return; | |||
} | |||
if (rc == null) { | |||
rc = new Vector(); | |||
rc = new Vector<ResourceCollection>(); | |||
} | |||
rc.add(c); | |||
invalidateExistingIterators(); | |||
@@ -193,8 +193,8 @@ public class Resources extends DataType implements ResourceCollection { | |||
} | |||
validate(); | |||
for (Iterator i = getNested().iterator(); i.hasNext();) { | |||
if ((!((ResourceCollection) i.next()).isFilesystemOnly())) { | |||
for (Iterator<ResourceCollection> i = getNested().iterator(); i.hasNext();) { | |||
if (!i.next().isFilesystemOnly()) { | |||
return false; | |||
} | |||
} | |||
@@ -230,7 +230,7 @@ public class Resources extends DataType implements ResourceCollection { | |||
* @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; | |||
@@ -238,10 +238,9 @@ public class Resources extends DataType implements ResourceCollection { | |||
if (isReference()) { | |||
super.dieOnCircularReference(stk, p); | |||
} else { | |||
for (Iterator i = getNested().iterator(); i.hasNext();) { | |||
Object o = i.next(); | |||
if (o instanceof DataType) { | |||
pushAndInvokeCircularReferenceCheck((DataType) o, stk, p); | |||
for (ResourceCollection resourceCollection : getNested()) { | |||
if (resourceCollection instanceof DataType) { | |||
pushAndInvokeCircularReferenceCheck((DataType) resourceCollection, stk, p); | |||
} | |||
} | |||
setChecked(true); | |||
@@ -269,7 +268,7 @@ public class Resources extends DataType implements ResourceCollection { | |||
coll = (coll == null) ? new MyCollection() : coll; | |||
} | |||
private synchronized List getNested() { | |||
return rc == null ? Collections.EMPTY_LIST : rc; | |||
private synchronized List<ResourceCollection> getNested() { | |||
return rc == null ? Collections.<ResourceCollection> emptyList() : rc; | |||
} | |||
} |
@@ -24,7 +24,6 @@ import java.io.InputStream; | |||
import java.io.OutputStreamWriter; | |||
import java.io.Writer; | |||
import java.util.ArrayList; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import org.apache.tools.ant.ProjectComponent; | |||
@@ -37,7 +36,7 @@ import org.apache.tools.ant.BuildException; | |||
* http://issues.apache.org/bugzilla/show_bug.cgi?id=31520</a> | |||
*/ | |||
public class Service extends ProjectComponent { | |||
private List providerList = new ArrayList(); | |||
private List<Provider> providerList = new ArrayList<Provider>(); | |||
private String type; | |||
/** | |||
@@ -84,16 +83,9 @@ public class Service extends ProjectComponent { | |||
* @throws IOException if there is an error. | |||
*/ | |||
public InputStream getAsStream() throws IOException { | |||
ByteArrayOutputStream arrayOut; | |||
Writer writer; | |||
Iterator providerIterator; | |||
Provider provider; | |||
arrayOut = new ByteArrayOutputStream(); | |||
writer = new OutputStreamWriter(arrayOut, "UTF-8"); | |||
providerIterator = providerList.iterator(); | |||
while (providerIterator.hasNext()) { | |||
provider = (Provider) providerIterator.next(); | |||
ByteArrayOutputStream arrayOut = new ByteArrayOutputStream(); | |||
Writer writer = new OutputStreamWriter(arrayOut, "UTF-8"); | |||
for (Provider provider : providerList) { | |||
writer.write(provider.getClassName()); | |||
writer.write("\n"); | |||
} | |||
@@ -23,7 +23,7 @@ import java.util.Stack; | |||
* Identity Stack. | |||
* @since Ant 1.7 | |||
*/ | |||
public class IdentityStack extends Stack { | |||
public class IdentityStack<E> extends Stack<E> { | |||
private static final long serialVersionUID = -5555522620060077046L; | |||
@@ -32,11 +32,11 @@ public class IdentityStack extends Stack { | |||
* @param s the Stack to copy; ignored if null. | |||
* @return an IdentityStack instance. | |||
*/ | |||
public static IdentityStack getInstance(Stack s) { | |||
public static <E> IdentityStack<E> getInstance(Stack<E> s) { | |||
if (s instanceof IdentityStack) { | |||
return (IdentityStack) s; | |||
return (IdentityStack<E>) s; | |||
} | |||
IdentityStack result = new IdentityStack(); | |||
IdentityStack<E> result = new IdentityStack<E>(); | |||
if (s != null) { | |||
result.addAll(s); | |||
} | |||
@@ -54,7 +54,7 @@ public class IdentityStack extends Stack { | |||
* as the bottom element. | |||
* @param o the bottom element. | |||
*/ | |||
public IdentityStack(Object o) { | |||
public IdentityStack(E o) { | |||
super(); | |||
push(o); | |||
} | |||
@@ -37,23 +37,25 @@ import java.util.Set; | |||
* | |||
* @since Ant 1.8.2 | |||
*/ | |||
public class LinkedHashtable extends Hashtable { | |||
private final LinkedHashMap map; | |||
public class LinkedHashtable<K, V> extends Hashtable<K, V> { | |||
private static final long serialVersionUID = 1L; | |||
private final LinkedHashMap<K, V> map; | |||
public LinkedHashtable() { | |||
map = new LinkedHashMap(); | |||
map = new LinkedHashMap<K, V>(); | |||
} | |||
public LinkedHashtable(int initialCapacity) { | |||
map = new LinkedHashMap(initialCapacity); | |||
map = new LinkedHashMap<K, V>(initialCapacity); | |||
} | |||
public LinkedHashtable(int initialCapacity, float loadFactor) { | |||
map = new LinkedHashMap(initialCapacity, loadFactor); | |||
map = new LinkedHashMap<K, V>(initialCapacity, loadFactor); | |||
} | |||
public LinkedHashtable(Map m) { | |||
map = new LinkedHashMap(m); | |||
public LinkedHashtable(Map<K, V> m) { | |||
map = new LinkedHashMap<K, V>(m); | |||
} | |||
public synchronized void clear() { | |||
@@ -72,11 +74,11 @@ public class LinkedHashtable extends Hashtable { | |||
return map.containsValue(value); | |||
} | |||
public Enumeration elements() { | |||
public Enumeration<V> elements() { | |||
return CollectionUtils.asEnumeration(values().iterator()); | |||
} | |||
public synchronized Set entrySet() { | |||
public synchronized Set<Map.Entry<K, V>> entrySet() { | |||
return map.entrySet(); | |||
} | |||
@@ -84,7 +86,7 @@ public class LinkedHashtable extends Hashtable { | |||
return map.equals(o); | |||
} | |||
public synchronized Object get(Object k) { | |||
public synchronized V get(Object k) { | |||
return map.get(k); | |||
} | |||
@@ -96,23 +98,23 @@ public class LinkedHashtable extends Hashtable { | |||
return map.isEmpty(); | |||
} | |||
public Enumeration keys() { | |||
public Enumeration<K> keys() { | |||
return CollectionUtils.asEnumeration(keySet().iterator()); | |||
} | |||
public synchronized Set keySet() { | |||
public synchronized Set<K> keySet() { | |||
return map.keySet(); | |||
} | |||
public synchronized Object put(Object k, Object v) { | |||
public synchronized V put(K k, V v) { | |||
return map.put(k, v); | |||
} | |||
public synchronized void putAll(Map m) { | |||
public synchronized void putAll(Map<? extends K, ? extends V> m) { | |||
map.putAll(m); | |||
} | |||
public synchronized Object remove(Object k) { | |||
public synchronized V remove(Object k) { | |||
return map.remove(k); | |||
} | |||
@@ -124,7 +126,7 @@ public class LinkedHashtable extends Hashtable { | |||
return map.toString(); | |||
} | |||
public synchronized Collection values() { | |||
public synchronized Collection<V> values() { | |||
return map.values(); | |||
} | |||
} |
@@ -41,11 +41,11 @@ public class ReflectUtil { | |||
* the given arguments. | |||
* @since Ant 1.8.0 | |||
*/ | |||
public static Object newInstance(Class ofClass, | |||
Class[] argTypes, | |||
public static <T> T newInstance(Class<T> ofClass, | |||
Class<?>[] argTypes, | |||
Object[] args) { | |||
try { | |||
Constructor con = ofClass.getConstructor(argTypes); | |||
Constructor<T> con = ofClass.getConstructor(argTypes); | |||
return con.newInstance(args); | |||
} catch (Exception t) { | |||
throwBuildException(t); | |||
@@ -82,7 +82,7 @@ public class ReflectUtil { | |||
public static Object invokeStatic(Object obj, String methodName) { | |||
try { | |||
Method method; | |||
method = ((Class) obj).getMethod( | |||
method = ((Class<?>) obj).getMethod( | |||
methodName, (Class[]) null); | |||
return method.invoke(obj, (Object[]) null); | |||
} catch (Exception t) { | |||
@@ -100,7 +100,7 @@ public class ReflectUtil { | |||
* @return the object returned by the method | |||
*/ | |||
public static Object invoke( | |||
Object obj, String methodName, Class argType, Object arg) { | |||
Object obj, String methodName, Class<?> argType, Object arg) { | |||
try { | |||
Method method; | |||
method = obj.getClass().getMethod( | |||
@@ -123,8 +123,8 @@ public class ReflectUtil { | |||
* @return the object returned by the method | |||
*/ | |||
public static Object invoke( | |||
Object obj, String methodName, Class argType1, Object arg1, | |||
Class argType2, Object arg2) { | |||
Object obj, String methodName, Class<?> argType1, Object arg1, | |||
Class<?> argType2, Object arg2) { | |||
try { | |||
Method method; | |||
method = obj.getClass().getMethod( | |||
@@ -49,7 +49,7 @@ public final class StringUtils { | |||
* @param data the string to split up into lines. | |||
* @return the list of lines available in the string. | |||
*/ | |||
public static Vector lineSplit(String data) { | |||
public static Vector<String> lineSplit(String data) { | |||
return split(data, '\n'); | |||
} | |||
@@ -60,8 +60,8 @@ public final class StringUtils { | |||
* @param ch the separator character. | |||
* @return the list of elements. | |||
*/ | |||
public static Vector split(String data, int ch) { | |||
Vector elems = new Vector(); | |||
public static Vector<String> split(String data, int ch) { | |||
Vector<String> elems = new Vector<String>(); | |||
int pos = -1; | |||
int i = 0; | |||
while ((pos = data.indexOf(ch, i)) != -1) { | |||