001: /******************************************************************************
002: * JBoss, a division of Red Hat *
003: * Copyright 2007, Red Hat Middleware, LLC, and individual *
004: * contributors as indicated by the @authors tag. See the *
005: * copyright.txt in the distribution for a full listing of *
006: * individual contributors. *
007: * *
008: * This is free software; you can redistribute it and/or modify it *
009: * under the terms of the GNU Lesser General Public License as *
010: * published by the Free Software Foundation; either version 2.1 of *
011: * the License, or (at your option) any later version. *
012: * *
013: * This software is distributed in the hope that it will be useful, *
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of *
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
016: * Lesser General Public License for more details. *
017: * *
018: * You should have received a copy of the GNU Lesser General Public *
019: * License along with this software; if not, write to the Free *
020: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
021: * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
022: ******************************************************************************/package org.jboss.portal.wsrp.consumer;
023:
024: import org.jboss.portal.common.util.ParameterValidation;
025: import org.jboss.portal.wsrp.registration.RegistrationPropertyDescription;
026:
027: /**
028: * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
029: * @version $Revision: 8784 $
030: * @since 2.6
031: */
032: public class RegistrationProperty {
033: private Long persistentId;
034: private RegistrationPropertyDescription persistentDescription;
035: private Boolean persistentInvalid;
036: private String persistentLang;
037: private String persistentName;
038: private String persistentValue;
039:
040: private transient String status;
041: public static final String INEXISTENT_STATUS = "Inexistent on Producer";
042: public static final String MISSING_STATUS = "Missing";
043: public static final String MISSING_VALUE_STATUS = "Missing value";
044: public static final String UNCHECKED_VALUE_STATUS = "Undetermined status";
045: public static final String INVALID_VALUE_STATUS = "Invalid value";
046:
047: public RegistrationProperty() {
048: }
049:
050: public RegistrationProperty(String name, String stringValue,
051: String lang) {
052: ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(name,
053: "Name", "RegistrationProperty");
054: ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(lang,
055: "Lang", "RegistrationProperty");
056: this .persistentName = name;
057: this .persistentLang = lang;
058: setValue(stringValue);
059: }
060:
061: public boolean equals(Object o) {
062: if (this == o) {
063: return true;
064: }
065: if (o == null || getClass() != o.getClass()) {
066: return false;
067: }
068:
069: RegistrationProperty that = (RegistrationProperty) o;
070:
071: if (persistentId != null ? !persistentId
072: .equals(that.persistentId) : that.persistentId != null) {
073: return false;
074: }
075: if (!persistentName.equals(that.persistentName)) {
076: return false;
077: }
078: if (!persistentValue.equals(that.persistentValue)) {
079: return false;
080: }
081: if (persistentDescription != null ? !persistentDescription
082: .equals(that.persistentDescription)
083: : that.persistentDescription != null) {
084: return false;
085: }
086: if (persistentInvalid != null ? !persistentInvalid
087: .equals(that.persistentInvalid)
088: : that.persistentInvalid != null) {
089: return false;
090: }
091: if (!persistentLang.equals(that.persistentLang)) {
092: return false;
093: }
094: if (status != null ? !status.equals(that.status)
095: : that.status != null) {
096: return false;
097: }
098:
099: return true;
100: }
101:
102: public int hashCode() {
103: int result;
104: result = (persistentId != null ? persistentId.hashCode() : 0);
105: result = 31 * result + persistentName.hashCode();
106: result = 31 * result + persistentValue.hashCode();
107: result = 31
108: * result
109: + (persistentDescription != null ? persistentDescription
110: .hashCode()
111: : 0);
112: result = 31
113: * result
114: + (persistentInvalid != null ? persistentInvalid
115: .hashCode() : 0);
116: result = 31 * result + persistentLang.hashCode();
117: result = 31 * result + (status != null ? status.hashCode() : 0);
118: return result;
119: }
120:
121: public Long getKey() {
122: return persistentId;
123: }
124:
125: public void setKey(Long key) {
126: this .persistentId = key;
127: }
128:
129: public String getName() {
130: return persistentName;
131: }
132:
133: public void setName(String name) {
134: ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(name,
135: "Name", "RegistrationProperty");
136: this .persistentName = name;
137: }
138:
139: public String getValue() {
140: return persistentValue;
141: }
142:
143: public RegistrationPropertyDescription getDescription() {
144: return persistentDescription;
145: }
146:
147: public void setDescription(
148: RegistrationPropertyDescription description) {
149: this .persistentDescription = description;
150: }
151:
152: public Boolean isInvalid() {
153: return persistentInvalid;
154: }
155:
156: void setInvalid(Boolean invalid) {
157: this .persistentInvalid = invalid;
158: }
159:
160: public boolean isDeterminedInvalid() {
161: return persistentInvalid != null
162: && persistentInvalid.booleanValue();
163: }
164:
165: public void setInvalid(Boolean invalid, String status) {
166: this .persistentInvalid = invalid;
167: this .status = status;
168: }
169:
170: public void setValue(String stringValue) {
171: if ((persistentValue != null && !persistentValue
172: .equals(stringValue))
173: || (persistentValue == null && stringValue != null)) {
174: persistentValue = stringValue;
175: persistentInvalid = null;
176: if (persistentValue == null) {
177: status = MISSING_VALUE_STATUS;
178: } else {
179: status = UNCHECKED_VALUE_STATUS;
180: }
181: }
182: }
183:
184: public String getLang() {
185: return persistentLang;
186: }
187:
188: public void setLang(String lang) {
189: ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(lang,
190: "Lang", "RegistrationProperty");
191: this .persistentLang = lang;
192: }
193:
194: public String getStatus() {
195: return status;
196: }
197:
198: void setStatus(String status) {
199: this.status = status;
200: }
201: }
|