1 /* 2 * Copyright [2005] [University Corporation for Advanced Internet Development, Inc.] 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 at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * 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 and 14 * limitations under the License. 15 */ 16 17 package org.opensaml.saml2.metadata; 18 19 /** 20 * Localized String with the language associated with it. 21 */ 22 public class LocalizedString { 23 24 /** Localized string. */ 25 private String localizedString; 26 27 /** Language of the localized string. */ 28 private String language; 29 30 /** Constructor. */ 31 public LocalizedString() { 32 33 } 34 35 /** 36 * Constructor. 37 * 38 * @param localString the localized string 39 * @param language the language of the string 40 */ 41 public LocalizedString(String localString, String language) { 42 localizedString = localString; 43 this.language = language; 44 } 45 46 /** 47 * Gets the localized string. 48 * 49 * @return the localized string 50 */ 51 public String getLocalString() { 52 return localizedString; 53 } 54 55 /** 56 * Sets the localized string. 57 * 58 * @param newString the localized string 59 */ 60 public void setLocalizedString(String newString) { 61 localizedString = newString; 62 } 63 64 /** 65 * Gets the language of the string. 66 * 67 * @return the language of the string 68 */ 69 public String getLanguage() { 70 return language; 71 } 72 73 /** 74 * Sets the language of the string. 75 * 76 * @param newLanguage the language of the string 77 */ 78 public void setLanguage(String newLanguage) { 79 language = newLanguage; 80 } 81 82 /** 83 * {@inheritDoc} 84 */ 85 public int hashCode() { 86 int hash = 1; 87 hash = hash * 31 + language.hashCode(); 88 hash = hash * 31 + localizedString.hashCode(); 89 return hash; 90 } 91 92 /** 93 * Determines if two LocalizedStrings are equal, that is, if both thier localized string and language have 94 * case-sentivite equality. 95 * 96 * @param obj the object this object is compared with 97 * 98 * @return true if the objects are equal, false if not 99 */ 100 public boolean equals(Object obj) { 101 if (obj == this) { 102 return true; 103 } 104 105 if (obj instanceof LocalizedString) { 106 LocalizedString otherLString = (LocalizedString) obj; 107 return localizedString.equals(otherLString.getLocalString()) && language.equals(otherLString.getLanguage()); 108 } 109 110 return false; 111 } 112 }