001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.jetspeed.decoration;
018:
019: import javax.portlet.PortletMode;
020: import javax.portlet.WindowState;
021:
022: public class DecoratorActionTemplate {
023: protected static final String ACTION_TYPE_MODE = "mode";
024: protected static final String ACTION_TYPE_STATE = "state";
025: protected static final String ACTION_TYPE_BOTH = "both";
026:
027: private String action;
028: private PortletMode mode;
029: private PortletMode customMode;
030: private WindowState state;
031: private WindowState customState;
032:
033: private String actionType;
034:
035: public DecoratorActionTemplate(String action, PortletMode mode,
036: PortletMode customMode, WindowState state,
037: WindowState customState) {
038: this .action = action;
039: this .mode = mode;
040: this .customMode = customMode;
041: this .state = state;
042: this .customState = customState;
043: if (mode != null) {
044: this .actionType = (state != null) ? ACTION_TYPE_BOTH
045: : ACTION_TYPE_MODE;
046: } else if (state != null) {
047: this .actionType = ACTION_TYPE_STATE;
048: }
049: }
050:
051: public DecoratorActionTemplate(String action, PortletMode mode,
052: WindowState state) {
053: this (action, mode, mode, state, state);
054: }
055:
056: public DecoratorActionTemplate(PortletMode mode,
057: PortletMode customMode) {
058: this (mode.toString(), mode, customMode, null, null);
059: }
060:
061: public DecoratorActionTemplate(PortletMode mode) {
062: this (mode, mode);
063: }
064:
065: public DecoratorActionTemplate(WindowState state,
066: WindowState customState) {
067: this (state.toString(), null, null, state, customState);
068: }
069:
070: public DecoratorActionTemplate(WindowState state) {
071: this (state, state);
072: }
073:
074: public String getAction() {
075: return action;
076: }
077:
078: public String getActionType() {
079: return actionType;
080: }
081:
082: public PortletMode getCustomMode() {
083: return customMode;
084: }
085:
086: public WindowState getCustomState() {
087: return customState;
088: }
089:
090: public PortletMode getMode() {
091: return mode;
092: }
093:
094: public WindowState getState() {
095: return state;
096: }
097:
098: public int hashCode() {
099: return action.hashCode();
100: }
101:
102: public boolean equals(Object o) {
103: if (o != null && o instanceof DecoratorActionTemplate) {
104: return action.equals(((DecoratorActionTemplate) o).action);
105: }
106: return false;
107: }
108:
109: public void setAction(String action) {
110: this .action = action;
111: }
112:
113: public void setActionType(String actionType) {
114: this .actionType = actionType;
115: }
116:
117: public void setCustomMode(PortletMode customMode) {
118: this .customMode = customMode;
119: }
120:
121: public void setCustomState(WindowState customState) {
122: this .customState = customState;
123: }
124:
125: public void setMode(PortletMode mode) {
126: this .mode = mode;
127: }
128:
129: public void setState(WindowState state) {
130: this.state = state;
131: }
132: }
|