blackboard.platform.intl
Class BbLocale

java.lang.Object
  extended by blackboard.data.BbObject
      extended by blackboard.platform.intl.BbLocale
All Implemented Interfaces:
Available, IBbObject, Identifiable, java.lang.Cloneable

public class BbLocale
extends BbObject
implements Available

This class represents a particular application locale setting. It provides methods to format data (date, times, names, etc.) according to the preferences configured for the locale. Using getLocaleObject() it can also be used with any Java objects/methods which require a Locale object.

Since:
Bb 6.0
Version:
$Revision: #1 $ $Date: 2007/06/27 $

Nested Class Summary
static class BbLocale.Date
          Date
static class BbLocale.Name
          Name
static class BbLocale.Time
          Time
 
Field Summary
static DataType DATA_TYPE
          Object data type constant used in brokering loaders and persisters
static java.lang.String RESOURCE_BUNDLE
          Resource bundle for this data object
 
Fields inherited from class blackboard.data.BbObject
_bbAttributes
 
Constructor Summary
BbLocale()
          Creates an instance of Course with default property values.
 
Method Summary
 java.lang.String formatCurrency(double currency)
          Formats a double as a currency value according to the current locale and returns it as a String.
 java.lang.String formatDate(java.util.Date date)
          Formats a date (not including time portion) according to the current locale and the default date style and returns it as a string.
 java.lang.String formatDate(java.util.Date date, BbLocale.Date dateStyle)
          Formats a date (not including time portion) according to the current locale and given date style and returns it as a string.
 java.lang.String formatDateTime(java.util.Date dateTime)
          Formats a date/time according to the current locale and the default date and time styles and returns it as a string.
 java.lang.String formatDateTime(java.util.Date dateTime, BbLocale.Date dateStyle, BbLocale.Time timeStyle)
          Formats a date/time according to the current locale and the given date and time styles and returns it as a string.
 java.lang.String formatDuration(long duration)
          Format a time duration (in milliseconds) as a string, broken down by days, hours, minutes, seconds and milliseconds.
 java.lang.String formatName(java.lang.String strGivenName, java.lang.String strMiddleName, java.lang.String strFamilyName, java.lang.String strTitle, BbLocale.Name nameStyle)
          Formats a name according to the current locale and given BbLocale.Name style and returns it as a string.
 java.lang.String formatName(User user, BbLocale.Name nameStyle)
          Formats the name of the given user according to the current locale and given BbLocale.Name style and returns it as a string.
 java.lang.String formatNumber(double num)
          Formats a number according to the current locale and returns it as a String.
 java.lang.String formatPercent(double percent)
          Formats a double as a percentage according to the current locale and returns it as a String.
 java.lang.String formatTime(java.util.Date time)
          Formats the time portion of a date according to the current locale and the default time style and returns it as a string.
 java.lang.String formatTime(java.util.Date time, BbLocale.Time timeStyle)
          Formats the time portion of a date according to the current locale and given time style and returns it as a string.
 java.lang.String getAlias()
          Returns the locale alias string for this locale object.
 java.lang.String getBbVersion()
          Returns the Bb Version for this locale object
 DataType getDataType()
          Returns the DataType identifier for this object.
 boolean getIsAvailable()
          Returns the availability flag for this BbLocale.
 boolean getIsCourseEnabled()
          Returns the availability flag for this BbLocale in a course context.
 boolean getIsDefault()
          Returns the is_default flag for this BbLocale.
 java.lang.Boolean getIsEditable()
          getIsEditable
 boolean getIsLeftToRight()
          Returns the is_left_to_right flag for this BbLocale.
 boolean getIsOrganizationEnabled()
          Returns the availability flag for this BbLocale in a organization context.
 boolean getIsUserEnabled()
          Returns the availability flag for this BbLocale in a user context.
 java.lang.String getLocale()
          Returns the locale name string for this locale object.
 java.util.Locale getLocaleObject()
          Returns a Java Locale object that represents the same language and country settings of this locale.
 java.lang.String getLongNameFormat()
          Returns the long name string for this locale object.
 java.lang.String getName()
          Returns the name string for this locale object.
 java.text.NumberFormat getNumberFormat()
          Returns a cloned instance of the current locale-specific NumberFormat.
 java.text.NumberFormat getPercentFormat()
          Returns a cloned instance of the current locale-specific percentage formatter.
 java.lang.String getPersistentAlias()
          Returns the persistent locale alias string for this locale object.
 java.lang.String getPersistentName()
          Returns the persistent name string for this locale object.
 java.lang.String getShortNameFormat()
          Returns the short name string for this locale object.
 java.lang.String getVendorDescription()
          Returns the vendor's description.
 java.lang.String getVendorId()
          Returns the vendor id associated with the plug-in.
 java.lang.String getVendorName()
          Returns the user-friendly name of the locale vendor.
 java.lang.String getVendorURL()
          Returns the URL for the vendor supplying the system extension.
 Version getVersion()
          Returns the version of this locale
 double parseNumber(java.lang.String str)
          Accepts a string representation for a number and parses according to the current locale.
 float parseNumberAsFloat(java.lang.String str)
          Accepts a string representation for a number and parses according to the current locale.
 void setAlias(java.lang.String strAlias)
          Sets the locale alias string for this locale object.
 void setBbVersion(java.lang.String strBbVersion)
          Sets the BbVersion string for this locale object
 void setIsAvailable(boolean bIsAvailable)
          Sets the availability flag for this BbLocale.
 void setIsCourseEnabled(boolean bIsAvailable)
          Sets the availability flag for this BbLocale in a course context.
 void setIsDefault(boolean bIsDefault)
          Sets the is_default flag for this BbLocale.
 void setIsEditable(boolean b)
          setIsEditable
 void setIsLeftToRight(boolean bIsLeftToRight)
          Sets the is_left_to_right flag for this BbLocale.
 void setIsOrganizationEnabled(boolean bIsAvailable)
          Sets the availability flag for this BbLocale in a organization context.
 void setIsUserEnabled(boolean bIsAvailable)
          Sets the availability flag for this BbLocale in a user context.
 void setLocale(java.lang.String strLocaleName)
          Sets the locale name string for this locale object.
 void setLongNameFormat(java.lang.String strName)
          Sets the long name string for this locale object.
 void setName(java.lang.String strName)
          Sets the name string for this locale object.
 void setShortNameFormat(java.lang.String strName)
          Sets the short name string for this locale object.
 void setVendorDescription(java.lang.String dscr)
          Sets the vendor description
 void setVendorId(java.lang.String vid)
          Sets the vendor id associated with this locale.
 void setVendorName(java.lang.String vendorName)
          Sets the user-friendly vendor name.
 void setVendorURL(java.lang.String url)
          Used during installation to set the extension vendor's URL.
 void setVersion(Version v)
          Sets the version for this locale.
 
