Package com.ibm.icu.impl.locale

Examples of com.ibm.icu.impl.locale.InternalLocaleBuilder


    if (base.getVariant().equalsIgnoreCase("POSIX")) {
      // special handling for variant POSIX
      base = BaseLocale.getInstance(base.getLanguage(), base.getScript(), base.getRegion(), "");
      if (exts.getUnicodeLocaleType("va") == null) {
        // add va-posix
        InternalLocaleBuilder ilocbld = new InternalLocaleBuilder();
        try {
          ilocbld.setLocale(BaseLocale.ROOT, exts);
          ilocbld.setUnicodeLocaleKeyword("va", "posix");
          exts = ilocbld.getLocaleExtensions();
        } catch (LocaleSyntaxException e) {
          // this should not happen
          throw new RuntimeException(e);
        }
      }
View Full Code Here


   *
   * @stable ICU 4.2
   */
  public static ULocale forLanguageTag(final String languageTag) {
    LanguageTag tag = LanguageTag.parse(languageTag, null);
    InternalLocaleBuilder bldr = new InternalLocaleBuilder();
    bldr.setLanguageTag(tag);
    return getInstance(bldr.getBaseLocale(), bldr.getLocaleExtensions());
  }
View Full Code Here

    if (extensions == null) {
      Iterator<String> kwitr = getKeywords();
      if (kwitr == null) {
        extensions = LocaleExtensions.EMPTY_EXTENSIONS;
      } else {
        InternalLocaleBuilder intbld = new InternalLocaleBuilder();
        while (kwitr.hasNext()) {
          String key = kwitr.next();
          if (key.equals(LOCALE_ATTRIBUTE_KEY)) {
            // special keyword used for representing Unicode locale attributes
            String[] uattributes = getKeywordValue(key).split("[-_]");
            for (String uattr : uattributes) {
              try {
                intbld.addUnicodeLocaleAttribute(uattr);
              } catch (LocaleSyntaxException e) {
                // ignore and fall through
              }
            }
          } else if (key.length() >= 2) {
            String bcpKey = ldmlKeyToBCP47(key);
            String bcpType = ldmlTypeToBCP47(key, getKeywordValue(key));
            if (bcpKey != null && bcpType != null) {
              try {
                intbld.setUnicodeLocaleKeyword(bcpKey, bcpType);
              } catch (LocaleSyntaxException e) {
                // ignore and fall through
              }
            }
          } else if (key.length() == 1 && (key.charAt(0) != UNICODE_LOCALE_EXTENSION)) {
            try {
              intbld.setExtension(key.charAt(0), getKeywordValue(key).replace("_", LanguageTag.SEP));
            } catch (LocaleSyntaxException e) {
              // ignore and fall through
            }
          }
        }
        extensions = intbld.getLocaleExtensions();
      }
    }
    return extensions;
  }
View Full Code Here

     * Constructs an empty Builder. The default value of all fields, extensions, and private use information is the empty string.
     *
     * @stable ICU 4.2
     */
    public Builder() {
      _locbld = new InternalLocaleBuilder();
    }
View Full Code Here

         *
         * @obsolete ICU 4.4 to be removed
         * @deprecated This API is obsolete.
         */
        public Builder(boolean isLenientVariant) {
            _locbld = new InternalLocaleBuilder();
        }
View Full Code Here

        if (base.getVariant().equalsIgnoreCase("POSIX")) {
            // special handling for variant POSIX
            base = BaseLocale.getInstance(base.getLanguage(), base.getScript(), base.getRegion(), "");
            if (exts.getUnicodeLocaleType("va") == null) {
                // add va-posix
                InternalLocaleBuilder ilocbld = new InternalLocaleBuilder();
                try {
                    ilocbld.setLocale(BaseLocale.ROOT, exts);
                    ilocbld.setUnicodeLocaleKeyword("va", "posix");
                    exts = ilocbld.getLocaleExtensions();
                } catch (LocaleSyntaxException e) {
                    // this should not happen
                    throw new RuntimeException(e);
                }
            }
View Full Code Here

     * @draft ICU 4.2
     * @provisional This API might change or be removed in a future release.
     */
    public static ULocale forLanguageTag(String languageTag) {
        LanguageTag tag = LanguageTag.parse(languageTag, null);
        InternalLocaleBuilder bldr = new InternalLocaleBuilder();
        bldr.setLanguageTag(tag);
        return getInstance(bldr.getBaseLocale(), bldr.getLocaleExtensions());
    }
View Full Code Here

        if (extensions == null) {
            Iterator<String> kwitr = getKeywords();
            if (kwitr == null) {
                extensions = LocaleExtensions.EMPTY_EXTENSIONS;
            } else {
                InternalLocaleBuilder intbld = new InternalLocaleBuilder();
                while (kwitr.hasNext()) {
                    String key = kwitr.next();
                    if (key.equals(LOCALE_ATTRIBUTE_KEY)) {
                        // special keyword used for representing Unicode locale attributes
                        String[] uattributes = getKeywordValue(key).split("[-_]");
                        for (String uattr : uattributes) {
                            try {
                                intbld.addUnicodeLocaleAttribute(uattr);
                            } catch (LocaleSyntaxException e) {
                                // ignore and fall through
                            }
                        }
                    } else if (key.length() >= 2) {
                        String bcpKey = ldmlKeyToBCP47(key);
                        String bcpType = ldmlTypeToBCP47(key, getKeywordValue(key));
                        if (bcpKey != null && bcpType != null) {
                            try {
                                intbld.setUnicodeLocaleKeyword(bcpKey, bcpType);
                            } catch (LocaleSyntaxException e) {
                                // ignore and fall through
                            }
                        }
                    } else if (key.length() == 1 && (key.charAt(0) != UNICODE_LOCALE_EXTENSION)) {
                        try  {
                            intbld.setExtension(key.charAt(0), getKeywordValue(key).replace("_",
                                    LanguageTag.SEP));
                        } catch (LocaleSyntaxException e) {
                            // ignore and fall through
                        }
                    }
                }
                extensions = intbld.getLocaleExtensions();
            }
        }
        return extensions;
    }
View Full Code Here

         *
         * @draft ICU 4.2
         * @provisional This API might change or be removed in a future release.
         */
        public Builder() {
            _locbld = new InternalLocaleBuilder();
        }
View Full Code Here

TOP

Related Classes of com.ibm.icu.impl.locale.InternalLocaleBuilder

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.