Author: ekoneil
Date: Tue Feb 22 14:23:10 2005
New Revision: 154902
URL: http://svn.apache.org/viewcvs?view=rev&rev=154902
Log:
Remove the "makeIterator" method on the IteratorFactory and delete the
exception that it threw.
None of this code is used.
BB: self
DRT: NetUI pass
Removed:
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/iterator/IteratorFactoryException.java
Modified:
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/iterator/IteratorFactory.java
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/iterator/IteratorFactoryTest.java
Modified:
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/iterator/IteratorFactory.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/iterator/IteratorFactory.java?view=diff&r1=154901&r2=154902
==============================================================================
---
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/iterator/IteratorFactory.java
(original)
+++
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/iterator/IteratorFactory.java
Tue Feb 22 14:23:10 2005
@@ -17,29 +17,20 @@
*/
package org.apache.beehive.netui.util.iterator;
-// java imports
-
-import java.io.InputStream;
-
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
-import java.util.Properties;
-
+import java.util.Collections;
import java.sql.ResultSet;
import javax.sql.RowSet;
-// internal imports
import org.apache.beehive.netui.util.config.ConfigUtil;
import
org.apache.beehive.netui.util.config.bean.NetuiConfigDocument.NetuiConfig;
import org.apache.beehive.netui.util.config.bean.IteratorFactories;
import org.apache.beehive.netui.util.logging.Logger;
-// external imports
-
/**
* <code>IteratorFactory</code> provides a way to create an
* <code>Iterator</code> for different kinds of objects. The supported types
@@ -61,36 +52,25 @@
*/
public class IteratorFactory {
+ public static final Iterator EMPTY_ITERATOR =
Collections.EMPTY_LIST.iterator();
+
private static final Logger LOGGER =
Logger.getInstance(IteratorFactory.class);
- public static final Iterator EMPTY_ITERATOR = new EmptyIterator();
- private static final Map _plantMap;
+ private static final LinkedHashMap ITERATOR_FACTORIES;
static {
- _plantMap = new LinkedHashMap();
-
+ ITERATOR_FACTORIES = new LinkedHashMap();
initialize();
}
/**
- * Create a new <code>Iterator</code> for the supplied object. If the
- * passed object is null, this method will return null;
- *
- * @param object the object to build an iterator from
- * @return an iterator for the supplied object or <code>null</code>
- * @deprecated
+ * @exclude
*/
- public static Iterator makeIterator(Object object)
- throws IteratorFactoryException {
- try {
- return createIterator(object);
- }
- // throw an IteratorFactoryException if anything goes
- // wrong creating an Iterator
- catch(Exception e) {
- Class objectType = object != null ? object.getClass() : null;
- String message = "An error occurred creating an iterator for type
\"" + objectType + "\"";
- throw new IteratorFactoryException(message, e, objectType);
- }
+ public abstract static class IteratorPlant {
+ /**
+ * If it is possible to create an iterator for this type, do so.
+ * Otherwise return null.
+ */
+ public abstract Iterator createIterator(Object value);
}
/**
@@ -126,9 +106,9 @@
// check to see if there is a registered IteratorPlant that can handle
this type
Iterator ret = null;
- Iterator factories = _plantMap.keySet().iterator();
+ Iterator factories = ITERATOR_FACTORIES.keySet().iterator();
while(factories.hasNext()) {
- IteratorPlant plant =
(IteratorPlant)_plantMap.get(factories.next());
+ IteratorPlant plant =
(IteratorPlant)ITERATOR_FACTORIES.get(factories.next());
ret = plant.createIterator(object);
if(ret != null) return ret;
@@ -149,14 +129,17 @@
private static final Map readFromConfig() {
NetuiConfig config = ConfigUtil.getConfig();
- if(config == null) return null;
+ if(config == null)
+ return null;
IteratorFactories factories = config.getIteratorFactories();
- if(factories == null) return null;
+ if(factories == null)
+ return null;
org.apache.beehive.netui.util.config.bean.IteratorFactories.IteratorFactory[]
factoryArray =
factories.getIteratorFactoryArray();
- if(factoryArray == null) return null;
+ if(factoryArray == null)
+ return null;
LinkedHashMap map = new LinkedHashMap();
for(int i = 0; i < factoryArray.length; i++) {
@@ -189,26 +172,14 @@
continue;
}
- if(_plantMap.containsKey(name)) {
+ if(ITERATOR_FACTORIES.containsKey(name)) {
if(LOGGER.isWarnEnabled())
LOGGER.warn("Overwriting a previously defined
IteratorPlant named \"" + name +
"\" with a new IteratorPlant of type \"" + className +
"\"");
} else if(LOGGER.isInfoEnabled())
LOGGER.info("Adding an IteratorPlant named \"" + name + "\"
with implementation \"" + className + "\"");
- _plantMap.put(name, plant);
+ ITERATOR_FACTORIES.put(name, plant);
}
- }
-
- /**
- * @exclude
- */
- public abstract static class IteratorPlant {
-
- /**
- * If it is possible to create an iterator for this type, do so.
- * Otherwise return null.
- */
- public abstract Iterator createIterator(Object value);
}
}
Modified:
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/iterator/IteratorFactoryTest.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/iterator/IteratorFactoryTest.java?view=diff&r1=154901&r2=154902
==============================================================================
---
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/iterator/IteratorFactoryTest.java
(original)
+++
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/iterator/IteratorFactoryTest.java
Tue Feb 22 14:23:10 2005
@@ -37,8 +37,7 @@
throws Exception {
Map map = new HashMap();
- Iterator i = null;
- i = IteratorFactory.makeIterator(map);
+ Iterator i = IteratorFactory.createIterator(map);
assertTrue(i instanceof MapIterator);
assertNotNull(i);
@@ -48,12 +47,12 @@
throws Exception {
String s = new String("atomic");
Iterator i = null;
- i = IteratorFactory.makeIterator(s);
+ i = IteratorFactory.createIterator(s);
assertTrue(i instanceof AtomicObjectIterator);
assertNotNull(i);
- i = IteratorFactory.makeIterator(null);
+ i = IteratorFactory.createIterator(null);
assertNull(i);
}