Methods inherited from class blackboard.data.BbObject
clone, getBbAttributes, getCreatedDate, getId, getModifiedDate, persist, setCreatedDate, setId, setModifiedDate, toString, validate
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DATA_TYPE

public static final DataType DATA_TYPE
Object data type constant used in brokering loaders and persisters


RESOURCE_BUNDLE

public static final java.lang.String RESOURCE_BUNDLE
Resource bundle for this data object

See Also:
Constant Field Values
Constructor Detail

BbLocale

public BbLocale()
Creates an instance of Course with default property values.

Method Detail

getDataType

public DataType getDataType()
Returns the DataType identifier for this object. Can be used to uniquely identify the "type" of this data object.

Specified by:
getDataType in interface IBbObject
Specified by:
getDataType in interface Identifiable
Specified by:
getDataType in class BbObject
Returns:
the DataType for this object

getLocaleObject

public java.util.Locale getLocaleObject()
Returns a Java Locale object that represents the same language and country settings of this locale.

Returns:
a Java Locale representing the same language and country settings of this locale.

getPersistentName

public java.lang.String getPersistentName()
Returns the persistent name string for this locale object.

Returns:
a locale name String

getName

public java.lang.String getName()
Returns the name string for this locale object.

Returns:
a locale name String

setName

public void setName(java.lang.String strName)
Sets the name string for this locale object.


getBbVersion

public java.lang.String getBbVersion()
Returns the Bb Version for this locale object

Returns:
a version string (@link String) String

setBbVersion

public void setBbVersion(java.lang.String strBbVersion)
Sets the BbVersion string for this locale object

Parameters:
strBbVersion - void

getShortNameFormat

public java.lang.String getShortNameFormat()
Returns the short name string for this locale object.

Returns:
a locale name String

setShortNameFormat

public void setShortNameFormat(java.lang.String strName)
Sets the short name string for this locale object.


getLongNameFormat

public java.lang.String getLongNameFormat()
Returns the long name string for this locale object.

Returns:
a locale name String

setLongNameFormat

public void setLongNameFormat(java.lang.String strName)
Sets the long name string for this locale object.


getLocale

public java.lang.String getLocale()
Returns the locale name string for this locale object. The locale string matches the language_Country used to create this locale.

Returns:
a locale String of the form language_Country (i.e., "en_US")

setLocale

public void setLocale(java.lang.String strLocaleName)
Sets the locale name string for this locale object. The locale string matches the language_Country used to create this locale. Also constructs a locale object given a locale string encapsulating both language and country.


getPersistentAlias

public java.lang.String getPersistentAlias()
Returns the persistent locale alias string for this locale object.

Returns:
a locale alias String

