001: /*
002: * JFolder, Copyright 2001-2006 Gary Steinmetz
003: *
004: * Distributable under LGPL license.
005: * See terms of license at gnu.org.
006: */
007:
008: package org.jfolder.common.web.template;
009:
010: //base classes
011:
012: //project specific classes
013: import org.jfolder.common.UnexpectedSystemException;
014: import org.jfolder.common.web.template.ConsoleParameterContext;
015:
016: //other classes
017:
018: public abstract class BaseActionContext extends BaseParameterContext {
019:
020: //
021: private final static String CONSOLE_ACTION_PREFIX = "CONSOLE_ACTION_";
022: //
023: //protected final static String FIRST_ACTION = "CONSOLE_FIRST_ACTION";
024: //protected final static String SECOND_ACTION = "CONSOLE_SECOND_ACTION";
025: //protected final static String THIRD_ACTION = "CONSOLE_THIRD_ACTION";
026: //
027: //
028: //private String consoleFirstAction = null;
029: //private String consoleSecondAction = null;
030: //private String consoleThirdAction = null;
031: //
032: private ConsoleParameterHolder actionCph = null;
033:
034: //
035: protected BaseActionContext() {
036: this .actionCph = ConsoleParameterHolder.newInstance();
037: }
038:
039: public int hashCode() {
040:
041: int outValue = 0;
042:
043: outValue += this .actionCph.hashCode();
044: outValue += super .hashCode();
045:
046: return outValue;
047: }
048:
049: public boolean equals(Object inObj) {
050:
051: boolean outValue = true;
052:
053: if (inObj instanceof BaseActionContext) {
054: BaseActionContext nextBac = ((BaseActionContext) inObj);
055: outValue &= (this .actionCph.equals(nextBac.actionCph));
056: outValue &= super .equals(nextBac);
057: } else {
058: outValue &= false;
059: }
060:
061: return outValue;
062: }
063:
064: public boolean isValid() {
065: return (
066: //
067: super .isValid() && getActionCount() == ConsoleParameterContext.MAX_CREATION_PARAMS);
068: //&& this.consoleFirstAction != null
069: //&& this.consoleSecondAction != null
070: //&& this.consoleThirdAction != null);
071: }
072:
073: //
074: public final int getActionCount() {
075: return this .actionCph.getIndexCount();
076: }
077:
078: //
079: public final String getAction(Integer inIndex) {
080:
081: String outValue = null;
082:
083: Object o = this .actionCph.getInput(inIndex);
084: outValue = (String) o;
085:
086: return outValue;
087: }
088:
089: public final void addAction(Integer inIndex, String inValue) {
090: this .actionCph.addInput(inIndex, inValue);
091: }
092:
093: //public final String getFirstAction() {
094: // return this.consoleFirstAction;
095: //}
096: //
097: //public final String getSecondAction() {
098: // return this.consoleSecondAction;
099: //}
100: //
101: //public final String getThirdAction() {
102: // return this.consoleThirdAction;
103: //}
104:
105: public final boolean isAction(String inFirstAction,
106: String inSecondAction, String inThirdAction) {
107:
108: return (inFirstAction.equals(getAction(FIRST_INPUT))
109: && inSecondAction.equals(getAction(SECOND_INPUT)) && inThirdAction
110: .equals(getAction(THIRD_INPUT)));
111: }
112:
113: public final boolean isAction(String inFirstAction,
114: String inSecondAction) {
115:
116: return (inFirstAction.equals(getAction(FIRST_INPUT)) && inSecondAction
117: .equals(getAction(SECOND_INPUT)));
118: }
119:
120: public final boolean isAction(String inFirstAction) {
121:
122: return (inFirstAction.equals(getAction(FIRST_INPUT)));
123: }
124:
125: public final boolean isSubAction(String inSecondAction,
126: String inThirdAction) {
127:
128: return (inSecondAction.equals(getAction(SECOND_INPUT)) && inThirdAction
129: .equals(getAction(THIRD_INPUT)));
130: }
131:
132: public final boolean isSubAction(String inSecondAction) {
133:
134: return (inSecondAction.equals(getAction(SECOND_INPUT)));
135: }
136:
137: //public final void setFirstAction(String inAction) {
138: // this.consoleFirstAction = inAction;
139: //}
140: //
141: //public final void setSecondAction(String inSubAction) {
142: // this.consoleSecondAction = inSubAction;
143: //}
144: //
145: //public final void setThirdAction(String inSubSecondAction) {
146: // this.consoleThirdAction = inSubSecondAction;
147: //}
148:
149: public void unknownAction() {
150: throw new UnexpectedSystemException(
151: "Unknown Action - FirstAction("
152: + getAction(FIRST_INPUT) + "), SecondAction("
153: + getAction(SECOND_INPUT) + "), ThirdAction("
154: + getAction(THIRD_INPUT) + ")");
155: }
156: }
|