net.sf.zekr.common.config
Class ApplicationConfig

java.lang.Object
  extended by net.sf.zekr.common.config.ApplicationConfig
All Implemented Interfaces:
ConfigNaming

public class ApplicationConfig
extends java.lang.Object
implements ConfigNaming

This singleton class reads the config files by the first invocation of getInstance(). You can then read any option by using available getter methods.

Author:
Mohsen Saboorian

Field Summary
 
Fields inherited from interface net.sf.zekr.common.config.ConfigNaming
AUTHOR_ATTR, BLOCK, COUNTRY_ATTR, DEFAULT_ATTR, DIRECTION_ATTR, ENCODING_ATTR, FILE_ATTR, ID_ATTR, LANG_ATTR, LINE_BY_LINE, LINE_DELIMITER_ATTR, LOCALIZED_NAME_ATTR, MIXED_LAYOUT, MULTI_TRANS_LAYOUT, NAME_ATTR, QURAN_ONLY_LAYOUT, SEPARATE_LAYOUT, SIGNATURE_ATTR, THEME_ATTR, TRANS_ONLY_LAYOUT, VERSION_ATTR
 
Method Summary
 boolean addNewTranslation(java.io.File transFile)
          This method is used to add a new translation during runtime.
 Audio getAudio()
           
 BookmarkSet getBookmark()
           
 BookmarkSetGroup getBookmarkSetGroup()
           
 java.util.List getCustomTranslationList()
           
 HttpServer getHttpServer()
           
 int getHttpServerPort()
           
static ApplicationConfig getInstance()
           
 Language getLanguage()
           
 LanguageEngine getLanguageEngine()
           
 LuceneIndexManager getLuceneIndexManager()
           
 int getPageNum()
           
 java.lang.String getPagingMode()
           
 org.apache.commons.configuration.PropertiesConfiguration getProps()
           
 java.lang.String getQuranLayout()
           
 IQuranLocation getQuranLocation()
           
 QuranPaging getQuranPaging()
           
 QuranRoot getQuranRoot()
           
 Revelation getRevelation()
           
 ApplicationRuntime getRuntime()
           
 SearchInfo getSearchInfo()
           
 boolean getShowSplash()
           
 Theme getTheme()
           
 Translation getTranslation()
           
 java.lang.String getTransLayout()
           
 IUserView getUserViewController()
           
 java.lang.String getViewLayout()
           
 java.lang.String getViewProp(java.lang.String propKey)
           
 boolean isAudioEnabled()
           
static boolean isFullyInitialized()
           
 boolean isHttpServerEnabled()
           
 boolean isRootDatabaseEnabled()
           
 RevelationData loadRevelationData(java.io.File revelZipFile)
           
 TranslationData loadTranslationData(java.io.File transZipFile)
           
 void saveConfig()
          Save properties configuration file, which was read into props, to ApplicationPath.USER_CONFIG.
 void setCurrentAudio(java.lang.String audioId)
           
 void setCurrentLanguage(java.lang.String langId)
           
 void setCurrentTheme(java.lang.String themeId)
           
 void setCurrentTranslation(java.lang.String transId)
           
 void setCustomTranslationList(java.util.List newIdList)
           
 void setPagingMode(java.lang.String pagingModeId)
           
 void setQuranLayout(java.lang.String newLayout)
           
 void setQuranLocation(IQuranLocation quranLocation)
           
 void setRuntime(ApplicationRuntime runtime)
           
 void setShowSplash(boolean showSplash)
           
 void setTransLayout(java.lang.String newLayout)
           
 void setViewLayout(java.lang.String layout)
           
 void setViewProp(java.lang.String propKey, java.lang.String value)
           
 void updateFile()
           
 boolean useMozilla()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ApplicationConfig getInstance()

saveConfig

public void saveConfig()
Save properties configuration file, which was read into props, to ApplicationPath.USER_CONFIG.


getProps

public org.apache.commons.configuration.PropertiesConfiguration getProps()
Returns:
User configuration properties

loadTranslationData

