1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package org.dbforms.event.eventtype;
25
26
27 /***
28 * EventType context class. Uses strategy to select the event type value from
29 * an input string.
30 *
31 * @author Luca Fossato
32 *
33 */
34 public class EventType {
35 /*** value of the database event */
36 public static final int EVENT_GROUP_DATABASE = 0;
37
38 /*** value of the navigation event */
39 public static final int EVENT_GROUP_NAVIGATION = 1;
40
41 /*** value of the navigation goto event */
42 public static final int EVENT_UNDEFINED = -1;
43
44 /*** value of the database insert event */
45 public static final String EVENT_DATABASE_INSERT = "insert";
46
47 /*** value of the database update event */
48 public static final String EVENT_DATABASE_UPDATE = "update";
49
50 /*** value of the database delete event */
51 public static final String EVENT_DATABASE_DELETE = "delete";
52
53 /*** value of the navigation first event */
54 public static final String EVENT_NAVIGATION_FIRST = "navFirst";
55
56 /*** value of the navigation previous event */
57 public static final String EVENT_NAVIGATION_PREV = "navPrev";
58
59 /*** value of the navigation next event */
60 public static final String EVENT_NAVIGATION_NEXT = "navNext";
61
62 /*** value of the navigation last event */
63 public static final String EVENT_NAVIGATION_LAST = "navLast";
64
65 /*** value of the navigation new event */
66 public static final String EVENT_NAVIGATION_NEW = "navNew";
67
68 /*** value of the navigation new event */
69 public static final String EVENT_NAVIGATION_COPY = "navCopy";
70
71 /*** value of the navigation goto event */
72 public static final String EVENT_NAVIGATION_GOTO = "navGoto";
73
74 /*** value of the navigation reload event */
75 public static final String EVENT_NAVIGATION_RELOAD = "navReload";
76
77 /*** value of the navigation force reload event */
78 public static final String EVENT_NAVIGATION_FORCERELOAD = "navForceReload";
79
80 /*** transfer value of the navigation first event */
81 public static final String EVENT_NAVIGATION_TRANSFER_FIRST = "ac_first_";
82
83 /*** transfer value of the navigation previous event */
84 public static final String EVENT_NAVIGATION_TRANSFER_PREV = "ac_prev_";
85
86 /*** transfer value of the navigation next event */
87 public static final String EVENT_NAVIGATION_TRANSFER_NEXT = "ac_next_";
88
89 /*** transfer value of the navigation last event */
90 public static final String EVENT_NAVIGATION_TRANSFER_LAST = "ac_last_";
91
92 /*** transfer value of the navigation new event */
93 public static final String EVENT_NAVIGATION_TRANSFER_NEW = "ac_new_";
94
95 /*** transfer value of the navigation new event */
96 public static final String EVENT_NAVIGATION_TRANSFER_COPY = "ac_copy_";
97
98 /*** transfer value of the navigation goto event */
99 public static final String EVENT_NAVIGATION_TRANSFER_GOTO = "ac_goto_";
100
101 /*** transfer value of the navigation reload event */
102 public static final String EVENT_NAVIGATION_TRANSFER_RELOAD = "ac_reload_";
103
104 /*** eventType strategy class */
105 private EventTypeStrategy eventTypeStrategy = null;
106
107 /*** the string that identifies the event type */
108 private String eventString = null;
109
110 /***
111 * Constructor; set the input EventTypeStrategy object as the default
112 * strategy.
113 *
114 * @param eventTypeStrategy an EventTypeStrategy object
115 */
116 public EventType(EventTypeStrategy eventTypeStrategy) {
117 this.eventTypeStrategy = eventTypeStrategy;
118 }
119
120 /***
121 * Gets the event group value
122 *
123 * @return The event group value
124 */
125 public int getEventGroup() {
126 int eventGroup = EVENT_UNDEFINED;
127
128 if (eventTypeStrategy != null) {
129 eventGroup = eventTypeStrategy.getEventGroup(eventString);
130 }
131
132 return eventGroup;
133 }
134
135
136 /***
137 * Sets the eventString attribute of the EventType object
138 *
139 * @param eventString The new eventString value
140 */
141 public void setEventString(String eventString) {
142 this.eventString = eventString;
143 }
144
145
146 /***
147 * Gets the eventString attribute of the EventType object
148 *
149 * @return The eventString value
150 */
151 public String getEventString() {
152 return eventString;
153 }
154
155
156 /***
157 * Gets the event type value
158 *
159 * @return The event type value
160 */
161 public String getEventType() {
162 String eventValue = String.valueOf(EVENT_UNDEFINED);
163
164 if (eventTypeStrategy != null) {
165 eventValue = eventTypeStrategy.getEventType(eventString);
166 }
167
168 return eventValue;
169 }
170
171
172 /***
173 * Sets the eventTypeStrategy attribute of the EventType object
174 *
175 * @param eventTypeStrategy The new eventTypeStrategy value
176 */
177 public void setEventTypeStrategy(EventTypeStrategy eventTypeStrategy) {
178 this.eventTypeStrategy = eventTypeStrategy;
179 }
180
181
182 /***
183 * Gets the eventTypeStrategy attribute of the EventType object
184 *
185 * @return The eventTypeStrategy value
186 */
187 public EventTypeStrategy getEventTypeStrategy() {
188 return eventTypeStrategy;
189 }
190 }