lcsim/src/org/lcsim/plugin/web/examples
diff -N BooleanCondition.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ BooleanCondition.java 9 Feb 2006 19:36:45 -0000 1.1
@@ -0,0 +1,41 @@
+import org.lcsim.event.EventHeader;
+import org.lcsim.util.Driver;
+
+/**
+ * An example of setting and retrieving a boolean value from the EventHeader.
+ *
+ * @author jeremym
+ * @version $Id: BooleanCondition.java,v 1.1 2006/02/09 19:36:45 jeremy Exp $
+ */
+public class BooleanCondition extends Driver
+{
+ public BooleanCondition()
+ {
+ add(new SetBoolean());
+ add(new GetBoolean());
+ }
+
+ public class SetBoolean extends Driver
+ {
+ protected void process(EventHeader event)
+ {
+ // Put a random boolean value into the EventHeader.
+ event.put("MyBool", getRandom().nextBoolean());
+ }
+ }
+
+ public class GetBoolean extends Driver
+ {
+ protected void process(EventHeader event)
+ {
+ // Get the boolean from EventHeader added by SetBoolean.
+ Boolean bool = (Boolean)event.get("MyBool");
+
+ // Condition based on the boolean value.
+ if (bool)
+ getLogger().info("MyBool is TRUE");
+ else
+ getLogger().info("MyBool is FALSE");
+ }
+ }
+}