com.ibm.as400.access
Class NLS

java.lang.Object
  extended bycom.ibm.as400.access.NLS

public final class NLS
extends Object

The NLS class contains a set of static methods that can be used to access various pieces of National Language Support information (such as language and country descriptions) on a system.


Method Summary
static String ccsidToEncoding(int ccsid)
          Returns a best-guess Java encoding given a CCSID.
static int encodingToCCSID(String encoding)
          Returns a best-guess CCSID given a Java encoding.
static String getCountryDescription(AS400 system, String countryID)
          Retrieves the descriptive text for the specified country or region identifier.
static String getLanguageDescription(AS400 system, String languageID)
          Retrieves the descriptive text for the specified language identifier.
static boolean isForceJavaConversion()
          Indicates whether or not any text conversion performed by the Toolbox uses the converter tables that are part of the Toolbox, or the converter tables that are part of the Java Runtime Environment.
static int localeToCCSID(Locale locale)
          Returns a best-guess CCSID given a Java Locale object.
static int localeToCCSID(String localeString)
          Returns a best-guess CCSID given a Java locale string.
static String localeToNLV(Locale locale)
          Returns a best-guess National Language Version (NLV) string given a Java Locale object.
static String localeToNLV(String localeString)
          Returns a best-guess National Language Version (NLV) string given a Java locale string.
static void setForceJavaConversion(boolean forceJavaTables)
          Sets whether or not any text conversion performed by the Toolbox uses the converter tables that are part of the Toolbox, or the converter tables that are part of the Java Runtime Environment.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

ccsidToEncoding

public static String ccsidToEncoding(int ccsid)
Returns a best-guess Java encoding given a CCSID.

Parameters:
ccsid - The coded character set identifier (CCSID), e.g. 37.
Returns:
The encoding that maps to the given CCSID, or null if one is not known.
See Also:
encodingToCCSID(java.lang.String), localeToCCSID(java.lang.String)

encodingToCCSID

public static int encodingToCCSID(String encoding)
Returns a best-guess CCSID given a Java encoding.

Parameters:
encoding - The encoding, e.g. "Cp037".
Returns:
The CCSID that maps to the given encoding, or -1 if one is not known.
See Also:
ccsidToEncoding(int), localeToCCSID(java.lang.String)

localeToCCSID

public static int localeToCCSID(String localeString)
Returns a best-guess CCSID given a Java locale string. Note that the CCSID returned will be the preferred system CCSID, i.e. usually EBCDIC. So, the locale string representing English "en" will return the single-byte EBCDIC CCSID of 37.

Parameters:
localeString - The locale string, e.g. "de_CH".
Returns:
The CCSID that maps the given locale string, or -1 if one is not known.

localeToCCSID

public static int localeToCCSID(Locale locale)
Returns a best-guess CCSID given a Java Locale object. Note that the CCSID returned will be the preferred system CCSID, i.e. usually EBCDIC. So, the Locale representing English (Locale.ENGLISH) will return the single-byte EBCDIC CCSID of 37.

Parameters:
locale - The Locale object.
Returns:
The CCSID that maps the given locale, or -1 if one is not known.

localeToNLV

public static String localeToNLV(String localeString)
Returns a best-guess National Language Version (NLV) string given a Java locale string. If there is no known mapping for the given Locale or one of its parents (e.g. "en" is a parent of "en_US"), then "" is returned.

Parameters:
localeString - The locale string, e.g. "de_CH".
Returns:
The NLV string (e.g. "2924") that maps the given locale, or "" if one is not known.

localeToNLV

public static String localeToNLV(Locale locale)
Returns a best-guess National Language Version (NLV) string given a Java Locale object. If there is no known mapping for the given Locale or one of its parents (e.g. "en" is a parent of "en_US"), then "" is returned.

Parameters:
locale - The Locale object.
Returns:
The NLV string (e.g. "2924") that maps the given locale, or "" if one is not known.

getCountryDescription

public static String getCountryDescription(AS400 system,
                                           String countryID)
                                    throws AS400Exception,
                                           AS400SecurityException,
                                           ErrorCompletingRequestException,
                                           InterruptedException,
                                           IOException,
                                           ObjectDoesNotExistException
Retrieves the descriptive text for the specified country or region identifier. The list is cached, so that a subsequent call to this method will return immediately if the specified country or region identifier is in the list. If it is not in the list, the system will be queried.

Parameters:
system - The system.
countryID - The country or region identifier.
Returns:
The descriptive text.
Throws:
AS400Exception
AS400SecurityException
ErrorCompletingRequestException
InterruptedException
IOException
ObjectDoesNotExistException
See Also:
getLanguageDescription(com.ibm.as400.access.AS400, java.lang.String)

getLanguageDescription

public static String getLanguageDescription(AS400 system,
                                            String languageID)
                                     throws AS400Exception,
                                            AS400SecurityException,
                                            ErrorCompletingRequestException,
                                            InterruptedException,
                                            IOException,
                                            ObjectDoesNotExistException
Retrieves the descriptive text for the specified language identifier. The list is cached, so that a subsequent call to this method will return immediately if the specified language identifier is in the list. If it is not in the list, the system will be queried.

Parameters:
system - The system.
languageID - The language identifier.
Returns:
The descriptive text.
Throws:
AS400Exception
AS400SecurityException
ErrorCompletingRequestException
InterruptedException
IOException
ObjectDoesNotExistException
See Also:
getCountryDescription(com.ibm.as400.access.AS400, java.lang.String)

isForceJavaConversion

public static boolean isForceJavaConversion()
Indicates whether or not any text conversion performed by the Toolbox uses the converter tables that are part of the Toolbox, or the converter tables that are part of the Java Runtime Environment. The default is to use the Toolbox converter tables, since their behavior more closely matches the behavior of text conversion on the system.

Returns:
true if the Java Runtime Environement converter tables are used; false if the Toolbox converter tables are used. The default is false.
See Also:
setForceJavaConversion(boolean)

setForceJavaConversion

public static void setForceJavaConversion(boolean forceJavaTables)
Sets whether or not any text conversion performed by the Toolbox uses the converter tables that are part of the Toolbox, or the converter tables that are part of the Java Runtime Environment. The default is to use the Toolbox converter tables, since their behavior more closely matches the behavior of text conversion on the system.

The usefulness of this method is arbitrary. Typically, applications only need to force Java conversion if they are seeing inconsistent character conversion between an older release of the Toolbox and a newer one. Some problem characters include EBCDIC line feeds and a few characters in Katakana, such as the middle dot or bullet.

Parameters:
forceJavaTables - Specify true if the Java Runtime Environement converter tables are used; false if the Toolbox converter tables are used. The default is false.
See Also:
isForceJavaConversion()