Browse Source

Move EmptyEnumeration to CollectionUtils

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274781 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 22 years ago
parent
commit
46c40044e1
3 changed files with 21 additions and 14 deletions
  1. +2
    -12
      src/main/org/apache/tools/ant/RuntimeConfigurable.java
  2. +3
    -1
      src/main/org/apache/tools/ant/Target.java
  3. +16
    -1
      src/main/org/apache/tools/ant/util/CollectionUtils.java

+ 2
- 12
src/main/org/apache/tools/ant/RuntimeConfigurable.java View File

@@ -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();
}
}



+ 3
- 1
src/main/org/apache/tools/ant/Target.java View File

@@ -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();
}
}



+ 16
- 1
src/main/org/apache/tools/ant/util/CollectionUtils.java View File

@@ -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();
}
}

}

Loading…
Cancel
Save