java.util.spi.CalendarDataProvider Java Examples

The following examples show how to use java.util.spi.CalendarDataProvider. 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: CalendarDataUtility.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Integer getObject(CalendarDataProvider calendarDataProvider,
                         Locale locale,
                         String requestID,    // resource key
                         Object... params) {
    assert params.length == 0;
    int value;
    switch (requestID) {
    case FIRST_DAY_OF_WEEK:
        value = calendarDataProvider.getFirstDayOfWeek(locale);
        break;
    case MINIMAL_DAYS_IN_FIRST_WEEK:
        value = calendarDataProvider.getMinimalDaysInFirstWeek(locale);
        break;
    default:
        throw new InternalError("invalid requestID: " + requestID);
    }
    return (value != 0) ? value : null;
}
 
Example #2
Source File: CalendarDataUtility.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Integer getObject(CalendarDataProvider calendarDataProvider,
                         Locale locale,
                         String requestID,    // resource key
                         Object... params) {
    assert params.length == 0;
    int value;
    switch (requestID) {
    case FIRST_DAY_OF_WEEK:
        value = calendarDataProvider.getFirstDayOfWeek(locale);
        break;
    case MINIMAL_DAYS_IN_FIRST_WEEK:
        value = calendarDataProvider.getMinimalDaysInFirstWeek(locale);
        break;
    default:
        throw new InternalError("invalid requestID: " + requestID);
    }
    return (value != 0) ? value : null;
}
 
Example #3
Source File: JRELocaleProviderAdapter.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
@Override
public CalendarDataProvider getCalendarDataProvider() {
    if (calendarDataProvider == null) {
        CalendarDataProvider provider = AccessController.doPrivileged(
            (PrivilegedAction<CalendarDataProvider>) () ->
                new CalendarDataProviderImpl(
                    getAdapterType(),
                    getLanguageTagSet("CalendarData")));

        synchronized (this) {
            if (calendarDataProvider == null) {
                calendarDataProvider = provider;
            }
        }
    }
    return calendarDataProvider;
}
 
Example #4
Source File: CalendarDataUtility.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Integer getObject(CalendarDataProvider calendarDataProvider,
                         Locale locale,
                         String requestID,    // resource key
                         Object... params) {
    assert params.length == 0;
    int value;
    switch (requestID) {
    case FIRST_DAY_OF_WEEK:
        value = calendarDataProvider.getFirstDayOfWeek(locale);
        break;
    case MINIMAL_DAYS_IN_FIRST_WEEK:
        value = calendarDataProvider.getMinimalDaysInFirstWeek(locale);
        break;
    default:
        throw new InternalError("invalid requestID: " + requestID);
    }
    return (value != 0) ? value : null;
}
 
Example #5
Source File: CalendarDataUtility.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Integer getObject(CalendarDataProvider calendarDataProvider,
                         Locale locale,
                         String requestID,    // resource key
                         Object... params) {
    assert params.length == 0;
    int value;
    switch (requestID) {
    case FIRST_DAY_OF_WEEK:
        value = calendarDataProvider.getFirstDayOfWeek(locale);
        break;
    case MINIMAL_DAYS_IN_FIRST_WEEK:
        value = calendarDataProvider.getMinimalDaysInFirstWeek(locale);
        break;
    default:
        throw new InternalError("invalid requestID: " + requestID);
    }
    return (value != 0) ? value : null;
}
 
Example #6
Source File: CalendarDataUtility.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Integer getObject(CalendarDataProvider calendarDataProvider,
                         Locale locale,
                         String requestID,    // resource key
                         Object... params) {
    assert params.length == 0;
    int value;
    switch (requestID) {
    case FIRST_DAY_OF_WEEK:
        value = calendarDataProvider.getFirstDayOfWeek(locale);
        break;
    case MINIMAL_DAYS_IN_FIRST_WEEK:
        value = calendarDataProvider.getMinimalDaysInFirstWeek(locale);
        break;
    default:
        throw new InternalError("invalid requestID: " + requestID);
    }
    return (value != 0) ? value : null;
}
 
Example #7
Source File: CalendarDataUtility.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Integer getObject(CalendarDataProvider calendarDataProvider,
                         Locale locale,
                         String requestID,    // resource key
                         Object... params) {
    assert params.length == 0;
    int value;
    switch (requestID) {
    case FIRST_DAY_OF_WEEK:
        value = calendarDataProvider.getFirstDayOfWeek(locale);
        break;
    case MINIMAL_DAYS_IN_FIRST_WEEK:
        value = calendarDataProvider.getMinimalDaysInFirstWeek(locale);
        break;
    default:
        throw new InternalError("invalid requestID: " + requestID);
    }
    return (value != 0) ? value : null;
}
 
