001: /******************************************************************************
002: * JBoss, a division of Red Hat *
003: * Copyright 2006, 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.registration;
023:
024: import org.jboss.portal.common.util.ParameterValidation;
025:
026: import java.util.Locale;
027:
028: /**
029: * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
030: * @version $Revision:5865 $
031: * @since 2.6
032: */
033: public class LocalizedString {
034: private String value;
035: private Locale locale;
036: private String resourceName;
037:
038: public LocalizedString(String value, Locale locale) {
039: setValue(value);
040: this .locale = locale;
041: }
042:
043: public LocalizedString(String value) {
044: this (value, Locale.getDefault());
045: }
046:
047: public LocalizedString() {
048: }
049:
050: public LocalizedString(LocalizedString other) {
051: ParameterValidation.throwIllegalArgExceptionIfNull(other,
052: "LocalizedString");
053: this .value = other.value;
054: this .locale = other.locale;
055: this .resourceName = other.resourceName;
056: }
057:
058: public String toString() {
059: return "LocalizedString{" + "value='" + value + '\''
060: + ", locale=" + locale + ", resourceName='"
061: + resourceName + '\'' + '}';
062: }
063:
064: public boolean equals(Object o) {
065: if (this == o) {
066: return true;
067: }
068: if (o == null || getClass() != o.getClass()) {
069: return false;
070: }
071:
072: LocalizedString that = (LocalizedString) o;
073:
074: if (!locale.equals(that.locale)) {
075: return false;
076: }
077: if (resourceName != null ? !resourceName
078: .equals(that.resourceName) : that.resourceName != null) {
079: return false;
080: }
081: if (value != null ? !value.equals(that.value)
082: : that.value != null) {
083: return false;
084: }
085:
086: return true;
087: }
088:
089: public int hashCode() {
090: int result;
091: result = (value != null ? value.hashCode() : 0);
092: result = 31 * result + locale.hashCode();
093: result = 31 * result
094: + (resourceName != null ? resourceName.hashCode() : 0);
095: return result;
096: }
097:
098: public String getValue() {
099: return value;
100: }
101:
102: public void setValue(String value) {
103: ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(
104: value, "value", "LocalizedString");
105: this .value = value;
106: }
107:
108: public Locale getLocale() {
109: return locale;
110: }
111:
112: public void setLocale(Locale locale) {
113: ParameterValidation.throwIllegalArgExceptionIfNull(locale,
114: "locale");
115: this .locale = locale;
116: }
117:
118: public String getResourceName() {
119: return resourceName;
120: }
121:
122: public void setResourceName(String resourceName) {
123: this.resourceName = resourceName;
124: }
125: }
|