getAlias

public java.lang.String getAlias()
Returns the locale alias string for this locale object.

Returns:
a locale alias String

setAlias

public void setAlias(java.lang.String strAlias)
Sets the locale alias string for this locale object.


getIsAvailable

public boolean getIsAvailable()
Returns the availability flag for this BbLocale. If a locale is marked as not available, no one can access it.

Specified by:
getIsAvailable in interface Available
Returns:
a boolean denoted whether this BbLocale is available

setIsAvailable

public void setIsAvailable(boolean bIsAvailable)
Sets the availability flag for this BbLocale. If a locale is marked as not available, no one can access it.

Specified by:
setIsAvailable in interface Available
Parameters:
bIsAvailable - true if the locale is to be made available, false otherwise.

getIsDefault

public boolean getIsDefault()
Returns the is_default flag for this BbLocale. Only one locale can be honored as the default.

Returns:
a boolean denoted whether this BbLocale is the default

setIsDefault

public void setIsDefault(boolean bIsDefault)
Sets the is_default flag for this BbLocale. Only one locale can be honored as the default.

Parameters:
bIsDefault - true if the locale is to be made the default, false otherwise.

getIsLeftToRight

public boolean getIsLeftToRight()
Returns the is_left_to_right flag for this BbLocale.

Returns:
a boolean denoted whether this BbLocale is rendered left-to-right.

setIsLeftToRight

public void setIsLeftToRight(boolean bIsLeftToRight)
Sets the is_left_to_right flag for this BbLocale.

Parameters:
bIsLeftToRight - true if the locale is to be rendered left-to-right.

getIsCourseEnabled

public boolean getIsCourseEnabled()
Returns the availability flag for this BbLocale in a course context.

Returns:
a boolean denoted whether this BbLocale is available in a course context.

setIsCourseEnabled

public void setIsCourseEnabled(boolean bIsAvailable)
Sets the availability flag for this BbLocale in a course context.

Parameters:
bIsAvailable - true if the locale is to be made available for a course.

getIsOrganizationEnabled

public boolean getIsOrganizationEnabled()
Returns the availability flag for this BbLocale in a organization context.

Returns:
a boolean denoted whether this BbLocale is available in a organization context.

setIsOrganizationEnabled

public void setIsOrganizationEnabled(boolean bIsAvailable)
Sets the availability flag for this BbLocale in a organization context.

Parameters:
bIsAvailable - true if the locale is to be made available for a organization.

getIsUserEnabled

public boolean getIsUserEnabled()
Returns the availability flag for this BbLocale in a user context.

Returns:
a boolean denoted whether this BbLocale is available in a user context.

setIsUserEnabled

public void setIsUserEnabled(boolean bIsAvailable)
Sets the availability flag for this BbLocale in a user context.

Parameters:
bIsAvailable - true if the locale is to be made available for a user.

getNumberFormat

public java.text.NumberFormat getNumberFormat()
Returns a cloned instance of the current locale-specific NumberFormat. Since it is cloned, formatting controls can be called without affecting the base formatting. E.g., setMaximumFractionDigits()

Returns:
Cloned NumberFormat instance

getPercentFormat

public java.text.NumberFormat getPercentFormat()
Returns a cloned instance of the current locale-specific percentage formatter. Since it is cloned, formatting controls can be called without affecting the base formatting. E.g., setMaximumFractionDigits()

Returns:
Cloned NumberFormat instance

formatNumber

public java.lang.String formatNumber(double num)
Formats a number according to the current locale and returns it as a String.

Parameters:
num - a double representing the value to be formatted

parseNumber

public double parseNumber(java.lang.String str)
                   throws java.lang.NumberFormatException
Accepts a string representation for a number and parses according to the current locale. This method uses java.text.NumberFormat, and thus will follow the parsing rules defined by that class.

Parameters:
str - Locale-dependent number string (e.g., "4.0" or "4,0").
Returns:
double value represented by the given string
Throws:
java.lang.NumberFormatException - thrown if the number cannot be parsed in the current locale

parseNumberAsFloat

public float parseNumberAsFloat(java.lang.String str)
                         throws java.lang.NumberFormatException
Accepts a string representation for a number and parses according to the current locale. This method uses java.text.NumberFormat, and thus will follow the parsing rules defined by that class.

Parameters:
str - Locale-dependent number string (e.g., "4.0", or "4,0").
Returns:
double value represented by the given string
Throws:
java.lang.NumberFormatException - thrown if the number cannot be parsed in the current locale

formatCurrency

public java.lang.String formatCurrency(double currency)
Formats a double as a currency value according to the current locale and returns it as a String.

Parameters:
currency - a double representing the value to be formatted as currency

formatPercent

public java.lang.String formatPercent(double percent)
Formats a double as a percentage according to the current locale and returns it as a String.

