001: /*
002: * Copyright (c) 2002-2006 by OpenSymphony
003: * All rights reserved.
004: */
005: package com.opensymphony.xwork.config.entities;
006:
007: import java.util.Map;
008: import java.util.LinkedHashMap;
009: import java.io.Serializable;
010:
011: import com.opensymphony.xwork.util.location.Located;
012:
013: /**
014: * Configuration for Interceptors.
015: * <p/>
016: * In the xml configuration file this is defined as the <code>interceptors</code> tag.
017: *
018: * @author Mike
019: */
020: public class InterceptorConfig extends Located implements
021: Parameterizable, Serializable {
022:
023: private static final long serialVersionUID = 198028869049302691L;
024:
025: Map params;
026: String className;
027: String name;
028:
029: public InterceptorConfig() {
030: }
031:
032: public InterceptorConfig(String name, Class clazz, Map params) {
033: this .name = name;
034: this .className = clazz.getName();
035: this .params = params;
036: }
037:
038: public InterceptorConfig(String name, String className, Map params) {
039: this .name = name;
040: this .className = className;
041: this .params = params;
042: }
043:
044: public void setClassName(String className) {
045: this .className = className;
046: }
047:
048: public String getClassName() {
049: return className;
050: }
051:
052: public void setName(String name) {
053: this .name = name;
054: }
055:
056: public String getName() {
057: return name;
058: }
059:
060: public void setParams(Map params) {
061: this .params = params;
062: }
063:
064: public Map getParams() {
065: if (params == null) {
066: params = new LinkedHashMap();
067: }
068:
069: return params;
070: }
071:
072: public void addParam(String name, Object value) {
073: getParams().put(name, value);
074: }
075:
076: public boolean equals(Object o) {
077: if (this == o) {
078: return true;
079: }
080:
081: if (!(o instanceof InterceptorConfig)) {
082: return false;
083: }
084:
085: final InterceptorConfig interceptorConfig = (InterceptorConfig) o;
086:
087: if ((className != null) ? (!className
088: .equals(interceptorConfig.className))
089: : (interceptorConfig.className != null)) {
090: return false;
091: }
092:
093: if ((name != null) ? (!name.equals(interceptorConfig.name))
094: : (interceptorConfig.name != null)) {
095: return false;
096: }
097:
098: if ((params != null) ? (!params
099: .equals(interceptorConfig.params))
100: : (interceptorConfig.params != null)) {
101: return false;
102: }
103:
104: return true;
105: }
106:
107: public int hashCode() {
108: int result;
109: result = ((name != null) ? name.hashCode() : 0);
110: result = (29 * result)
111: + ((className != null) ? className.hashCode() : 0);
112: result = (29 * result)
113: + ((params != null) ? params.hashCode() : 0);
114:
115: return result;
116: }
117: }
|