Example #8
Source File: CLDRLocaleProviderAdapter.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
@Override
public CalendarDataProvider getCalendarDataProvider() {
    if (calendarDataProvider == null) {
        CalendarDataProvider provider = AccessController.doPrivileged(
            (PrivilegedAction<CalendarDataProvider>) () ->
                new CLDRCalendarDataProviderImpl(
                    getAdapterType(),
                    getLanguageTagSet("CalendarData")));

        synchronized (this) {
            if (calendarDataProvider == null) {
                calendarDataProvider = provider;
            }
        }
    }
    return calendarDataProvider;
}
 
Example #9
Source File: JRELocaleProviderAdapter.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public CalendarDataProvider getCalendarDataProvider() {
    if (calendarDataProvider == null) {
        CalendarDataProvider provider = AccessController.doPrivileged(
            (PrivilegedAction<CalendarDataProvider>) () ->
                new CalendarDataProviderImpl(
                    getAdapterType(),
                    getLanguageTagSet("CalendarData")));

        synchronized (this) {
            if (calendarDataProvider == null) {
                calendarDataProvider = provider;
            }
        }
    }
    return calendarDataProvider;
}
 
Example #10
Source File: CalendarDataUtility.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Integer getObject(CalendarDataProvider calendarDataProvider,
                         Locale locale,
                         String requestID,    // resource key
                         Object... params) {
    assert params.length == 0;
    int value;
    switch (requestID) {
    case FIRST_DAY_OF_WEEK:
        value = calendarDataProvider.getFirstDayOfWeek(locale);
        break;
    case MINIMAL_DAYS_IN_FIRST_WEEK:
        value = calendarDataProvider.getMinimalDaysInFirstWeek(locale);
        break;
    default:
        throw new InternalError("invalid requestID: " + requestID);
    }
    return (value != 0) ? value : null;
}
 
Example #11
Source File: CalendarDataUtility.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static int retrieveFirstDayOfWeek(Locale locale) {
    LocaleServiceProviderPool pool =
            LocaleServiceProviderPool.getPool(CalendarDataProvider.class);
    Integer value = pool.getLocalizedObject(CalendarWeekParameterGetter.INSTANCE,
                                            locale, FIRST_DAY_OF_WEEK);
    return (value != null && (value >= SUNDAY && value <= SATURDAY)) ? value : SUNDAY;
}
 
Example #12
Source File: CalendarDataUtility.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static int retrieveMinimalDaysInFirstWeek(Locale locale) {
    LocaleServiceProviderPool pool =
            LocaleServiceProviderPool.getPool(CalendarDataProvider.class);
    Integer value = pool.getLocalizedObject(CalendarWeekParameterGetter.INSTANCE,
                                            locale, MINIMAL_DAYS_IN_FIRST_WEEK);
    return (value != null && (value >= 1 && value <= 7)) ? value : 1;
}
 
Example #13
Source File: JRELocaleProviderAdapter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public CalendarDataProvider getCalendarDataProvider() {
    if (calendarDataProvider == null) {
        CalendarDataProvider provider;
        provider = new CalendarDataProviderImpl(getAdapterType(),
                                                getLanguageTagSet("CalendarData"));
        synchronized (this) {
            if (calendarDataProvider == null) {
                calendarDataProvider = provider;
            }
        }
    }
    return calendarDataProvider;
}
 
Example #14
Source File: CalendarDataUtility.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static int retrieveMinimalDaysInFirstWeek(Locale locale) {
    LocaleServiceProviderPool pool =
            LocaleServiceProviderPool.getPool(CalendarDataProvider.class);
    Integer value = pool.getLocalizedObject(CalendarWeekParameterGetter.INSTANCE,
                                            locale, MINIMAL_DAYS_IN_FIRST_WEEK);
    return (value != null && (value >= 1 && value <= 7)) ? value : 1;
}
 
