From 46c40044e121ccf6096148a2def4159a4887e405 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Mon, 7 Jul 2003 08:20:52 +0000 Subject: [PATCH] Move EmptyEnumeration to CollectionUtils git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274781 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tools/ant/RuntimeConfigurable.java | 14 ++------------ src/main/org/apache/tools/ant/Target.java | 4 +++- .../apache/tools/ant/util/CollectionUtils.java | 17 ++++++++++++++++- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/main/org/apache/tools/ant/RuntimeConfigurable.java b/src/main/org/apache/tools/ant/RuntimeConfigurable.java index 02de7b025..df314630b 100644 --- a/src/main/org/apache/tools/ant/RuntimeConfigurable.java +++ b/src/main/org/apache/tools/ant/RuntimeConfigurable.java @@ -63,8 +63,8 @@ import java.util.Hashtable; import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.NoSuchElementException; +import org.apache.tools.ant.util.CollectionUtils; import org.xml.sax.AttributeList; import org.xml.sax.helpers.AttributeListImpl; @@ -236,17 +236,7 @@ public class RuntimeConfigurable implements Serializable { if (children != null) { return Collections.enumeration(children); } else { - return new EmptyEnumeration(); - } - } - - static final class EmptyEnumeration implements Enumeration { - public EmptyEnumeration() {} - public boolean hasMoreElements() { - return false; - } - public Object nextElement() throws NoSuchElementException { - throw new NoSuchElementException(); + return new CollectionUtils.EmptyEnumeration(); } } diff --git a/src/main/org/apache/tools/ant/Target.java b/src/main/org/apache/tools/ant/Target.java index a6de5acc2..1433aa249 100644 --- a/src/main/org/apache/tools/ant/Target.java +++ b/src/main/org/apache/tools/ant/Target.java @@ -61,6 +61,8 @@ import java.util.Iterator; import java.util.List; import java.util.StringTokenizer; +import org.apache.tools.ant.util.CollectionUtils; + /** * Class to implement a target object with required parameters. * @@ -222,7 +224,7 @@ public class Target implements TaskContainer { if (dependencies != null) { return Collections.enumeration(dependencies); } else { - return new RuntimeConfigurable.EmptyEnumeration(); + return new CollectionUtils.EmptyEnumeration(); } } diff --git a/src/main/org/apache/tools/ant/util/CollectionUtils.java b/src/main/org/apache/tools/ant/util/CollectionUtils.java index 706810552..56ffadb23 100644 --- a/src/main/org/apache/tools/ant/util/CollectionUtils.java +++ b/src/main/org/apache/tools/ant/util/CollectionUtils.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2002 The Apache Software Foundation. All rights + * Copyright (c) 2002-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -55,6 +55,7 @@ package org.apache.tools.ant.util; import java.util.Dictionary; import java.util.Enumeration; +import java.util.NoSuchElementException; import java.util.Vector; /** @@ -146,4 +147,18 @@ public class CollectionUtils { m1.put(key, m2.get(key)); } } + + /** + * @since Ant 1.6 + */ + public static final class EmptyEnumeration implements Enumeration { + public EmptyEnumeration() {} + public boolean hasMoreElements() { + return false; + } + public Object nextElement() throws NoSuchElementException { + throw new NoSuchElementException(); + } + } + }