com.konakart.bl
Class LanguageMgr

java.lang.Object
  extended by com.konakart.bl.BaseMgr
      extended by com.konakart.bl.LanguageMgr
All Implemented Interfaces:
LanguageMgrIf

public class LanguageMgr
extends BaseMgr
implements LanguageMgrIf

Manages all business logic relevant to the management of languages within the system


Nested Class Summary
protected  class LanguageMgr.StaticData
          Used to store the static data of this manager
 
Field Summary
static int DEFAULT_LANG
          Default language id is selected with a value of ConstantsMgr.NOT_SET.
protected static org.apache.commons.logging.Log log
          the log
protected static java.lang.String mutex
          Mutex for the Manager
protected static java.util.Map<java.lang.String,LanguageMgr.StaticData> staticDataHM
          Hash Map that contains the static data
 
Fields inherited from class com.konakart.bl.BaseMgr
templateBaseDir
 
Constructor Summary
LanguageMgr(KKEngIf eng)
          Constructor
 
Method Summary
protected  Language fetchDefaultLanguage()
          The default language is referenced by a configuration variable called DEFAULT_LANGUAGE.
 Language[] getAllLanguages()
          Returns an array of language objects for all languages that have been defined in the system.
 Language getDefaultLanguage()
          Returns the default language object
 int getDefaultLanguageId()
          Returns the default language id
 java.lang.String getDefaultLocale()
           
 Language getLanguagePerCode(java.lang.String code)
          Retrieves the language object referenced by the code (i.e.
 Language getLanguagePerId(int languageId)
          Returns the language object with id = languageId.
 NameValue[] getMessages(int type, java.lang.String locale)
          Used to fetch a message catalog for a locale and message type.
 java.lang.String getMsgValue(java.lang.String key, int type, java.lang.String locale)
          Get an Application Message Value.
 void refreshConfigs()
          Refresh the configuration of the language manager
 
Methods inherited from class com.konakart.bl.BaseMgr
addInsertAttr, addInsertAttr, checkRequired, getAdminEngMgr, getBasketMgr, getBillingMgr, getBookableProductMgr, getCatMgr, getConfigMgr, getCookieMgr, getCurrMgr, getCustMgr, getCustomerIdFromSession, getCustomerStatsMgr, getCustomerTagMgr, getEmailMgr, getEng, getLangMgr, getManuMgr, getMiscItemMgr, getMode, getModeString, getMqMgr, getMultiStoreMgr, getNewCriteria, getNewCriteria, getOrderMgr, getOrderTotalMgr, getPaymentMgr, getProdMgr, getPromMgr, getRewardPointMgr, getSecMgr, getShippingMgr, getSolrMgr, getStoreId, getTaxMgr, getTemplate, getTemplateRoot, getVelocityContextMgr, getWishListMgr, init, isEnterprise, isMultiStoreShareCustomers, isMultiStoreShareProducts
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.commons.logging.Log log
the log


DEFAULT_LANG

public static final int DEFAULT_LANG
Default language id is selected with a value of ConstantsMgr.NOT_SET.

See Also:
Constant Field Values

mutex

protected static java.lang.String mutex
Mutex for the Manager


staticDataHM

protected static java.util.Map<java.lang.String,LanguageMgr.StaticData> staticDataHM
Hash Map that contains the static data

Constructor Detail

LanguageMgr

public LanguageMgr(KKEngIf eng)
            throws java.lang.Exception
Constructor

Parameters:
eng -
Throws:
java.lang.Exception
Method Detail

getAllLanguages

public Language[] getAllLanguages()
                           throws org.apache.torque.TorqueException,
                                  com.workingdogs.village.DataSetException,
                                  KKException
Returns an array of language objects for all languages that have been defined in the system.

Specified by:
getAllLanguages in interface LanguageMgrIf
Returns:
An array of language objects.
Throws:
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException
KKException

getDefaultLanguageId

public int getDefaultLanguageId()
                         throws KKException
Description copied from interface: LanguageMgrIf
Returns the default language id

Specified by:
getDefaultLanguageId in interface LanguageMgrIf
Returns:
Returns the default language id
Throws:
KKException

getDefaultLanguage

public Language getDefaultLanguage()
                            throws KKException
Description copied from interface: LanguageMgrIf
Returns the default language object

Specified by:
getDefaultLanguage in interface LanguageMgrIf
Returns:
Returns the default language object
Throws:
KKException

getDefaultLocale

public java.lang.String getDefaultLocale()
                                  throws KKException
Returns:
Returns the default locale
Throws:
KKException

getLanguagePerId

public Language getLanguagePerId(int languageId)
                          throws org.apache.torque.TorqueException,
                                 com.workingdogs.village.DataSetException,
                                 KKException
Description copied from interface: LanguageMgrIf
Returns the language object with id = languageId. Null if no object is found.

Specified by:
getLanguagePerId in interface LanguageMgrIf
Parameters:
languageId -
Returns:
The language object with id = languageId. Null if no object is found.
Throws:
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException
KKException

getLanguagePerCode

public Language getLanguagePerCode(java.lang.String code)
                            throws com.workingdogs.village.DataSetException,
                                   org.apache.torque.TorqueException,
                                   KKException
Retrieves the language object referenced by the code (i.e. en, de, es)

Specified by:
getLanguagePerCode in interface LanguageMgrIf
Parameters:
code -
Returns:
Returns a language object
Throws:
com.workingdogs.village.DataSetException
org.apache.torque.TorqueException
KKException

fetchDefaultLanguage

protected Language fetchDefaultLanguage()
                                 throws java.lang.Exception
The default language is referenced by a configuration variable called DEFAULT_LANGUAGE. If this variable isn't set, then the method returns the id of the language with the lowest sort order value. We assume that this language is the default language and will be used when no other language is specified. The default language is retrieved from the database first time round and is then stored in a static variable.

Returns:
the default Language object
Throws:
java.lang.Exception

getMsgValue

public java.lang.String getMsgValue(java.lang.String key,
                                    int type,
                                    java.lang.String locale)
                             throws org.apache.torque.TorqueException,
                                    com.workingdogs.village.DataSetException,
                                    KKException
Get an Application Message Value. If locale is null, the default locale is used.

Specified by:
getMsgValue in interface LanguageMgrIf
Parameters:
key - the message key
type - the message type (should use KKConstants.MSG_TYP_APPLICATION for application messages)
locale - the message locale (eg. "en_GB")
Returns:
The message for the key, type and locale. If the message isn't found the String "[key:type:locale]" is returned.
Throws:
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException
KKException

getMessages

public NameValue[] getMessages(int type,
                               java.lang.String locale)
                        throws KKException,
                               com.workingdogs.village.DataSetException,
                               org.apache.torque.TorqueException
Used to fetch a message catalog for a locale and message type. If locale is null, the default locale is used.

Specified by:
getMessages in interface LanguageMgrIf
Parameters:
type - the message type (should use KKConstants.MSG_TYP_APPLICATION for application messages)
locale - the message locale (eg. "en_GB")
Returns:
Returns and array of NameValue objects containing the message catalog
Throws:
KKException
com.workingdogs.village.DataSetException
org.apache.torque.TorqueException

refreshConfigs

public void refreshConfigs()
                    throws java.lang.Exception
Refresh the configuration of the language manager

Specified by:
refreshConfigs in interface LanguageMgrIf
Throws:
java.lang.Exception


Copyright © 2011 DS Data Systems UK Ltd.