KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/event/eventtype/DatabaseEventTypeStrategy.java,v 1.6 2004/10/03 18:53:22 hkollmann Exp $
3  * $Revision: 1.6 $
4  * $Date: 2004/10/03 18:53:22 $
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 Database events.
30  *
31  * @author Luca Fossato
32  *
33  */

34 public class DatabaseEventTypeStrategy implements EventTypeStrategy {
35
36    /**
37     * Gets the eventGroup attribute of the EventTypeStrategyImpl object
38     *
39     * @param eventString Description of the Parameter
40     *
41     * @return The eventGroup value, or EventType.EVENT_UNDEFINED otherwise
42     */

43    public int getEventGroup(String JavaDoc eventString) {
44       int eventGroup = EventType.EVENT_UNDEFINED;
45
46       if ((eventString.startsWith("ac_insert_"))
47                 || (eventString.startsWith("ac_update_"))
48                 || (eventString.startsWith("ac_updatear_"))
49                 || (eventString.startsWith("ac_delete_"))
50                 || (eventString.startsWith("ac_deletear_"))) {
51          eventGroup = EventType.EVENT_GROUP_DATABASE;
52       }
53
54       return eventGroup;
55    }
56
57
58    /**
59     * Gets the eventType attribute of the EventTypeStrategyImpl object
60     *
61     * @param eventString Description of the Parameter
62     *
63     * @return The eventType value
64     */

65    public String JavaDoc getEventType(String JavaDoc eventString) {
66       String JavaDoc eventType = String.valueOf(EventType.EVENT_UNDEFINED);
67
68       if (eventString.startsWith("ac_insert_")) {
69          eventType = EventType.EVENT_DATABASE_INSERT;
70       } else if (eventString.startsWith("ac_update_")
71                        || eventString.startsWith("ac_updatear_")) {
72          eventType = EventType.EVENT_DATABASE_UPDATE;
73       } else if (eventString.startsWith("ac_delete_")
74                        || eventString.startsWith("ac_deletear_")) {
75          eventType = EventType.EVENT_DATABASE_DELETE;
76       }
77
78       return eventType;
79    }
80
81
82    /**
83     * Gets the EventTypeStrategy identifier.
84     *
85     * @return the EventTypeStrategy identifier
86     */

87    public String JavaDoc getId() {
88       return "DatabaseEventTypeStrategy";
89    }
90 }
91
Popular Tags