rt/emul/compact/src/main/java/java/util/Locale.java
changeset 1337 c794024954b5
parent 1320 e49c4c2c3737
child 1781 681e61714a1d
     1.1 --- a/rt/emul/compact/src/main/java/java/util/Locale.java	Sat Sep 28 02:45:17 2013 +0200
     1.2 +++ b/rt/emul/compact/src/main/java/java/util/Locale.java	Thu Oct 03 17:36:44 2013 +0200
     1.3 @@ -514,6 +514,15 @@
     1.4      private static final int DISPLAY_COUNTRY  = 1;
     1.5      private static final int DISPLAY_VARIANT  = 2;
     1.6      private static final int DISPLAY_SCRIPT   = 3;
     1.7 +
     1.8 +    static Locale getInstance(String language, String script, String region, String v, Object object) {
     1.9 +        return new Locale(language, script, region);
    1.10 +    }
    1.11 +
    1.12 +    static Locale getInstance(String no, String no0, String ny) {
    1.13 +        return new Locale(no, no0, ny);
    1.14 +    }
    1.15 +    
    1.16      private String language;
    1.17      private String country;
    1.18      private String variant;
    1.19 @@ -629,6 +638,26 @@
    1.20      }
    1.21  
    1.22      /**
    1.23 +     * Gets the current value of the default locale for the specified Category
    1.24 +     * for this instance of the Java Virtual Machine.
    1.25 +     * <p>
    1.26 +     * The Java Virtual Machine sets the default locale during startup based
    1.27 +     * on the host environment. It is used by many locale-sensitive methods
    1.28 +     * if no locale is explicitly specified. It can be changed using the
    1.29 +     * setDefault(Locale.Category, Locale) method.
    1.30 +     *
    1.31 +     * @param category - the specified category to get the default locale
    1.32 +     * @throws NullPointerException - if category is null
    1.33 +     * @return the default locale for the specified Category for this instance
    1.34 +     *     of the Java Virtual Machine
    1.35 +     * @see #setDefault(Locale.Category, Locale)
    1.36 +     * @since 1.7
    1.37 +     */
    1.38 +    public static Locale getDefault(Locale.Category category) {
    1.39 +        return Locale.US;
    1.40 +    }
    1.41 +    
    1.42 +    /**
    1.43       * Sets the default locale for this instance of the Java Virtual Machine.
    1.44       * This does not affect the host locale.
    1.45       * <p>
    1.46 @@ -938,5 +967,46 @@
    1.47          return true;
    1.48      }
    1.49  
    1.50 +    /**
    1.51 +     * Enum for locale categories.  These locale categories are used to get/set
    1.52 +     * the default locale for the specific functionality represented by the
    1.53 +     * category.
    1.54 +     *
    1.55 +     * @see #getDefault(Locale.Category)
    1.56 +     * @see #setDefault(Locale.Category, Locale)
    1.57 +     * @since 1.7
    1.58 +     */
    1.59 +    public enum Category {
    1.60 +
    1.61 +        /**
    1.62 +         * Category used to represent the default locale for
    1.63 +         * displaying user interfaces.
    1.64 +         */
    1.65 +        DISPLAY("user.language.display",
    1.66 +                "user.script.display",
    1.67 +                "user.country.display",
    1.68 +                "user.variant.display"),
    1.69 +
    1.70 +        /**
    1.71 +         * Category used to represent the default locale for
    1.72 +         * formatting dates, numbers, and/or currencies.
    1.73 +         */
    1.74 +        FORMAT("user.language.format",
    1.75 +               "user.script.format",
    1.76 +               "user.country.format",
    1.77 +               "user.variant.format");
    1.78 +
    1.79 +        Category(String languageKey, String scriptKey, String countryKey, String variantKey) {
    1.80 +            this.languageKey = languageKey;
    1.81 +            this.scriptKey = scriptKey;
    1.82 +            this.countryKey = countryKey;
    1.83 +            this.variantKey = variantKey;
    1.84 +        }
    1.85 +
    1.86 +        final String languageKey;
    1.87 +        final String scriptKey;
    1.88 +        final String countryKey;
    1.89 +        final String variantKey;
    1.90 +    }
    1.91  
    1.92  }