merged 1.1 branch into head
[mir.git] / source / mir / producer / ListEnumeratingProducerNode.java
index e9a68fc..a80a556 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2001, 2002 The Mir-coders group
+ * Copyright (C) 2001-2006 The Mir-coders group
  *
  * This file is part of Mir.
  *
@@ -19,8 +19,6 @@
  *
  * In addition, as a special exception, The Mir-coders gives permission to link
  * the code of this program with  any library licensed under the Apache Software License,
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
- * (or with modified versions of the above that use the same license as the above),
  * and distribute linked combinations including the two.  You must obey the
  * GNU General Public License in all respects for all of the code used other than
  * the above mentioned libraries.  If you modify this file, you may extend this
  */
 package mir.producer;
 
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-
-import mir.log.LoggerWrapper;
 import mir.util.ParameterExpander;
 import mir.util.RewindableIterator;
 
+import java.util.Collection;
+import java.util.Iterator;
+
 public class ListEnumeratingProducerNode extends ProducerNodeDecorator {
   private String key;
   private String listExpression;
@@ -48,32 +44,36 @@ public class ListEnumeratingProducerNode extends ProducerNodeDecorator {
     listExpression = aListExpression;
   }
 
-  public void produce(Map aValueMap, String aVerb, LoggerWrapper aLogger) throws ProducerFailure, ProducerExc {
+  public void produce(ProductionContext aProductionContext) throws ProducerFailure, ProducerExc {
     Iterator browser;
     Object list;
 
     try {
-      list = ParameterExpander.evaluateExpression(aValueMap, listExpression);
+      list = ParameterExpander.evaluateExpression(aProductionContext.getValueSet(), listExpression);
       if (list != null) {
-        if (list instanceof Collection)
+        if (list instanceof Collection) {
           browser = ( (Collection) list).iterator();
-        else if (list instanceof Iterator)
+        }
+        else if (list instanceof Iterator) {
           browser = (Iterator) list;
-        else
+        }
+        else {
           throw new ProducerExc("Can't enumarate a " + list.getClass().getName());
+        }
 
         if (browser instanceof RewindableIterator) {
-          ( (RewindableIterator) browser).rewind();
+          ((RewindableIterator) browser).rewind();
         }
 
-        while (browser.hasNext() && !isAborted(aValueMap)) {
-          ParameterExpander.setValueForKey(aValueMap, key, browser.next());
-          super.produce(aValueMap, aVerb, aLogger);
+        while (browser.hasNext() && !isAborted(aProductionContext)) {
+          ParameterExpander.setValueForKey(aProductionContext.getValueSet(), key, browser.next());
+
+          super.produce(aProductionContext);
         }
       }
     }
     catch (Throwable t) {
-      aLogger.error("Exception occurred inside an ListEnumeratingProducerNode: " + t.getMessage());
+      aProductionContext.getLogger().warn("Exception occurred inside an ListEnumeratingProducerNode", t);
     }
-  };
+  }
 }