org.pf.nls
Class NLSIniFileDetector

java.lang.Object
  extended by org.pf.nls.NLSIniFileDetector

public class NLSIniFileDetector
extends Object

This class is responsible to lookup the classpath for a specified base name to which it depends the file extension ".ini". All found files are read to retrieve the included metadata which defines which texts for which locale can be found in which file. Eventually it provides a FileLocator per locale which allows to load the associated texts with a NLSIniFileLoader.

Version:
1.0
Author:
M.Duchrow

Field Summary
static boolean DEBUG
           
static String DEFAULT_FILE_EXTENSTION
           
 
Constructor Summary
NLSIniFileDetector()
          Initialize the new instance with default values.
 
Method Summary
 boolean detect(String baseName)
          Detects all meta information files for the given base name on the current NLS lookup path.
 org.pf.file.FileLocator getFileForLocales(Locale locale)
          Returns the file locator for the given locale or null if not found.
 org.pf.file.FileLocator[] getFilesForLocales(Locale[] locales)
          Returns a file locators for wich a mapping to the given locales have been found.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public static final boolean DEBUG

DEFAULT_FILE_EXTENSTION

public static final String DEFAULT_FILE_EXTENSTION
See Also:
Constant Field Values
Constructor Detail

NLSIniFileDetector

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

Method Detail

detect

public boolean detect(String baseName)
Detects all meta information files for the given base name on the current NLS lookup path.

This path usually is the classpath. However, it can explicitly set with -Dorg.pf.nls.path=any classpath.

After calling this method the getFilesForLocales() can be used to get the names of the file that contain the NLS text data.

Parameters:
baseName - The filename without file extension (".ini" will be appended)
Returns:
true if at least one language-to-file mapping was found.

getFilesForLocales

public org.pf.file.FileLocator[] getFilesForLocales(Locale[] locales)
Returns a file locators for wich a mapping to the given locales have been found.

This method should be called only after detect() has been called at least once before.

Parameters:
locales - The locales for which to return the corresponding file locators

getFileForLocales

public org.pf.file.FileLocator getFileForLocales(Locale locale)
Returns the file locator for the given locale or null if not found.



Copyright © 2015 Manfred Duchrow Consulting & Software. All rights reserved.