org.pfsw.nls
Class NLSIniFileLoader

java.lang.Object
  extended by org.pfsw.nls.NLSIniFileLoader

public class NLSIniFileLoader
extends java.lang.Object

This loader is capable of reading text values from an NLS-ini file to one or more TextContainer objects.


Constructor Summary
NLSIniFileLoader()
          Initialize the new instance with default values.
 
Method Summary
protected  org.pfsw.util.CollectionUtil coll()
           
protected  TextContainerList createTextContainerList(java.util.Locale[] locales)
           
protected  java.lang.String getCharacterEncoding()
           
 java.lang.String getDefaultEncoding()
          Returns the default encoding that will be used to read text from a file if no explicit encoding was provided.
protected  java.lang.String getEncoding()
          Returns the encoding that should be used.
protected  java.lang.String getMetadataIndicator()
          Sections that start with the prefix returned by this method are treated as metedata sections.
protected  void handleMetadataSection(org.pfsw.settings.Settings settings, java.lang.String sectionName)
           
protected  void handleMetadataSections(org.pfsw.settings.Settings settings, java.lang.String[] sectionNames)
           
protected  void handleTextKeys(TextContainerList textContainers, org.pfsw.settings.Settings settings, java.lang.String[] textKeys, java.lang.String[] localeNames)
           
 TextContainer loadText(java.io.File file, java.util.Locale locale)
          Returns a text container with all texts for the specified locale from the given file.
 TextContainerList loadText(java.io.File file, java.util.Locale[] locales)
          Returns a list of text containers with all texts for the specified locales from the given file.
 TextContainer loadText(org.pfsw.file.FileLocator fileLocator, java.util.Locale locale)
          Returns a text container with all texts for the specified locale from the given file.
 TextContainerList loadText(org.pfsw.file.FileLocator fileLocator, java.util.Locale[] locales)
          Returns a list of text containers with all texts for the specified locales from the given file.
 TextContainer loadText(org.pfsw.file.FileLocator fileLocator, java.lang.String localeName)
          Returns a text container with all texts for the specified locale from the given file.
 TextContainerList loadText(org.pfsw.file.FileLocator fileLocator, java.lang.String[] localeNames)
          Returns a list of text containers with all texts for the specified locales from the given file.
 TextContainer loadText(java.io.File file, java.lang.String localeName)
          Returns a text container with all texts for the specified locale from the given file.
 TextContainerList loadText(java.io.File file, java.lang.String[] localeNames)
          Returns a list of text containers with all texts for the specified locales from the given file.
protected  TextContainerList loadTextContainers(org.pfsw.file.FileLocator locator, java.util.Locale[] locales)
           
protected  java.lang.String[] localesToStrings(java.util.Locale[] locales)
           
protected  NLSUtil nls()
           
protected  org.pfsw.text.StringUtil str()
           
protected  java.util.Locale[] stringsToLocales(java.lang.String[] localeNames)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NLSIniFileLoader

public NLSIniFileLoader()
Initialize the new instance with default values.

Method Detail

loadText

public TextContainer loadText(java.io.File file,
                              java.lang.String localeName)
Returns a text container with all texts for the specified locale from the given file.


loadText

public TextContainer loadText(java.io.File file,
                              java.util.Locale locale)
Returns a text container with all texts for the specified locale from the given file.


loadText

public TextContainerList loadText(java.io.File file,
                                  java.util.Locale[] locales)
Returns a list of text containers with all texts for the specified locales from the given file.


loadText

public TextContainerList loadText(java.io.File file,
                                  java.lang.String[] localeNames)
Returns a list of text containers with all texts for the specified locales from the given file. Returns null if the given file is null or the localeNames are null or empty.


loadText

public TextContainer loadText(org.pfsw.file.FileLocator fileLocator,
                              java.lang.String localeName)
Returns a text container with all texts for the specified locale from the given file.


loadText

public TextContainer loadText(org.pfsw.file.FileLocator fileLocator,
                              java.util.Locale locale)
Returns a text container with all texts for the specified locale from the given file.


loadText

public TextContainerList loadText(org.pfsw.file.FileLocator fileLocator,
                                  java.util.Locale[] locales)
Returns a list of text containers with all texts for the specified locales from the given file.


loadText

public TextContainerList loadText(org.pfsw.file.FileLocator fileLocator,
                                  java.lang.String[] localeNames)
Returns a list of text containers with all texts for the specified locales from the given file. Returns null if the given file is null or the localeNames are null or empty.


getDefaultEncoding

public java.lang.String getDefaultEncoding()
Returns the default encoding that will be used to read text from a file if no explicit encoding was provided.

Returns:
"UTF-8"

loadTextContainers

protected TextContainerList loadTextContainers(org.pfsw.file.FileLocator locator,
                                               java.util.Locale[] locales)

handleTextKeys

protected void handleTextKeys(TextContainerList textContainers,
                              org.pfsw.settings.Settings settings,
                              java.lang.String[] textKeys,
                              java.lang.String[] localeNames)

localesToStrings

protected java.lang.String[] localesToStrings(java.util.Locale[] locales)

stringsToLocales

protected java.util.Locale[] stringsToLocales(java.lang.String[] localeNames)

createTextContainerList

protected TextContainerList createTextContainerList(java.util.Locale[] locales)

handleMetadataSections

protected void handleMetadataSections(org.pfsw.settings.Settings settings,
                                      java.lang.String[] sectionNames)

handleMetadataSection

protected void handleMetadataSection(org.pfsw.settings.Settings settings,
                                     java.lang.String sectionName)

getCharacterEncoding

protected java.lang.String getCharacterEncoding()

getEncoding

protected java.lang.String getEncoding()
Returns the encoding that should be used. Subclasses must override this method in order to support other encoding than the default encoding (i.e. UTF-8).

See Also:
getDefaultEncoding()

getMetadataIndicator

protected java.lang.String getMetadataIndicator()
Sections that start with the prefix returned by this method are treated as metedata sections. That is, they do not contain localized text for any language.


coll

protected org.pfsw.util.CollectionUtil coll()

nls

protected NLSUtil nls()

str

protected org.pfsw.text.StringUtil str()