lcsim/src/org/lcsim/util
diff -N ListAddDriver.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ListAddDriver.java 17 Feb 2006 01:57:03 -0000 1.1
@@ -0,0 +1,41 @@
+package org.lcsim.util;
+
+import java.util.List;
+import java.util.Vector;
+
+import org.lcsim.event.EventHeader;
+import org.lcsim.util.Driver;
+
+/**
+ * Add a number of named lists together and write the combined list to the event.
+ *
+ * @version $Id: ListAddDriver.java,v 1.1 2006/02/17 01:57:03 mcharles Exp $
+ */
+
+public class ListAddDriver<T> extends Driver
+{
+ /** Simple constructor */
+ public ListAddDriver () {
+ super();
+ }
+
+ /** Process one event, performing merge. */
+ public void process(EventHeader event)
+ {
+ List<T> outputList = new Vector<T>();
+ for (String inputName : m_inputNames) {
+ List<T> currentList = (List<T>) (event.get(inputName));
+ outputList.addAll(currentList);
+ }
+ event.put(m_outputName, outputList);
+ }
+
+ /** Add one input list */
+ public void addInputList(String name) { m_inputNames.add(name); }
+
+ /** Set the name to write the output list to */
+ public void setOutputList(String name) { m_outputName = name; }
+
+ protected List<String> m_inputNames = new Vector<String>();
+ protected String m_outputName;
+}