public TranslationData loadTranslationData(java.io.File transZipFile)
                                    throws java.io.IOException,
                                           org.apache.commons.configuration.ConfigurationException
Throws:
java.io.IOException
org.apache.commons.configuration.ConfigurationException

loadRevelationData

public RevelationData loadRevelationData(java.io.File revelZipFile)
                                  throws java.io.IOException,
                                         org.apache.commons.configuration.ConfigurationException
Throws:
java.io.IOException
org.apache.commons.configuration.ConfigurationException

getLanguageEngine

public LanguageEngine getLanguageEngine()
Returns:
application language engine
See Also:
Language.getInstance()

setCurrentLanguage

public void setCurrentLanguage(java.lang.String langId)

setCurrentTheme

public void setCurrentTheme(java.lang.String themeId)

setCurrentTranslation

public void setCurrentTranslation(java.lang.String transId)
                           throws TranslationException
Throws:
TranslationException

setCurrentAudio

public void setCurrentAudio(java.lang.String audioId)

getViewProp

public java.lang.String getViewProp(java.lang.String propKey)

setViewProp

public void setViewProp(java.lang.String propKey,
                        java.lang.String value)

getQuranLayout

public java.lang.String getQuranLayout()

setQuranLayout

public void setQuranLayout(java.lang.String newLayout)

getPageNum

public int getPageNum()

getQuranLocation

public IQuranLocation getQuranLocation()

setQuranLocation

public void setQuranLocation(IQuranLocation quranLocation)

getTransLayout

public java.lang.String getTransLayout()

setTransLayout

public void setTransLayout(java.lang.String newLayout)

setViewLayout

public void setViewLayout(java.lang.String layout)

getViewLayout

public java.lang.String getViewLayout()

setPagingMode

public void setPagingMode(java.lang.String pagingModeId)

getPagingMode

public java.lang.String getPagingMode()

isHttpServerEnabled

public boolean isHttpServerEnabled()

isRootDatabaseEnabled

public boolean isRootDatabaseEnabled()

useMozilla

public boolean useMozilla()

getHttpServerPort

public int getHttpServerPort()
Returns:
HTTP server port or -1 if nothing found.

getLanguage

public Language getLanguage()

updateFile

public void updateFile()

getTranslation

public Translation getTranslation()

getTheme

public Theme getTheme()

getAudio

public Audio getAudio()

getRevelation

public Revelation getRevelation()

getQuranPaging

public QuranPaging getQuranPaging()

getQuranRoot

public QuranRoot getQuranRoot()

getSearchInfo

public SearchInfo getSearchInfo()

getHttpServer

public HttpServer getHttpServer()

getRuntime

public ApplicationRuntime getRuntime()

setRuntime

public void setRuntime(ApplicationRuntime runtime)

getBookmarkSetGroup

public BookmarkSetGroup getBookmarkSetGroup()

getBookmark

public BookmarkSet getBookmark()

getUserViewController

public IUserView getUserViewController()

isFullyInitialized

public static boolean isFullyInitialized()
Returns:
true if an instance of this class is initialized, and false otherwise.

setShowSplash

public void setShowSplash(boolean showSplash)

getShowSplash

public boolean getShowSplash()

getCustomTranslationList

public java.util.List getCustomTranslationList()
Returns:
A list of TranslationData

setCustomTranslationList

public void setCustomTranslationList(java.util.List newIdList)
                              throws TranslationException
Parameters:
newIdList - a list of new translation data IDs (list contains Strings).
Throws:
TranslationException

getLuceneIndexManager

public LuceneIndexManager getLuceneIndexManager()

isAudioEnabled

public boolean isAudioEnabled()

addNewTranslation

public boolean addNewTranslation(java.io.File transFile)
                          throws ZekrMessageException
This method is used to add a new translation during runtime. It loads translation metadata and adds it to the list of translations. If translation pack is not authentic, it throws a ZekrMessageException just to inform user.

Parameters:
transFile - a translation zip archive to be loaded
Throws:
ZekrMessageException - with the proper message key and parameters if any exception occurred