001: /*
002: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
003: * Distributed under the terms of either:
004: * - the common development and distribution license (CDDL), v1.0; or
005: * - the GNU Lesser General Public License, v2.1 or later
006: * $Id: TriggerContext.java 3634 2007-01-08 21:42:24Z gbevin $
007: */
008: package com.uwyn.rife.engine;
009:
010: import java.util.HashMap;
011: import java.util.Map;
012:
013: class TriggerContext {
014: private String mDeclarationName = null;
015: private int mType = -1;
016: private String mTriggerName = null;
017: private String[] mTriggerValues = null;
018: private Map<String, String[]> mParameters = null;
019:
020: static final int TRIGGER_CHILD = 1;
021: static final int TRIGGER_EXIT = 2;
022:
023: TriggerContext() {
024: mParameters = new HashMap<String, String[]>();
025: mTriggerName = "";
026: mTriggerValues = new String[0];
027: }
028:
029: TriggerContext(String declarationName, int type) {
030: this ();
031: mDeclarationName = declarationName;
032: mType = type;
033: }
034:
035: static TriggerContext generateChildTrigger(ElementInfo elementInfo,
036: String name, String[] values, Map<String, String[]> inputs) {
037: TriggerContext trigger_context = new TriggerContext(elementInfo
038: .getDeclarationName(), TRIGGER_CHILD);
039: trigger_context.setTriggerName(name);
040: trigger_context.setTriggerValues(values);
041: trigger_context.setParameters(inputs);
042:
043: return trigger_context;
044: }
045:
046: static TriggerContext generateExitTrigger(ElementInfo elementInfo,
047: String name, Map<String, String[]> inputs) {
048: TriggerContext trigger_context = new TriggerContext(elementInfo
049: .getDeclarationName(), TRIGGER_EXIT);
050: trigger_context.setTriggerName(name);
051: trigger_context.setParameters(inputs);
052:
053: return trigger_context;
054: }
055:
056: void setDeclarationName(String declarationName) {
057: mDeclarationName = declarationName;
058: }
059:
060: String getDeclarationName() {
061: return mDeclarationName;
062: }
063:
064: void setType(int type) {
065: mType = type;
066: }
067:
068: int getType() {
069: return mType;
070: }
071:
072: void setTriggerName(String triggerName) {
073: mTriggerName = triggerName;
074: }
075:
076: String getTriggerName() {
077: return mTriggerName;
078: }
079:
080: void setTriggerValues(String[] triggerValues) {
081: mTriggerValues = triggerValues;
082: }
083:
084: String[] getTriggerValues() {
085: return mTriggerValues;
086: }
087:
088: void setParameters(Map<String, String[]> parameters) {
089: mParameters = parameters;
090: }
091:
092: Map<String, String[]> getParameters() {
093: return mParameters;
094: }
095:
096: String[] getParameterValues() {
097: if (0 == mParameters.size()) {
098: return null;
099: } else {
100: return mParameters.values().iterator().next();
101: }
102: }
103: }
|