001: /*
002: * Copyright (c) 2002-2006 by OpenSymphony
003: * All rights reserved.
004: */
005:
006: package com.opensymphony.xwork.config.entities;
007:
008: import java.util.Map;
009: import java.util.LinkedHashMap;
010: import java.io.Serializable;
011:
012: import com.opensymphony.xwork.util.location.Located;
013:
014: /**
015: * Configuration for exception mapping.
016: *
017: * @author Rainer Hermanns
018: * @author Matthew E. Porter (matthew dot porter at metissian dot com)
019: */
020: public class ExceptionMappingConfig extends Located implements
021: Serializable {
022:
023: private String name;
024: private String exceptionClassName;
025: private String result;
026: private Map params;
027:
028: public ExceptionMappingConfig() {
029: }
030:
031: public ExceptionMappingConfig(String name,
032: String exceptionClassName, String result) {
033: this (name, exceptionClassName, result, new LinkedHashMap());
034: }
035:
036: public ExceptionMappingConfig(String name,
037: String exceptionClassName, String result, Map params) {
038: this .name = name;
039: this .exceptionClassName = exceptionClassName;
040: this .result = result;
041: this .params = params;
042: }
043:
044: public String getName() {
045: return name;
046: }
047:
048: public void setName(String name) {
049: this .name = name;
050: }
051:
052: public String getExceptionClassName() {
053: return exceptionClassName;
054: }
055:
056: public void setExceptionClassName(String exceptionClassName) {
057: this .exceptionClassName = exceptionClassName;
058: }
059:
060: public String getResult() {
061: return result;
062: }
063:
064: public void setResult(String result) {
065: this .result = result;
066: }
067:
068: public Map getParams() {
069: if (params == null) {
070: params = new LinkedHashMap();
071: }
072:
073: return params;
074: }
075:
076: public void addParam(String name, Object value) {
077: getParams().put(name, value);
078: }
079:
080: public boolean equals(Object o) {
081: if (this == o) {
082: return true;
083: }
084:
085: if (!(o instanceof ExceptionMappingConfig)) {
086: return false;
087: }
088:
089: final ExceptionMappingConfig exceptionMappingConfig = (ExceptionMappingConfig) o;
090:
091: if ((name != null) ? (!name.equals(exceptionMappingConfig.name))
092: : (exceptionMappingConfig.name != null)) {
093: return false;
094: }
095:
096: if ((exceptionClassName != null) ? (!exceptionClassName
097: .equals(exceptionMappingConfig.exceptionClassName))
098: : (exceptionMappingConfig.exceptionClassName != null)) {
099: return false;
100: }
101:
102: if ((result != null) ? (!result
103: .equals(exceptionMappingConfig.result))
104: : (exceptionMappingConfig.result != null)) {
105: return false;
106: }
107:
108: if ((params != null) ? (!params
109: .equals(exceptionMappingConfig.params))
110: : (exceptionMappingConfig.params != null)) {
111: return false;
112: }
113:
114: return true;
115: }
116:
117: public int hashCode() {
118: int hashCode;
119: hashCode = ((name != null) ? name.hashCode() : 0);
120: hashCode = (29 * hashCode)
121: + ((exceptionClassName != null) ? exceptionClassName
122: .hashCode() : 0);
123: hashCode = (29 * hashCode)
124: + ((result != null) ? result.hashCode() : 0);
125: hashCode = (29 * hashCode)
126: + ((params != null) ? params.hashCode() : 0);
127:
128: return hashCode;
129: }
130:
131: }
|