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.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
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 }