com.arsdigita.globalization
Class Locale

java.lang.Object
  extended bycom.arsdigita.domain.DomainObject
      extended bycom.arsdigita.globalization.Locale

public class Locale
extends DomainObject

Locale DomainObject implements a persistent Locale object.

Version:
$Revision: #11 $ $Date: 2004/04/07 $
Author:
Yon Feldman

Field Summary
static String BASE_DATA_OBJECT_TYPE
           
static String versionId
           
 
Constructor Summary
Locale()
           Constructor.
Locale(DataObject dataObject)
           Constructor.
Locale(OID oid)
           Constructor.
Locale(String language)
           Constructor.
Locale(String language, String country)
           Constructor.
Locale(String language, String country, String variant)
           Constructor.
 
Method Summary
protected  void afterDelete()
           
protected  void afterSave()
           
protected  void beforeSave()
           
 Locale fallback()
           Fallback to the more generic version of this locale.
static Locale fallback(Locale locale)
           Fallback to the more generic version of the locale.
static Locale fromJavaLocale(Locale locale)
           Retrieve a Locale DomainObject based on a java.util.Locale
static Locale fromJavaLocaleBestMatch(Locale locale)
           Retrieve the best matching Locale DomainObject based on a java.util.Locale
 String getBaseDataObjectType()
           Returns the appropriate object type for a Locale so that the proper type validation can take place when retrieving Locales by OID.
 String getCountry()
           Retrieve the country for this Locale.
 Charset getDefaultCharset()
           Retrieve the default character set for this Locale.
 BigDecimal getID()
           Return ID.
 String getLanguage()
           Retrieve the language for this Locale.
 String getVariant()
           Retrieve the variant for this Locale.
protected  void initialize()
          Called from all of the DomainObject constructors to initalize or validate the new domain object or its encapsulated data object.
static Locale retrieve(String language)
           Retrieve a Locale DomainObject.
static Locale retrieve(String language, String country)
           Retrieve a Locale DomainObject.
static Locale retrieve(String language, String country, String variant)
           Retrieve a Locale DomainObject.
 void setCountry(String country)
           Set the country for this Locale.
 void setDefaultCharset(Charset charset)
           Set the default character set for this Locale.
 void setLanguage(String language)
           Set the language for this Locale.
 void setVariant(String variant)
           Set the variant for this Locale.
 Locale toJavaLocale()
           Create an equivalent java.util.Locale
static Locale toJavaLocale(Locale locale)
           Create a java.util.Locale from a Locale DomainObject
 
Methods inherited from class com.arsdigita.domain.DomainObject
add, add, addToAssociation, beforeDelete, clear, delete, disconnect, equals, get, getObjectType, getOID, getSession, hashCode, isDeleted, isDisconnected, isModified, isNew, isPropertyModified, isValid, remove, remove, remove, removeFromAssociation, save, set, setAssociation, setAssociation, specializeDataObject, specializeDataObject, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values

BASE_DATA_OBJECT_TYPE

public static final String BASE_DATA_OBJECT_TYPE
See Also:
Constant Field Values
Constructor Detail

Locale

public Locale()

Constructor. Creates an instance for a new Locale.


Locale

public Locale(String language)

Constructor. Creates a persistent Locale DomainObject.

Parameters:
language - The language of the Locale to create.

Locale

public Locale(String language,
              String country)

Constructor. Creates a persistent Locale DomainObject.

Parameters:
language - The language of the Locale to create.
country - The country of the Locale to create.

Locale

public Locale(String language,
              String country,
              String variant)

Constructor. Creates a persistent Locale DomainObject.

Parameters:
language - The language of the Locale to create.
country - The country of the Locale to create.
variant - The variant of the Locale to create.

Locale

public Locale(OID oid)
       throws DataObjectNotFoundException

Constructor. Retrieves a persistent Locale DomainObject.

Parameters:
oid - Object ID of the Locale to retrieve.
Throws:
DataObjectNotFoundException - Thrown if we cannot retrieve a DataObject for the specified OID.

Locale

public Locale(DataObject dataObject)

Constructor. Retrieves a persistent Locale DomainObject.

Parameters:
dataObject - DataObject of the Locale to retrieve.
Method Detail

