de.folt.util
Class LanguageHandling

java.lang.Object
  extended by de.folt.util.LanguageHandling

public class LanguageHandling
extends java.lang.Object

This class contains several methods for handling standard language codes. Language codes are read from a file and stored in a hash table. The file format looks currently like this (lancodes.txt in the in directory.
A language can be accessed in various ways: (Example Abkhazian=ab)
the short name: ab
the long name: Abkhazian
the combined name: Abkhazian ab

 Afar=aa
 Abkhazian=ab
 Afrikaans=af
 ...
 Arabic (Egypt)=ar-eg
 Arabic (Jordan)=ar-jo
 Arabic (Kuwait)=ar-kw
Actually three tables are used which have the following structure (Example Abkhazian=ab) *
 
        languagecombinedtable     Key: "Abkhazian ab"   Value: "ab"
        lanshorttable             Key: "Abkhazian"      Value: "ab"
        lanlongtable              Key: "ab"             Value: "Abkhazian"
        

Author:
klemens

Constructor Summary
LanguageHandling()
           
 
Method Summary
static java.lang.String getCombinedLanguageCodeFromShortLanguageCode(java.lang.String language)
          getCombinedLanguageCodeFromShortLanguageCode return the combined language code from a short language looking like this "ab" -> "ab Abkhazian"
Method uses hash table lanlongtable to get the correct language.
static java.lang.String[] getCombinedLanguages()
          getCombinedLanguages return a sorted array of language codes
static java.util.Hashtable<java.lang.String,java.lang.String> getLanguagecodetable()
           
static java.util.Hashtable<java.lang.String,java.lang.String> getLanlongtable()
           
static java.util.Hashtable<java.lang.String,java.lang.String> getLanshorttable()
           
static java.lang.String getLongLanguageCodeFromShortLanguageCode(java.lang.String language)
          getLongLanguageCodeFromShortLanguageCode return the long language code from a short language looking like this "ab" -> "Abkhazian"
Method uses hash table lanlongtable to get the correct language.
static java.lang.String[] getLongLanguages()
          getLongLanguages return a sorted array of language codes
static java.lang.String getShortLanguageCodeFromCombinedTable(java.lang.String language)
          getShortLanguageCodeFromCombinedTable return the short language code for a language looking like this "Abkhazian ab"
Method uses hash table languagecombinedtable to get the correct language.
static java.lang.String getShortLanguageCodeFromLongLanguageCode(java.lang.String language)
          getShortLanguageCodeFromLongLanguageCode return the short language code from a long language looking like this "Abkhazian" -> "ab"
Method uses hash table lanshorttable to get the correct language.
static java.lang.String[] getShortLanguages()
          getShortLanguages return a sorted array of the short language codes
static java.util.Hashtable<java.lang.String,java.lang.String> readLanguageCodesFromFile()
          readLanguageCodesFromFile read the language codes from a default file (lancodes.txt in the ini directory)
static java.util.Hashtable<java.lang.String,java.lang.String> readLanguageCodesFromFile(java.lang.String langCodeFileName)
          readLanguageCodesFromFile read the language codes from a file
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LanguageHandling

public LanguageHandling()
Method Detail

getCombinedLanguageCodeFromShortLanguageCode

public static java.lang.String getCombinedLanguageCodeFromShortLanguageCode(java.lang.String language)
getCombinedLanguageCodeFromShortLanguageCode return the combined language code from a short language looking like this "ab" -> "ab Abkhazian"
Method uses hash table lanlongtable to get the correct language.

Parameters:
language - the short name of a language, e.g. "ab"
Returns:
the short language code, e.g. "ab Abkhazian"

getCombinedLanguages

public static java.lang.String[] getCombinedLanguages()
getCombinedLanguages return a sorted array of language codes

Returns:
the sorted array with the combined language codes

getLanguagecodetable

public static java.util.Hashtable<java.lang.String,java.lang.String> getLanguagecodetable()
Returns:
the languagecodetable

getLanlongtable

public static java.util.Hashtable<java.lang.String,java.lang.String> getLanlongtable()
Returns:
the lanlongtable

getLanshorttable

public static java.util.Hashtable<java.lang.String,java.lang.String> getLanshorttable()
Returns:
the lanshorttable

getLongLanguageCodeFromShortLanguageCode

public static java.lang.String getLongLanguageCodeFromShortLanguageCode(java.lang.String language)
getLongLanguageCodeFromShortLanguageCode return the long language code from a short language looking like this "ab" -> "Abkhazian"
Method uses hash table lanlongtable to get the correct language.

Parameters:
language - the long name of a language, e.g. "ab"
Returns:
the short language code, e.g. "Abkhazian"

getLongLanguages

public static java.lang.String[] getLongLanguages()
getLongLanguages return a sorted array of language codes

Returns:
the sorted array with the combined language codes

getShortLanguageCodeFromCombinedTable

public static java.lang.String getShortLanguageCodeFromCombinedTable(java.lang.String language)
getShortLanguageCodeFromCombinedTable return the short language code for a language looking like this "Abkhazian ab"
Method uses hash table languagecombinedtable to get the correct language.

Parameters:
language - the long name of a language, e.g. "Abkhazian ab"
Returns:
the short language code, e.g. "ab"

getShortLanguageCodeFromLongLanguageCode

public static java.lang.String getShortLanguageCodeFromLongLanguageCode(java.lang.String language)
getShortLanguageCodeFromLongLanguageCode return the short language code from a long language looking like this "Abkhazian" -> "ab"
Method uses hash table lanshorttable to get the correct language.

Parameters:
language - the long name of a language, e.g. "Abkhazian"
Returns:
the short language code, e.g. "ab"

getShortLanguages

public static java.lang.String[] getShortLanguages()
getShortLanguages return a sorted array of the short language codes

Returns:
the sorted array with the short language codes

readLanguageCodesFromFile

public static java.util.Hashtable<java.lang.String,java.lang.String> readLanguageCodesFromFile()
readLanguageCodesFromFile read the language codes from a default file (lancodes.txt in the ini directory)

Returns:
a hash table key short code - value long language code - Key: Abkhazian ab Value: ab

readLanguageCodesFromFile

public static java.util.Hashtable<java.lang.String,java.lang.String> readLanguageCodesFromFile(java.lang.String langCodeFileName)
readLanguageCodesFromFile read the language codes from a file

Parameters:
langCodeFileName - the file name to use
Returns:
a hash table key short code - value long language code - Key: Abkhazian ab Value: ab