Package com.ibm.icu.impl

Examples of com.ibm.icu.impl.LocaleIDParser


   * @return The new tag string.
   **/
  private static String createTagString(final String lang, final String script, final String region, final String trailing,
      final String alternateTags) {

    LocaleIDParser parser = null;
    boolean regionAppended = false;

    StringBuilder tag = new StringBuilder();

    if (!isEmptyString(lang)) {
      appendTag(lang, tag);
    } else if (isEmptyString(alternateTags)) {
      /*
       * Append the value for an unknown language, if
       * we found no language.
       */
      appendTag(UNDEFINED_LANGUAGE, tag);
    } else {
      parser = new LocaleIDParser(alternateTags);

      String alternateLang = parser.getLanguage();

      /*
       * Append the value for an unknown language, if
       * we found no language.
       */
      appendTag(!isEmptyString(alternateLang) ? alternateLang : UNDEFINED_LANGUAGE, tag);
    }

    if (!isEmptyString(script)) {
      appendTag(script, tag);
    } else if (!isEmptyString(alternateTags)) {
      /*
       * Parse the alternateTags string for the script.
       */
      if (parser == null) {
        parser = new LocaleIDParser(alternateTags);
      }

      String alternateScript = parser.getScript();

      if (!isEmptyString(alternateScript)) {
        appendTag(alternateScript, tag);
      }
    }

    if (!isEmptyString(region)) {
      appendTag(region, tag);

      regionAppended = true;
    } else if (!isEmptyString(alternateTags)) {
      /*
       * Parse the alternateTags string for the region.
       */
      if (parser == null) {
        parser = new LocaleIDParser(alternateTags);
      }

      String alternateRegion = parser.getCountry();

      if (!isEmptyString(alternateRegion)) {
        appendTag(alternateRegion, tag);

        regionAppended = true;
View Full Code Here


   * @param tags
   *            An array of three String references to return the subtag strings.
   * @return The number of chars of the localeID parameter consumed.
   **/
  private static int parseTagString(final String localeID, final String tags[]) {
    LocaleIDParser parser = new LocaleIDParser(localeID);

    String lang = parser.getLanguage();
    String script = parser.getScript();
    String region = parser.getCountry();

    if (isEmptyString(lang)) {
      tags[0] = UNDEFINED_LANGUAGE;
    } else {
      tags[0] = lang;
    }

    if (script.equals(UNDEFINED_SCRIPT)) {
      tags[1] = "";
    } else {
      tags[1] = script;
    }

    if (region.equals(UNDEFINED_REGION)) {
      tags[2] = "";
    } else {
      tags[2] = region;
    }

    /*
     * Search for the variant.  If there is one, then return the index of
     * the preceeding separator.
     * If there's no variant, search for the keyword delimiter,
     * and return its index.  Otherwise, return the length of the
     * string.
     *
     * $TOTO(dbertoni) we need to take into account that we might
     * find a part of the language as the variant, since it can
     * can have a variant portion that is long enough to contain
     * the same characters as the variant.
     */
    String variant = parser.getVariant();

    if (!isEmptyString(variant)) {
      int index = localeID.indexOf(variant);

      return index > 0 ? index - 1 : index;
View Full Code Here

      if (locStr.length() == 0) {
        uloc = ULocale.ROOT;
      } else {
        for (String[] element : JAVA6_MAPDATA) {
          if (element[0].equals(locStr)) {
            LocaleIDParser p = new LocaleIDParser(element[1]);
            p.setKeywordValue(element[2], element[3]);
            locStr = p.getName();
            break;
          }
        }
        uloc = new ULocale(getName(locStr), loc);
      }
View Full Code Here

            locstr = element[0];
            break;
          }
        }
      }
      LocaleIDParser p = new LocaleIDParser(locstr);
      String[] names = p.getLanguageScriptCountryVariant();
      return new Locale(names[0], names[2], names[3]);
    }
View Full Code Here

            if (locStr.length() == 0) {
                uloc = ULocale.ROOT;
            } else {
                for (int i = 0; i < JAVA6_MAPDATA.length; i++) {
                    if (JAVA6_MAPDATA[i][0].equals(locStr)) {
                        LocaleIDParser p = new LocaleIDParser(JAVA6_MAPDATA[i][1]);
                        p.setKeywordValue(JAVA6_MAPDATA[i][2], JAVA6_MAPDATA[i][3]);
                        locStr = p.getName();
                        break;
                    }
                }
                uloc = new ULocale(getName(locStr), loc);
            }
View Full Code Here

                        locstr = JAVA6_MAPDATA[i][0];
                        break;
                    }
                }
            }
            LocaleIDParser p = new LocaleIDParser(locstr);
            String[] names = p.getLanguageScriptCountryVariant();
            return new Locale(names[0], names[2], names[3]);
        }
View Full Code Here

     * @see #getDisplayLanguage()
     * @see #getDisplayLanguage(ULocale)
     * @stable ICU 3.0
     */
    public static String getLanguage(String localeID) {
        return new LocaleIDParser(localeID).getLanguage();
    }
View Full Code Here

     * @see #getDisplayScript()
     * @see #getDisplayScript(ULocale)
     * @stable ICU 3.0
     */
    public static String getScript(String localeID) {
        return new LocaleIDParser(localeID).getScript();
    }
View Full Code Here

     * @see #getDisplayCountry()
     * @see #getDisplayCountry(ULocale)
     * @stable ICU 3.0
     */
    public static String getCountry(String localeID) {
        return new LocaleIDParser(localeID).getCountry();
    }
View Full Code Here

     * @see #getDisplayVariant()
     * @see #getDisplayVariant(ULocale)
     * @stable ICU 3.0
     */
    public static String getVariant(String localeID) {
        return new LocaleIDParser(localeID).getVariant();
    }
View Full Code Here

TOP

Related Classes of com.ibm.icu.impl.LocaleIDParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.