Example #15
Source File: CalendarDataUtility.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static int retrieveFirstDayOfWeek(Locale locale) {
    LocaleServiceProviderPool pool =
            LocaleServiceProviderPool.getPool(CalendarDataProvider.class);
    Integer value = pool.getLocalizedObject(CalendarWeekParameterGetter.INSTANCE,
                                            locale, FIRST_DAY_OF_WEEK);
    return (value != null && (value >= SUNDAY && value <= SATURDAY)) ? value : SUNDAY;
}
 
Example #16
Source File: CalendarDataUtility.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static int retrieveFirstDayOfWeek(Locale locale) {
    LocaleServiceProviderPool pool =
            LocaleServiceProviderPool.getPool(CalendarDataProvider.class);
    Integer value = pool.getLocalizedObject(CalendarWeekParameterGetter.INSTANCE,
                                            locale, FIRST_DAY_OF_WEEK);
    return (value != null && (value >= SUNDAY && value <= SATURDAY)) ? value : SUNDAY;
}
 
Example #17
Source File: CalendarDataUtility.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static int retrieveMinimalDaysInFirstWeek(Locale locale) {
    LocaleServiceProviderPool pool =
            LocaleServiceProviderPool.getPool(CalendarDataProvider.class);
    Integer value = pool.getLocalizedObject(CalendarWeekParameterGetter.INSTANCE,
                                            locale, MINIMAL_DAYS_IN_FIRST_WEEK);
    return (value != null && (value >= 1 && value <= 7)) ? value : 1;
}
 
Example #18
Source File: CalendarDataUtility.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static int retrieveMinimalDaysInFirstWeek(Locale locale) {
    LocaleServiceProviderPool pool =
            LocaleServiceProviderPool.getPool(CalendarDataProvider.class);
    Integer value = pool.getLocalizedObject(CalendarWeekParameterGetter.INSTANCE,
                                            locale, MINIMAL_DAYS_IN_FIRST_WEEK);
    return (value != null && (value >= 1 && value <= 7)) ? value : 1;
}
 
Example #19
Source File: CalendarDataUtility.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static int retrieveMinimalDaysInFirstWeek(Locale locale) {
    LocaleServiceProviderPool pool =
            LocaleServiceProviderPool.getPool(CalendarDataProvider.class);
    Integer value = pool.getLocalizedObject(CalendarWeekParameterGetter.INSTANCE,
                                            locale, MINIMAL_DAYS_IN_FIRST_WEEK);
    return (value != null && (value >= 1 && value <= 7)) ? value : 1;
}
 
Example #20
Source File: JRELocaleProviderAdapter.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public CalendarDataProvider getCalendarDataProvider() {
    if (calendarDataProvider == null) {
        CalendarDataProvider provider;
        provider = new CalendarDataProviderImpl(getAdapterType(),
                                                getLanguageTagSet("CalendarData"));
        synchronized (this) {
            if (calendarDataProvider == null) {
                calendarDataProvider = provider;
            }
        }
    }
    return calendarDataProvider;
}
 
Example #21
Source File: JRELocaleProviderAdapter.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public CalendarDataProvider getCalendarDataProvider() {
    if (calendarDataProvider == null) {
        CalendarDataProvider provider;
        provider = new CalendarDataProviderImpl(getAdapterType(),
                                                getLanguageTagSet("CalendarData"));
        synchronized (this) {
            if (calendarDataProvider == null) {
                calendarDataProvider = provider;
            }
        }
    }
    return calendarDataProvider;
}
 
Example #22
Source File: CalendarDataUtility.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static int retrieveFirstDayOfWeek(Locale locale) {
    LocaleServiceProviderPool pool =
            LocaleServiceProviderPool.getPool(CalendarDataProvider.class);
    Integer value = pool.getLocalizedObject(CalendarWeekParameterGetter.INSTANCE,
                                            locale, FIRST_DAY_OF_WEEK);
    return (value != null && (value >= SUNDAY && value <= SATURDAY)) ? value : SUNDAY;
}
 
Example #23
Source File: CalendarDataUtility.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public static int retrieveFirstDayOfWeek(Locale locale) {
    // Look for the Unicode Extension in the locale parameter
    if (locale.hasExtensions()) {
        String fw = locale.getUnicodeLocaleType("fw");
        if (fw != null) {
            switch (fw.toLowerCase(Locale.ROOT)) {
                case "mon":
                    return MONDAY;
                case "tue":
                    return TUESDAY;
                case "wed":
                    return WEDNESDAY;
                case "thu":
                    return THURSDAY;
                case "fri":
                    return FRIDAY;
                case "sat":
                    return SATURDAY;
                case "sun":
                    return SUNDAY;
            }
        }
    }

    LocaleServiceProviderPool pool =
            LocaleServiceProviderPool.getPool(CalendarDataProvider.class);
    Integer value = pool.getLocalizedObject(CalendarWeekParameterGetter.INSTANCE,
                                            findRegionOverride(locale),
                                            true, FIRST_DAY_OF_WEEK);
    return (value != null && (value >= SUNDAY && value <= SATURDAY)) ? value : SUNDAY;
}
 
