com.ibm.as400.access

Class 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

      Methods 
      Modifier and Type Method and Description
      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.

    • Method Detail

      • 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.
      • 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()