View Javadoc

1   /*
2    * $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/config/EventInfo.java,v 1.10 2006/01/25 20:05:32 hkollmann Exp $
3    * $Revision: 1.10 $
4    * $Date: 2006/01/25 20:05:32 $
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.config;
25  
26  import org.apache.commons.logging.Log;
27  import org.apache.commons.logging.LogFactory;
28  
29  import org.dbforms.util.Util;
30  
31  import java.io.Serializable;
32  import java.util.Properties;
33  
34  
35  
36  /***
37   * Event information class
38   *
39   * @author Luca Fossato
40   *
41   */
42  public class EventInfo implements Serializable{
43     /*** logging category */
44     private static Log        logCat     = LogFactory.getLog(EventInfo.class.getName());
45     private Properties properties = null;
46     private String     className  = null;
47     private String     id         = null;
48     private String     type       = null;
49  
50     /***
51      * Default constructor.
52      */
53     public EventInfo() {
54        properties = new Properties();
55     }
56  
57  
58     /***
59      * Constructor.
60      *
61      * @param type the event type
62      * @param className the full qualified bname of the event class
63      */
64     public EventInfo(String type,
65                      String className) {
66        this();
67        this.type      = type;
68        this.className = className;
69     }
70  
71     /***
72      * Sets the className attribute of the EventInfo object
73      *
74      * @param className The new className value
75      */
76     public void setClassName(String className) {
77        this.className = className;
78     }
79  
80  
81     /***
82      * Gets the className attribute of the EventInfo object
83      *
84      * @return The className value
85      */
86     public String getClassName() {
87        return className;
88     }
89  
90  
91     /***
92      * Sets the id attribute of the EventInfo object
93      *
94      * @param id The new id value
95      */
96     public void setId(String id) {
97        this.id = id;
98     }
99  
100 
101    /***
102     * Gets the id attribute of the EventInfo object
103     *
104     * @return The id value
105     */
106    public String getId() {
107       //return id;
108       return (!Util.isNull(id)) ? id
109                                 : type;
110    }
111 
112 
113    /***
114     * Gets the properties attribute of the EventInfo object
115     *
116     * @return The properties value
117     */
118    public Properties getProperties() {
119       return properties;
120    }
121 
122 
123    /***
124     * Sets the type attribute of the EventInfo object
125     *
126     * @param type The new type value
127     */
128    public void setType(String type) {
129       this.type = type;
130    }
131 
132 
133    /***
134     * Gets the type attribute of the EventInfo object
135     *
136     * @return The type value
137     */
138    public String getType() {
139       return type;
140    }
141 
142 
143    /***
144     * Adds a new property to this EventInfo object.
145     *
146     * @param property The feature to be added to the Property attribute
147     */
148    public void addProperty(String name, String value) {
149       properties.put(name, value);
150       logCat.info("::addProperty - added the property [" + name + ", " + value
151                   + "] to event [" + getId() + "]");
152    }
153 
154 
155    /***
156     * Return the String representation of this object.
157     *
158     * @return the String representation of this object
159     */
160    public String toString() {
161       return new StringBuffer("event: id = ").append(getId())
162                                              .append("; type = ")
163                                              .append(type)
164                                              .append("; className = ")
165                                              .append(className)
166                                              .toString();
167    }
168 }