Event.java.
- By Prashant Sarode
- June 24, 2001
Enterprise Java
Writing a Reusable Implementation of the MVC Design Pattern
by Prashant Sarode
Listing 2. Event.java.
package com.framework;
import org.apache.xerces.parsers.*;
import org.w3c.dom.*;
import com.framework.*;
public class Event{
private String debugMsg="Event--0";
private String id;
private String type;
private String functionalityClass;
private String errorView;
private String refererView;
private String responseView;
private EventParam[] eventParams;
public Event(Node event){
try {
//Set the properties of the Event Object.The Node is a
XML node which has event information from
BusinessEventMapping.xml
setEventProperties(event);
}catch (Exception e) {
debugMsg="Event--problem in Constructor---" +
e.getClass().getName();
}
}
public String getId() {
return id;
}
public String getType() {
return type;
}
public String getFunctionalityClass() {
return functionalityClass;
}
public String getResponseView() {
return responseView;
}
public String getErrorView() {
return errorView;
}
public EventParam[] getEventParams() {
return eventParams;
}
public EventParam getEventParam(String paramName) {
EventParam eventParam=null;
int k;
for (k=0; k <eventParams.length; k++) {
//The outer if is to take care of null array elements caused due to
//white space in the XML file.
if (eventParams[k] != null){
if (eventParams[k].getName().trim().equals(paramName)){
eventParam=eventParams[k];
break;
}
}
}
return eventParam;
}s
public String getDebugMsg() {
return debugMsg;
}
private void setEventProperties(Node event){
. . . . . .
}
}