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 Result.
015: * <p/>
016: * In the xml configuration file this is defined as the <code>result</code> tag.
017: *
018: * @author Mike
019: * @author tm_jee
020: *
021: * @version $Date: 2006-07-22 16:30:28 +0200 (Sa, 22 Jul 2006) $ $Id: ResultConfig.java 1083 2006-07-22 14:30:28Z tm_jee $
022: */
023: public class ResultConfig extends Located implements Parameterizable,
024: Serializable {
025:
026: private static final long serialVersionUID = 2840978123123791897L;
027:
028: private Map params;
029: private String className;
030: private String name;
031:
032: public ResultConfig() {
033: params = new LinkedHashMap();
034: }
035:
036: public ResultConfig(String name, String clazz) {
037: this (name, clazz, new LinkedHashMap());
038: }
039:
040: public ResultConfig(String name, String clazz, Map params) {
041: this .name = name;
042: this .className = clazz;
043: this .params = params;
044: }
045:
046: public void setClassName(String className) {
047: this .className = className;
048: }
049:
050: public String getClassName() {
051: return className;
052: }
053:
054: public void setName(String name) {
055: this .name = name;
056: }
057:
058: public String getName() {
059: return name;
060: }
061:
062: public void setParams(Map params) {
063: this .params = params;
064: }
065:
066: public Map getParams() {
067: if (params == null) {
068: params = new LinkedHashMap();
069: }
070:
071: return params;
072: }
073:
074: public void addParam(String name, Object value) {
075: getParams().put(name, value);
076: }
077:
078: public boolean equals(Object o) {
079: if (this == o) {
080: return true;
081: }
082:
083: if (!(o instanceof ResultConfig)) {
084: return false;
085: }
086:
087: final ResultConfig resultConfig = (ResultConfig) o;
088:
089: if ((className != null) ? (!className
090: .equals(resultConfig.className))
091: : (resultConfig.className != null)) {
092: return false;
093: }
094:
095: if ((name != null) ? (!name.equals(resultConfig.name))
096: : (resultConfig.name != null)) {
097: return false;
098: }
099:
100: if ((params != null) ? (!params.equals(resultConfig.params))
101: : (resultConfig.params != null)) {
102: return false;
103: }
104:
105: return true;
106: }
107:
108: public int hashCode() {
109: int result;
110: result = ((name != null) ? name.hashCode() : 0);
111: result = (29 * result)
112: + ((className != null) ? className.hashCode() : 0);
113: result = (29 * result)
114: + ((params != null) ? params.hashCode() : 0);
115:
116: return result;
117: }
118: }
|