< prev index next >

src/java.base/share/classes/java/util/Locale.java

Print this page




3217         @Override
3218         public boolean equals(Object obj) {
3219             if (this == obj) {
3220                 return true;
3221             }
3222             if (!(obj instanceof LanguageRange)) {
3223                 return false;
3224             }
3225             LanguageRange other = (LanguageRange)obj;
3226             return hash == other.hash
3227                    && range.equals(other.range)
3228                    && weight == other.weight;
3229         }
3230 
3231         /**
3232          * Returns an informative string representation of this {@code LanguageRange}
3233          * object, consisting of language range and weight if the range is
3234          * weighted and the weight is less than the max weight.
3235          *
3236          * @return a string representation of this {@code LanguageRange} object.

3237          */
3238         @Override
3239         public String toString() {
3240             return (weight == MAX_WEIGHT) ? range : range + ";q=" + weight;
3241         }
3242     }
3243 
3244     /**
3245      * Returns a list of matching {@code Locale} instances using the filtering
3246      * mechanism defined in RFC 4647.
3247      *
3248      * @param priorityList user's Language Priority List in which each language
3249      *     tag is sorted in descending order based on priority or weight
3250      * @param locales {@code Locale} instances used for matching
3251      * @param mode filtering mode
3252      * @return a list of {@code Locale} instances for matching language tags
3253      *     sorted in descending order based on priority or weight, or an empty
3254      *     list if nothing matches. The list is modifiable.
3255      * @throws NullPointerException if {@code priorityList} or {@code locales}
3256      *     is {@code null}




3217         @Override
3218         public boolean equals(Object obj) {
3219             if (this == obj) {
3220                 return true;
3221             }
3222             if (!(obj instanceof LanguageRange)) {
3223                 return false;
3224             }
3225             LanguageRange other = (LanguageRange)obj;
3226             return hash == other.hash
3227                    && range.equals(other.range)
3228                    && weight == other.weight;
3229         }
3230 
3231         /**
3232          * Returns an informative string representation of this {@code LanguageRange}
3233          * object, consisting of language range and weight if the range is
3234          * weighted and the weight is less than the max weight.
3235          *
3236          * @return a string representation of this {@code LanguageRange} object.
3237          * @since 9
3238          */
3239         @Override
3240         public String toString() {
3241             return (weight == MAX_WEIGHT) ? range : range + ";q=" + weight;
3242         }
3243     }
3244 
3245     /**
3246      * Returns a list of matching {@code Locale} instances using the filtering
3247      * mechanism defined in RFC 4647.
3248      *
3249      * @param priorityList user's Language Priority List in which each language
3250      *     tag is sorted in descending order based on priority or weight
3251      * @param locales {@code Locale} instances used for matching
3252      * @param mode filtering mode
3253      * @return a list of {@code Locale} instances for matching language tags
3254      *     sorted in descending order based on priority or weight, or an empty
3255      *     list if nothing matches. The list is modifiable.
3256      * @throws NullPointerException if {@code priorityList} or {@code locales}
3257      *     is {@code null}


< prev index next >