com.davisor.data
Class LocaleType

java.lang.Object
  extended byjava.text.Format
      extended bycom.davisor.data.Type
          extended bycom.davisor.data.LocaleType
All Implemented Interfaces:
java.lang.Cloneable, java.util.Comparator, com.davisor.core.Dupable, java.io.Serializable
Direct Known Subclasses:
FormatType

public abstract class LocaleType
extends Type

LocaleType implements an abstract base class for locale-dependent types. All the changes that this class makes to the locale member variable go through the setLocale method.

In cases where locale is unspecified, all LocaleType sub-classes should always use DEFAULT_LOCALE (US locale) instead of system default locale. This brings important consistency over different runtime environments, where system own default locales are different.

Since:
JDK1.1
See Also:
DateType, TimestampType, Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.text.Format
java.text.Format.Field
 
Field Summary
static java.util.Locale DEFAULT_LOCALE
          Default locale (US).
protected  java.util.Locale M_locale
          Locale.
 
Fields inherited from class com.davisor.data.Type
METADATA_GROUP, METADATA_NAME, METADATA_PARENT, METADATA_SUBCHANNELS, TYPENAME
 
Constructor Summary
protected LocaleType(LocaleType lt)
          Deep copy constructor.
protected LocaleType(java.lang.String typeName, java.lang.String dataName, java.lang.String id, java.util.Map metaData, java.util.Locale locale)
          Creates a new locale type.
 
Method Summary
 boolean equals(java.lang.Object o)
          Tests if this object is equal with another object.
 java.lang.String getFormat()
          Gets a localization specification string.
 java.util.Locale getLocale()
          Gets the current locale.
 int hashCode()
          Returns a hash code value for the object.
 void setFormat(java.lang.String format)
          Sets the type specification.
 void setLocale(java.util.Locale locale)
          Sets the current locale.
 void setLocale(java.lang.String localeString)
          Sets the current locale by a locale string.
 
Methods inherited from class com.davisor.data.Type
ceil, check, check, compare, create, create, create, create, create, dup, dup, floor, format, getCompatibility, getDataName, getId, getID, getMetaData, getMetaData, getSpecs, getSQLCode, getSQLName, getSQLName, getTypeName, getValueClass, isNull, parseObject, register, register, setDataName, setId, setID, setMetaData, setMetaData, setSpecs, toData, toData, toData, toData, toString, toXML, xmlEnd, xmlStart, zero
 
Methods inherited from class java.text.Format
clone, format, formatToCharacterIterator, parseObject
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_LOCALE

public static final java.util.Locale DEFAULT_LOCALE
Default locale (US).


M_locale

protected java.util.Locale M_locale
Locale.

Constructor Detail

LocaleType

protected LocaleType(LocaleType lt)
Deep copy constructor.


LocaleType

protected LocaleType(java.lang.String typeName,
                     java.lang.String dataName,
                     java.lang.String id,
                     java.util.Map metaData,
                     java.util.Locale locale)
Creates a new locale type.

Parameters:
typeName - type name
dataName - data name
id - type identity
metaData - type meta data map (may be null)
locale - type locale (may be null)
Method Detail

equals

public boolean equals(java.lang.Object o)
Tests if this object is equal with another object.

Locale types are equal if their super-classes and locales are.

Specified by:
equals in interface java.util.Comparator
Overrides:
equals in class Type
See Also:
Compare.equals(Object,Object)

hashCode

public int hashCode()
Returns a hash code value for the object.

Overrides:
hashCode in class Type

getFormat

public java.lang.String getFormat()
Gets a localization specification string. The string is either a standard Java Locale object representation string, or a null string.

Overrides:
getFormat in class Type
Returns:
default, null specification string
See Also:
getLocale()

setFormat

public void setFormat(java.lang.String format)
Sets the type specification.

Overrides:
setFormat in class Type
Parameters:
format - type specification string (may be null)
See Also:
getFormat(), setLocale(String)

getLocale

public java.util.Locale getLocale()
Gets the current locale.

Returns:
current locale (may be null)
See Also:
setLocale(String), getFormat()

setLocale

public void setLocale(java.util.Locale locale)
Sets the current locale.

Parameters:
locale - new locale (may be null)
See Also:
getLocale(), setLocale(String), setFormat(java.lang.String)

setLocale

public void setLocale(java.lang.String localeString)
Sets the current locale by a locale string.

The locale is extracted from the given locale string, as described by the LocaleParser class. If the locale string cannot be interpreted as a locale, then the type locale is set to null.

Parameters:
localeString - locale string (may be null)
See Also:
getLocale(), setLocale(String), setFormat(java.lang.String), LocaleParser


Copyright © 2001-2004 Davisor Oy. All Rights Reserved.