You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by mb...@apache.org on 2012/08/21 16:27:49 UTC
svn commit: r1375571 [3/3] - in
/ant/core/trunk/src/main/org/apache/tools/ant: ./ dispatch/ filters/
filters/util/ helper/ input/ launch/ listener/ loader/ property/ taskdefs/
taskdefs/email/ types/ types/resources/ types/spi/ util/
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javadoc.java?rev=1375571&r1=1375570&r2=1375571&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javadoc.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javadoc.java Tue Aug 21 14:27:46 2012
@@ -78,7 +78,7 @@ import org.apache.tools.ant.util.JavaEnv
public class Javadoc extends Task {
// Whether *this VM* is 1.4+ (but also check executable != null).
- private static final boolean JAVADOC_5 =
+ private static final boolean JAVADOC_5 =
!JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_4);
/**
@@ -214,7 +214,7 @@ public class Javadoc extends Task {
public class DocletInfo extends ExtensionInfo {
/** Collection of doclet parameters. */
- private Vector params = new Vector();
+ private Vector<DocletParam> params = new Vector<DocletParam>();
/**
* Create a doclet parameter to be configured by Ant.
@@ -233,7 +233,7 @@ public class Javadoc extends Task {
*
* @return an Enumeration of DocletParam instances.
*/
- public Enumeration getParams() {
+ public Enumeration<DocletParam> getParams() {
return params.elements();
}
}
@@ -366,7 +366,7 @@ public class Javadoc extends Task {
* task runtime.</p>
*/
public class ResourceCollectionContainer {
- private ArrayList rcs = new ArrayList();
+ private ArrayList<ResourceCollection> rcs = new ArrayList<ResourceCollection>();
/**
* Add a resource collection to the container.
* @param rc the collection to add.
@@ -379,7 +379,7 @@ public class Javadoc extends Task {
* Get an iterator on the collection.
* @return an iterator.
*/
- private Iterator iterator() {
+ private Iterator<ResourceCollection> iterator() {
return rcs.iterator();
}
}
@@ -425,9 +425,9 @@ public class Javadoc extends Task {
private boolean failOnError = false;
private Path sourcePath = null;
private File destDir = null;
- private Vector sourceFiles = new Vector();
- private Vector packageNames = new Vector();
- private Vector excludePackageNames = new Vector(1);
+ private Vector<SourceFile> sourceFiles = new Vector<SourceFile>();
+ private Vector<PackageName> packageNames = new Vector<PackageName>();
+ private Vector<PackageName> excludePackageNames = new Vector<PackageName>(1);
private boolean author = true;
private boolean version = true;
private DocletInfo doclet = null;
@@ -435,9 +435,9 @@ public class Javadoc extends Task {
private Path bootclasspath = null;
private String group = null;
private String packageList = null;
- private Vector links = new Vector();
- private Vector groups = new Vector();
- private Vector tags = new Vector();
+ private Vector<LinkArgument> links = new Vector<LinkArgument>();
+ private Vector<GroupArgument> groups = new Vector<GroupArgument>();
+ private Vector<Object> tags = new Vector<Object>();
private boolean useDefaultExcludes = true;
private Html doctitle = null;
private Html header = null;
@@ -455,7 +455,7 @@ public class Javadoc extends Task {
private ResourceCollectionContainer nestedSourceFiles
= new ResourceCollectionContainer();
- private Vector packageSets = new Vector();
+ private Vector<DirSet> packageSets = new Vector<DirSet>();
/**
* Work around command line length limit by using an external file
@@ -1450,7 +1450,7 @@ public class Javadoc extends Task {
*/
public class GroupArgument {
private Html title;
- private Vector packages = new Vector();
+ private Vector<PackageName> packages = new Vector<PackageName>();
/** Constructor for GroupArgument */
public GroupArgument() {
@@ -1662,7 +1662,7 @@ public class Javadoc extends Task {
public void execute() throws BuildException {
checkTaskName();
- Vector packagesToDoc = new Vector();
+ Vector<String> packagesToDoc = new Vector<String>();
Path sourceDirs = new Path(getProject());
checkPackageAndSourcePath();
@@ -1674,7 +1674,8 @@ public class Javadoc extends Task {
parsePackages(packagesToDoc, sourceDirs);
checkPackages(packagesToDoc, sourceDirs);
- Vector sourceFilesToDoc = (Vector) sourceFiles.clone();
+ @SuppressWarnings("unchecked")
+ Vector<SourceFile> sourceFilesToDoc = (Vector<SourceFile>) sourceFiles.clone();
addSourceFiles(sourceFilesToDoc);
checkPackagesToDoc(packagesToDoc, sourceFilesToDoc);
@@ -1799,7 +1800,7 @@ public class Javadoc extends Task {
}
}
- private void checkPackages(Vector packagesToDoc, Path sourceDirs) {
+ private void checkPackages(Vector<String> packagesToDoc, Path sourceDirs) {
if (packagesToDoc.size() != 0 && sourceDirs.size() == 0) {
String msg = "sourcePath attribute must be set when "
+ "specifying package names.";
@@ -1808,7 +1809,7 @@ public class Javadoc extends Task {
}
private void checkPackagesToDoc(
- Vector packagesToDoc, Vector sourceFilesToDoc) {
+ Vector<String> packagesToDoc, Vector<SourceFile> sourceFilesToDoc) {
if (packageList == null && packagesToDoc.size() == 0
&& sourceFilesToDoc.size() == 0) {
throw new BuildException("No source files and no packages have "
@@ -1880,9 +1881,9 @@ public class Javadoc extends Task {
toExecute.createArgument().setPath(docletPath);
}
}
- for (Enumeration e = doclet.getParams();
+ for (Enumeration<DocletParam> e = doclet.getParams();
e.hasMoreElements();) {
- DocletParam param = (DocletParam) e.nextElement();
+ DocletParam param = e.nextElement();
if (param.getName() == null) {
throw new BuildException("Doclet parameters must "
+ "have a name");
@@ -1952,8 +1953,8 @@ public class Javadoc extends Task {
private void doLinks(Commandline toExecute) {
if (links.size() != 0) {
- for (Enumeration e = links.elements(); e.hasMoreElements();) {
- LinkArgument la = (LinkArgument) e.nextElement();
+ for (Enumeration<LinkArgument> e = links.elements(); e.hasMoreElements();) {
+ LinkArgument la = e.nextElement();
if (la.getHref() == null || la.getHref().length() == 0) {
log("No href was given for the link - skipping",
@@ -2065,8 +2066,8 @@ public class Javadoc extends Task {
// add the group arguments
private void doGroups(Commandline toExecute) {
if (groups.size() != 0) {
- for (Enumeration e = groups.elements(); e.hasMoreElements();) {
- GroupArgument ga = (GroupArgument) e.nextElement();
+ for (Enumeration<GroupArgument> e = groups.elements(); e.hasMoreElements();) {
+ GroupArgument ga = e.nextElement();
String title = ga.getTitle();
String packages = ga.getPackages();
if (title == null || packages == null) {
@@ -2083,7 +2084,7 @@ public class Javadoc extends Task {
// Do java1.4 arguments
private void doJava14(Commandline toExecute) {
- for (Enumeration e = tags.elements(); e.hasMoreElements();) {
+ for (Enumeration<Object> e = tags.elements(); e.hasMoreElements();) {
Object element = e.nextElement();
if (element instanceof TagArgument) {
TagArgument ta = (TagArgument) element;
@@ -2170,15 +2171,13 @@ public class Javadoc extends Task {
private void doSourceAndPackageNames(
Commandline toExecute,
- Vector packagesToDoc,
- Vector sourceFilesToDoc,
+ Vector<String> packagesToDoc,
+ Vector<SourceFile> sourceFilesToDoc,
boolean useExternalFile,
File tmpList,
BufferedWriter srcListWriter)
throws IOException {
- Enumeration e = packagesToDoc.elements();
- while (e.hasMoreElements()) {
- String packageName = (String) e.nextElement();
+ for (String packageName : packagesToDoc) {
if (useExternalFile) {
srcListWriter.write(packageName);
srcListWriter.newLine();
@@ -2187,9 +2186,7 @@ public class Javadoc extends Task {
}
}
- e = sourceFilesToDoc.elements();
- while (e.hasMoreElements()) {
- SourceFile sf = (SourceFile) e.nextElement();
+ for (SourceFile sf : sourceFilesToDoc) {
String sourceFileName = sf.getFile().getAbsolutePath();
if (useExternalFile) {
// XXX what is the following doing?
@@ -2288,10 +2285,10 @@ public class Javadoc extends Task {
*
* @since 1.7
*/
- private void addSourceFiles(Vector sf) {
- Iterator e = nestedSourceFiles.iterator();
+ private void addSourceFiles(Vector<SourceFile> sf) {
+ Iterator<ResourceCollection> e = nestedSourceFiles.iterator();
while (e.hasNext()) {
- ResourceCollection rc = (ResourceCollection) e.next();
+ ResourceCollection rc = e.next();
if (!rc.isFilesystemOnly()) {
throw new BuildException("only file system based resources are"
+ " supported by javadoc");
@@ -2321,9 +2318,10 @@ public class Javadoc extends Task {
*
* @since 1.5
*/
- private void parsePackages(Vector pn, Path sp) {
- HashSet addedPackages = new HashSet();
- Vector dirSets = (Vector) packageSets.clone();
+ private void parsePackages(Vector<String> pn, Path sp) {
+ HashSet<String> addedPackages = new HashSet<String>();
+ @SuppressWarnings("unchecked")
+ Vector<DirSet> dirSets = (Vector<DirSet>) packageSets.clone();
// for each sourcePath entry, add a directoryset with includes
// taken from packagenames attribute and nested package
@@ -2333,9 +2331,9 @@ public class Javadoc extends Task {
PatternSet ps = new PatternSet();
ps.setProject(getProject());
if (packageNames.size() > 0) {
- Enumeration e = packageNames.elements();
+ Enumeration<PackageName> e = packageNames.elements();
while (e.hasMoreElements()) {
- PackageName p = (PackageName) e.nextElement();
+ PackageName p = e.nextElement();
String pkg = p.getName().replace('.', '/');
if (pkg.endsWith("*")) {
pkg += "*";
@@ -2346,9 +2344,9 @@ public class Javadoc extends Task {
ps.createInclude().setName("**");
}
- Enumeration e = excludePackageNames.elements();
+ Enumeration<PackageName> e = excludePackageNames.elements();
while (e.hasMoreElements()) {
- PackageName p = (PackageName) e.nextElement();
+ PackageName p = e.nextElement();
String pkg = p.getName().replace('.', '/');
if (pkg.endsWith("*")) {
pkg += "*";
@@ -2374,9 +2372,9 @@ public class Javadoc extends Task {
}
}
- Enumeration e = dirSets.elements();
+ Enumeration<DirSet> e = dirSets.elements();
while (e.hasMoreElements()) {
- DirSet ds = (DirSet) e.nextElement();
+ DirSet ds = e.nextElement();
File baseDir = ds.getDir(getProject());
log("scanning " + baseDir + " for packages.", Project.MSG_DEBUG);
DirectoryScanner dsc = ds.getDirectoryScanner(getProject());
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/KeySubst.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/KeySubst.java?rev=1375571&r1=1375570&r2=1375571&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/KeySubst.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/KeySubst.java Tue Aug 21 14:27:46 2012
@@ -44,7 +44,7 @@ public class KeySubst extends Task {
private File source = null;
private File dest = null;
private String sep = "*";
- private Hashtable replacements = new Hashtable();
+ private Hashtable<String, String> replacements = new Hashtable<String, String>();
/**
* Do the execution.
@@ -146,7 +146,7 @@ public class KeySubst extends Task {
*/
public static void main(String[] args) {
try {
- Hashtable hash = new Hashtable();
+ Hashtable<String, String> hash = new Hashtable<String, String>();
hash.put("VERSION", "1.0.3");
hash.put("b", "ffff");
System.out.println(KeySubst.replace("$f ${VERSION} f ${b} jj $",
@@ -163,7 +163,7 @@ public class KeySubst extends Task {
* @return the string with the replacements in it.
* @throws BuildException on error
*/
- public static String replace(String origString, Hashtable keys)
+ public static String replace(String origString, Hashtable<String, String> keys)
throws BuildException {
StringBuffer finalString = new StringBuffer();
int index = 0;
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Length.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Length.java?rev=1375571&r1=1375570&r2=1375571&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Length.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Length.java Tue Aug 21 14:27:46 2012
@@ -21,7 +21,6 @@ package org.apache.tools.ant.taskdefs;
import java.io.File;
import java.io.PrintStream;
import java.io.OutputStream;
-import java.util.Iterator;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.Project;
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/LoadProperties.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/LoadProperties.java?rev=1375571&r1=1375570&r2=1375571&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/LoadProperties.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/LoadProperties.java Tue Aug 21 14:27:46 2012
@@ -55,13 +55,13 @@ public class LoadProperties extends Task
/**
* Holds filterchains
*/
- private final Vector filterChains = new Vector();
+ private final Vector<FilterChain> filterChains = new Vector<FilterChain>();
/**
* Encoding to use for input; defaults to the platform's default encoding.
*/
private String encoding = null;
-
+
/**
* Prefix for loaded properties.
*/
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/LoadResource.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/LoadResource.java?rev=1375571&r1=1375570&r2=1375571&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/LoadResource.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/LoadResource.java Tue Aug 21 14:27:46 2012
@@ -69,7 +69,7 @@ public class LoadResource extends Task {
/**
* Holds FilterChains
*/
- private final Vector filterChains = new Vector();
+ private final Vector<FilterChain> filterChains = new Vector<FilterChain>();
/**
* Encoding to use for input, defaults to the platform's default
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/MacroInstance.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/MacroInstance.java?rev=1375571&r1=1375570&r2=1375571&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/MacroInstance.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/MacroInstance.java Tue Aug 21 14:27:46 2012
@@ -23,6 +23,7 @@ import java.util.List;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import java.util.HashSet;
import java.util.HashMap;
@@ -38,6 +39,7 @@ import org.apache.tools.ant.Task;
import org.apache.tools.ant.TaskContainer;
import org.apache.tools.ant.UnknownElement;
import org.apache.tools.ant.property.LocalProperties;
+import org.apache.tools.ant.taskdefs.MacroDef.Attribute;
/**
* The class to be placed in the ant type definition.
@@ -48,13 +50,13 @@ import org.apache.tools.ant.property.Loc
*/
public class MacroInstance extends Task implements DynamicAttribute, TaskContainer {
private MacroDef macroDef;
- private Map map = new HashMap();
- private Map nsElements = null;
- private Map presentElements;
- private Hashtable localAttributes;
+ private Map<String, String> map = new HashMap<String, String>();
+ private Map<String, MacroDef.TemplateElement> nsElements = null;
+ private Map<String, UnknownElement> presentElements;
+ private Hashtable<String, String> localAttributes;
private String text = null;
private String implicitTag = null;
- private List unknownElements = new ArrayList();
+ private List<Task> unknownElements = new ArrayList<Task>();
/**
* Called from MacroDef.MyAntTypeDefinition#create()
@@ -93,20 +95,18 @@ public class MacroInstance extends Task
throw new BuildException("Not implemented any more");
}
- private Map getNsElements() {
+ private Map<String, MacroDef.TemplateElement> getNsElements() {
if (nsElements == null) {
- nsElements = new HashMap();
- for (Iterator i = macroDef.getElements().entrySet().iterator();
- i.hasNext();) {
- Map.Entry entry = (Map.Entry) i.next();
- nsElements.put((String) entry.getKey(),
- entry.getValue());
- MacroDef.TemplateElement te = (MacroDef.TemplateElement)
- entry.getValue();
- if (te.isImplicit()) {
- implicitTag = te.getName();
- }
+ nsElements = new HashMap<String, MacroDef.TemplateElement>();
+ for (Entry<String, MacroDef.TemplateElement> entry : macroDef.getElements().entrySet()) {
+ nsElements.put((String) entry.getKey(),
+ entry.getValue());
+ MacroDef.TemplateElement te = (MacroDef.TemplateElement)
+ entry.getValue();
+ if (te.isImplicit()) {
+ implicitTag = te.getName();
}
+ }
}
return nsElements;
}
@@ -124,7 +124,7 @@ public class MacroInstance extends Task
if (implicitTag != null) {
return;
}
- for (Iterator i = unknownElements.iterator(); i.hasNext();) {
+ for (Iterator<Task> i = unknownElements.iterator(); i.hasNext();) {
UnknownElement ue = (UnknownElement) i.next();
String name = ProjectHelper.extractNameFromComponentName(
ue.getTag()).toLowerCase(Locale.ENGLISH);
@@ -142,7 +142,7 @@ public class MacroInstance extends Task
* Embedded element in macro instance
*/
public static class Element implements TaskContainer {
- private List unknownElements = new ArrayList();
+ private List<Task> unknownElements = new ArrayList<Task>();
/**
* Add an unknown element (to be snipped into the macroDef instance)
@@ -156,7 +156,7 @@ public class MacroInstance extends Task
/**
* @return the list of unknown elements
*/
- public List getUnknownElements() {
+ public List<Task> getUnknownElements() {
return unknownElements;
}
}
@@ -165,7 +165,7 @@ public class MacroInstance extends Task
private static final int STATE_EXPECT_BRACKET = 1;
private static final int STATE_EXPECT_NAME = 2;
- private String macroSubs(String s, Map macroMapping) {
+ private String macroSubs(String s, Map<String, String> macroMapping) {
if (s == null) {
return null;
}
@@ -262,26 +262,25 @@ public class MacroInstance extends Task
RuntimeConfigurable rc = new RuntimeConfigurable(
ret, ue.getTaskName());
rc.setPolyType(ue.getWrapper().getPolyType());
- Map m = ue.getWrapper().getAttributeMap();
- for (Iterator i = m.entrySet().iterator(); i.hasNext();) {
- Map.Entry entry = (Map.Entry) i.next();
+ Map<String, Object> m = ue.getWrapper().getAttributeMap();
+ for (Map.Entry<String, Object> entry : m.entrySet()) {
rc.setAttribute(
- (String) entry.getKey(),
+ entry.getKey(),
macroSubs((String) entry.getValue(), localAttributes));
}
rc.addText(macroSubs(ue.getWrapper().getText().toString(),
localAttributes));
- Enumeration e = ue.getWrapper().getChildren();
+ Enumeration<RuntimeConfigurable> e = ue.getWrapper().getChildren();
while (e.hasMoreElements()) {
- RuntimeConfigurable r = (RuntimeConfigurable) e.nextElement();
+ RuntimeConfigurable r = e.nextElement();
UnknownElement unknownElement = (UnknownElement) r.getProxy();
String tag = unknownElement.getTaskType();
if (tag != null) {
tag = tag.toLowerCase(Locale.ENGLISH);
}
MacroDef.TemplateElement templateElement =
- (MacroDef.TemplateElement) getNsElements().get(tag);
+ getNsElements().get(tag);
if (templateElement == null || nested) {
UnknownElement child = copy(unknownElement, nested);
rc.addChild(child.getWrapper());
@@ -292,7 +291,7 @@ public class MacroInstance extends Task
"Missing nested elements for implicit element "
+ templateElement.getName());
}
- for (Iterator i = unknownElements.iterator();
+ for (Iterator<Task> i = unknownElements.iterator();
i.hasNext();) {
UnknownElement child
= copy((UnknownElement) i.next(), true);
@@ -315,12 +314,12 @@ public class MacroInstance extends Task
if (!"".equals(presentText)) {
rc.addText(macroSubs(presentText, localAttributes));
}
- List list = presentElement.getChildren();
+ List<UnknownElement> list = presentElement.getChildren();
if (list != null) {
- for (Iterator i = list.iterator();
+ for (Iterator<UnknownElement> i = list.iterator();
i.hasNext();) {
UnknownElement child
- = copy((UnknownElement) i.next(), true);
+ = copy(i.next(), true);
rc.addChild(child.getWrapper());
ret.addChild(child);
}
@@ -337,13 +336,12 @@ public class MacroInstance extends Task
*
*/
public void execute() {
- presentElements = new HashMap();
+ presentElements = new HashMap<String, UnknownElement>();
getNsElements();
processTasks();
- localAttributes = new Hashtable();
- Set copyKeys = new HashSet(map.keySet());
- for (Iterator i = macroDef.getAttributes().iterator(); i.hasNext();) {
- MacroDef.Attribute attribute = (MacroDef.Attribute) i.next();
+ localAttributes = new Hashtable<String, String>();
+ Set<String> copyKeys = new HashSet<String>(map.keySet());
+ for (Attribute attribute : macroDef.getAttributes()) {
String value = (String) map.get(attribute.getName());
if (value == null && "description".equals(attribute.getName())) {
value = getDescription();
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/MakeUrl.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/MakeUrl.java?rev=1375571&r1=1375570&r2=1375571&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/MakeUrl.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/MakeUrl.java Tue Aug 21 14:27:46 2012
@@ -61,12 +61,12 @@ public class MakeUrl extends Task {
/**
* filesets of nested files to add to this url
*/
- private List filesets = new LinkedList();
+ private List<FileSet> filesets = new LinkedList<FileSet>();
/**
* paths to add
*/
- private List paths = new LinkedList();
+ private List<Path> paths = new LinkedList<Path>();
/**
* validation flag
@@ -148,8 +148,8 @@ public class MakeUrl extends Task {
return "";
}
int count = 0;
- StringBuffer urls = new StringBuffer();
- ListIterator list = filesets.listIterator();
+ StringBuilder urls = new StringBuilder();
+ ListIterator<FileSet> list = filesets.listIterator();
while (list.hasNext()) {
FileSet set = (FileSet) list.next();
DirectoryScanner scanner = set.getDirectoryScanner(getProject());
@@ -176,7 +176,7 @@ public class MakeUrl extends Task {
* @param count number of URL entries
* @return trimmed string, or empty string
*/
- private String stripTrailingSeparator(StringBuffer urls,
+ private String stripTrailingSeparator(StringBuilder urls,
int count) {
if (count > 0) {
urls.delete(urls.length() - separator.length(), urls.length());
@@ -197,8 +197,8 @@ public class MakeUrl extends Task {
return "";
}
int count = 0;
- StringBuffer urls = new StringBuffer();
- ListIterator list = paths.listIterator();
+ StringBuilder urls = new StringBuilder();
+ ListIterator<Path> list = paths.listIterator();
while (list.hasNext()) {
Path path = (Path) list.next();
String[] elements = path.list();
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Manifest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Manifest.java?rev=1375571&r1=1375570&r2=1375571&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Manifest.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Manifest.java Tue Aug 21 14:27:46 2012
@@ -27,7 +27,6 @@ import java.io.Reader;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.util.Enumeration;
-import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;
@@ -127,7 +126,7 @@ public class Manifest {
private String name = null;
/** The attribute's value */
- private Vector values = new Vector();
+ private Vector<String> values = new Vector<String>();
/**
* For multivalued attributes, this is the index of the attribute
@@ -276,8 +275,8 @@ public class Manifest {
}
String fullValue = "";
- for (Enumeration e = getValues(); e.hasMoreElements();) {
- String value = (String) e.nextElement();
+ for (Enumeration<String> e = getValues(); e.hasMoreElements();) {
+ String value = e.nextElement();
fullValue += value + " ";
}
return fullValue.trim();
@@ -298,7 +297,7 @@ public class Manifest {
*
* @return an enumeration of the attributes values
*/
- public Enumeration getValues() {
+ public Enumeration<String> getValues() {
return values.elements();
}
@@ -342,8 +341,8 @@ public class Manifest {
public void write(PrintWriter writer, boolean flatten)
throws IOException {
if (!flatten) {
- for (Enumeration e = getValues(); e.hasMoreElements();) {
- writeValue(writer, (String) e.nextElement());
+ for (Enumeration<String> e = getValues(); e.hasMoreElements();) {
+ writeValue(writer, e.nextElement());
}
} else {
writeValue(writer, getValue());
@@ -402,7 +401,7 @@ public class Manifest {
*/
public static class Section {
/** Warnings for this section */
- private Vector warnings = new Vector();
+ private Vector<String> warnings = new Vector<String>();
/**
* The section's name if any. The main section in a
@@ -411,7 +410,7 @@ public class Manifest {
private String name = null;
/** The section's attributes.*/
- private Map attributes = new LinkedHashMap();
+ private Map<String, Attribute> attributes = new LinkedHashMap<String, Attribute>();
/**
* The name of the section; optional -default is the main section.
@@ -509,19 +508,19 @@ public class Manifest {
+ "with different names");
}
- Enumeration e = section.getAttributeKeys();
+ Enumeration<String> e = section.getAttributeKeys();
Attribute classpathAttribute = null;
while (e.hasMoreElements()) {
- String attributeName = (String) e.nextElement();
+ String attributeName = e.nextElement();
Attribute attribute = section.getAttribute(attributeName);
if (attributeName.equalsIgnoreCase(ATTRIBUTE_CLASSPATH)) {
if (classpathAttribute == null) {
classpathAttribute = new Attribute();
classpathAttribute.setName(ATTRIBUTE_CLASSPATH);
}
- Enumeration cpe = attribute.getValues();
+ Enumeration<String> cpe = attribute.getValues();
while (cpe.hasMoreElements()) {
- String value = (String) cpe.nextElement();
+ String value = cpe.nextElement();
classpathAttribute.addValue(value);
}
} else {
@@ -534,9 +533,9 @@ public class Manifest {
if (mergeClassPaths) {
Attribute currentCp = getAttribute(ATTRIBUTE_CLASSPATH);
if (currentCp != null) {
- for (Enumeration attribEnum = currentCp.getValues();
+ for (Enumeration<String> attribEnum = currentCp.getValues();
attribEnum.hasMoreElements(); ) {
- String value = (String) attribEnum.nextElement();
+ String value = attribEnum.nextElement();
classpathAttribute.addValue(value);
}
}
@@ -545,7 +544,7 @@ public class Manifest {
}
// add in the warnings
- Enumeration warnEnum = section.warnings.elements();
+ Enumeration<String> warnEnum = section.warnings.elements();
while (warnEnum.hasMoreElements()) {
warnings.addElement(warnEnum.nextElement());
}
@@ -580,9 +579,9 @@ public class Manifest {
Attribute nameAttr = new Attribute(ATTRIBUTE_NAME, name);
nameAttr.write(writer);
}
- Enumeration e = getAttributeKeys();
+ Enumeration<String> e = getAttributeKeys();
while (e.hasMoreElements()) {
- String key = (String) e.nextElement();
+ String key = e.nextElement();
Attribute attribute = getAttribute(key);
attribute.write(writer, flatten);
}
@@ -607,7 +606,7 @@ public class Manifest {
* @return an Enumeration of Strings, each string being the lower case
* key of an attribute of the section.
*/
- public Enumeration getAttributeKeys() {
+ public Enumeration<String> getAttributeKeys() {
return CollectionUtils.asEnumeration(attributes.keySet().iterator());
}
@@ -695,9 +694,9 @@ public class Manifest {
+ "are supported but violate the Jar "
+ "specification and may not be correctly "
+ "processed in all environments");
- Enumeration e = attribute.getValues();
+ Enumeration<String> e = attribute.getValues();
while (e.hasMoreElements()) {
- String value = (String) e.nextElement();
+ String value = e.nextElement();
classpathAttribute.addValue(value);
}
}
@@ -721,9 +720,9 @@ public class Manifest {
public Object clone() {
Section cloned = new Section();
cloned.setName(name);
- Enumeration e = getAttributeKeys();
+ Enumeration<String> e = getAttributeKeys();
while (e.hasMoreElements()) {
- String key = (String) e.nextElement();
+ String key = e.nextElement();
Attribute attribute = getAttribute(key);
cloned.storeAttribute(new Attribute(attribute.getName(),
attribute.getValue()));
@@ -749,7 +748,7 @@ public class Manifest {
*
* @return an Enumeration of warning strings.
*/
- public Enumeration getWarnings() {
+ public Enumeration<String> getWarnings() {
return warnings.elements();
}
@@ -789,7 +788,7 @@ public class Manifest {
private Section mainSection = new Section();
/** The named sections of this manifest */
- private Map sections = new LinkedHashMap();
+ private Map<String, Section> sections = new LinkedHashMap<String, Section>();
/**
* Construct a manifest from Ant's default manifest file.
@@ -981,12 +980,12 @@ public class Manifest {
manifestVersion = other.manifestVersion;
}
- Enumeration e = other.getSectionNames();
+ Enumeration<String> e = other.getSectionNames();
while (e.hasMoreElements()) {
- String sectionName = (String) e.nextElement();
- Section ourSection = (Section) sections.get(sectionName);
+ String sectionName = e.nextElement();
+ Section ourSection = sections.get(sectionName);
Section otherSection
- = (Section) other.sections.get(sectionName);
+ = other.sections.get(sectionName);
if (ourSection == null) {
if (otherSection != null) {
addConfiguredSection((Section) otherSection.clone());
@@ -1043,9 +1042,7 @@ public class Manifest {
}
}
- Iterator e = sections.keySet().iterator();
- while (e.hasNext()) {
- String sectionName = (String) e.next();
+ for (String sectionName : sections.keySet()) {
Section section = getSection(sectionName);
section.write(writer, flatten);
}
@@ -1072,19 +1069,17 @@ public class Manifest {
*
* @return an enumeration of warning strings
*/
- public Enumeration getWarnings() {
- Vector warnings = new Vector();
+ public Enumeration<String> getWarnings() {
+ Vector<String> warnings = new Vector<String>();
- Enumeration warnEnum = mainSection.getWarnings();
+ Enumeration<String> warnEnum = mainSection.getWarnings();
while (warnEnum.hasMoreElements()) {
warnings.addElement(warnEnum.nextElement());
}
// create a vector and add in the warnings for all the sections
- Iterator e = sections.values().iterator();
- while (e.hasNext()) {
- Section section = (Section) e.next();
- Enumeration e2 = section.getWarnings();
+ for (Section section : sections.values()) {
+ Enumeration<String> e2 = section.getWarnings();
while (e2.hasMoreElements()) {
warnings.addElement(e2.nextElement());
}
@@ -1173,7 +1168,7 @@ public class Manifest {
*
* @return an Enumeration of section names
*/
- public Enumeration getSectionNames() {
+ public Enumeration<String> getSectionNames() {
return CollectionUtils.asEnumeration(sections.keySet().iterator());
}
}
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Zip.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Zip.java?rev=1375571&r1=1375570&r2=1375571&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Zip.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Zip.java Tue Aug 21 14:27:46 2012
@@ -32,7 +32,6 @@ import java.util.Comparator;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
-import java.util.Iterator;
import java.util.Map;
import java.util.Stack;
import java.util.Vector;
@@ -67,6 +66,7 @@ import org.apache.tools.zip.ZipEntry;
import org.apache.tools.zip.ZipExtraField;
import org.apache.tools.zip.ZipFile;
import org.apache.tools.zip.ZipOutputStream;
+import org.apache.tools.zip.ZipOutputStream.UnicodeExtraFieldPolicy;
/**
* Create a Zip file.
@@ -84,9 +84,9 @@ public class Zip extends MatchingTask {
// use to scan own archive
private ZipScanner zs;
private File baseDir;
- protected Hashtable entries = new Hashtable();
- private Vector groupfilesets = new Vector();
- private Vector filesetsFromGroupfilesets = new Vector();
+ protected Hashtable<String, String> entries = new Hashtable<String, String>();
+ private Vector<FileSet> groupfilesets = new Vector<FileSet>();
+ private Vector<ZipFileSet> filesetsFromGroupfilesets = new Vector<ZipFileSet>();
protected String duplicate = "add";
private boolean doCompress = true;
private boolean doUpdate = false;
@@ -98,9 +98,9 @@ public class Zip extends MatchingTask {
// For directories:
private static final long EMPTY_CRC = new CRC32 ().getValue ();
protected String emptyBehavior = "skip";
- private Vector resources = new Vector();
- protected Hashtable addedDirs = new Hashtable();
- private Vector addedFiles = new Vector();
+ private Vector<ResourceCollection> resources = new Vector<ResourceCollection>();
+ protected Hashtable<String, String> addedDirs = new Hashtable<String, String>();
+ private Vector<String> addedFiles = new Vector<String>();
private static final ResourceSelector MISSING_SELECTOR =
new ResourceSelector() {
@@ -596,7 +596,7 @@ public class Zip extends MatchingTask {
processGroupFilesets();
// collect filesets to pass them to getResourcesToAdd
- Vector vfss = new Vector();
+ Vector<ResourceCollection> vfss = new Vector<ResourceCollection>();
if (baseDir != null) {
FileSet fs = (FileSet) getImplicitFileSet().clone();
fs.setDir(baseDir);
@@ -1204,8 +1204,8 @@ public class Zip extends MatchingTask {
File zipFile,
boolean needsUpdate)
throws BuildException {
- ArrayList filesets = new ArrayList();
- ArrayList rest = new ArrayList();
+ ArrayList<ResourceCollection> filesets = new ArrayList<ResourceCollection>();
+ ArrayList<ResourceCollection> rest = new ArrayList<ResourceCollection>();
for (int i = 0; i < rcs.length; i++) {
if (rcs[i] instanceof FileSet) {
filesets.add(rcs[i]);
@@ -1213,7 +1213,7 @@ public class Zip extends MatchingTask {
rest.add(rcs[i]);
}
}
- ResourceCollection[] rc = (ResourceCollection[])
+ ResourceCollection[] rc =
rest.toArray(new ResourceCollection[rest.size()]);
ArchiveState as = getNonFileSetResourcesToAdd(rc, zipFile,
needsUpdate);
@@ -1253,8 +1253,8 @@ public class Zip extends MatchingTask {
* to move the withEmpty behavior checks (since either would break
* subclasses in several ways).
*/
- private static ThreadLocal haveNonFileSetResourcesToAdd = new ThreadLocal() {
- protected Object initialValue() {
+ private static final ThreadLocal<Boolean> HAVE_NON_FILE_SET_RESOURCES_TO_ADD = new ThreadLocal<Boolean>() {
+ protected Boolean initialValue() {
return Boolean.FALSE;
}
};
@@ -1288,7 +1288,7 @@ public class Zip extends MatchingTask {
Resource[][] initialResources = grabResources(filesets);
if (isEmpty(initialResources)) {
- if (Boolean.FALSE.equals(haveNonFileSetResourcesToAdd.get())) {
+ if (Boolean.FALSE.equals(HAVE_NON_FILE_SET_RESOURCES_TO_ADD.get())) {
if (needsUpdate && doUpdate) {
/*
* This is a rather hairy case.
@@ -1453,7 +1453,7 @@ public class Zip extends MatchingTask {
Resource[][] initialResources = grabNonFileSetResources(rcs);
boolean empty = isEmpty(initialResources);
- haveNonFileSetResourcesToAdd.set(Boolean.valueOf(!empty));
+ HAVE_NON_FILE_SET_RESOURCES_TO_ADD.set(Boolean.valueOf(!empty));
if (empty) {
// no emptyBehavior handling since the FileSet version
// will take care of it.
@@ -1521,10 +1521,10 @@ public class Zip extends MatchingTask {
getZipScanner(),
MISSING_DIR_PROVIDER);
if (rc.size() > 0) {
- ArrayList newer = new ArrayList();
+ ArrayList<Resource> newer = new ArrayList<Resource>();
newer.addAll(Arrays.asList(((Union) rc).listResources()));
newer.addAll(Arrays.asList(result));
- result = (Resource[]) newer.toArray(result);
+ result = newer.toArray(result);
}
}
return result;
@@ -1552,7 +1552,7 @@ public class Zip extends MatchingTask {
if (rs instanceof ZipScanner) {
((ZipScanner) rs).setEncoding(encoding);
}
- Vector resources = new Vector();
+ Vector<Resource> resources = new Vector<Resource>();
if (!doFilesonly) {
String[] directories = rs.getIncludedDirectories();
for (int j = 0; j < directories.length; j++) {
@@ -1585,8 +1585,8 @@ public class Zip extends MatchingTask {
protected Resource[][] grabNonFileSetResources(ResourceCollection[] rcs) {
Resource[][] result = new Resource[rcs.length][];
for (int i = 0; i < rcs.length; i++) {
- ArrayList dirs = new ArrayList();
- ArrayList files = new ArrayList();
+ ArrayList<Resource> dirs = new ArrayList<Resource>();
+ ArrayList<Resource> files = new ArrayList<Resource>();
for (Resource r : rcs[i]) {
if (r.isExists()) {
if (r.isDirectory()) {
@@ -1598,16 +1598,14 @@ public class Zip extends MatchingTask {
}
// make sure directories are in alpha-order - this also
// ensures parents come before their children
- Collections.sort(dirs, new Comparator() {
- public int compare(Object o1, Object o2) {
- Resource r1 = (Resource) o1;
- Resource r2 = (Resource) o2;
+ Collections.sort(dirs, new Comparator<Resource>() {
+ public int compare(Resource r1, Resource r2) {
return r1.getName().compareTo(r2.getName());
}
});
- ArrayList rs = new ArrayList(dirs);
+ ArrayList<Resource> rs = new ArrayList<Resource>(dirs);
rs.addAll(files);
- result[i] = (Resource[]) rs.toArray(new Resource[rs.size()]);
+ result[i] = rs.toArray(new Resource[rs.size()]);
}
return result;
}
@@ -1702,11 +1700,7 @@ public class Zip extends MatchingTask {
* support a new parameter (extra fields to preserve) without
* breaking subclasses that override the old method signature.
*/
- private static ThreadLocal currentZipExtra = new ThreadLocal() {
- protected Object initialValue() {
- return null;
- }
- };
+ private static final ThreadLocal<ZipExtraField[]> CURRENT_ZIP_EXTRA = new ThreadLocal<ZipExtraField[]>();
/**
* Provides the extra fields for the zip entry currently being
@@ -1714,7 +1708,7 @@ public class Zip extends MatchingTask {
* @since Ant 1.8.0
*/
protected final ZipExtraField[] getCurrentExtraFields() {
- return (ZipExtraField[]) currentZipExtra.get();
+ return (ZipExtraField[]) CURRENT_ZIP_EXTRA.get();
}
/**
@@ -1723,7 +1717,7 @@ public class Zip extends MatchingTask {
* @since Ant 1.8.0
*/
protected final void setCurrentExtraFields(ZipExtraField[] extra) {
- currentZipExtra.set(extra);
+ CURRENT_ZIP_EXTRA.set(extra);
}
/**
@@ -1907,7 +1901,7 @@ public class Zip extends MatchingTask {
int dirMode)
throws IOException {
if (!doFilesonly) {
- Stack directories = new Stack();
+ Stack<String> directories = new Stack<String>();
int slashPos = entry.length();
while ((slashPos = entry.lastIndexOf('/', slashPos - 1)) != -1) {
@@ -1919,7 +1913,7 @@ public class Zip extends MatchingTask {
}
while (!directories.isEmpty()) {
- String dir = (String) directories.pop();
+ String dir = directories.pop();
File f = null;
if (baseDir != null) {
f = new File(baseDir, dir);
@@ -1951,13 +1945,13 @@ public class Zip extends MatchingTask {
entries.clear();
addingNewFiles = false;
doUpdate = savedDoUpdate;
- Enumeration e = filesetsFromGroupfilesets.elements();
+ Enumeration<ZipFileSet> e = filesetsFromGroupfilesets.elements();
while (e.hasMoreElements()) {
- ZipFileSet zf = (ZipFileSet) e.nextElement();
+ ZipFileSet zf = e.nextElement();
resources.removeElement(zf);
}
filesetsFromGroupfilesets.removeAllElements();
- haveNonFileSetResourcesToAdd.set(Boolean.FALSE);
+ HAVE_NON_FILE_SET_RESOURCES_TO_ADD.set(Boolean.FALSE);
}
/**
@@ -2049,7 +2043,7 @@ public class Zip extends MatchingTask {
return orig;
}
- ArrayList v = new ArrayList(orig.length);
+ ArrayList<Resource> v = new ArrayList<Resource>(orig.length);
for (int i = 0; i < orig.length; i++) {
if (selector.isSelected(orig[i])) {
v.add(orig[i]);
@@ -2057,8 +2051,7 @@ public class Zip extends MatchingTask {
}
if (v.size() != orig.length) {
- Resource[] r = new Resource[v.size()];
- return (Resource[]) v.toArray(r);
+ return v.toArray(new Resource[v.size()]);
}
return orig;
}
@@ -2146,7 +2139,7 @@ public class Zip extends MatchingTask {
* @since Ant 1.8.0
*/
public static final class UnicodeExtraField extends EnumeratedAttribute {
- private static final Map POLICIES = new HashMap();
+ private static final Map<String, UnicodeExtraFieldPolicy> POLICIES = new HashMap<String, UnicodeExtraFieldPolicy>();
private static final String NEVER_KEY = "never";
private static final String ALWAYS_KEY = "always";
private static final String N_E_KEY = "not-encodeable";
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/EmailTask.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/EmailTask.java?rev=1375571&r1=1375570&r2=1375571&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/EmailTask.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/EmailTask.java Tue Aug 21 14:27:46 2012
@@ -446,7 +446,7 @@ public class EmailTask extends Task {
if (encoding.equals(MIME)
|| (encoding.equals(AUTO) && !autoFound)) {
try {
- //check to make sure that activation.jar
+ //check to make sure that activation.jar
//and mail.jar are available - see bug 31969
Class.forName("javax.activation.DataHandler");
Class.forName("javax.mail.internet.MimeMessage");
@@ -529,7 +529,7 @@ public class EmailTask extends Task {
}
// identify which files should be attached
- Vector files = new Vector();
+ Vector<File> files = new Vector<File>();
if (attachments != null) {
for (Resource r : attachments) {
files.addElement(r.as(FileProvider.class)
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/Mailer.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/Mailer.java?rev=1375571&r1=1375570&r2=1375571&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/Mailer.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/Mailer.java Tue Aug 21 14:27:46 2012
@@ -17,6 +17,7 @@
*/
package org.apache.tools.ant.taskdefs.email;
+import java.io.File;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
@@ -38,15 +39,15 @@ public abstract class Mailer {
// CheckStyle:MemberNameCheck ON
protected Message message;
protected EmailAddress from;
- protected Vector replyToList = null;
- protected Vector toList = null;
- protected Vector ccList = null;
- protected Vector bccList = null;
- protected Vector files = null;
+ protected Vector<EmailAddress> replyToList = null;
+ protected Vector<EmailAddress> toList = null;
+ protected Vector<EmailAddress> ccList = null;
+ protected Vector<EmailAddress> bccList = null;
+ protected Vector<File> files = null;
protected String subject = null;
protected Task task;
protected boolean includeFileNames = false;
- protected Vector headers = null;
+ protected Vector<Header> headers = null;
// CheckStyle:VisibilityModifier ON
private boolean ignoreInvalidRecipients = false;
private boolean starttls = false;
@@ -71,7 +72,7 @@ public abstract class Mailer {
}
/**
- * Whether the port has been explicitly specified by the user.
+ * Whether the port has been explicitly specified by the user.
* @since Ant 1.8.2
*/
public void setPortExplicitlySpecified(boolean explicit) {
@@ -79,7 +80,7 @@ public abstract class Mailer {
}
/**
- * Whether the port has been explicitly specified by the user.
+ * Whether the port has been explicitly specified by the user.
* @since Ant 1.8.2
*/
protected boolean isPortExplicitlySpecified() {
@@ -154,7 +155,7 @@ public abstract class Mailer {
* @param list a vector of reployTo addresses.
* @since Ant 1.6
*/
- public void setReplyToList(Vector list) {
+ public void setReplyToList(Vector<EmailAddress> list) {
this.replyToList = list;
}
@@ -163,7 +164,7 @@ public abstract class Mailer {
*
* @param list a vector of recipient addresses.
*/
- public void setToList(Vector list) {
+ public void setToList(Vector<EmailAddress> list) {
this.toList = list;
}
@@ -172,7 +173,7 @@ public abstract class Mailer {
*
* @param list a vector of cc addresses.
*/
- public void setCcList(Vector list) {
+ public void setCcList(Vector<EmailAddress> list) {
this.ccList = list;
}
@@ -181,7 +182,7 @@ public abstract class Mailer {
*
* @param list a vector of the bcc addresses.
*/
- public void setBccList(Vector list) {
+ public void setBccList(Vector<EmailAddress> list) {
this.bccList = list;
}
@@ -190,7 +191,7 @@ public abstract class Mailer {
*
* @param files list of files to attach to the email.
*/
- public void setFiles(Vector files) {
+ public void setFiles(Vector<File> files) {
this.files = files;
}
@@ -226,7 +227,7 @@ public abstract class Mailer {
* @param v a Vector presumed to contain Header objects.
* @since Ant 1.7
*/
- public void setHeaders(Vector v) {
+ public void setHeaders(Vector<Header> v) {
this.headers = v;
}
Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/AntFilterReader.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/AntFilterReader.java?rev=1375571&r1=1375570&r2=1375571&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/AntFilterReader.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/AntFilterReader.java Tue Aug 21 14:27:46 2012
@@ -31,7 +31,7 @@ public final class AntFilterReader
private String className;
- private final Vector parameters = new Vector();
+ private final Vector<Parameter> parameters = new Vector<Parameter>();
private Path classpath;
@@ -160,7 +160,7 @@ public final class AntFilterReader
super.setRefid(r);
}
- protected synchronized void dieOnCircularReference(Stack stk, Project p)
+ protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p)
throws BuildException {
if (isChecked()) {
return;
Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/DataType.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/DataType.java?rev=1375571&r1=1375570&r2=1375571&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/DataType.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/DataType.java Tue Aug 21 14:27:46 2012
@@ -112,7 +112,7 @@ public abstract class DataType extends P
if (checked || !isReference()) {
return;
}
- dieOnCircularReference(new IdentityStack(this), p);
+ dieOnCircularReference(new IdentityStack<Object>(this), p);
}
/**
@@ -134,7 +134,7 @@ public abstract class DataType extends P
* @param project the project to use to dereference the references.
* @throws BuildException on error.
*/
- protected void dieOnCircularReference(final Stack stack,
+ protected void dieOnCircularReference(final Stack<Object> stack,
final Project project)
throws BuildException {
@@ -144,7 +144,7 @@ public abstract class DataType extends P
Object o = ref.getReferencedObject(project);
if (o instanceof DataType) {
- IdentityStack id = IdentityStack.getInstance(stack);
+ IdentityStack<Object> id = IdentityStack.getInstance(stack);
if (id.contains(o)) {
throw circularReference();
@@ -166,7 +166,7 @@ public abstract class DataType extends P
* @throws BuildException on error.
* @since Ant 1.7
*/
- public static void invokeCircularReferenceCheck(DataType dt, Stack stk,
+ public static void invokeCircularReferenceCheck(DataType dt, Stack<Object> stk,
Project p) {
dt.dieOnCircularReference(stk, p);
}
@@ -184,7 +184,7 @@ public abstract class DataType extends P
* @since Ant 1.8.0
*/
public static void pushAndInvokeCircularReferenceCheck(DataType dt,
- Stack stk,
+ Stack<Object> stk,
Project p) {
stk.push(dt);
dt.dieOnCircularReference(stk, p);
@@ -223,7 +223,7 @@ public abstract class DataType extends P
* @return the dereferenced object.
* @throws BuildException if the reference is invalid (circular ref, wrong class, etc).
*/
- protected Object getCheckedRef(final Class requiredClass,
+ protected <T> T getCheckedRef(final Class<T> requiredClass,
final String dataTypeName) {
return getCheckedRef(requiredClass, dataTypeName, getProject());
}
@@ -240,7 +240,7 @@ public abstract class DataType extends P
* or if <code>project</code> is <code>null</code>.
* @since Ant 1.7
*/
- protected Object getCheckedRef(final Class requiredClass,
+ protected <T> T getCheckedRef(final Class<T> requiredClass,
final String dataTypeName, final Project project) {
if (project == null) {
throw new BuildException("No Project specified");
@@ -253,7 +253,9 @@ public abstract class DataType extends P
String msg = ref.getRefId() + " doesn\'t denote a " + dataTypeName;
throw new BuildException(msg);
}
- return o;
+ @SuppressWarnings("unchecked")
+ final T result = (T) o;
+ return result;
}
/**
Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/Environment.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/Environment.java?rev=1375571&r1=1375570&r2=1375571&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/Environment.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/Environment.java Tue Aug 21 14:27:46 2012
@@ -32,7 +32,7 @@ public class Environment {
* a vector of type Environment.Variable
* @see Variable
*/
- protected Vector variables;
+ protected Vector<Variable> variables;
// CheckStyle:VisibilityModifier ON
@@ -135,7 +135,7 @@ public class Environment {
* constructor
*/
public Environment() {
- variables = new Vector();
+ variables = new Vector<Variable>();
}
/**
@@ -170,7 +170,7 @@ public class Environment {
* Variable
* @since Ant 1.7
*/
- public Vector getVariablesVector() {
+ public Vector<Variable> getVariablesVector() {
return variables;
}
}
Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/FilterChain.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/FilterChain.java?rev=1375571&r1=1375570&r2=1375571&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/FilterChain.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/FilterChain.java Tue Aug 21 14:27:46 2012
@@ -48,7 +48,7 @@ import org.apache.tools.ant.filters.Toke
public class FilterChain extends DataType
implements Cloneable {
- private Vector filterReaders = new Vector();
+ private Vector<Object> filterReaders = new Vector<Object>();
/**
* Add an AntFilterReader filter.
@@ -68,7 +68,7 @@ public class FilterChain extends DataTyp
*
* @return a <code>Vector</code> value containing the filters
*/
- public Vector getFilterReaders() {
+ public Vector<Object> getFilterReaders() {
if (isReference()) {
return ((FilterChain) getCheckedRef()).getFilterReaders();
}
@@ -396,7 +396,7 @@ public class FilterChain extends DataTyp
filterReaders.addElement(filter);
}
- protected synchronized void dieOnCircularReference(Stack stk, Project p)
+ protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p)
throws BuildException {
if (isChecked()) {
return;
@@ -404,7 +404,7 @@ public class FilterChain extends DataTyp
if (isReference()) {
super.dieOnCircularReference(stk, p);
} else {
- for (Iterator i = filterReaders.iterator(); i.hasNext(); ) {
+ for (Iterator<Object> i = filterReaders.iterator(); i.hasNext(); ) {
Object o = i.next();
if (o instanceof DataType) {
pushAndInvokeCircularReferenceCheck((DataType) o, stk, p);
Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/Path.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/Path.java?rev=1375571&r1=1375570&r2=1375571&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/Path.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/Path.java Tue Aug 21 14:27:46 2012
@@ -79,9 +79,6 @@ public class Path extends DataType imple
public static final Path systemBootClasspath =
new Path(null, System.getProperty("sun.boot.class.path"));
- private static final Iterator EMPTY_ITERATOR
- = Collections.EMPTY_SET.iterator();
-
// CheckStyle:VisibilityModifier OFF - bc
/**
@@ -397,7 +394,7 @@ public class Path extends DataType imple
* @return an array of strings, one for each path element
*/
public static String[] translatePath(Project project, String source) {
- final Vector result = new Vector();
+ final Vector<String> result = new Vector<String>();
if (source == null) {
return new String[0];
}
@@ -418,9 +415,7 @@ public class Path extends DataType imple
result.addElement(element.toString());
element = new StringBuffer();
}
- String[] res = new String[result.size()];
- result.copyInto(res);
- return res;
+ return result.toArray(new String[result.size()]);
}
/**
@@ -489,7 +484,7 @@ public class Path extends DataType imple
* @param p the project to use to dereference the references.
* @throws BuildException on error.
*/
- protected synchronized void dieOnCircularReference(Stack stk, Project p)
+ protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p)
throws BuildException {
if (isChecked()) {
return;
@@ -553,7 +548,7 @@ public class Path extends DataType imple
Path result = new Path(getProject());
String order = defValue;
- String o = getProject() != null
+ String o = getProject() != null
? getProject().getProperty(MagicNames.BUILD_SYSCLASSPATH)
: System.getProperty(MagicNames.BUILD_SYSCLASSPATH);
if (o != null) {
@@ -709,7 +704,7 @@ public class Path extends DataType imple
if (getPreserveBC()) {
return new FileResourceIterator(getProject(), null, list());
}
- return union == null ? EMPTY_ITERATOR
+ return union == null ? Collections.<Resource> emptySet().iterator()
: assertFilesystemOnly(union).iterator();
}
Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Resources.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Resources.java?rev=1375571&r1=1375570&r2=1375571&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Resources.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Resources.java Tue Aug 21 14:27:46 2012
@@ -89,7 +89,7 @@ public class Resources extends DataType
return coll;
}
private class MyIterator implements Iterator<Resource> {
- private Iterator rci = getNested().iterator();
+ private Iterator<ResourceCollection> rci = getNested().iterator();
private Iterator<Resource> ri = null;
public boolean hasNext() {
@@ -112,7 +112,7 @@ public class Resources extends DataType
}
}
- private Vector rc;
+ private Vector<ResourceCollection> rc;
private Collection<Resource> coll;
private boolean cache = false;
@@ -151,7 +151,7 @@ public class Resources extends DataType
return;
}
if (rc == null) {
- rc = new Vector();
+ rc = new Vector<ResourceCollection>();
}
rc.add(c);
invalidateExistingIterators();
@@ -193,8 +193,8 @@ public class Resources extends DataType
}
validate();
- for (Iterator i = getNested().iterator(); i.hasNext();) {
- if ((!((ResourceCollection) i.next()).isFilesystemOnly())) {
+ for (Iterator<ResourceCollection> i = getNested().iterator(); i.hasNext();) {
+ if (!i.next().isFilesystemOnly()) {
return false;
}
}
@@ -230,7 +230,7 @@ public class Resources extends DataType
* @param p the project to use to dereference the references.
* @throws BuildException on error.
*/
- protected void dieOnCircularReference(Stack stk, Project p)
+ protected void dieOnCircularReference(Stack<Object> stk, Project p)
throws BuildException {
if (isChecked()) {
return;
@@ -238,10 +238,9 @@ public class Resources extends DataType
if (isReference()) {
super.dieOnCircularReference(stk, p);
} else {
- for (Iterator i = getNested().iterator(); i.hasNext();) {
- Object o = i.next();
- if (o instanceof DataType) {
- pushAndInvokeCircularReferenceCheck((DataType) o, stk, p);
+ for (ResourceCollection resourceCollection : getNested()) {
+ if (resourceCollection instanceof DataType) {
+ pushAndInvokeCircularReferenceCheck((DataType) resourceCollection, stk, p);
}
}
setChecked(true);
@@ -269,7 +268,7 @@ public class Resources extends DataType
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;
}
}
Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/spi/Service.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/spi/Service.java?rev=1375571&r1=1375570&r2=1375571&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/spi/Service.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/spi/Service.java Tue Aug 21 14:27:46 2012
@@ -24,7 +24,6 @@ import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import org.apache.tools.ant.ProjectComponent;
@@ -37,7 +36,7 @@ import org.apache.tools.ant.BuildExcepti
* http://issues.apache.org/bugzilla/show_bug.cgi?id=31520</a>
*/
public class Service extends ProjectComponent {
- private List providerList = new ArrayList();
+ private List<Provider> providerList = new ArrayList<Provider>();
private String type;
/**
@@ -84,16 +83,9 @@ public class Service extends ProjectComp
* @throws IOException if there is an error.
*/
public InputStream getAsStream() throws IOException {
- ByteArrayOutputStream arrayOut;
- Writer writer;
- Iterator providerIterator;
- Provider provider;
-
- arrayOut = new ByteArrayOutputStream();
- writer = new OutputStreamWriter(arrayOut, "UTF-8");
- providerIterator = providerList.iterator();
- while (providerIterator.hasNext()) {
- provider = (Provider) providerIterator.next();
+ ByteArrayOutputStream arrayOut = new ByteArrayOutputStream();
+ Writer writer = new OutputStreamWriter(arrayOut, "UTF-8");
+ for (Provider provider : providerList) {
writer.write(provider.getClassName());
writer.write("\n");
}
Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/IdentityStack.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/IdentityStack.java?rev=1375571&r1=1375570&r2=1375571&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/IdentityStack.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/IdentityStack.java Tue Aug 21 14:27:46 2012
@@ -23,7 +23,7 @@ import java.util.Stack;
* Identity Stack.
* @since Ant 1.7
*/
-public class IdentityStack extends Stack {
+public class IdentityStack<E> extends Stack<E> {
private static final long serialVersionUID = -5555522620060077046L;
@@ -32,11 +32,11 @@ public class IdentityStack extends Stack
* @param s the Stack to copy; ignored if null.
* @return an IdentityStack instance.
*/
- public static IdentityStack getInstance(Stack s) {
+ public static <E> IdentityStack<E> getInstance(Stack<E> s) {
if (s instanceof IdentityStack) {
- return (IdentityStack) s;
+ return (IdentityStack<E>) s;
}
- IdentityStack result = new IdentityStack();
+ IdentityStack<E> result = new IdentityStack<E>();
if (s != null) {
result.addAll(s);
}
@@ -54,7 +54,7 @@ public class IdentityStack extends Stack
* as the bottom element.
* @param o the bottom element.
*/
- public IdentityStack(Object o) {
+ public IdentityStack(E o) {
super();
push(o);
}
Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/LinkedHashtable.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/LinkedHashtable.java?rev=1375571&r1=1375570&r2=1375571&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/LinkedHashtable.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/LinkedHashtable.java Tue Aug 21 14:27:46 2012
@@ -37,23 +37,25 @@ import java.util.Set;
*
* @since Ant 1.8.2
*/
-public class LinkedHashtable extends Hashtable {
- private final LinkedHashMap map;
+public class LinkedHashtable<K, V> extends Hashtable<K, V> {
+ private static final long serialVersionUID = 1L;
+
+ private final LinkedHashMap<K, V> map;
public LinkedHashtable() {
- map = new LinkedHashMap();
+ map = new LinkedHashMap<K, V>();
}
public LinkedHashtable(int initialCapacity) {
- map = new LinkedHashMap(initialCapacity);
+ map = new LinkedHashMap<K, V>(initialCapacity);
}
public LinkedHashtable(int initialCapacity, float loadFactor) {
- map = new LinkedHashMap(initialCapacity, loadFactor);
+ map = new LinkedHashMap<K, V>(initialCapacity, loadFactor);
}
- public LinkedHashtable(Map m) {
- map = new LinkedHashMap(m);
+ public LinkedHashtable(Map<K, V> m) {
+ map = new LinkedHashMap<K, V>(m);
}
public synchronized void clear() {
@@ -72,11 +74,11 @@ public class LinkedHashtable extends Has
return map.containsValue(value);
}
- public Enumeration elements() {
+ public Enumeration<V> elements() {
return CollectionUtils.asEnumeration(values().iterator());
}
- public synchronized Set entrySet() {
+ public synchronized Set<Map.Entry<K, V>> entrySet() {
return map.entrySet();
}
@@ -84,7 +86,7 @@ public class LinkedHashtable extends Has
return map.equals(o);
}
- public synchronized Object get(Object k) {
+ public synchronized V get(Object k) {
return map.get(k);
}
@@ -96,23 +98,23 @@ public class LinkedHashtable extends Has
return map.isEmpty();
}
- public Enumeration keys() {
+ public Enumeration<K> keys() {
return CollectionUtils.asEnumeration(keySet().iterator());
}
- public synchronized Set keySet() {
+ public synchronized Set<K> keySet() {
return map.keySet();
}
- public synchronized Object put(Object k, Object v) {
+ public synchronized V put(K k, V v) {
return map.put(k, v);
}
- public synchronized void putAll(Map m) {
+ public synchronized void putAll(Map<? extends K, ? extends V> m) {
map.putAll(m);
}
- public synchronized Object remove(Object k) {
+ public synchronized V remove(Object k) {
return map.remove(k);
}
@@ -124,7 +126,7 @@ public class LinkedHashtable extends Has
return map.toString();
}
- public synchronized Collection values() {
+ public synchronized Collection<V> values() {
return map.values();
}
}
Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/ReflectUtil.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/ReflectUtil.java?rev=1375571&r1=1375570&r2=1375571&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/ReflectUtil.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/ReflectUtil.java Tue Aug 21 14:27:46 2012
@@ -41,11 +41,11 @@ public class ReflectUtil {
* the given arguments.
* @since Ant 1.8.0
*/
- public static Object newInstance(Class ofClass,
- Class[] argTypes,
+ public static <T> T newInstance(Class<T> ofClass,
+ Class<?>[] argTypes,
Object[] args) {
try {
- Constructor con = ofClass.getConstructor(argTypes);
+ Constructor<T> con = ofClass.getConstructor(argTypes);
return con.newInstance(args);
} catch (Exception t) {
throwBuildException(t);
@@ -82,7 +82,7 @@ public class ReflectUtil {
public static Object invokeStatic(Object obj, String methodName) {
try {
Method method;
- method = ((Class) obj).getMethod(
+ method = ((Class<?>) obj).getMethod(
methodName, (Class[]) null);
return method.invoke(obj, (Object[]) null);
} catch (Exception t) {
@@ -100,7 +100,7 @@ public class ReflectUtil {
* @return the object returned by the method
*/
public static Object invoke(
- Object obj, String methodName, Class argType, Object arg) {
+ Object obj, String methodName, Class<?> argType, Object arg) {
try {
Method method;
method = obj.getClass().getMethod(
@@ -123,8 +123,8 @@ public class ReflectUtil {
* @return the object returned by the method
*/
public static Object invoke(
- Object obj, String methodName, Class argType1, Object arg1,
- Class argType2, Object arg2) {
+ Object obj, String methodName, Class<?> argType1, Object arg1,
+ Class<?> argType2, Object arg2) {
try {
Method method;
method = obj.getClass().getMethod(
Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/StringUtils.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/StringUtils.java?rev=1375571&r1=1375570&r2=1375571&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/StringUtils.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/StringUtils.java Tue Aug 21 14:27:46 2012
@@ -49,7 +49,7 @@ public final class StringUtils {
* @param data the string to split up into lines.
* @return the list of lines available in the string.
*/
- public static Vector lineSplit(String data) {
+ public static Vector<String> lineSplit(String data) {
return split(data, '\n');
}
@@ -60,8 +60,8 @@ public final class StringUtils {
* @param ch the separator character.
* @return the list of elements.
*/
- public static Vector split(String data, int ch) {
- Vector elems = new Vector();
+ public static Vector<String> split(String data, int ch) {
+ Vector<String> elems = new Vector<String>();
int pos = -1;
int i = 0;
while ((pos = data.indexOf(ch, i)) != -1) {