1/*2 * Copyright 2001-2009 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 *16 */17package org.apache.juddi.v3.client.i18n;
1819import java.util.List;
2021import org.uddi.api_v3.Address;
22import org.uddi.api_v3.Description;
23import org.uddi.api_v3.Name;
24/** 25 * Returns the entity in the proper language. If no language is specified26 * or if no language is matched return the value of the first entity in the list.27 */28publicclassEntityForLang {
2930publicstaticName getName(List<Name> entityList, String lang) {
3132if (entityList.size()==0) {
33 Name name = newName();
34 name.setValue("");
35 name.setLang(lang);
36 entityList.add(name);
37 }
38if (lang==null) return entityList.get(0);
39for (Name entity : entityList) {
40if (lang.equalsIgnoreCase(entity.getLang())) {
41return entity;
42 }
43 }
44return entityList.get(0);
45 }
4647publicstaticAddress getAddress(List<Address> entityList, String lang) {
4849if (entityList.size()==0) {
50 Address address = newAddress();
51 address.setLang(lang);
52 entityList.add(address);
53 }
54if (lang==null) return entityList.get(0);
55for (Address entity : entityList) {
56if (lang.equalsIgnoreCase(entity.getLang())) {
57return entity;
58 }
59 }
60return entityList.get(0);
61 }
6263publicstaticDescription getDescription(List<Description> entityList, String lang) {
6465if (entityList.size()==0) {
66 Description description = newDescription();
67 description.setValue("");
68 description.setLang(lang);
69 entityList.add(description);
70 }
71if (lang==null) return entityList.get(0);
72for (Description entity : entityList) {
73if (lang.equalsIgnoreCase(entity.getLang())) {
74return entity;
75 }
76 }
77return entityList.get(0);
78 }
798081 }