initialize

protected void initialize()
Description copied from class: DomainObject
Called from all of the DomainObject constructors to initalize or validate the new domain object or its encapsulated data object. This was introduced in order to support efficient validation of the encapsualted data object's type. If the validation is typically performed in class constructors, then redundant validation is performed in superclass constructors. This validation now occurs here.

Overrides:
initialize in class DomainObject

fallback

public Locale fallback()

Fallback to the more generic version of this locale. That is, if the current locale is "en_US_WIN" then this method returns "en_US", if called again on that locale it will return "en", and if called again it will return null.

Returns:
Locale DomainObject or null

fallback

public static Locale fallback(Locale locale)

Fallback to the more generic version of the locale. That is, if the passed in locale is "en_US_WIN" then this method returns "en_US", if called again on that locale it will return "en", and if called again it will return null.

Parameters:
locale - java.util.Locale
Returns:
Locale DomainObject or null

getBaseDataObjectType

public String getBaseDataObjectType()

Returns the appropriate object type for a Locale so that the proper type validation can take place when retrieving Locales by OID.

Overrides:
getBaseDataObjectType in class DomainObject
Returns:
String The fully qualified name of the base data object type for the Locale DataObject.

getID

public BigDecimal getID()

Return ID.

Returns:
BigDecimal The ID of this DataObject.

getLanguage

public String getLanguage()

Retrieve the language for this Locale.

Returns:
String ISO-639 language code.

setLanguage

public void setLanguage(String language)

Set the language for this Locale.

Parameters:
language - ISO-639 language code.

getCountry

public String getCountry()

Retrieve the country for this Locale.

Returns:
String ISO-3166 country code.

setCountry

public void setCountry(String country)

Set the country for this Locale.

Parameters:
country - ISO-3166 country code.

getVariant

public String getVariant()

Retrieve the variant for this Locale.

Returns:
String variant.

setVariant

public void setVariant(String variant)

Set the variant for this Locale.

Parameters:
variant - variant.

getDefaultCharset

public Charset getDefaultCharset()

Retrieve the default character set for this Locale.

Returns:
Charset DomainObject

setDefaultCharset

public void setDefaultCharset(Charset charset)

Set the default character set for this Locale.

Parameters:
charset - Charset DomainObject.

retrieve

public static Locale retrieve(String language)
                       throws DataObjectNotFoundException

Retrieve a Locale DomainObject.

Parameters:
language - The language of the Locale to retrieve.
Returns:
Locale DomainObject
Throws:
DataObjectNotFoundException

retrieve

public static Locale retrieve(String language,
                              String country)
                       throws DataObjectNotFoundException

Retrieve a Locale DomainObject.

Parameters:
language - The language of the Locale to retrieve.
country - The country of the Locale to retrieve.
Returns:
Locale DomainObject
Throws:
DataObjectNotFoundException

retrieve

public static Locale retrieve(String language,
                              String country,
                              String variant)
                       throws DataObjectNotFoundException

Retrieve a Locale DomainObject.

Parameters:
language - The language of the Locale to retrieve.
country - The country of the Locale to retrieve.
variant - The variant of the Locale to retrieve.
Returns:
Locale DomainObject
Throws:
DataObjectNotFoundException

fromJavaLocale

public static Locale fromJavaLocale(Locale locale)
                             throws GlobalizationException

Retrieve a Locale DomainObject based on a java.util.Locale

Returns:
Locale
Throws:
GlobalizationException

fromJavaLocaleBestMatch

public static Locale fromJavaLocaleBestMatch(Locale locale)

Retrieve the best matching Locale DomainObject based on a java.util.Locale

Returns:
Locale

toJavaLocale

public Locale toJavaLocale()

Create an equivalent java.util.Locale

Returns:
java.util.Locale

toJavaLocale

public static Locale toJavaLocale(Locale locale)

Create a java.util.Locale from a Locale DomainObject

Returns:
java.util.Locale

beforeSave

protected void beforeSave()
Overrides:
beforeSave in class DomainObject

afterSave

protected void afterSave()
Overrides:
afterSave in class DomainObject

afterDelete

protected void afterDelete()
Overrides:
afterDelete in class DomainObject


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 21 2004:2337 UTC