1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.decoration;
18
19 import javax.portlet.PortletMode;
20 import javax.portlet.WindowState;
21
22 public class DecoratorActionTemplate
23 {
24 protected static final String ACTION_TYPE_MODE = "mode";
25 protected static final String ACTION_TYPE_STATE = "state";
26 protected static final String ACTION_TYPE_BOTH = "both";
27
28 private String action;
29 private PortletMode mode;
30 private PortletMode customMode;
31 private WindowState state;
32 private WindowState customState;
33
34 private String actionType;
35
36 public DecoratorActionTemplate(String action, PortletMode mode, PortletMode customMode, WindowState state, WindowState customState)
37 {
38 this.action = action;
39 this.mode = mode;
40 this.customMode = customMode;
41 this.state = state;
42 this.customState = customState;
43 if ( mode != null )
44 {
45 this.actionType = ( state != null ) ? ACTION_TYPE_BOTH : ACTION_TYPE_MODE;
46 }
47 else if ( state != null )
48 {
49 this.actionType = ACTION_TYPE_STATE;
50 }
51 }
52
53 public DecoratorActionTemplate(String action, PortletMode mode, WindowState state)
54 {
55 this(action,mode,mode,state,state);
56 }
57
58 public DecoratorActionTemplate(PortletMode mode, PortletMode customMode)
59 {
60 this(mode.toString(), mode, customMode, null, null);
61 }
62
63 public DecoratorActionTemplate(PortletMode mode)
64 {
65 this(mode,mode);
66 }
67
68 public DecoratorActionTemplate(WindowState state, WindowState customState)
69 {
70 this(state.toString(), null, null, state, customState);
71 }
72
73 public DecoratorActionTemplate(WindowState state)
74 {
75 this(state,state);
76 }
77
78 public String getAction()
79 {
80 return action;
81 }
82
83 public String getActionType()
84 {
85 return actionType;
86 }
87
88 public PortletMode getCustomMode()
89 {
90 return customMode;
91 }
92
93 public WindowState getCustomState()
94 {
95 return customState;
96 }
97
98 public PortletMode getMode()
99 {
100 return mode;
101 }
102
103 public WindowState getState()
104 {
105 return state;
106 }
107
108 public int hashCode()
109 {
110 return action.hashCode();
111 }
112
113 public boolean equals(Object o)
114 {
115 if ( o != null && o instanceof DecoratorActionTemplate)
116 {
117 return action.equals(((DecoratorActionTemplate)o).action);
118 }
119 return false;
120 }
121
122 public void setAction(String action)
123 {
124 this.action = action;
125 }
126
127 public void setActionType( String actionType )
128 {
129 this.actionType = actionType;
130 }
131
132 public void setCustomMode(PortletMode customMode)
133 {
134 this.customMode = customMode;
135 }
136
137 public void setCustomState(WindowState customState)
138 {
139 this.customState = customState;
140 }
141
142 public void setMode(PortletMode mode)
143 {
144 this.mode = mode;
145 }
146
147 public void setState(WindowState state)
148 {
149 this.state = state;
150 }
151 }