Parameters:
percent - a double representing the value to be formatted as a percentage

formatDate

public java.lang.String formatDate(java.util.Date date)
Formats a date (not including time portion) according to the current locale and the default date style and returns it as a string.

Parameters:
date - the Date object describing the date to be formatted.

formatDate

public java.lang.String formatDate(java.util.Date date,
                                   BbLocale.Date dateStyle)
Formats a date (not including time portion) according to the current locale and given date style and returns it as a string.

Parameters:
date - the Date object describing the date to be formatted.
dateStyle - a BbLocale.Date value defining how the date should be formatted

formatTime

public java.lang.String formatTime(java.util.Date time)
Formats the time portion of a date according to the current locale and the default time style and returns it as a string.

Parameters:
time - the Date object describing the date to be formatted.

formatTime

public java.lang.String formatTime(java.util.Date time,
                                   BbLocale.Time timeStyle)
Formats the time portion of a date according to the current locale and given time style and returns it as a string.

Parameters:
time - the Date object describing the date to be formatted.
timeStyle - a BbLocale.Time value defining how the time portion of the given date should be formatted

formatDateTime

public java.lang.String formatDateTime(java.util.Date dateTime)
Formats a date/time according to the current locale and the default date and time styles and returns it as a string.

Parameters:
dateTime - the Date object describing the date/time to be formatted.

formatDateTime

public java.lang.String formatDateTime(java.util.Date dateTime,
                                       BbLocale.Date dateStyle,
                                       BbLocale.Time timeStyle)
Formats a date/time according to the current locale and the given date and time styles and returns it as a string.

Parameters:
dateTime - the Date object describing the date/time to be formatted.
dateStyle - a BbLocale.Date value defining how the date portion of the given date/time should be formatted
timeStyle - a BbLocale.Time value defining how the time portion of the given date/time should be formatted

formatDuration

public java.lang.String formatDuration(long duration)
Format a time duration (in milliseconds) as a string, broken down by days, hours, minutes, seconds and milliseconds.

Parameters:
duration - The time duration in milliseconds
Returns:
A string breakdown of the duration

formatName

public java.lang.String formatName(User user,
                                   BbLocale.Name nameStyle)
Formats the name of the given user according to the current locale and given BbLocale.Name style and returns it as a string.

Parameters:
user - the User whose name should be formatted
nameStyle - a BbLocale.Name value defining how the name of the given user should be formatted

formatName

public java.lang.String formatName(java.lang.String strGivenName,
                                   java.lang.String strMiddleName,
                                   java.lang.String strFamilyName,
                                   java.lang.String strTitle,
                                   BbLocale.Name nameStyle)
Formats a name according to the current locale and given BbLocale.Name style and returns it as a string.

Parameters:
strGivenName - a String containing the User's first name
strMiddleName - a String containing the User's middle name
strFamilyName - a String containing the User's last name
strTitle - a String containing the User's title
nameStyle - a BbLocale.Name value defining how the given name should be formatted

setIsEditable

public void setIsEditable(boolean b)
setIsEditable


getIsEditable

public java.lang.Boolean getIsEditable()
getIsEditable


setVersion

public void setVersion(Version v)
Sets the version for this locale. Set at install time.

Parameters:
v - Fully qualified/parsed version object

getVersion

public Version getVersion()
Returns the version of this locale

Returns:
Fully qualified version object, with major/minor/patch elements

setVendorDescription

public void setVendorDescription(java.lang.String dscr)
Sets the vendor description

Parameters:
dscr - Description. Must not exceed 255 characters. Excess data will be truncated.

getVendorDescription

public java.lang.String getVendorDescription()
Returns the vendor's description.

Returns:
String, which will not exceed 255 characters

setVendorURL

public void setVendorURL(java.lang.String url)
Used during installation to set the extension vendor's URL.

Parameters:
url - Should be a string-based URL.

getVendorURL

public java.lang.String getVendorURL()
Returns the URL for the vendor supplying the system extension. This is provided by the extension manifest.

Returns:
URL string.

setVendorName

public void setVendorName(java.lang.String vendorName)
Sets the user-friendly vendor name. Only called during installation or database loads.

Parameters:
vendorName - vendor name

getVendorName

public java.lang.String getVendorName()
Returns the user-friendly name of the locale vendor.


setVendorId

public void setVendorId(java.lang.String vid)
Sets the vendor id associated with this locale. This should only be called from installation routines, or when loading from the database.

Parameters:
vid - Blackboard-assigned vendor id

getVendorId

public java.lang.String getVendorId()
Returns the vendor id associated with the plug-in. Vendor ids are assigned by Blackboard, and consist of a simple 4 character string.



Copyright © 2003 Blackboard, Inc. All Rights Reserved.