1/*2 * Copyright 2001-2004 The Apache Software Foundation.3 *4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 *8 * http://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */1617package org.apache.ws.scout.registry.infomodel;
1819import java.util.Locale;
2021import javax.xml.registry.infomodel.LocalizedString;
2223/**24 * Implements JAXR Interface.25 * For futher details, look into the JAXR API Javadoc.26 *27 * @author Anil Saldhana <anil@apache.org>28 */29publicclassLocalizedStringImplimplements LocalizedString
30 {
31private String charsetName;
32private Locale locale;
33private String value;
3435publicLocalizedStringImpl()
36 {
37this.locale = Locale.getDefault();
38this.charsetName = LocalizedString.DEFAULT_CHARSET_NAME;
39 }
4041/**42 * Constuctor for a LocalizedString.43 *44 * @param locale the locale; must not be null45 * @param value the value; may be null46 * @param charsetName the charset; must not be null47 */48publicLocalizedStringImpl(Locale locale, String value, String charsetName)
49 {
50if (locale == null)
51 {
52thrownew IllegalArgumentException("locale cannot be null");
53 }
54if (charsetName == null)
55 {
56thrownew IllegalArgumentException("charsetName cannot be null");
57 }
58this.locale = locale;
59this.value = value;
60this.charsetName = charsetName;
61 }
6263public String getCharsetName()
64 {
65return charsetName;
66 }
6768public Locale getLocale()
69 {
70return locale;
71 }
7273public String getValue()
74 {
75return value;
76 }
7778publicvoid setCharsetName(String charsetName)
79 {
80if (charsetName == null)
81 {
82thrownew IllegalArgumentException("charsetName cannot be null");
83 }
84this.charsetName = charsetName;
85 }
8687publicvoid setLocale(Locale locale)
88 {
89if (locale == null)
90 {
91thrownew IllegalArgumentException("locale cannot be null");
92 }
93this.locale = locale;
94 }
9596publicvoid setValue(String value)
97 {
98this.value = value;
99 }
100101/**102 * There is a spec ambiguity here as it does not define how equals is determined for LocalizedString103 * but they are intended to be used in Collections.104 * We define it as locale, charsetName and value being equal.105 *106 * @param o the other object107 * @return true if they are equal108 */109publicboolean equals(Object o)
110 {
111if (this == o) returntrue;
112if (!(o instanceof LocalizedStringImpl)) return false;
113finalLocalizedStringImplapache/ws/scout/registry/infomodel/LocalizedStringImpl.html#LocalizedStringImpl">LocalizedStringImpl localizedString = (LocalizedStringImpl) o;
114if (!charsetName.equals(localizedString.charsetName)) return false;
115if (!locale.equals(localizedString.locale)) return false;
116if (value != null ? !value.equals(localizedString.value) : localizedString.value != null) return false;
117returntrue;
118 }
119120publicint hashCode()
121 {
122int result;
123 result = charsetName.hashCode();
124 result = 29 * result + locale.hashCode();
125 result = 29 * result + (value != null ? value.hashCode() : 0);
126return result;
127 }
128129public String toString()
130 {
131return value;
132 }
133 }