| URLMapping.java |
/*
* @author : Umesh Kulkarni
* @version 1.0
*
* Development Environment : Oracle9i JDeveloper
* Name of the File : URLMapping.java
* Creation / Modification History
* Umesh 26-Apr-2002 Created
*
*/
package oracle.otnsamples.ibfbs.control;
/**
* In a typical web application, there exists various events in the form of
* button clicks, combo box selections, URL Clicks etc.
*
* In response to these events, application executes the functionality embedded in
* some business methods in some classes. This Class helps to capture the relationship
* between the Event Name, Class Name, Method to be invoked, JSP Page to be used to
* display the results and the various Roles which can access this method.
*
* @version 1.0
* @since 1.0
*/
public class URLMapping implements java.io.Serializable {
// Declare Instance Variables
private String eventName; // Name of the Event
private String className; // Model Class Name
private String methodName; // Business Method to be invoked when this event happens
private String nextScreen; // Next Screen Page which will be used to show the results
private String[] roles; // Various Roles which can access this method
/**
* Empty Constructor of this Class
*
* @since 1.0
*/
public URLMapping() {}
/**
* Constructor with appropriate parameters.
* @param eventName Name of the Event.
* @param className Name of the Class which need to be invoked when this event
* happens.
* @param methodName Name of the method which need to be invoked when this event
* happens.
* @param nextScreen Name of the JSP Page which will act as a View or which will
* represent the data.
* @param roles Set of Roles which can access these methods.
* @since 1.0
*/
public URLMapping(String eventName, String className, String methodName,
String nextScreen, String[] roles) {
this.eventName = eventName;
this.className = className;
this.methodName = methodName;
this.nextScreen = nextScreen;
this.roles = roles;
}
/**
* Method to retrieve the Event Name
* @return Desired Event Name
* @since 1.0
*/
public String getEventName() {
return eventName;
}
/**
* Method to retrieve the Class Name associated with the event
* @return Desired Class Name
* @since 1.0
*/
public String getClassName() {
return className;
}
/**
* Method to retrieve the Method Name associated with the event
* @return Desired Method Name
* @since 1.0
*/
public String getMethodName() {
return methodName;
}
/**
* Method to retrieve the Next Screen associated with the event
* @return Desired Next Screen Name
* @since 1.0
*/
public String getNextScreen() {
return nextScreen;
}
/**
* Method to retrieve all the valid roles associated with the event
* @return Desired List of all roles
* @since 1.0
*/
public String[] getRoles() {
return roles;
}
/**
* Method to set the Event Name
* @param eventName Name of the Event
* @since 1.0
*/
public void setEventName(String eventName) {
this.eventName = eventName;
}
/**
* Method to set the Class Name associated with the event
* @param className Name of the Class
* @since 1.0
*/
public void setClassName(String className) {
this.className = className;
}
/**
* Method to set the Method Name associated with the event
* @param methodName Name of the method
* @since 1.0
*/
public void setMethodName(String methodName) {
this.methodName = methodName;
}
/**
* Method to set the Next Screen associated with the event
* @param nextScreen Next Screen value
* @since 1.0
*/
public void setNextScreen(String nextScreen) {
this.nextScreen = nextScreen;
}
/**
* Method to set all the valid roles associated with the event
* @param roles Valid Roles who can invoke this operation
* @since 1.0
*/
public void setRoles(String[] roles) {
this.roles = roles;
}
/**
* Method to check whether the provided role is a Valid Role for this operation.
* This method checks whether the provided role is present in the given set of
* roles. Then it returns appropriate boolean flag back to the calling method.
*
* @param role Input Role which need to be checked whether it is valid
* @return Boolean Flag indicating whether the role is valid or not
* @since 1.0
*/
public boolean isValidRole(String role) {
boolean validRole = false;
// Loop through all the roles and check whether the role exists in
// given list of roles.
for (int ctr = 0; ctr < roles.length; ctr++) {
if (roles[ctr].equals(role)) {
validRole = true;
break;
}
}
return validRole;
}
/**
* Method returning String representation this Class. This method overrides the
* toString() method in java.lang.Object
* @return String representation of this Class.
* @since 1.0
*/
public String toString() {
return (eventName + " " + className + " " + methodName + " " + nextScreen
+ " " + roles);
}
}