KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > dbforms > event > eventtype > NavigationEventTypeStrategy


1 /*
2  * $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/event/eventtype/NavigationEventTypeStrategy.java,v 1.10 2004/08/18 12:26:04 hkollmann Exp $
3  * $Revision: 1.10 $
4  * $Date: 2004/08/18 12:26:04 $
5  *
6  * DbForms - a Rapid Application Development Framework
7  * Copyright (C) 2001 Joachim Peer <joepeer@excite.com>
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22  */

23
24 package org.dbforms.event.eventtype;
25
26
27 /**
28  * Database EventTypeStrategy class. Provides implementations of the super
29  * class methods for Navigation events.
30  *
31  * @author Luca Fossato
32  *
33  */

34 public class NavigationEventTypeStrategy implements EventTypeStrategy {
35    /**
36     * Gets the event group value.
37     *
38     * @param eventString the string that identifies an event type
39     *
40     * @return The event group value, or <code>EventType.EVENT_UNDEFINED</code>
41     */

42    public int getEventGroup(String JavaDoc eventString) {
43       int eventGroup = EventType.EVENT_UNDEFINED;
44
45       // could implement this with an hash map;
46
if (eventString.startsWith(EventType.EVENT_NAVIGATION_TRANSFER_FIRST)
47                 || eventString.startsWith(EventType.EVENT_NAVIGATION_TRANSFER_PREV)
48                 || eventString.startsWith(EventType.EVENT_NAVIGATION_TRANSFER_NEXT)
49                 || eventString.startsWith(EventType.EVENT_NAVIGATION_TRANSFER_LAST)
50                 || eventString.startsWith(EventType.EVENT_NAVIGATION_TRANSFER_NEW)
51                 || eventString.startsWith(EventType.EVENT_NAVIGATION_TRANSFER_RELOAD)
52                 || eventString.startsWith(EventType.EVENT_NAVIGATION_TRANSFER_GOTO)
53                 || eventString.startsWith(EventType.EVENT_NAVIGATION_TRANSFER_COPY)
54                 || eventString.equals(EventType.EVENT_NAVIGATION_FIRST)
55                 || eventString.equals(EventType.EVENT_NAVIGATION_PREV)
56                 || eventString.equals(EventType.EVENT_NAVIGATION_NEXT)
57                 || eventString.equals(EventType.EVENT_NAVIGATION_LAST)
58                 || eventString.equals(EventType.EVENT_NAVIGATION_NEW)
59                 || eventString.equals(EventType.EVENT_NAVIGATION_RELOAD)
60                 || eventString.equals(EventType.EVENT_NAVIGATION_GOTO)
61                 || eventString.equals(EventType.EVENT_NAVIGATION_COPY)
62                 || eventString.equals("goto")) {
63          eventGroup = EventType.EVENT_GROUP_NAVIGATION;
64       }
65
66       return eventGroup;
67    }
68
69
70    /**
71     * Gets the event type value
72     *
73     * @param eventString the string that identifies an event type
74     *
75     * @return The event type value, or <code>EventType.EVENT_UNDEFINED</code>
76     */

77    public String JavaDoc getEventType(String JavaDoc eventString) {
78       String JavaDoc eventType = String.valueOf(EventType.EVENT_UNDEFINED);
79
80       if (eventString.startsWith(EventType.EVENT_NAVIGATION_TRANSFER_FIRST)
81                 || eventString.equals(EventType.EVENT_NAVIGATION_FIRST)) {
82          eventType = EventType.EVENT_NAVIGATION_FIRST;
83       } else if (eventString.startsWith(EventType.EVENT_NAVIGATION_TRANSFER_PREV)
84                        || eventString.equals(EventType.EVENT_NAVIGATION_PREV)) {
85          eventType = EventType.EVENT_NAVIGATION_PREV;
86       } else if (eventString.startsWith(EventType.EVENT_NAVIGATION_TRANSFER_NEXT)
87                        || eventString.equals(EventType.EVENT_NAVIGATION_NEXT)) {
88          eventType = EventType.EVENT_NAVIGATION_NEXT;
89       } else if (eventString.startsWith(EventType.EVENT_NAVIGATION_TRANSFER_LAST)
90                        || eventString.equals(EventType.EVENT_NAVIGATION_LAST)) {
91          eventType = EventType.EVENT_NAVIGATION_LAST;
92       } else if (eventString.startsWith(EventType.EVENT_NAVIGATION_TRANSFER_NEW)
93                        || eventString.equals(EventType.EVENT_NAVIGATION_NEW)) {
94          eventType = EventType.EVENT_NAVIGATION_NEW;
95       } else if (eventString.startsWith(EventType.EVENT_NAVIGATION_TRANSFER_COPY)
96                        || eventString.equals(EventType.EVENT_NAVIGATION_COPY)) {
97          eventType = EventType.EVENT_NAVIGATION_COPY;
98       } else if (eventString.startsWith(EventType.EVENT_NAVIGATION_TRANSFER_RELOAD)
99                        || eventString.equals(EventType.EVENT_NAVIGATION_RELOAD)) {
100          eventType = EventType.EVENT_NAVIGATION_RELOAD;
101       } else if (eventString.startsWith(EventType.EVENT_NAVIGATION_TRANSFER_GOTO)
102                        || eventString.equals(EventType.EVENT_NAVIGATION_GOTO)
103                        || eventString.equals("goto")) {
104          eventType = EventType.EVENT_NAVIGATION_GOTO;
105       }
106
107       return eventType;
108    }
109
110
111    /**
112     * Gets the EventTypeStrategy identifier.
113     *
114     * @return the EventTypeStrategy identifier
115     */

116    public String JavaDoc getId() {
117       return "NavigationEventTypeStrategy";
118    }
119 }
120
Popular Tags