Java Code Examples for java.util.Locale#Category

The following examples show how to use java.util.Locale#Category . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ULocale.java    From j2objc with Apache License 2.0 5 votes vote down vote up
public static Locale getDefault(Category category) {
    Locale.Category cat = null;
    switch (category) {
    case DISPLAY:
        cat = Locale.Category.DISPLAY;
        break;
    case FORMAT:
        cat = Locale.Category.FORMAT;
        break;
    }
    return Locale.getDefault(cat);
}
 
Example 2
Source File: ULocale.java    From j2objc with Apache License 2.0 5 votes vote down vote up
public static void setDefault(Category category, Locale newLocale) {
    Locale.Category cat = null;
    switch (category) {
    case DISPLAY:
        cat = Locale.Category.DISPLAY;
        break;
    case FORMAT:
        cat = Locale.Category.FORMAT;
        break;
    }
    Locale.setDefault(cat, newLocale);
}
 
Example 3
Source File: TLocale.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
public static Locale getDefault(final Locale.Category aCategory) {
    return getDefault();
}
 
Example 4
Source File: WKTFormat.java    From sis with Apache License 2.0 3 votes vote down vote up
/**
 * Returns the locale for the given category. This method implements the following mapping:
 *
 * <ul>
 *   <li>{@link java.util.Locale.Category#FORMAT}: the value of {@link Symbols#getLocale()},
 *       normally fixed to {@link Locale#ROOT}, used for number formatting.</li>
 *   <li>{@link java.util.Locale.Category#DISPLAY}: the {@code locale} given at construction time,
 *       used for {@link InternationalString} localization.</li>
 * </ul>
 *
 * @param  category  the category for which a locale is desired.
 * @return the locale for the given category (never {@code null}).
 */
@Override
public Locale getLocale(final Locale.Category category) {
    if (category == Locale.Category.FORMAT) {
        return symbols.getLocale();
    }
    return super.getLocale(category);
}
 
Example 5
Source File: StatisticsFormat.java    From sis with Apache License 2.0 3 votes vote down vote up
/**
 * Returns the locale for the given category. This method implements the following mapping:
 *
 * <ul>
 *   <li>{@link java.util.Locale.Category#DISPLAY} — the {@code headerLocale} given at construction time.</li>
 *   <li>{@link java.util.Locale.Category#FORMAT} — the {@code locale} given at construction time,
 *       used for all values below the header row.</li>
 * </ul>
 *
 * @param  category  the category for which a locale is desired.
 * @return the locale for the given category (never {@code null}).
 *
 * @since 0.4
 */
@Override
public Locale getLocale(final Locale.Category category) {
    if (category == Locale.Category.DISPLAY) {
        return headerLocale;
    }
    return super.getLocale(category);
}
 
Example 6
Source File: ParameterFormat.java    From sis with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the locale for the given category.
 *
 * <ul>
 *   <li>{@link java.util.Locale.Category#FORMAT} specifies the locale to use for values.</li>
 *   <li>{@link java.util.Locale.Category#DISPLAY} specifies the locale to use for labels.</li>
 * </ul>
 *
 * @param  category  the category for which a locale is desired.
 * @return the locale for the given category (never {@code null}).
 */
@Override
public Locale getLocale(final Locale.Category category) {
    return (category == Locale.Category.DISPLAY) ? displayLocale : super.getLocale(category);
}
 
Example 7
Source File: FeatureFormat.java    From sis with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the locale for the given category.
 *
 * <ul>
 *   <li>{@link java.util.Locale.Category#FORMAT} specifies the locale to use for values.</li>
 *   <li>{@link java.util.Locale.Category#DISPLAY} specifies the locale to use for labels.</li>
 * </ul>
 *
 * @param  category  the category for which a locale is desired.
 * @return the locale for the given category (never {@code null}).
 */
@Override
public Locale getLocale(final Locale.Category category) {
    return (category == Locale.Category.DISPLAY) ? displayLocale : super.getLocale(category);
}
 
Example 8
Source File: CompoundFormat.java    From sis with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the locale for the given category. Subclasses may override this method in order to assign
 * different roles to the different locale categories. A typical (but not mandatory) mapping is:
 *
 * <ul>
 *   <li>{@link java.util.Locale.Category#FORMAT} specifies the locale to use for numbers, dates and angles formatting.</li>
 *   <li>{@link java.util.Locale.Category#DISPLAY} specifies the locale to use for {@link org.opengis.util.CodeList} labels
 *       and {@link org.opengis.util.InternationalString} contents.</li>
 * </ul>
 *
 * <div class="note"><b>Example:</b>
 * The ISO 19162 (<cite>Well Known Text</cite>) standard requires a number format similar to the one defined by
 * {@code Locale.ROOT} while it allows informative texts (remarks, <i>etc.</i>) to be formatted according the
 * user's locale. Consequently {@code WKTFormat} fixes (usually) the locale for {@code Category.FORMAT} to
 * {@code Locale.ROOT} and let {@code Category.DISPLAY} be any locale.</div>
 *
 * For subclasses that do not override this method, the default implementation returns {@link #getLocale()}.
 *
 * @param  category  the category for which a locale is desired.
 * @return the locale for the given category (never {@code null}).
 *
 * @since 0.4
 */
public Locale getLocale(final Locale.Category category) {
    ArgumentChecks.ensureNonNull("category", category);
    return getLocale();
}