public static ULocale getDefault ( Category category ) { synchronized ( ULocale . class ) { int idx = category . ordinal ( ) ; if ( defaultCategoryULocales [ idx ] == null ) { // Just in case this method is called during ULocale class // initialization. Unlike getDefault(), we do not have // cyclic dependency for category default. return ULocale . ROOT ; } if ( JDKLocaleHelper . hasLocaleCategories ( ) ) { Locale currentCategoryDefault = JDKLocaleHelper . getDefault ( category ) ; if ( ! defaultCategoryLocales [ idx ] . equals ( currentCategoryDefault ) ) { defaultCategoryLocales [ idx ] = currentCategoryDefault ; defaultCategoryULocales [ idx ] = forLocale ( currentCategoryDefault ) ; } } else { // java.util.Locale.setDefault(Locale) in Java 7 updates // category locale defaults. On Java 6 or older environment, // ICU4J checks if the default locale has changed and update // category ULocales here if necessary. // Note: When java.util.Locale.setDefault(Locale) is called // with a Locale same with the previous one, Java 7 still // updates category locale defaults. On Java 6 or older env, // there is no good way to detect the event, ICU4J simply // check if the default Java Locale has changed since last // time. Locale currentDefault = Locale . getDefault ( ) ; if ( ! defaultLocale . equals ( currentDefault ) ) { defaultLocale = currentDefault ; defaultULocale = forLocale ( currentDefault ) ; for ( Category cat : Category . values ( ) ) { int tmpIdx = cat . ordinal ( ) ; defaultCategoryLocales [ tmpIdx ] = currentDefault ; defaultCategoryULocales [ tmpIdx ] = forLocale ( currentDefault ) ; } } // No synchronization with JDK Locale, because category default // is not supported in Java 6 or older versions } return defaultCategoryULocales [ idx ] ; } }
Returns the current default ULocale for the specified category .