com.ibm.as400.access

Class NLS

  • java.lang.Object
    • com.ibm.as400.access.NLS


  • public final class NLS
    extends java.lang.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 java.lang.String ccsidToEncoding(int ccsid)
      Returns a best-guess Java encoding given a CCSID.
      static int encodingToCCSID(java.lang.String encoding)
      Returns a best-guess CCSID given a Java encoding.
      static java.lang.String getCountryDescription(AS400 system, java.lang.String countryID)
      Retrieves the descriptive text for the specified country or region identifier.
      static java.lang.String getLanguageDescription(AS400 system, java.lang.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(java.util.Locale locale)
      Returns a best-guess CCSID given a Java Locale object.
      static int localeToCCSID(java.lang.String localeString)
      Returns a best-guess CCSID given a Java locale string.
      static java.lang.String localeToNLV(java.util.Locale locale)
      Returns a best-guess National Language Version (NLV) string given a Java Locale object.
      static java.lang.String localeToNLV(java.lang.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 java.lang.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(java.lang.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(java.lang.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(java.util.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 java.lang.String localeToNLV(java.lang.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 java.lang.String localeToNLV(java.util.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()