📄 actionconfig.java
字号:
* Prefix used to match request parameter names to form bean property
* names, if any.
*/
protected String prefix = null;
/**
* Retruns prefix used to match request parameter names to form bean property
* names, if any.
*/
public String getPrefix() {
return (this.prefix);
}
/**
* @param prefix Prefix used to match request parameter names to
* form bean property names, if any.
*/
public void setPrefix(String prefix) {
if (configured) {
throw new IllegalStateException("Configuration is frozen");
}
this.prefix = prefix;
}
/**
* Comma-delimited list of security role names allowed to request
* this Action.
*/
protected String roles = null;
public String getRoles() {
return (this.roles);
}
public void setRoles(String roles) {
if (configured) {
throw new IllegalStateException("Configuration is frozen");
}
this.roles = roles;
if (roles == null) {
roleNames = new String[0];
return;
}
ArrayList list = new ArrayList();
while (true) {
int comma = roles.indexOf(',');
if (comma < 0)
break;
list.add(roles.substring(0, comma).trim());
roles = roles.substring(comma + 1);
}
roles = roles.trim();
if (roles.length() > 0)
list.add(roles);
roleNames = (String[]) list.toArray(new String[list.size()]);
}
/**
* The set of security role names used to authorize access to this
* Action, as an array for faster access.
*/
protected String[] roleNames = new String[0];
/**
* Get array of security role names used to authorize access to this
* Action.
*/
public String[] getRoleNames() {
return (this.roleNames);
}
/**
* Identifier of the scope ("request" or "session") within which
* our form bean is accessed, if any.
*/
protected String scope = "session";
/**
* Get the scope ("request" or "session") within which
* our form bean is accessed, if any.
*/
public String getScope() {
return (this.scope);
}
/**
* @param scope scope ("request" or "session") within which
* our form bean is accessed, if any.
*/
public void setScope(String scope) {
if (configured) {
throw new IllegalStateException("Configuration is frozen");
}
this.scope = scope;
}
/**
* Suffix used to match request parameter names to form bean property
* names, if any.
*/
protected String suffix = null;
/**
* Return suffix used to match request parameter names to form bean property
* names, if any.
*/
public String getSuffix() {
return (this.suffix);
}
/**
* @param suffix Suffix used to match request parameter names to form bean property
* names, if any.
*/
public void setSuffix(String suffix) {
if (configured) {
throw new IllegalStateException("Configuration is frozen");
}
this.suffix = suffix;
}
/**
* Fully qualified Java class name of the <code>Action</code> class
* to be used to process requests for this mapping if the
* <code>forward</code> and <code>include</code> properties are not set.
* Exactly one of <code>forward</code>, <code>include</code>, or
* <code>type</code> must be specified.
*/
protected String type = null;
public String getType() {
return (this.type);
}
public void setType(String type) {
if (configured) {
throw new IllegalStateException("Configuration is frozen");
}
this.type = type;
}
/**
* Indicates Action be configured as the default one for this
* application, when true.
*/
protected boolean unknown = false;
/**
* Determine whether Action is configured as the default one for this
* application.
*/
public boolean getUnknown() {
return (this.unknown);
}
/**
* @param unknown Indicates Action is configured as the default one for this
* application, when true.
*/
public void setUnknown(boolean unknown) {
if (configured) {
throw new IllegalStateException("Configuration is frozen");
}
this.unknown = unknown;
}
/**
* Should the <code>validate()</code> method of the form bean associated
* with this action be called?
*/
protected boolean validate = true;
public boolean getValidate() {
return (this.validate);
}
public void setValidate(boolean validate) {
if (configured) {
throw new IllegalStateException("Configuration is frozen");
}
this.validate = validate;
}
// --------------------------------------------------------- Public Methods
/**
* Add a new <code>ExceptionConfig</code> instance to the set associated
* with this action.
*
* @param config The new configuration instance to be added
*
* @exception IllegalStateException if this module configuration
* has been frozen
*/
public void addExceptionConfig(ExceptionConfig config) {
if (configured) {
throw new IllegalStateException("Configuration is frozen");
}
exceptions.put(config.getType(), config);
}
/**
* Add a new <code>ForwardConfig</code> instance to the set of global
* forwards associated with this action.
*
* @param config The new configuration instance to be added
*
* @exception IllegalStateException if this module configuration
* has been frozen
*/
public void addForwardConfig(ForwardConfig config) {
if (configured) {
throw new IllegalStateException("Configuration is frozen");
}
forwards.put(config.getName(), config);
}
/**
* Return the exception configuration for the specified type, if any;
* otherwise return <code>null</code>.
*
* @param type Exception class name to find a configuration for
*/
public ExceptionConfig findExceptionConfig(String type) {
return ((ExceptionConfig) exceptions.get(type));
}
/**
* Return the exception configurations for this action. If there
* are none, a zero-length array is returned.
*/
public ExceptionConfig[] findExceptionConfigs() {
ExceptionConfig results[] = new ExceptionConfig[exceptions.size()];
return ((ExceptionConfig[]) exceptions.values().toArray(results));
}
/**
* Return the forward configuration for the specified key, if any;
* otherwise return <code>null</code>.
*
* @param name Name of the forward configuration to return
*/
public ForwardConfig findForwardConfig(String name) {
return ((ForwardConfig) forwards.get(name));
}
/**
* Return the form bean configurations for this application. If there
* are none, a zero-length array is returned.
*/
public ForwardConfig[] findForwardConfigs() {
ForwardConfig results[] = new ForwardConfig[forwards.size()];
return ((ForwardConfig[]) forwards.values().toArray(results));
}
/**
* Freeze the configuration of this action.
*/
public void freeze() {
configured = true;
ExceptionConfig[] econfigs = findExceptionConfigs();
for (int i = 0; i < econfigs.length; i++) {
econfigs[i].freeze();
}
ForwardConfig[] fconfigs = findForwardConfigs();
for (int i = 0; i < fconfigs.length; i++) {
fconfigs[i].freeze();
}
}
/**
* Remove the specified exception configuration instance.
*
* @param config ExceptionConfig instance to be removed
*
* @exception IllegalStateException if this module configuration
* has been frozen
*/
public void removeExceptionConfig(ExceptionConfig config) {
if (configured) {
throw new IllegalStateException("Configuration is frozen");
}
exceptions.remove(config.getType());
}
/**
* Remove the specified forward configuration instance.
*
* @param config ForwardConfig instance to be removed
*
* @exception IllegalStateException if this module configuration
* has been frozen
*/
public void removeForwardConfig(ForwardConfig config) {
if (configured) {
throw new IllegalStateException("Configuration is frozen");
}
forwards.remove(config.getName());
}
/**
* Return a String representation of this object.
*/
public String toString() {
StringBuffer sb = new StringBuffer("ActionConfig[");
sb.append("path=");
sb.append(path);
if (attribute != null) {
sb.append(",attribute=");
sb.append(attribute);
}
if (forward != null) {
sb.append(",forward=");
sb.append(forward);
}
if (include != null) {
sb.append(",include=");
sb.append(include);
}
if (input != null) {
sb.append(",input=");
sb.append(input);
}
if (multipartClass != null) {
sb.append(",multipartClass=");
sb.append(multipartClass);
}
if (name != null) {
sb.append(",name=");
sb.append(name);
}
if (parameter != null) {
sb.append(",parameter=");
sb.append(parameter);
}
if (prefix != null) {
sb.append(",prefix=");
sb.append(prefix);
}
if (roles != null) {
sb.append(",roles=");
sb.append(roles);
}
if (scope != null) {
sb.append(",scope=");
sb.append(scope);
}
if (suffix != null) {
sb.append(",suffix=");
sb.append(suffix);
}
if (type != null) {
sb.append(",type=");
sb.append(type);
}
return (sb.toString());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -