From 87b2b995fa883ba014a36641c1a2513760792510 Mon Sep 17 00:00:00 2001 From: quasi Date: Mon, 11 May 2009 11:11:12 +0000 Subject: [PATCH] =?UTF-8?q?BaseAddress:=20Hoffentlich=20alle=20ben=C3=B6ti?= =?UTF-8?q?gten=20Felder=20und=20Methoden=20vorhanden=20Z.Z.=20kein=20Auth?= =?UTF-8?q?oringkit.=20Da=20dieser=20Contenttyp=20nicht=20direkt=20verwend?= =?UTF-8?q?et=20werden=20soll,=20sondern=20als=20Basis=20f=C3=BCr=20weiter?= =?UTF-8?q?e=20Contenttypen=20dienen=20soll,=20w=C3=A4re=20wohl=20ein=20AK?= =?UTF-8?q?=20=20n=C3=B6tig,=20da=C3=9F=20man=20von=20den=20anderen=20verw?= =?UTF-8?q?enden=20und=20erweitern=20kann.=20Ich=20wei=C3=9F=20aber=20ncoh?= =?UTF-8?q?=20nicht,=20wie=20das=20geschehen=20soll.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.libreccm.org/ccm/trunk@162 8810af33-2d31-482b-a856-94f89814c4df --- .../cms/contenttypes/BaseAddress.java | 79 +++++++++++++------ 1 file changed, 56 insertions(+), 23 deletions(-) diff --git a/ccm-cms-types-baseAddress/src/com/arsdigita/cms/contenttypes/BaseAddress.java b/ccm-cms-types-baseAddress/src/com/arsdigita/cms/contenttypes/BaseAddress.java index ea7505714..e3e03e12e 100755 --- a/ccm-cms-types-baseAddress/src/com/arsdigita/cms/contenttypes/BaseAddress.java +++ b/ccm-cms-types-baseAddress/src/com/arsdigita/cms/contenttypes/BaseAddress.java @@ -19,6 +19,7 @@ package com.arsdigita.cms.contenttypes; +import com.arsdigita.globalization.LocaleNegotiator; import com.arsdigita.cms.ContentType; import com.arsdigita.cms.ContentItem; import com.arsdigita.domain.DataObjectNotFoundException; @@ -26,6 +27,9 @@ import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.OID; import com.arsdigita.util.Assert; import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Locale; /** *

DomainObject class to represent address ContentType @@ -34,11 +38,10 @@ import java.math.BigDecimal; * This content type represents a generic address which is not country specific. * It provides methods for creating new address objects, retrieving existing * objects from the persistent storage and retrieving and setting is properties.

- *

This class extends {@link com.arsdigita.cms.ContentPage content page} and + *

This class extends {@link com.arsdigita.cms.ContentItem content item} and * adds extended attributes specific for an not country specific address:

* - * @author Dominik Kacprzak - * @version $Revision: #6 $ $Date: 2004/08/17 $ + * @author Sören Bernstein **/ public class BaseAddress extends ContentItem { @@ -131,44 +134,74 @@ public class BaseAddress extends ContentItem { } /* accessors *****************************************************/ - public String getAddress( ) { - return ( String ) get( ADDRESS ); + public String getAddress() { + return (String) get(ADDRESS); } - public void setAddress( String address ) { - set( ADDRESS, address ); + public void setAddress(String address) { + set(ADDRESS, address); } - public String getIsoCountryCode( ) { - return ( String ) get( ISO_COUNTRY_CODE ); + public String getIsoCountryCode() { + return (String) get(ISO_COUNTRY_CODE); } - public void setIsoCountryCode( String isoCountryCode ) { - set( ISO_COUNTRY_CODE, isoCountryCode ); + public void setIsoCountryCode(String isoCountryCode) { + set(ISO_COUNTRY_CODE, isoCountryCode); } - public String getPostalCode( ) { - return ( String ) get( POSTAL_CODE ); + public String getPostalCode() { + return (String) get(POSTAL_CODE); } - public void setPostalCode( String postalCode ) { - set( POSTAL_CODE, postalCode ); + public void setPostalCode(String postalCode) { + set(POSTAL_CODE, postalCode); } - public String getCity( ) { - return ( String ) get( CITY ); + public String getCity() { + return (String) get(CITY); } - public void setCity( String city ) { - set( CITY, city ); + public void setCity(String city) { + set(CITY, city); } - public String getState( ) { - return ( String ) get( STATE ); + public String getState() { + return (String) get(STATE); } - public void setState( String state ) { - set( STATE, state ); + public void setState(String state) { + set(STATE, state); } + // Convert the iso country code to country names using the current locale + public String getCountryNameFromIsoCode(String isoCountryCode) { + + LocaleNegotiator negotiatedLocale = new LocaleNegotiator("", "", "", null); + + java.util.Locale locale = new java.util.Locale("", isoCountryCode); + + return locale.getDisplayCountry(negotiatedLocale.getLocale()); + + } + + // Get a sorted list auf all countries + public ArrayList getSortedListOfCountries(Locale inLang) { + + Locale[] locales = Locale.getAvailableLocales(); + ArrayList countryNames = new ArrayList(); + + for(Locale locale : locales) { + + if(locale.getDisplayCountry(inLang) != null) { + + countryNames.add(locale.getDisplayCountry(inLang)); + + } + } + + Collections.sort(countryNames); + + return countryNames; + } }