Example #24
Source File: CalendarDataUtility.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public static int retrieveMinimalDaysInFirstWeek(Locale locale) {
    LocaleServiceProviderPool pool =
            LocaleServiceProviderPool.getPool(CalendarDataProvider.class);
    Integer value = pool.getLocalizedObject(CalendarWeekParameterGetter.INSTANCE,
                                            findRegionOverride(locale),
                                            true, MINIMAL_DAYS_IN_FIRST_WEEK);
    return (value != null && (value >= 1 && value <= 7)) ? value : 1;
}
 
Example #25
Source File: CalendarDataUtility.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
@Override
public Integer getObject(CalendarDataProvider calendarDataProvider,
                         Locale locale,
                         String requestID,    // resource key
                         Object... params) {
    assert params.length == 0;
    int value;
    switch (requestID) {
    case FIRST_DAY_OF_WEEK:
        value = calendarDataProvider.getFirstDayOfWeek(locale);
        if (value == 0) {
            value = MONDAY; // default for the world ("001")
        }
        break;
    case MINIMAL_DAYS_IN_FIRST_WEEK:
        value = calendarDataProvider.getMinimalDaysInFirstWeek(locale);
        if (value == 0) {
            value = 1; // default for the world ("001")
        }
        break;
    default:
        throw new InternalError("invalid requestID: " + requestID);
    }

    assert value != 0;
    return value;
}
 
Example #26
Source File: CalendarDataUtility.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static int retrieveMinimalDaysInFirstWeek(Locale locale) {
    LocaleServiceProviderPool pool =
            LocaleServiceProviderPool.getPool(CalendarDataProvider.class);
    Integer value = pool.getLocalizedObject(CalendarWeekParameterGetter.INSTANCE,
                                            locale, true, MINIMAL_DAYS_IN_FIRST_WEEK);
    return (value != null && (value >= 1 && value <= 7)) ? value : 1;
}
 
Example #27
Source File: CalendarDataUtility.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static int retrieveFirstDayOfWeek(Locale locale) {
    LocaleServiceProviderPool pool =
            LocaleServiceProviderPool.getPool(CalendarDataProvider.class);
    Integer value = pool.getLocalizedObject(CalendarWeekParameterGetter.INSTANCE,
                                            locale, true, FIRST_DAY_OF_WEEK);
    return (value != null && (value >= SUNDAY && value <= SATURDAY)) ? value : SUNDAY;
}
 
Example #28
Source File: CalendarDataUtility.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static int retrieveMinimalDaysInFirstWeek(Locale locale) {
    LocaleServiceProviderPool pool =
            LocaleServiceProviderPool.getPool(CalendarDataProvider.class);
    Integer value = pool.getLocalizedObject(CalendarWeekParameterGetter.INSTANCE,
                                            locale, MINIMAL_DAYS_IN_FIRST_WEEK);
    return (value != null && (value >= 1 && value <= 7)) ? value : 1;
}
 
Example #29
Source File: CalendarDataUtility.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static int retrieveFirstDayOfWeek(Locale locale) {
    LocaleServiceProviderPool pool =
            LocaleServiceProviderPool.getPool(CalendarDataProvider.class);
    Integer value = pool.getLocalizedObject(CalendarWeekParameterGetter.INSTANCE,
                                            locale, FIRST_DAY_OF_WEEK);
    return (value != null && (value >= SUNDAY && value <= SATURDAY)) ? value : SUNDAY;
}
 
Example #30
Source File: CalendarDataUtility.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static int retrieveMinimalDaysInFirstWeek(Locale locale) {
    LocaleServiceProviderPool pool =
            LocaleServiceProviderPool.getPool(CalendarDataProvider.class);
    Integer value = pool.getLocalizedObject(CalendarWeekParameterGetter.INSTANCE,
                                            locale, MINIMAL_DAYS_IN_FIRST_WEEK);
    return (value != null && (value >= 1 && value <= 7)) ? value : 1;
}