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