| @@ -35,6 +35,7 @@ import java.util.HashMap; | |||
| import java.util.Hashtable; | |||
| import java.util.Map; | |||
| import java.util.NoSuchElementException; | |||
| import java.util.Objects; | |||
| import java.util.StringTokenizer; | |||
| import java.util.Vector; | |||
| import java.util.jar.Attributes; | |||
| @@ -42,10 +43,11 @@ import java.util.jar.Attributes.Name; | |||
| import java.util.jar.JarEntry; | |||
| import java.util.jar.JarFile; | |||
| import java.util.jar.Manifest; | |||
| import java.util.stream.Collectors; | |||
| import java.util.stream.Stream; | |||
| import org.apache.tools.ant.launch.Locator; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.util.CollectionUtils; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| import org.apache.tools.ant.util.JavaEnvUtils; | |||
| import org.apache.tools.ant.util.LoaderUtils; | |||
| @@ -740,14 +742,9 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener, Clo | |||
| private InputStream loadResource(final String name) { | |||
| // we need to search the components of the path to see if we can | |||
| // find the class we want. | |||
| InputStream stream = null; | |||
| final Enumeration<File> e = pathComponents.elements(); | |||
| while (e.hasMoreElements() && stream == null) { | |||
| final File pathComponent = e.nextElement(); | |||
| stream = getResourceStream(pathComponent, name); | |||
| } | |||
| return stream; | |||
| return Collections.list(pathComponents.elements()).stream() | |||
| .map(path -> getResourceStream(path, name)) | |||
| .filter(Objects::nonNull).findFirst().orElse(null); | |||
| } | |||
| /** | |||
| @@ -829,23 +826,10 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener, Clo | |||
| // TODO - shouldn't this always return false in isolated mode? | |||
| boolean useParentFirst = parentFirst; | |||
| for (final Enumeration<String> e = systemPackages.elements(); e.hasMoreElements();) { | |||
| final String packageName = e.nextElement(); | |||
| if (resourceName.startsWith(packageName)) { | |||
| useParentFirst = true; | |||
| break; | |||
| } | |||
| } | |||
| for (final Enumeration<String> e = loaderPackages.elements(); e.hasMoreElements();) { | |||
| final String packageName = e.nextElement(); | |||
| if (resourceName.startsWith(packageName)) { | |||
| useParentFirst = false; | |||
| break; | |||
| } | |||
| } | |||
| return useParentFirst; | |||
| return Collections.list(loaderPackages.elements()).stream() | |||
| .noneMatch(resourceName::startsWith) | |||
| && (Collections.list(systemPackages.elements()).stream() | |||
| .anyMatch(resourceName::startsWith) || parentFirst); | |||
| } | |||
| /** | |||
| @@ -885,12 +869,11 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener, Clo | |||
| } else { | |||
| // try and load from this loader if the parent either didn't find | |||
| // it or wasn't consulted. | |||
| final Enumeration<File> e = pathComponents.elements(); | |||
| while (e.hasMoreElements() && url == null) { | |||
| final File pathComponent = e.nextElement(); | |||
| for (final File pathComponent : Collections.list(pathComponents.elements())) { | |||
| url = getResourceURL(pathComponent, name); | |||
| if (url != null) { | |||
| log("Resource " + name + " loaded from ant loader", Project.MSG_DEBUG); | |||
| break; | |||
| } | |||
| } | |||
| } | |||
| @@ -974,14 +957,19 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener, Clo | |||
| } | |||
| if (isParentFirst(name)) { | |||
| // Normal case. | |||
| return CollectionUtils.append(base, mine); | |||
| return append(base, mine); | |||
| } | |||
| if (ignoreBase) { | |||
| return getRootLoader() == null ? mine : CollectionUtils.append(mine, getRootLoader() | |||
| .getResources(name)); | |||
| return getRootLoader() == null ? mine | |||
| : append(mine, getRootLoader().getResources(name)); | |||
| } | |||
| // parent last: | |||
| return CollectionUtils.append(mine, base); | |||
| return append(mine, base); | |||
| } | |||
| private static Enumeration<URL> append(Enumeration<URL> one, Enumeration<URL> two) { | |||
| return Stream.concat(Collections.list(one).stream(), Collections.list(two).stream()) | |||
| .collect(Collectors.collectingAndThen(Collectors.toList(), Collections::enumeration)); | |||
| } | |||
| /** | |||
| @@ -1355,9 +1343,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener, Clo | |||
| // we need to search the components of the path to see if | |||
| // we can find the class we want. | |||
| final String classFilename = getClassFilename(name); | |||
| final Enumeration<File> e = pathComponents.elements(); | |||
| while (e.hasMoreElements()) { | |||
| final File pathComponent = e.nextElement(); | |||
| for (final File pathComponent : Collections.list(pathComponents.elements())) { | |||
| InputStream stream = null; | |||
| try { | |||
| stream = getResourceStream(pathComponent, classFilename); | |||
| @@ -1519,12 +1505,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener, Clo | |||
| * here | |||
| */ | |||
| public void addJavaLibraries() { | |||
| final Vector<String> packages = JavaEnvUtils.getJrePackages(); | |||
| final Enumeration<String> e = packages.elements(); | |||
| while (e.hasMoreElements()) { | |||
| final String packageName = e.nextElement(); | |||
| addSystemPackageRoot(packageName); | |||
| } | |||
| JavaEnvUtils.getJrePackages().forEach(this::addSystemPackageRoot); | |||
| } | |||
| /** | |||
| @@ -25,7 +25,7 @@ import java.io.UnsupportedEncodingException; | |||
| import java.net.URL; | |||
| import java.net.URLConnection; | |||
| import java.util.ArrayList; | |||
| import java.util.Enumeration; | |||
| import java.util.Collections; | |||
| import java.util.List; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| @@ -74,9 +74,7 @@ public class ArgumentProcessorRegistry { | |||
| try { | |||
| ClassLoader classLoader = LoaderUtils.getContextClassLoader(); | |||
| if (classLoader != null) { | |||
| Enumeration<URL> resources = classLoader.getResources(SERVICE_ID); | |||
| while (resources.hasMoreElements()) { | |||
| URL resource = resources.nextElement(); | |||
| for (URL resource : Collections.list(classLoader.getResources(SERVICE_ID))) { | |||
| URLConnection conn = resource.openConnection(); | |||
| conn.setUseCaches(false); | |||
| ArgumentProcessor processor = getProcessorByService(conn.getInputStream()); | |||
| @@ -25,7 +25,6 @@ import java.io.StringWriter; | |||
| import java.lang.reflect.InvocationTargetException; | |||
| import java.lang.reflect.Modifier; | |||
| import java.util.ArrayList; | |||
| import java.util.Enumeration; | |||
| import java.util.HashMap; | |||
| import java.util.HashSet; | |||
| import java.util.Hashtable; | |||
| @@ -756,10 +755,9 @@ public class ComponentHelper { | |||
| ClassLoader classLoader = getClassLoader(null); | |||
| Properties props = getDefaultDefinitions(false); | |||
| for (String name : props.stringPropertyNames()) { | |||
| String className = props.getProperty(name); | |||
| AntTypeDefinition def = new AntTypeDefinition(); | |||
| def.setName(name); | |||
| def.setClassName(className); | |||
| def.setClassName(props.getProperty(name)); | |||
| def.setClassLoader(classLoader); | |||
| def.setAdaptToClass(Task.class); | |||
| def.setAdapterClass(TaskAdapter.class); | |||
| @@ -816,13 +814,10 @@ public class ComponentHelper { | |||
| private void initTypes() { | |||
| ClassLoader classLoader = getClassLoader(null); | |||
| Properties props = getDefaultDefinitions(true); | |||
| Enumeration<?> e = props.propertyNames(); | |||
| while (e.hasMoreElements()) { | |||
| String name = (String) e.nextElement(); | |||
| String className = props.getProperty(name); | |||
| for (String name : props.stringPropertyNames()) { | |||
| AntTypeDefinition def = new AntTypeDefinition(); | |||
| def.setName(name); | |||
| def.setClassName(className); | |||
| def.setClassName(props.getProperty(name)); | |||
| def.setClassLoader(classLoader); | |||
| antTypeTable.put(name, def); | |||
| } | |||
| @@ -27,7 +27,6 @@ import java.lang.reflect.Method; | |||
| import java.net.URL; | |||
| import java.nio.file.Files; | |||
| import java.util.Calendar; | |||
| import java.util.Enumeration; | |||
| import java.util.Properties; | |||
| import java.util.TimeZone; | |||
| @@ -357,12 +356,8 @@ public final class Diagnostics { | |||
| out.println("Access to System.getProperties() blocked " + "by a security manager"); | |||
| return; | |||
| } | |||
| for (Enumeration<?> keys = sysprops.propertyNames(); | |||
| keys.hasMoreElements();) { | |||
| String key = (String) keys.nextElement(); | |||
| String value = getProperty(key); | |||
| out.println(key + " : " + value); | |||
| } | |||
| sysprops.stringPropertyNames().stream() | |||
| .map(key -> key + " : " + getProperty(key)).forEach(out::println); | |||
| } | |||
| /** | |||
| @@ -483,8 +478,7 @@ public final class Diagnostics { | |||
| Properties props = new Properties(); | |||
| try { | |||
| props.load(is); | |||
| for (Enumeration<?> keys = props.keys(); keys.hasMoreElements();) { | |||
| String key = (String) keys.nextElement(); | |||
| for (String key : props.stringPropertyNames()) { | |||
| String classname = props.getProperty(key); | |||
| try { | |||
| Class.forName(classname); | |||
| @@ -33,10 +33,10 @@ import java.util.HashSet; | |||
| import java.util.Iterator; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| import java.util.Map.Entry; | |||
| import java.util.Properties; | |||
| import java.util.Set; | |||
| import java.util.Vector; | |||
| import java.util.stream.Collectors; | |||
| import org.apache.tools.ant.input.DefaultInputHandler; | |||
| import org.apache.tools.ant.input.InputHandler; | |||
| @@ -45,7 +45,6 @@ import org.apache.tools.ant.listener.SilentLogger; | |||
| import org.apache.tools.ant.property.GetProperty; | |||
| import org.apache.tools.ant.property.ResolvePropertyMap; | |||
| import org.apache.tools.ant.util.ClasspathUtils; | |||
| import org.apache.tools.ant.util.CollectionUtils; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| import org.apache.tools.ant.util.ProxySetup; | |||
| @@ -213,12 +212,8 @@ public class Main implements AntMain { | |||
| } | |||
| if (additionalUserProperties != null) { | |||
| for (final Enumeration<?> e = additionalUserProperties.keys(); | |||
| e.hasMoreElements();) { | |||
| final String key = (String) e.nextElement(); | |||
| final String property = additionalUserProperties.getProperty(key); | |||
| definedProps.put(key, property); | |||
| } | |||
| additionalUserProperties.stringPropertyNames() | |||
| .forEach(key -> definedProps.put(key, additionalUserProperties.getProperty(key))); | |||
| } | |||
| // expect the worst | |||
| @@ -407,9 +402,7 @@ public class Main implements AntMain { | |||
| final int newI = processor.readArguments(args, i); | |||
| if (newI != -1) { | |||
| List<String> extraArgs = extraArguments.computeIfAbsent(processor.getClass(), k -> new ArrayList<>()); | |||
| for (; i < newI && i < args.length; i++) { | |||
| extraArgs.add(args[i]); | |||
| } | |||
| extraArgs.addAll(Arrays.asList(args).subList(newI, args.length)); | |||
| processed = true; | |||
| break; | |||
| } | |||
| @@ -656,13 +649,9 @@ public class Main implements AntMain { | |||
| } | |||
| // ensure that -D properties take precedence | |||
| final Enumeration<?> propertyNames = props.propertyNames(); | |||
| while (propertyNames.hasMoreElements()) { | |||
| final String name = (String) propertyNames.nextElement(); | |||
| if (definedProps.getProperty(name) == null) { | |||
| definedProps.put(name, props.getProperty(name)); | |||
| } | |||
| } | |||
| props.stringPropertyNames().stream() | |||
| .filter(name -> definedProps.getProperty(name) == null) | |||
| .forEach(name -> definedProps.put(name, props.getProperty(name))); | |||
| } | |||
| } | |||
| @@ -896,11 +885,7 @@ public class Main implements AntMain { | |||
| resolver.resolveAllProperties(props, null, false); | |||
| // set user-define properties | |||
| for (final Entry<String, Object> ent : props.entrySet()) { | |||
| final String arg = ent.getKey(); | |||
| final Object value = ent.getValue(); | |||
| project.setUserProperty(arg, String.valueOf(value)); | |||
| } | |||
| props.forEach((arg, value) -> project.setUserProperty(arg, String.valueOf(value))); | |||
| project.setUserProperty(MagicNames.ANT_FILE, | |||
| buildFile.getAbsolutePath()); | |||
| @@ -915,7 +900,7 @@ public class Main implements AntMain { | |||
| // Setting it here allows top-level tasks to access the | |||
| // property. | |||
| project.setUserProperty(MagicNames.PROJECT_INVOKED_TARGETS, | |||
| CollectionUtils.flattenToString(targets)); | |||
| targets.stream().collect(Collectors.joining(","))); | |||
| } | |||
| /** | |||
| @@ -1136,25 +1121,18 @@ public class Main implements AntMain { | |||
| */ | |||
| private static Map<String, Target> removeDuplicateTargets(final Map<String, Target> targets) { | |||
| final Map<Location, Target> locationMap = new HashMap<>(); | |||
| for (final Entry<String, Target> entry : targets.entrySet()) { | |||
| final String name = entry.getKey(); | |||
| final Target target = entry.getValue(); | |||
| targets.forEach((name, target) -> { | |||
| final Target otherTarget = locationMap.get(target.getLocation()); | |||
| // Place this entry in the location map if | |||
| // a) location is not in the map | |||
| // b) location is in map, but its name is longer | |||
| // (an imported target will have a name. prefix) | |||
| if (otherTarget == null | |||
| || otherTarget.getName().length() > name.length()) { | |||
| locationMap.put( | |||
| target.getLocation(), target); // Smallest name wins | |||
| if (otherTarget == null || otherTarget.getName().length() > name.length()) { | |||
| locationMap.put(target.getLocation(), target); // Smallest name wins | |||
| } | |||
| } | |||
| final Map<String, Target> ret = new HashMap<>(); | |||
| for (final Target target : locationMap.values()) { | |||
| ret.put(target.getName(), target); | |||
| } | |||
| return ret; | |||
| }); | |||
| return locationMap.values().stream() | |||
| .collect(Collectors.toMap(Target::getName, target -> target, (a, b) -> b)); | |||
| } | |||
| /** | |||
| @@ -1287,18 +1265,9 @@ public class Main implements AntMain { | |||
| msg.append(descriptions.elementAt(i)); | |||
| } | |||
| msg.append(eol); | |||
| if (!dependencies.isEmpty()) { | |||
| final Enumeration<String> deps = dependencies.elementAt(i); | |||
| if (deps.hasMoreElements()) { | |||
| msg.append(" depends on: "); | |||
| while (deps.hasMoreElements()) { | |||
| msg.append(deps.nextElement()); | |||
| if (deps.hasMoreElements()) { | |||
| msg.append(", "); | |||
| } | |||
| } | |||
| msg.append(eol); | |||
| } | |||
| if (!dependencies.isEmpty() && dependencies.elementAt(i).hasMoreElements()) { | |||
| msg.append(Collections.list(dependencies.elementAt(i)).stream() | |||
| .collect(Collectors.joining(", ", " depends on: ", eol))); | |||
| } | |||
| } | |||
| project.log(msg.toString(), Project.MSG_WARN); | |||
| @@ -25,7 +25,6 @@ import java.lang.reflect.Method; | |||
| import java.lang.reflect.Modifier; | |||
| import java.util.Arrays; | |||
| import java.util.Collections; | |||
| import java.util.Enumeration; | |||
| import java.util.HashMap; | |||
| import java.util.HashSet; | |||
| import java.util.Hashtable; | |||
| @@ -48,7 +47,6 @@ import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.types.Resource; | |||
| import org.apache.tools.ant.types.ResourceFactory; | |||
| import org.apache.tools.ant.types.resources.FileResource; | |||
| import org.apache.tools.ant.util.CollectionUtils; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| import org.apache.tools.ant.util.JavaEnvUtils; | |||
| import org.apache.tools.ant.util.VectorSet; | |||
| @@ -1249,7 +1247,7 @@ public class Project implements ResourceFactory { | |||
| */ | |||
| public void executeTargets(final Vector<String> names) throws BuildException { | |||
| setUserProperty(MagicNames.PROJECT_INVOKED_TARGETS, | |||
| CollectionUtils.flattenToString(names)); | |||
| names.stream().collect(Collectors.joining(","))); | |||
| getExecutor().executeTargets(this, names.toArray(new String[names.size()])); | |||
| } | |||
| @@ -1374,9 +1372,7 @@ public class Project implements ResourceFactory { | |||
| BuildException buildException = null; // first build exception | |||
| for (final Target curtarget : sortedTargets) { | |||
| boolean canExecute = true; | |||
| for (final Enumeration<String> depIter = curtarget.getDependencies(); | |||
| depIter.hasMoreElements();) { | |||
| final String dependencyName = depIter.nextElement(); | |||
| for (final String dependencyName : Collections.list(curtarget.getDependencies())) { | |||
| if (!succeededTargets.contains(dependencyName)) { | |||
| canExecute = false; | |||
| log(curtarget, | |||
| @@ -1833,8 +1829,7 @@ public class Project implements ResourceFactory { | |||
| + " is " + ret, MSG_VERBOSE); | |||
| final Vector<Target> complete = (returnAll) ? ret : new Vector<>(ret); | |||
| for (final Enumeration<String> en = targetTable.keys(); en.hasMoreElements();) { | |||
| final String curTarget = en.nextElement(); | |||
| for (final String curTarget : targetTable.keySet()) { | |||
| final String st = state.get(curTarget); | |||
| if (st == null) { | |||
| tsort(curTarget, targetTable, state, visiting, complete); | |||
| @@ -1912,8 +1907,7 @@ public class Project implements ResourceFactory { | |||
| } | |||
| throw new BuildException(new String(sb)); | |||
| } | |||
| for (final Enumeration<String> en = target.getDependencies(); en.hasMoreElements();) { | |||
| final String cur = en.nextElement(); | |||
| for (final String cur : Collections.list(target.getDependencies())) { | |||
| final String m = state.get(cur); | |||
| if (m == null) { | |||
| // Not been visited | |||
| @@ -24,7 +24,7 @@ import java.lang.reflect.Constructor; | |||
| import java.net.URL; | |||
| import java.net.URLConnection; | |||
| import java.util.ArrayList; | |||
| import java.util.Enumeration; | |||
| import java.util.Collections; | |||
| import java.util.Iterator; | |||
| import java.util.List; | |||
| import java.util.stream.Stream; | |||
| @@ -85,10 +85,7 @@ public class ProjectHelperRepository { | |||
| try { | |||
| ClassLoader classLoader = LoaderUtils.getContextClassLoader(); | |||
| if (classLoader != null) { | |||
| Enumeration<URL> resources = | |||
| classLoader.getResources(ProjectHelper.SERVICE_ID); | |||
| while (resources.hasMoreElements()) { | |||
| URL resource = resources.nextElement(); | |||
| for (URL resource : Collections.list(classLoader.getResources(ProjectHelper.SERVICE_ID))) { | |||
| URLConnection conn = resource.openConnection(); | |||
| conn.setUseCaches(false); | |||
| projectHelper = | |||
| @@ -19,7 +19,7 @@ | |||
| package org.apache.tools.ant; | |||
| import java.io.IOException; | |||
| import java.util.Enumeration; | |||
| import java.util.Collections; | |||
| import org.apache.tools.ant.dispatch.DispatchUtils; | |||
| @@ -425,11 +425,8 @@ public abstract class Task extends ProjectComponent { | |||
| */ | |||
| private void replaceChildren(RuntimeConfigurable wrapper, | |||
| UnknownElement parentElement) { | |||
| Enumeration<RuntimeConfigurable> e = wrapper.getChildren(); | |||
| while (e.hasMoreElements()) { | |||
| RuntimeConfigurable childWrapper = e.nextElement(); | |||
| UnknownElement childElement = | |||
| new UnknownElement(childWrapper.getElementTag()); | |||
| for (RuntimeConfigurable childWrapper : Collections.list(wrapper.getChildren())) { | |||
| UnknownElement childElement = new UnknownElement(childWrapper.getElementTag()); | |||
| parentElement.addChild(childElement); | |||
| childElement.setProject(getProject()); | |||
| childElement.setRuntimeConfigurableWrapper(childWrapper); | |||
| @@ -20,7 +20,7 @@ package org.apache.tools.ant; | |||
| import java.io.IOException; | |||
| import java.util.ArrayList; | |||
| import java.util.Enumeration; | |||
| import java.util.Collections; | |||
| import java.util.Iterator; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| @@ -679,8 +679,7 @@ public class UnknownElement extends Task { | |||
| } | |||
| copyRC.addText(getWrapper().getText().toString()); | |||
| for (Enumeration<RuntimeConfigurable> e = getWrapper().getChildren(); e.hasMoreElements();) { | |||
| RuntimeConfigurable r = e.nextElement(); | |||
| for (RuntimeConfigurable r : Collections.list(getWrapper().getChildren())) { | |||
| UnknownElement ueChild = (UnknownElement) r.getProxy(); | |||
| UnknownElement copyChild = ueChild.copy(newProject); | |||
| copyRC.addChild(copyChild.getWrapper()); | |||
| @@ -24,7 +24,7 @@ import java.io.PrintStream; | |||
| import java.io.Writer; | |||
| import java.nio.file.Files; | |||
| import java.nio.file.Paths; | |||
| import java.util.Enumeration; | |||
| import java.util.Collections; | |||
| import java.util.Hashtable; | |||
| import java.util.Stack; | |||
| @@ -345,14 +345,9 @@ public class XmlLogger implements BuildLogger { | |||
| if (element != null) { | |||
| return element; | |||
| } | |||
| for (Enumeration<Task> e = tasks.keys(); e.hasMoreElements();) { | |||
| Task key = e.nextElement(); | |||
| if (key instanceof UnknownElement | |||
| && ((UnknownElement) key).getTask() == task) { | |||
| return tasks.get(key); | |||
| } | |||
| } | |||
| return null; | |||
| return Collections.list(tasks.keys()).stream().filter(UnknownElement.class::isInstance) | |||
| .filter(key -> ((UnknownElement) key).getTask() == task).findFirst() | |||
| .map(key -> tasks.get(key)).orElse(null); | |||
| } | |||
| /** | |||
| @@ -21,7 +21,6 @@ import java.io.File; | |||
| import java.io.IOException; | |||
| import java.io.InputStream; | |||
| import java.io.Reader; | |||
| import java.util.Enumeration; | |||
| import java.util.Hashtable; | |||
| import java.util.Map; | |||
| import java.util.Properties; | |||
| @@ -330,11 +329,7 @@ public final class ReplaceTokens | |||
| private void makeTokensFromProperties(Resource r) { | |||
| Properties props = getProperties(r); | |||
| for (Enumeration<?> e = props.keys(); e.hasMoreElements();) { | |||
| String key = (String) e.nextElement(); | |||
| String value = props.getProperty(key); | |||
| hash.put(key, value); | |||
| } | |||
| props.stringPropertyNames().forEach(key -> hash.put(key, props.getProperty(key))); | |||
| } | |||
| /** | |||
| @@ -22,7 +22,6 @@ import java.io.InputStream; | |||
| import java.io.PrintStream; | |||
| import java.nio.file.Files; | |||
| import java.nio.file.Paths; | |||
| import java.util.Enumeration; | |||
| import java.util.Map; | |||
| import java.util.Properties; | |||
| import java.util.StringTokenizer; | |||
| @@ -129,11 +128,8 @@ public class MailLogger extends DefaultLogger { | |||
| } | |||
| } | |||
| for (Enumeration<?> e = fileProperties.keys(); e.hasMoreElements();) { | |||
| String key = (String) e.nextElement(); | |||
| String value = fileProperties.getProperty(key); | |||
| properties.put(key, project.replaceProperties(value)); | |||
| } | |||
| fileProperties.stringPropertyNames() | |||
| .forEach(key -> properties.put(key, project.replaceProperties(fileProperties.getProperty(key)))); | |||
| boolean success = (event.getException() == null); | |||
| String prefix = success ? "success" : "failure"; | |||
| @@ -27,7 +27,7 @@ import java.io.PrintWriter; | |||
| import java.io.UnsupportedEncodingException; | |||
| import java.nio.file.Files; | |||
| import java.util.ArrayList; | |||
| import java.util.Enumeration; | |||
| import java.util.Collections; | |||
| import java.util.Hashtable; | |||
| import java.util.List; | |||
| import java.util.Set; | |||
| @@ -309,10 +309,7 @@ public class AntStructure extends Task { | |||
| v.add(TASKS); | |||
| } | |||
| Enumeration<String> e = ih.getNestedElements(); | |||
| while (e.hasMoreElements()) { | |||
| v.add(e.nextElement()); | |||
| } | |||
| v.addAll(Collections.list(ih.getNestedElements())); | |||
| final Collector<CharSequence, ?, String> joinAlts = | |||
| Collectors.joining(" | ", "(", ")"); | |||
| @@ -331,9 +328,7 @@ public class AntStructure extends Task { | |||
| sb = new StringBuilder(); | |||
| sb.append(String.format("<!ATTLIST %s%n id ID #IMPLIED", name)); | |||
| e = ih.getAttributes(); | |||
| while (e.hasMoreElements()) { | |||
| final String attrName = e.nextElement(); | |||
| for (final String attrName : Collections.list(ih.getAttributes())) { | |||
| if ("id".equals(attrName)) { | |||
| continue; | |||
| } | |||
| @@ -24,8 +24,8 @@ import java.io.IOException; | |||
| import java.io.InputStream; | |||
| import java.io.OutputStream; | |||
| import java.nio.file.Files; | |||
| import java.util.Collections; | |||
| import java.util.Date; | |||
| import java.util.Enumeration; | |||
| import java.util.HashSet; | |||
| import java.util.List; | |||
| import java.util.Set; | |||
| @@ -189,10 +189,8 @@ public class Expand extends Task { | |||
| } | |||
| try (ZipFile zf = new ZipFile(srcF, encoding, scanForUnicodeExtraFields)) { | |||
| boolean empty = true; | |||
| Enumeration<ZipEntry> e = zf.getEntries(); | |||
| while (e.hasMoreElements()) { | |||
| for (ZipEntry ze : Collections.list(zf.getEntries())) { | |||
| empty = false; | |||
| ZipEntry ze = e.nextElement(); | |||
| InputStream is = null; | |||
| log("extracting " + ze.getName(), Project.MSG_DEBUG); | |||
| try { | |||
| @@ -23,7 +23,7 @@ import java.net.Inet6Address; | |||
| import java.net.InetAddress; | |||
| import java.net.NetworkInterface; | |||
| import java.util.Arrays; | |||
| import java.util.Enumeration; | |||
| import java.util.Collections; | |||
| import java.util.LinkedList; | |||
| import java.util.List; | |||
| @@ -117,14 +117,8 @@ public class HostInfo extends Task { | |||
| private void executeLocal() { | |||
| try { | |||
| inetAddrs = new LinkedList<>(); | |||
| Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); | |||
| while (interfaces.hasMoreElements()) { | |||
| NetworkInterface currentif = interfaces.nextElement(); | |||
| Enumeration<InetAddress> addrs = currentif.getInetAddresses(); | |||
| while (addrs.hasMoreElements()) { | |||
| inetAddrs.add(addrs.nextElement()); | |||
| } | |||
| } | |||
| Collections.list(NetworkInterface.getNetworkInterfaces()) | |||
| .forEach(netInterface -> inetAddrs.addAll(Collections.list(netInterface.getInetAddresses()))); | |||
| selectAddresses(); | |||
| if (nameAddr != null && hasHostName(nameAddr)) { | |||
| @@ -33,7 +33,6 @@ import java.nio.file.Files; | |||
| import java.util.ArrayList; | |||
| import java.util.Collections; | |||
| import java.util.Comparator; | |||
| import java.util.Enumeration; | |||
| import java.util.HashSet; | |||
| import java.util.List; | |||
| import java.util.Set; | |||
| @@ -325,10 +324,8 @@ public class Jar extends Zip { | |||
| // must not use getEntry as "well behaving" applications | |||
| // must accept the manifest in any capitalization | |||
| Enumeration<? extends ZipEntry> e = zf.entries(); | |||
| while (e.hasMoreElements()) { | |||
| ZipEntry ze = e.nextElement(); | |||
| if (MANIFEST_NAME.equalsIgnoreCase(ze.getName())) { | |||
| for (ZipEntry ze : Collections.list(zf.entries())) { | |||
| if (MANIFEST_NAME.equalsIgnoreCase(ze.getName())) { | |||
| try (InputStreamReader isr = | |||
| new InputStreamReader(zf.getInputStream(ze), "UTF-8")) { | |||
| return getManifest(isr); | |||
| @@ -354,14 +351,8 @@ public class Jar extends Zip { | |||
| private boolean jarHasIndex(File jarFile) throws IOException { | |||
| try (ZipFile zf = new ZipFile(jarFile)) { | |||
| Enumeration<? extends ZipEntry> e = zf.entries(); | |||
| while (e.hasMoreElements()) { | |||
| ZipEntry ze = e.nextElement(); | |||
| if (INDEX_NAME.equalsIgnoreCase(ze.getName())) { | |||
| return true; | |||
| } | |||
| } | |||
| return false; | |||
| return Collections.list(zf.entries()).stream() | |||
| .anyMatch(ze -> INDEX_NAME.equalsIgnoreCase(ze.getName())); | |||
| } | |||
| } | |||
| @@ -1072,11 +1063,8 @@ public class Jar extends Zip { | |||
| List<String> files) | |||
| throws IOException { | |||
| try (org.apache.tools.zip.ZipFile zf = new org.apache.tools.zip.ZipFile(file, "utf-8")) { | |||
| Enumeration<org.apache.tools.zip.ZipEntry> entries = zf.getEntries(); | |||
| Set<String> dirSet = new HashSet<>(); | |||
| while (entries.hasMoreElements()) { | |||
| org.apache.tools.zip.ZipEntry ze = | |||
| entries.nextElement(); | |||
| for (org.apache.tools.zip.ZipEntry ze : Collections.list(zf.getEntries())) { | |||
| String name = ze.getName(); | |||
| if (ze.isDirectory()) { | |||
| dirSet.add(name); | |||
| @@ -19,7 +19,7 @@ | |||
| package org.apache.tools.ant.taskdefs; | |||
| import java.util.ArrayList; | |||
| import java.util.Enumeration; | |||
| import java.util.Collections; | |||
| import java.util.HashMap; | |||
| import java.util.HashSet; | |||
| import java.util.Hashtable; | |||
| @@ -277,9 +277,7 @@ public class MacroInstance extends Task implements DynamicAttribute, TaskContain | |||
| rc.addText(macroSubs(ue.getWrapper().getText().toString(), | |||
| localAttributes)); | |||
| Enumeration<RuntimeConfigurable> e = ue.getWrapper().getChildren(); | |||
| while (e.hasMoreElements()) { | |||
| RuntimeConfigurable r = e.nextElement(); | |||
| for (RuntimeConfigurable r : Collections.list(ue.getWrapper().getChildren())) { | |||
| UnknownElement unknownElement = (UnknownElement) r.getProxy(); | |||
| String tag = unknownElement.getTaskType(); | |||
| if (tag != null) { | |||
| @@ -26,6 +26,7 @@ import java.io.PrintWriter; | |||
| import java.io.Reader; | |||
| import java.io.StringWriter; | |||
| import java.io.UnsupportedEncodingException; | |||
| import java.util.ArrayList; | |||
| import java.util.Collections; | |||
| import java.util.Enumeration; | |||
| import java.util.LinkedHashMap; | |||
| @@ -37,7 +38,6 @@ import java.util.Vector; | |||
| import java.util.stream.Collectors; | |||
| import org.apache.tools.ant.BuildException; | |||
| import org.apache.tools.ant.util.CollectionUtils; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| /** | |||
| @@ -490,21 +490,15 @@ public class Manifest { | |||
| "Unable to merge sections with different names"); | |||
| } | |||
| Enumeration<String> e = section.getAttributeKeys(); | |||
| Attribute classpathAttribute = null; | |||
| while (e.hasMoreElements()) { | |||
| String attributeName = e.nextElement(); | |||
| for (String attributeName : Collections.list(section.getAttributeKeys())) { | |||
| Attribute attribute = section.getAttribute(attributeName); | |||
| if (ATTRIBUTE_CLASSPATH.equalsIgnoreCase(attributeName)) { | |||
| if (classpathAttribute == null) { | |||
| classpathAttribute = new Attribute(); | |||
| classpathAttribute.setName(ATTRIBUTE_CLASSPATH); | |||
| } | |||
| Enumeration<String> cpe = attribute.getValues(); | |||
| while (cpe.hasMoreElements()) { | |||
| String value = cpe.nextElement(); | |||
| classpathAttribute.addValue(value); | |||
| } | |||
| Collections.list(attribute.getValues()).forEach(classpathAttribute::addValue); | |||
| } else { | |||
| // the merge file always wins | |||
| storeAttribute(attribute); | |||
| @@ -515,11 +509,7 @@ public class Manifest { | |||
| if (mergeClassPaths) { | |||
| Attribute currentCp = getAttribute(ATTRIBUTE_CLASSPATH); | |||
| if (currentCp != null) { | |||
| for (Enumeration<String> attribEnum = currentCp.getValues(); | |||
| attribEnum.hasMoreElements();) { | |||
| String value = attribEnum.nextElement(); | |||
| classpathAttribute.addValue(value); | |||
| } | |||
| Collections.list(currentCp.getValues()).forEach(classpathAttribute::addValue); | |||
| } | |||
| } | |||
| storeAttribute(classpathAttribute); | |||
| @@ -558,11 +548,8 @@ public class Manifest { | |||
| Attribute nameAttr = new Attribute(ATTRIBUTE_NAME, name); | |||
| nameAttr.write(writer); | |||
| } | |||
| Enumeration<String> e = getAttributeKeys(); | |||
| while (e.hasMoreElements()) { | |||
| String key = e.nextElement(); | |||
| Attribute attribute = getAttribute(key); | |||
| attribute.write(writer, flatten); | |||
| for (String key : Collections.list(getAttributeKeys())) { | |||
| getAttribute(key).write(writer, flatten); | |||
| } | |||
| writer.print(EOL); | |||
| } | |||
| @@ -586,7 +573,7 @@ public class Manifest { | |||
| * key of an attribute of the section. | |||
| */ | |||
| public Enumeration<String> getAttributeKeys() { | |||
| return CollectionUtils.asEnumeration(attributes.keySet().iterator()); | |||
| return Collections.enumeration(attributes.keySet()); | |||
| } | |||
| /** | |||
| @@ -666,11 +653,7 @@ public class Manifest { | |||
| } else { | |||
| warnings.add( | |||
| "Multiple Class-Path attributes are supported but violate the Jar specification and may not be correctly processed in all environments"); | |||
| Enumeration<String> e = attribute.getValues(); | |||
| while (e.hasMoreElements()) { | |||
| String value = e.nextElement(); | |||
| classpathAttribute.addValue(value); | |||
| } | |||
| Collections.list(attribute.getValues()).forEach(classpathAttribute::addValue); | |||
| } | |||
| } else if (attributes.containsKey(attributeKey)) { | |||
| throw new ManifestException("The attribute \"" | |||
| @@ -693,13 +676,9 @@ public class Manifest { | |||
| public Object clone() { | |||
| Section cloned = new Section(); | |||
| cloned.setName(name); | |||
| Enumeration<String> e = getAttributeKeys(); | |||
| while (e.hasMoreElements()) { | |||
| String key = e.nextElement(); | |||
| Attribute attribute = getAttribute(key); | |||
| cloned.storeAttribute(new Attribute(attribute.getName(), | |||
| attribute.getValue())); | |||
| } | |||
| Collections.list(getAttributeKeys()).stream() | |||
| .map(key -> new Attribute(getAttribute(key).getName(), | |||
| getAttribute(key).getValue())).forEach(cloned::storeAttribute); | |||
| return cloned; | |||
| } | |||
| @@ -951,9 +930,7 @@ public class Manifest { | |||
| manifestVersion = other.manifestVersion; | |||
| } | |||
| Enumeration<String> e = other.getSectionNames(); | |||
| while (e.hasMoreElements()) { | |||
| String sectionName = e.nextElement(); | |||
| for (String sectionName : Collections.list(other.getSectionNames())) { | |||
| Section ourSection = sections.get(sectionName); | |||
| Section otherSection | |||
| = other.sections.get(sectionName); | |||
| @@ -1042,22 +1019,14 @@ public class Manifest { | |||
| * @return an enumeration of warning strings | |||
| */ | |||
| public Enumeration<String> getWarnings() { | |||
| Vector<String> warnings = new Vector<>(); | |||
| // create a vector and add in the warnings for the main section | |||
| List<String> warnings = new ArrayList<>(Collections.list(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 | |||
| for (Section section : sections.values()) { | |||
| Enumeration<String> e2 = section.getWarnings(); | |||
| while (e2.hasMoreElements()) { | |||
| warnings.addElement(e2.nextElement()); | |||
| } | |||
| } | |||
| // add in the warnings for all the sections | |||
| sections.values().stream().map(section -> Collections.list(section.getWarnings())) | |||
| .forEach(warnings::addAll); | |||
| return warnings.elements(); | |||
| return Collections.enumeration(warnings); | |||
| } | |||
| /** | |||
| @@ -1140,6 +1109,6 @@ public class Manifest { | |||
| * @return an Enumeration of section names | |||
| */ | |||
| public Enumeration<String> getSectionNames() { | |||
| return CollectionUtils.asEnumeration(sections.keySet().iterator()); | |||
| return Collections.enumeration(sections.keySet()); | |||
| } | |||
| } | |||
| @@ -25,12 +25,11 @@ import java.io.OutputStreamWriter; | |||
| import java.io.PrintWriter; | |||
| import java.nio.charset.Charset; | |||
| import java.nio.file.Files; | |||
| import java.util.Enumeration; | |||
| import java.util.Collections; | |||
| import org.apache.tools.ant.BuildException; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.taskdefs.Manifest.Attribute; | |||
| import org.apache.tools.ant.types.EnumeratedAttribute; | |||
| /** | |||
| @@ -113,12 +112,8 @@ public class ManifestTask extends Task { | |||
| */ | |||
| public void addConfiguredSection(Manifest.Section section) | |||
| throws ManifestException { | |||
| Enumeration<String> attributeKeys = section.getAttributeKeys(); | |||
| while (attributeKeys.hasMoreElements()) { | |||
| Attribute attribute = section.getAttribute( | |||
| attributeKeys.nextElement()); | |||
| checkAttribute(attribute); | |||
| } | |||
| Collections.list(section.getAttributeKeys()).stream() | |||
| .map(section::getAttribute).forEach(this::checkAttribute); | |||
| nestedManifest.addConfiguredSection(section); | |||
| } | |||
| @@ -245,12 +240,9 @@ public class ManifestTask extends Task { | |||
| } | |||
| } | |||
| //look for and print warnings | |||
| for (Enumeration<String> e = nestedManifest.getWarnings(); | |||
| e.hasMoreElements();) { | |||
| log("Manifest warning: " + e.nextElement(), | |||
| Project.MSG_WARN); | |||
| } | |||
| // look for and print warnings | |||
| Collections.list(nestedManifest.getWarnings()) | |||
| .forEach(e -> log("Manifest warning: " + e, Project.MSG_WARN)); | |||
| try { | |||
| if ("update".equals(mode.getValue()) && manifestFile.exists()) { | |||
| if (current != null) { | |||
| @@ -18,7 +18,7 @@ | |||
| package org.apache.tools.ant.taskdefs.condition; | |||
| import java.util.Enumeration; | |||
| import java.util.Collections; | |||
| import org.apache.tools.ant.BuildException; | |||
| @@ -38,13 +38,7 @@ public class And extends ConditionBase implements Condition { | |||
| */ | |||
| @Override | |||
| public boolean eval() throws BuildException { | |||
| Enumeration<Condition> e = getConditions(); | |||
| while (e.hasMoreElements()) { | |||
| if (!e.nextElement().eval()) { | |||
| return false; | |||
| } | |||
| } | |||
| return true; | |||
| return Collections.list(getConditions()).stream().allMatch(Condition::eval); | |||
| } | |||
| } | |||
| @@ -19,13 +19,12 @@ package org.apache.tools.ant.taskdefs.condition; | |||
| import java.io.File; | |||
| import java.io.IOException; | |||
| import java.util.Enumeration; | |||
| import java.util.Collections; | |||
| import org.apache.tools.ant.BuildException; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.taskdefs.ManifestTask; | |||
| import org.apache.tools.ant.types.DataType; | |||
| import org.apache.tools.zip.ZipEntry; | |||
| import org.apache.tools.zip.ZipFile; | |||
| /** | |||
| @@ -73,15 +72,8 @@ public class IsSigned extends DataType implements Condition { | |||
| throws IOException { | |||
| try (ZipFile jarFile = new ZipFile(zipFile)) { | |||
| if (null == name) { | |||
| Enumeration<ZipEntry> entries = jarFile.getEntries(); | |||
| while (entries.hasMoreElements()) { | |||
| String eName = entries.nextElement().getName(); | |||
| if (eName.startsWith(SIG_START) | |||
| && eName.endsWith(SIG_END)) { | |||
| return true; | |||
| } | |||
| } | |||
| return false; | |||
| return Collections.list(jarFile.getEntries()).stream() | |||
| .anyMatch(e -> e.getName().startsWith(SIG_START) && e.getName().endsWith(SIG_END)); | |||
| } | |||
| name = replaceInvalidChars(name); | |||
| boolean shortSig = jarFile.getEntry(SIG_START | |||
| @@ -18,7 +18,7 @@ | |||
| package org.apache.tools.ant.taskdefs.condition; | |||
| import java.util.Enumeration; | |||
| import java.util.Collections; | |||
| import org.apache.tools.ant.BuildException; | |||
| @@ -38,14 +38,7 @@ public class Or extends ConditionBase implements Condition { | |||
| */ | |||
| @Override | |||
| public boolean eval() throws BuildException { | |||
| Enumeration<Condition> e = getConditions(); | |||
| while (e.hasMoreElements()) { | |||
| Condition c = e.nextElement(); | |||
| if (c.eval()) { | |||
| return true; | |||
| } | |||
| } | |||
| return false; | |||
| return Collections.list(getConditions()).stream().anyMatch(Condition::eval); | |||
| } | |||
| } | |||
| @@ -17,7 +17,7 @@ | |||
| */ | |||
| package org.apache.tools.ant.taskdefs.condition; | |||
| import java.util.Enumeration; | |||
| import java.util.Collections; | |||
| import org.apache.tools.ant.BuildException; | |||
| @@ -36,12 +36,10 @@ public class Xor extends ConditionBase implements Condition { | |||
| */ | |||
| @Override | |||
| public boolean eval() throws BuildException { | |||
| Enumeration<Condition> e = getConditions(); | |||
| //initial state is false. | |||
| // initial state is false. | |||
| boolean state = false; | |||
| while (e.hasMoreElements()) { | |||
| Condition c = e.nextElement(); | |||
| //every condition is xored against the previous one | |||
| for (Condition c : Collections.list(getConditions())) { | |||
| // every condition is xored against the previous one | |||
| state ^= c.eval(); | |||
| } | |||
| return state; | |||
| @@ -28,10 +28,11 @@ import java.nio.file.Files; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| import java.util.StringTokenizer; | |||
| import java.util.stream.Collectors; | |||
| import org.apache.tools.ant.BuildException; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.taskdefs.AbstractCvsTask; | |||
| import org.apache.tools.ant.util.CollectionUtils; | |||
| import org.apache.tools.ant.util.DOMElementWriter; | |||
| import org.apache.tools.ant.util.DOMUtils; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| @@ -420,7 +421,7 @@ public class CvsTagDiff extends AbstractCvsTask { | |||
| root.setAttribute("cvsroot", getCvsRoot()); | |||
| root.setAttribute("package", | |||
| CollectionUtils.flattenToString(packageNames)); | |||
| packageNames.stream().collect(Collectors.joining(","))); | |||
| DOM_WRITER.openElement(root, writer, 0, "\t"); | |||
| writer.println(); | |||
| for (CvsTagEntry entry : entries) { | |||
| @@ -618,16 +618,11 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||
| final XSLTProcess.Factory factory = xsltTask.getFactory(); | |||
| if (factory != null) { | |||
| setFactory(factory.getName()); | |||
| // configure factory attributes | |||
| for (final XSLTProcess.Factory.Attribute attr | |||
| : Collections.list(factory.getAttributes())) { | |||
| setAttribute(attr.getName(), attr.getValue()); | |||
| } | |||
| for (final XSLTProcess.Factory.Feature feature | |||
| : factory.getFeatures()) { | |||
| setFeature(feature.getName(), feature.getValue()); | |||
| } | |||
| Collections.list(factory.getAttributes()) | |||
| .forEach(attr -> setAttribute(attr.getName(), attr.getValue())); | |||
| factory.getFeatures() | |||
| .forEach(feature -> setFeature(feature.getName(), feature.getValue())); | |||
| } | |||
| final XMLCatalog xmlCatalog = xsltTask.getXMLCatalog(); | |||
| @@ -637,12 +632,9 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||
| setURIResolver(xmlCatalog); | |||
| } | |||
| // configure output properties | |||
| for (final XSLTProcess.OutputProperty prop | |||
| : Collections.list(xsltTask.getOutputProperties())) { | |||
| setOutputProperty(prop.getName(), prop.getValue()); | |||
| } | |||
| Collections.list(xsltTask.getOutputProperties()) | |||
| .forEach(prop -> setOutputProperty(prop.getName(), prop.getValue())); | |||
| suppressWarnings = xsltTask.getSuppressWarnings(); | |||
| @@ -51,15 +51,15 @@ public class AntAnalyzer extends AbstractAnalyzer { | |||
| protected void determineDependencies(Vector<File> files, Vector<String> classes) { | |||
| // we get the root classes and build up a set of | |||
| // classes upon which they depend | |||
| Set<String> dependencies = new HashSet<>(); | |||
| Set<File> containers = new HashSet<>(); | |||
| Set<String> toAnalyze = new HashSet<>(Collections.list(getRootClasses())); | |||
| Set<String> analyzedDeps = new HashSet<>(); | |||
| int count = 0; | |||
| int maxCount = isClosureRequired() ? MAX_LOOPS : 1; | |||
| Set<String> dependencies = new HashSet<>(); | |||
| Set<File> containers = new HashSet<>(); | |||
| Set<String> analyzedDeps = null; | |||
| while (!toAnalyze.isEmpty() && count++ < maxCount) { | |||
| analyzedDeps = new HashSet<>(); | |||
| analyzedDeps.clear(); | |||
| for (String classname : toAnalyze) { | |||
| dependencies.add(classname); | |||
| try { | |||
| @@ -76,11 +76,9 @@ public class AntAnalyzer extends AbstractAnalyzer { | |||
| inStream = Files.newInputStream(Paths.get(container.getPath())); | |||
| } else { | |||
| zipFile = new ZipFile(container.getPath()); | |||
| String entryName | |||
| = classname.replace('.', '/') + ".class"; | |||
| String entryName = classname.replace('.', '/') + ".class"; | |||
| ZipEntry entry = new ZipEntry(entryName); | |||
| inStream | |||
| = zipFile.getInputStream(entry); | |||
| inStream = zipFile.getInputStream(entry); | |||
| } | |||
| ClassFile classFile = new ClassFile(); | |||
| classFile.read(inStream); | |||
| @@ -95,13 +93,9 @@ public class AntAnalyzer extends AbstractAnalyzer { | |||
| } | |||
| toAnalyze.clear(); | |||
| // now recover all the dependencies collected and add to the list. | |||
| for (String className : analyzedDeps) { | |||
| if (!dependencies.contains(className)) { | |||
| toAnalyze.add(className); | |||
| } | |||
| } | |||
| analyzedDeps.stream().filter(className -> !dependencies.contains(className)) | |||
| .forEach(toAnalyze::add); | |||
| } | |||
| // pick up the last round of dependencies that were determined | |||
| @@ -25,7 +25,7 @@ import java.io.FileWriter; | |||
| import java.io.IOException; | |||
| import java.net.URL; | |||
| import java.util.ArrayList; | |||
| import java.util.Enumeration; | |||
| import java.util.Collections; | |||
| import java.util.HashMap; | |||
| import java.util.HashSet; | |||
| import java.util.LinkedHashSet; | |||
| @@ -322,14 +322,9 @@ public class Depend extends MatchingTask { | |||
| analyzer.addRootClass(info.className); | |||
| analyzer.addClassPath(destPath); | |||
| analyzer.setClosure(false); | |||
| dependencyList = new ArrayList<>(); | |||
| Enumeration<String> depEnum = analyzer.getClassDependencies(); | |||
| while (depEnum.hasMoreElements()) { | |||
| String o = depEnum.nextElement(); | |||
| dependencyList.add(o); | |||
| log("Class " + info.className + " depends on " + o, | |||
| Project.MSG_DEBUG); | |||
| } | |||
| dependencyList = new ArrayList<>(Collections.list(analyzer.getClassDependencies())); | |||
| dependencyList.forEach(o -> log("Class " + info.className + " depends on " + o, | |||
| Project.MSG_DEBUG)); | |||
| cacheDirty = true; | |||
| dependencyMap.put(info.className, dependencyList); | |||
| } | |||
| @@ -21,7 +21,7 @@ import java.io.File; | |||
| import java.io.IOException; | |||
| import java.io.InputStream; | |||
| import java.nio.file.Files; | |||
| import java.util.Enumeration; | |||
| import java.util.Collections; | |||
| import java.util.HashSet; | |||
| import java.util.Hashtable; | |||
| import java.util.Map; | |||
| @@ -838,12 +838,8 @@ public class GenericDeploymentTool implements EJBDeploymentTool { | |||
| } | |||
| } | |||
| Enumeration<String> e = dependencyAnalyzer.getClassDependencies(); | |||
| while (e.hasMoreElements()) { | |||
| String classname = e.nextElement(); | |||
| String location | |||
| = classname.replace('.', File.separatorChar) + ".class"; | |||
| for (String classname : Collections.list(dependencyAnalyzer.getClassDependencies())) { | |||
| String location = classname.replace('.', File.separatorChar) + ".class"; | |||
| File classFile = new File(config.srcDir, location); | |||
| if (classFile.exists()) { | |||
| checkEntries.put(location, classFile); | |||
| @@ -766,9 +766,7 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool { | |||
| newJarStream.setLevel(0); | |||
| // Copy files from old WebLogic jar | |||
| for (Enumeration<JarEntry> e = wlEntries.elements(); e.hasMoreElements();) { | |||
| JarEntry je = e.nextElement(); | |||
| for (JarEntry je : wlEntries.values()) { | |||
| if (je.getCompressedSize() == -1 | |||
| || je.getCompressedSize() == je.getSize()) { | |||
| newJarStream.setLevel(0); | |||
| @@ -21,17 +21,18 @@ import java.io.File; | |||
| import java.io.IOException; | |||
| import java.io.InputStream; | |||
| import java.nio.file.Files; | |||
| import java.util.Enumeration; | |||
| import java.util.Collections; | |||
| import java.util.Hashtable; | |||
| import java.util.jar.JarEntry; | |||
| import java.util.jar.JarFile; | |||
| import java.util.jar.JarOutputStream; | |||
| import java.util.stream.Collectors; | |||
| import java.util.zip.ZipEntry; | |||
| import org.apache.tools.ant.AntClassLoader; | |||
| import org.apache.tools.ant.BuildException; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.taskdefs.Java; | |||
| import org.apache.tools.ant.taskdefs.optional.ejb.EjbJar.DTDLocation; | |||
| import org.apache.tools.ant.types.Environment; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| @@ -353,9 +354,7 @@ public class WebsphereDeploymentTool extends GenericDeploymentTool { | |||
| // any supplied by the user | |||
| handler.registerDTD(PUBLICID_EJB11, ejb11DTD); | |||
| for (DTDLocation dtdLocation : getConfig().dtdLocations) { | |||
| handler.registerDTD(dtdLocation.getPublicId(), dtdLocation.getLocation()); | |||
| } | |||
| getConfig().dtdLocations.forEach(l -> handler.registerDTD(l.getPublicId(), l.getLocation())); | |||
| return handler; | |||
| } | |||
| @@ -372,9 +371,7 @@ public class WebsphereDeploymentTool extends GenericDeploymentTool { | |||
| } | |||
| }; | |||
| for (DTDLocation dtdLocation : getConfig().dtdLocations) { | |||
| handler.registerDTD(dtdLocation.getPublicId(), dtdLocation.getLocation()); | |||
| } | |||
| getConfig().dtdLocations.forEach(l -> handler.registerDTD(l.getPublicId(), l.getLocation())); | |||
| return handler; | |||
| } | |||
| @@ -669,73 +666,64 @@ public class WebsphereDeploymentTool extends GenericDeploymentTool { | |||
| genericJar = new JarFile(genericJarFile); | |||
| wasJar = new JarFile(websphereJarFile); | |||
| Hashtable<String, JarEntry> genericEntries = new Hashtable<>(); | |||
| Hashtable<String, JarEntry> wasEntries = new Hashtable<>(); | |||
| Hashtable<String, JarEntry> replaceEntries = new Hashtable<>(); | |||
| //get the list of generic jar entries | |||
| for (Enumeration<JarEntry> e = genericJar.entries(); e.hasMoreElements();) { | |||
| JarEntry je = e.nextElement(); | |||
| genericEntries.put(je.getName().replace('\\', '/'), je); | |||
| } | |||
| Hashtable<String, JarEntry> genericEntries = Collections.list(genericJar.entries()).stream() | |||
| .collect(Collectors.toMap(je -> je.getName().replace('\\', '/'), | |||
| je -> je, (a, b) -> b, Hashtable::new)); | |||
| // get the list of WebSphere jar entries | |||
| for (Enumeration<JarEntry> e = wasJar.entries(); e.hasMoreElements();) { | |||
| JarEntry je = e.nextElement(); | |||
| wasEntries.put(je.getName(), je); | |||
| } | |||
| Hashtable<String, JarEntry> wasEntries = Collections.list(wasJar.entries()).stream() | |||
| .collect(Collectors.toMap(ZipEntry::getName, je -> je, (a, b) -> b, Hashtable::new)); | |||
| // Cycle through generic and make sure its in WebSphere | |||
| genericLoader = getClassLoaderFromJar(genericJarFile); | |||
| for (Enumeration<String> e = genericEntries.keys(); e.hasMoreElements();) { | |||
| String filepath = e.nextElement(); | |||
| if (wasEntries.containsKey(filepath)) { | |||
| // File name/path match | |||
| // Check files see if same | |||
| JarEntry genericEntry = genericEntries.get(filepath); | |||
| JarEntry wasEntry = wasEntries.get(filepath); | |||
| if (genericEntry.getCrc() != wasEntry.getCrc() | |||
| || genericEntry.getSize() != wasEntry.getSize()) { | |||
| if (genericEntry.getName().endsWith(".class")) { | |||
| //File are different see if its an object or an interface | |||
| String classname | |||
| = genericEntry.getName().replace(File.separatorChar, '.'); | |||
| classname = classname.substring(0, classname.lastIndexOf(".class")); | |||
| Class<?> genclass = genericLoader.loadClass(classname); | |||
| if (genclass.isInterface()) { | |||
| //Interface changed rebuild jar. | |||
| log("Interface " + genclass.getName() | |||
| + " has changed", Project.MSG_VERBOSE); | |||
| rebuild = true; | |||
| break; | |||
| } | |||
| //Object class Changed update it. | |||
| replaceEntries.put(filepath, genericEntry); | |||
| } else { | |||
| // is it the manifest. If so ignore it | |||
| if (!genericEntry.getName().equals("META-INF/MANIFEST.MF")) { | |||
| //File other then class changed rebuild | |||
| log("Non class file " + genericEntry.getName() | |||
| + " has changed", Project.MSG_VERBOSE); | |||
| rebuild = true; | |||
| } | |||
| break; | |||
| } | |||
| } | |||
| } else { | |||
| Hashtable<String, JarEntry> replaceEntries = new Hashtable<>(); | |||
| for (String filepath : genericEntries.keySet()) { | |||
| if (!wasEntries.containsKey(filepath)) { | |||
| // a file doesn't exist rebuild | |||
| log("File " + filepath + " not present in websphere jar", | |||
| Project.MSG_VERBOSE); | |||
| rebuild = true; | |||
| break; | |||
| } | |||
| // File name/path match | |||
| // Check files see if same | |||
| JarEntry genericEntry = genericEntries.get(filepath); | |||
| JarEntry wasEntry = wasEntries.get(filepath); | |||
| if (genericEntry.getCrc() != wasEntry.getCrc() | |||
| || genericEntry.getSize() != wasEntry.getSize()) { | |||
| if (genericEntry.getName().endsWith(".class")) { | |||
| //File are different see if its an object or an interface | |||
| String classname | |||
| = genericEntry.getName().replace(File.separatorChar, '.'); | |||
| classname = classname.substring(0, classname.lastIndexOf(".class")); | |||
| Class<?> genclass = genericLoader.loadClass(classname); | |||
| if (genclass.isInterface()) { | |||
| //Interface changed rebuild jar. | |||
| log("Interface " + genclass.getName() | |||
| + " has changed", Project.MSG_VERBOSE); | |||
| rebuild = true; | |||
| break; | |||
| } | |||
| //Object class Changed update it. | |||
| replaceEntries.put(filepath, genericEntry); | |||
| } else { | |||
| // is it the manifest. If so ignore it | |||
| if (!genericEntry.getName().equals("META-INF/MANIFEST.MF")) { | |||
| //File other then class changed rebuild | |||
| log("Non class file " + genericEntry.getName() | |||
| + " has changed", Project.MSG_VERBOSE); | |||
| rebuild = true; | |||
| } | |||
| break; | |||
| } | |||
| } | |||
| } | |||
| if (!rebuild) { | |||
| @@ -749,9 +737,7 @@ public class WebsphereDeploymentTool extends GenericDeploymentTool { | |||
| newJarStream.setLevel(0); | |||
| // Copy files from old WebSphere jar | |||
| for (Enumeration<JarEntry> e = wasEntries.elements(); e.hasMoreElements();) { | |||
| JarEntry je = e.nextElement(); | |||
| for (JarEntry je : Collections.list(wasEntries.elements())) { | |||
| if (je.getCompressedSize() == -1 | |||
| || je.getCompressedSize() == je.getSize()) { | |||
| newJarStream.setLevel(0); | |||
| @@ -28,7 +28,7 @@ import java.io.IOException; | |||
| import java.io.InputStream; | |||
| import java.nio.file.Files; | |||
| import java.nio.file.Paths; | |||
| import java.util.Enumeration; | |||
| import java.util.Collections; | |||
| import java.util.List; | |||
| import java.util.Vector; | |||
| import java.util.zip.CRC32; | |||
| @@ -207,10 +207,7 @@ public class jlink { | |||
| return; | |||
| } | |||
| try (ZipFile zipf = new ZipFile(f)) { | |||
| Enumeration<? extends ZipEntry> entries = zipf.entries(); | |||
| while (entries.hasMoreElements()) { | |||
| ZipEntry inputEntry = entries.nextElement(); | |||
| for (ZipEntry inputEntry : Collections.list(zipf.entries())) { | |||
| //Ignore manifest entries. They're bound to cause conflicts between | |||
| //files that are being merged. User should supply their own | |||
| //manifest file when doing the merge. | |||
| @@ -18,8 +18,9 @@ | |||
| package org.apache.tools.ant.taskdefs.optional.junit; | |||
| import java.io.File; | |||
| import java.util.Arrays; | |||
| import java.util.Collections; | |||
| import java.util.Enumeration; | |||
| import java.util.Vector; | |||
| import java.util.stream.Stream; | |||
| @@ -99,8 +100,7 @@ public final class BatchTest extends BaseTest { | |||
| * a <tt>JUnitTest</tt> instance. | |||
| */ | |||
| public Enumeration<JUnitTest> elements() { | |||
| JUnitTest[] tests = createAllJUnitTest(); | |||
| return Enumerations.fromArray(tests); | |||
| return Collections.enumeration(Arrays.asList(createAllJUnitTest())); | |||
| } | |||
| /** | |||
| @@ -28,6 +28,7 @@ import java.util.NoSuchElementException; | |||
| * instead of 1.1. | |||
| * | |||
| */ | |||
| @Deprecated | |||
| public final class Enumerations { | |||
| private Enumerations() { | |||
| @@ -38,7 +39,9 @@ public final class Enumerations { | |||
| * @param <T> object type | |||
| * @param array the array of object to enumerate. | |||
| * @return the enumeration over the array of objects. | |||
| * @deprecated use Collections.enumeration(Arrays.asList(array)) | |||
| */ | |||
| @Deprecated | |||
| @SafeVarargs | |||
| public static <T> Enumeration<T> fromArray(T... array) { | |||
| return Collections.enumeration(Arrays.asList(array)); | |||
| @@ -51,7 +54,10 @@ public final class Enumerations { | |||
| * @param <T> object type | |||
| * @param enums the array of enumerations. | |||
| * @return the enumeration over the array of enumerations. | |||
| * @deprecated Stream.concat(Collections.list ( one).stream(), Collections.list(two).stream()) | |||
| * .collect(Collectors.collectingAndThen(Collectors.toList(), Collections::enumeration)) | |||
| */ | |||
| @Deprecated | |||
| @SafeVarargs | |||
| public static <T> Enumeration<T> fromCompound(Enumeration<? extends T>... enums) { | |||
| return new CompoundEnumeration<>(enums); | |||
| @@ -89,6 +95,7 @@ public final class Enumerations { | |||
| * } | |||
| * </pre> | |||
| */ | |||
| @Deprecated | |||
| class CompoundEnumeration<T> implements Enumeration<T> { | |||
| /** enumeration array */ | |||
| @@ -43,6 +43,8 @@ import java.util.Locale; | |||
| import java.util.Map; | |||
| import java.util.Properties; | |||
| import java.util.Vector; | |||
| import java.util.stream.Collectors; | |||
| import java.util.stream.Stream; | |||
| import org.apache.tools.ant.AntClassLoader; | |||
| import org.apache.tools.ant.BuildException; | |||
| @@ -1376,9 +1378,7 @@ public class JUnitTask extends Task { | |||
| LoaderUtils.classNameToResource(Project.class.getName()); | |||
| URL previous = null; | |||
| try { | |||
| for (final Enumeration<URL> e = loader.getResources(projectResourceName); | |||
| e.hasMoreElements();) { | |||
| final URL current = e.nextElement(); | |||
| for (final URL current : Collections.list(loader.getResources(projectResourceName))) { | |||
| if (previous != null && !urlEquals(current, previous)) { | |||
| log(String.format( | |||
| "WARNING: multiple versions of ant detected in path for junit%n" | |||
| @@ -1660,16 +1660,9 @@ public class JUnitTask extends Task { | |||
| * @since Ant 1.3 | |||
| */ | |||
| protected Enumeration<JUnitTest> getIndividualTests() { | |||
| final int count = batchTests.size(); | |||
| @SuppressWarnings("unchecked") | |||
| final Enumeration<JUnitTest>[] enums = new Enumeration[ count + 1]; | |||
| for (int i = 0; i < count; i++) { | |||
| final BatchTest batchtest = batchTests.get(i); | |||
| enums[i] = batchtest.elements(); | |||
| } | |||
| enums[enums.length - 1] = Collections.enumeration(tests); | |||
| return Enumerations.fromCompound(enums); | |||
| return Collections.enumeration(Stream.concat(batchTests.stream() | |||
| .flatMap(b -> Collections.list(b.elements()).stream()), tests.stream()) | |||
| .collect(Collectors.toList())); | |||
| } | |||
| /** | |||
| @@ -1685,11 +1678,8 @@ public class JUnitTask extends Task { | |||
| if (tests.isEmpty()) { | |||
| return; | |||
| } | |||
| for (JUnitTest test : tests) { | |||
| if (test.hasMethodsSpecified() && test.shouldRun(getProject())) { | |||
| test.resolveMethods(); | |||
| } | |||
| } | |||
| tests.stream().filter(test -> test.hasMethodsSpecified() && test.shouldRun(getProject())) | |||
| .forEach(JUnitTest::resolveMethods); | |||
| } | |||
| /** | |||
| @@ -1763,8 +1753,8 @@ public class JUnitTask extends Task { | |||
| * @since Ant 1.3 | |||
| */ | |||
| protected Enumeration<BaseTest> allTests() { | |||
| return Enumerations.fromCompound(Collections.enumeration(tests), | |||
| Collections.enumeration(batchTests)); | |||
| return Collections.enumeration(Stream.concat(tests.stream(), batchTests.stream()) | |||
| .collect(Collectors.toList())); | |||
| } | |||
| /** | |||
| @@ -2164,8 +2154,7 @@ public class JUnitTask extends Task { | |||
| final Enumeration<JUnitTest> testList, final boolean runIndividual) { | |||
| final Map<ForkedTestConfiguration, List<JUnitTest>> testConfigurations = | |||
| new HashMap<>(); | |||
| while (testList.hasMoreElements()) { | |||
| final JUnitTest test = testList.nextElement(); | |||
| for (final JUnitTest test : Collections.list(testList)) { | |||
| if (test.shouldRun(getProject())) { | |||
| /* with multi-threaded runs need to defer execution of even */ | |||
| /* individual tests so the threads can pick tests off the queue. */ | |||
| @@ -20,7 +20,7 @@ package org.apache.tools.ant.types; | |||
| import java.io.File; | |||
| import java.io.InputStream; | |||
| import java.nio.file.Files; | |||
| import java.util.Enumeration; | |||
| import java.util.Collections; | |||
| import java.util.Hashtable; | |||
| import java.util.Map; | |||
| import java.util.Properties; | |||
| @@ -252,10 +252,8 @@ public class FilterSet extends DataType implements Cloneable { | |||
| dieOnCircularReference(); | |||
| if (filterHash == null) { | |||
| filterHash = new Hashtable<>(getFilters().size()); | |||
| for (Enumeration<Filter> e = getFilters().elements(); e.hasMoreElements();) { | |||
| Filter filter = e.nextElement(); | |||
| filterHash.put(filter.getToken(), filter.getValue()); | |||
| } | |||
| Collections.list(getFilters().elements()) | |||
| .forEach(filter -> filterHash.put(filter.getToken(), filter.getValue())); | |||
| } | |||
| return filterHash; | |||
| } | |||
| @@ -19,7 +19,6 @@ | |||
| package org.apache.tools.ant.types; | |||
| import java.util.ArrayList; | |||
| import java.util.Enumeration; | |||
| import java.util.HashMap; | |||
| import java.util.HashSet; | |||
| import java.util.Iterator; | |||
| @@ -31,6 +30,7 @@ import java.util.Properties; | |||
| import java.util.Set; | |||
| import java.util.Stack; | |||
| import java.util.TreeMap; | |||
| import java.util.stream.Collectors; | |||
| import java.util.stream.Stream; | |||
| import org.apache.tools.ant.BuildException; | |||
| @@ -276,17 +276,12 @@ public class PropertySet extends DataType implements ResourceCollection { | |||
| /** | |||
| * Convert the system properties to a Map. | |||
| * Use propertynames to get the list of properties (including | |||
| * Use stringPropertyNames to get the list of properties (including | |||
| * default ones). | |||
| */ | |||
| private Map<String, Object> getAllSystemProperties() { | |||
| Map<String, Object> ret = new HashMap<>(); | |||
| for (Enumeration<?> e = System.getProperties().propertyNames(); | |||
| e.hasMoreElements();) { | |||
| String name = (String) e.nextElement(); | |||
| ret.put(name, System.getProperties().getProperty(name)); | |||
| } | |||
| return ret; | |||
| return System.getProperties().stringPropertyNames().stream() | |||
| .collect(Collectors.toMap(name -> name, name -> System.getProperties().getProperty(name), (a, b) -> b)); | |||
| } | |||
| /** | |||
| @@ -20,7 +20,7 @@ package org.apache.tools.ant.types; | |||
| import java.io.File; | |||
| import java.io.IOException; | |||
| import java.util.Enumeration; | |||
| import java.util.Collections; | |||
| import java.util.Map; | |||
| import java.util.zip.ZipException; | |||
| @@ -62,10 +62,7 @@ public class ZipScanner extends ArchiveScanner { | |||
| "Only file provider resources are supported")); | |||
| try (ZipFile zf = new ZipFile(srcFile, encoding)) { | |||
| Enumeration<ZipEntry> e = zf.getEntries(); | |||
| while (e.hasMoreElements()) { | |||
| ZipEntry entry = e.nextElement(); | |||
| for (ZipEntry entry : Collections.list(zf.getEntries())) { | |||
| Resource r = new ZipResource(srcFile, encoding, entry); | |||
| String name = entry.getName(); | |||
| if (entry.isDirectory()) { | |||
| @@ -18,7 +18,7 @@ | |||
| package org.apache.tools.ant.types.optional.depend; | |||
| import java.io.File; | |||
| import java.util.Enumeration; | |||
| import java.util.Collections; | |||
| import java.util.Set; | |||
| import java.util.Vector; | |||
| import java.util.stream.Collectors; | |||
| @@ -126,12 +126,8 @@ public class DependScanner extends DirectoryScanner { | |||
| Set<String> parentSet = Stream.of(parentScanner.getIncludedFiles()) | |||
| .collect(Collectors.toSet()); | |||
| Enumeration<String> e = analyzer.getClassDependencies(); | |||
| while (e.hasMoreElements()) { | |||
| String classname = e.nextElement(); | |||
| String filename = | |||
| classname.replace('.', File.separatorChar) + ".class"; | |||
| for (String classname : Collections.list(analyzer.getClassDependencies())) { | |||
| String filename = classname.replace('.', File.separatorChar) + ".class"; | |||
| File depFile = new File(basedir, filename); | |||
| if (depFile.exists() && parentSet.contains(filename)) { | |||
| // This is included | |||
| @@ -34,7 +34,6 @@ import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.types.DataType; | |||
| import org.apache.tools.ant.types.Resource; | |||
| import org.apache.tools.ant.types.ResourceCollection; | |||
| import org.apache.tools.ant.util.CollectionUtils; | |||
| /** | |||
| * Generic ResourceCollection: Either stores nested ResourceCollections, | |||
| @@ -90,7 +89,8 @@ public class Resources extends DataType implements ResourceCollection { | |||
| private synchronized Collection<Resource> getCache() { | |||
| Collection<Resource> coll = cached; | |||
| if (coll == null) { | |||
| coll = CollectionUtils.asCollection(new MyIterator()); | |||
| coll = new ArrayList<>(); | |||
| new MyIterator().forEachRemaining(coll::add); | |||
| if (cache) { | |||
| cached = coll; | |||
| } | |||
| @@ -19,7 +19,7 @@ | |||
| package org.apache.tools.ant.types.selectors; | |||
| import java.io.File; | |||
| import java.util.Enumeration; | |||
| import java.util.Collections; | |||
| /** | |||
| * This selector is here just to shake up your thinking a bit. Don't get | |||
| @@ -75,11 +75,9 @@ public class MajoritySelector extends BaseSelectorContainer { | |||
| validate(); | |||
| int yesvotes = 0; | |||
| int novotes = 0; | |||
| Enumeration<FileSelector> e = selectorElements(); | |||
| while (e.hasMoreElements()) { | |||
| if (e.nextElement().isSelected(basedir, | |||
| filename, file)) { | |||
| for (FileSelector fs : Collections.list(selectorElements())) { | |||
| if (fs.isSelected(basedir, filename, file)) { | |||
| yesvotes++; | |||
| } else { | |||
| novotes++; | |||
| @@ -221,11 +221,7 @@ public class SelectSelector extends BaseSelectorContainer { | |||
| } | |||
| Enumeration<FileSelector> e = selectorElements(); | |||
| if (!e.hasMoreElements()) { | |||
| return true; | |||
| } | |||
| FileSelector f = e.nextElement(); | |||
| return f.isSelected(basedir, filename, file); | |||
| return !e.hasMoreElements() || e.nextElement().isSelected(basedir, filename, file); | |||
| } | |||
| } | |||
| @@ -36,6 +36,7 @@ import java.util.stream.Collectors; | |||
| * | |||
| * @since Ant 1.5 | |||
| */ | |||
| @Deprecated | |||
| public class CollectionUtils { | |||
| @SuppressWarnings("rawtypes") | |||
| @@ -80,20 +81,10 @@ public class CollectionUtils { | |||
| return false; | |||
| } | |||
| Enumeration<?> e1 = d1.keys(); | |||
| while (e1.hasMoreElements()) { | |||
| Object key = e1.nextElement(); | |||
| Object value1 = d1.get(key); | |||
| Object value2 = d2.get(key); | |||
| if (!value1.equals(value2)) { | |||
| return false; | |||
| } | |||
| } | |||
| // don't need the opposite check as the Dictionaries have the | |||
| // same size, so we've also covered all keys of d2 already. | |||
| return true; | |||
| return Collections.list(d1.keys()).stream() | |||
| .allMatch(key -> d1.get(key).equals(d2.get(key))); | |||
| } | |||
| /** | |||
| @@ -103,7 +94,9 @@ public class CollectionUtils { | |||
| * @param c collection to transform | |||
| * @return string representation of the collection | |||
| * @since Ant 1.8.0 | |||
| * @deprecated use stream().collect(Collectors.joining(",")) | |||
| */ | |||
| @Deprecated | |||
| public static String flattenToString(Collection<?> c) { | |||
| return c.stream().map(String::valueOf).collect(Collectors.joining(",")); | |||
| } | |||
| @@ -120,10 +113,7 @@ public class CollectionUtils { | |||
| @Deprecated | |||
| public static <K, V> void putAll(Dictionary<? super K, ? super V> m1, | |||
| Dictionary<? extends K, ? extends V> m2) { | |||
| for (Enumeration<? extends K> it = m2.keys(); it.hasMoreElements();) { | |||
| K key = it.nextElement(); | |||
| m1.put(key, m2.get(key)); | |||
| } | |||
| Collections.list(m2.keys()).forEach(key -> m1.put(key, m2.get(key))); | |||
| } | |||
| /** | |||
| @@ -159,7 +149,10 @@ public class CollectionUtils { | |||
| * @param <E> element type | |||
| * @return an enumeration representing e1 followed by e2. | |||
| * @since Ant 1.6.3 | |||
| * @deprecated use Stream.concat(Collections.list(e1).stream(), Collections.list(e2).stream()) | |||
| * .collect(Collectors.collectingAndThen(Collectors.toList(), Collections::enumeration)) | |||
| */ | |||
| @Deprecated | |||
| public static <E> Enumeration<E> append(Enumeration<E> e1, Enumeration<E> e2) { | |||
| return new CompoundEnumeration<>(e1, e2); | |||
| } | |||
| @@ -169,7 +162,9 @@ public class CollectionUtils { | |||
| * @param iter the Iterator to adapt. | |||
| * @param <E> element type | |||
| * @return an Enumeration. | |||
| * @deprecated use Collections.enumeration() | |||
| */ | |||
| @Deprecated | |||
| public static <E> Enumeration<E> asEnumeration(final Iterator<E> iter) { | |||
| return new Enumeration<E>() { | |||
| @Override | |||
| @@ -188,7 +183,9 @@ public class CollectionUtils { | |||
| * @param e the Enumeration to adapt. | |||
| * @param <E> element type | |||
| * @return an Iterator. | |||
| * @deprecated use Collections.list(e).iterator() | |||
| */ | |||
| @Deprecated | |||
| public static <E> Iterator<E> asIterator(final Enumeration<E> e) { | |||
| return new Iterator<E>() { | |||
| @Override | |||
| @@ -213,7 +210,9 @@ public class CollectionUtils { | |||
| * @param <T> element type | |||
| * @return the collection | |||
| * @since Ant 1.8.0 | |||
| * @deprecated instantiate a list an use forEachRemaining(list::add) | |||
| */ | |||
| @Deprecated | |||
| public static <T> Collection<T> asCollection(final Iterator<? extends T> iter) { | |||
| List<T> l = new ArrayList<>(); | |||
| iter.forEachRemaining(l::add); | |||
| @@ -18,6 +18,7 @@ | |||
| package org.apache.tools.ant.util; | |||
| import java.util.Collection; | |||
| import java.util.Collections; | |||
| import java.util.Enumeration; | |||
| import java.util.Hashtable; | |||
| import java.util.LinkedHashMap; | |||
| @@ -79,7 +80,7 @@ public class LinkedHashtable<K, V> extends Hashtable<K, V> { | |||
| @Override | |||
| public Enumeration<V> elements() { | |||
| return CollectionUtils.asEnumeration(values().iterator()); | |||
| return Collections.enumeration(values()); | |||
| } | |||
| @Override | |||
| @@ -109,7 +110,7 @@ public class LinkedHashtable<K, V> extends Hashtable<K, V> { | |||
| @Override | |||
| public Enumeration<K> keys() { | |||
| return CollectionUtils.asEnumeration(keySet().iterator()); | |||
| return Collections.enumeration(keySet()); | |||
| } | |||
| @Override | |||
| @@ -16,9 +16,10 @@ | |||
| * | |||
| */ | |||
| package org.apache.tools.ant.util.depend.bcel; | |||
| import java.io.File; | |||
| import java.io.IOException; | |||
| import java.util.Enumeration; | |||
| import java.util.Collections; | |||
| import java.util.HashSet; | |||
| import java.util.Set; | |||
| import java.util.Vector; | |||
| @@ -69,13 +70,9 @@ public class AncestorAnalyzer extends AbstractAnalyzer { | |||
| // classes upon which they depend | |||
| Set<String> dependencies = new HashSet<>(); | |||
| Set<File> containers = new HashSet<>(); | |||
| Set<String> toAnalyze = new HashSet<>(); | |||
| Set<String> toAnalyze = new HashSet<>(Collections.list(getRootClasses())); | |||
| Set<String> nextAnalyze = new HashSet<>(); | |||
| for (Enumeration<String> e = getRootClasses(); e.hasMoreElements();) { | |||
| toAnalyze.add(e.nextElement()); | |||
| } | |||
| int count = 0; | |||
| int maxCount = isClosureRequired() ? MAX_LOOPS : 2; | |||
| while (!toAnalyze.isEmpty() && count++ < maxCount) { | |||
| @@ -115,9 +112,8 @@ public class AncestorAnalyzer extends AbstractAnalyzer { | |||
| } | |||
| } | |||
| Set<String> temp = toAnalyze; | |||
| toAnalyze = nextAnalyze; | |||
| nextAnalyze = temp; | |||
| toAnalyze.clear(); | |||
| toAnalyze.addAll(nextAnalyze); | |||
| } | |||
| files.clear(); | |||
| @@ -19,7 +19,6 @@ package org.apache.tools.ant.util.depend.bcel; | |||
| import java.io.File; | |||
| import java.io.IOException; | |||
| import java.util.Collections; | |||
| import java.util.Enumeration; | |||
| import java.util.HashSet; | |||
| import java.util.Set; | |||
| import java.util.Vector; | |||
| @@ -102,15 +101,10 @@ public class FullAnalyzer extends AbstractAnalyzer { | |||
| } | |||
| toAnalyze.clear(); | |||
| // now recover all the dependencies collected and add to the list. | |||
| Enumeration<String> depsEnum = dependencyVisitor.getDependencies(); | |||
| while (depsEnum.hasMoreElements()) { | |||
| String className = depsEnum.nextElement(); | |||
| if (!dependencies.contains(className)) { | |||
| toAnalyze.add(className); | |||
| } | |||
| } | |||
| Collections.list(dependencyVisitor.getDependencies()).stream() | |||
| .filter(className -> !dependencies.contains(className)) | |||
| .forEach(toAnalyze::add); | |||
| } | |||
| files.clear(); | |||
| @@ -18,6 +18,7 @@ | |||
| package org.apache.tools.ant.util; | |||
| import java.util.Collections; | |||
| import java.util.Hashtable; | |||
| import java.util.Iterator; | |||
| import java.util.Map; | |||
| @@ -112,7 +113,7 @@ public class LinkedHashtableTest { | |||
| @Test | |||
| public void testKeys() { | |||
| multiSetup(); | |||
| assertKeys(CollectionUtils.asIterator(h.keys())); | |||
| assertKeys(Collections.list(h.keys()).iterator()); | |||
| } | |||
| @Test | |||
| @@ -124,7 +125,7 @@ public class LinkedHashtableTest { | |||
| @Test | |||
| public void testElements() { | |||
| multiSetup(); | |||
| assertValues(CollectionUtils.asIterator(h.elements())); | |||
| assertValues(Collections.list(h.elements()).iterator()); | |||
| } | |||
| @Test | |||