X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=source%2Fmir%2Fproducer%2FListEnumeratingProducerNode.java;h=a80a556dd40edafb1d9b3960b8936a4955fe4410;hb=10f4bb84a35aadd3a3fd5ba80fcf2ad9f2d54a0c;hp=6dc6d01aa3e648e36cbd4543c8f1dabd35b41825;hpb=efd96b7b35414b0970616a881330b1767c2e54e3;p=mir.git diff --git a/source/mir/producer/ListEnumeratingProducerNode.java b/source/mir/producer/ListEnumeratingProducerNode.java index 6dc6d01a..a80a556d 100755 --- a/source/mir/producer/ListEnumeratingProducerNode.java +++ b/source/mir/producer/ListEnumeratingProducerNode.java @@ -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 @@ -29,13 +27,11 @@ */ package mir.producer; -import java.util.*; -import java.util.Map; +import mir.util.ParameterExpander; +import mir.util.RewindableIterator; -import mir.entity.adapter.EntityAdapterModel; -import mir.entity.adapter.EntityIteratorAdapter; -import mir.log.LoggerWrapper; -import mir.util.*; +import java.util.Collection; +import java.util.Iterator; public class ListEnumeratingProducerNode extends ProducerNodeDecorator { private String key; @@ -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); } - }; + } }