// Is locale code set?
if (this.getLocaleCode() == null) {
// Throw NPE
- throw new NullPointerException("this.localeCode is null");
+ throw new NullPointerException("this.localeCode is null"); //NOI18N
} else if (this.getLocaleCode().isEmpty()) {
// Throw IAE
- throw new IllegalArgumentException("this.localeCode is empty");
+ throw new IllegalArgumentException("this.localeCode is empty"); //NOI18N
}
// Default new locale is null, will be handled later
// Iterate over whole map
for (Map.Entry<String, Locale> entry : this.getSupportedLocales().entrySet()) {
Locale foundLocale = entry.getValue();
- System.out.println(MessageFormat.format("foundLocale={0},this.localeCode={1}", foundLocale, this.getLocaleCode()));
// Does the language match?
if (Objects.equals(foundLocale.toString(), this.getLocaleCode())) {
this.clear();
// Has a matching locale
- System.out.println("newLocale=" + newLocale);
if (null == newLocale) {
// Throw NPE
- throw new NullPointerException("this.localeCode=" + this.getLocaleCode() + " cannot be found.");
+ throw new NullPointerException("this.localeCode=" + this.getLocaleCode() + " cannot be found."); //NOI18N
}
// Then change it
* @return Locale
*/
public Locale getLocale () {
- System.out.println("Getting this.locale=" + this.locale);
return this.locale;
}
* @param locale Locale
*/
public void setLocale (final Locale locale) {
- System.out.println("Setting locale=" + locale);
this.locale = locale;
}
* @return Language code
*/
public String getLocaleCode () {
- System.out.println("Getting this.localeCode=" + this.localeCode);
return this.localeCode;
}
* @param localeCode Language code
*/
public void setLocaleCode (final String localeCode) {
- System.out.println("Setting localeCode=" + localeCode);
this.localeCode = localeCode;
}
public void init () {
// Get default locale
Locale defaultLocale = FacesContext.getCurrentInstance().getApplication().getDefaultLocale();
- System.out.println("defaultLocale=" + defaultLocale);
// Add it to list
this.getSupportedLocales().put(defaultLocale.toString(), defaultLocale);
while (iterator.hasNext()) {
// Get next locale
Locale supportedLocale = iterator.next();
- System.out.println("supportedLocale=" + supportedLocale);
// Add it
this.getSupportedLocales().put(supportedLocale.toString(), supportedLocale);
// Is no country code found?
if (requestLocale.getCountry().isEmpty()) {
- // Then try to find one
- System.out.println("Request locale is without country information, looking up in map ...");
-
- // Get language from it
+ // Then try to find one, get language from it
String language = requestLocale.getLanguage();
Boolean found = Boolean.FALSE;
for (Map.Entry<String, Locale> entry : this.getSupportedLocales().entrySet()) {
String languageCode = entry.getKey();
Locale foundLocale = entry.getValue();
- System.out.println(MessageFormat.format("languageCode={0},language={1}", languageCode, language));
// Does the language match?
if (languageCode.startsWith(language)) {
// Is the locale language_country at least?
if (null == locale) {
// Throw NPE
- throw new NullPointerException("locale is null");
- } else if (!locale.toString().contains("_")) {
+ throw new NullPointerException("locale is null"); //NOI18N
+ } else if (!locale.toString().contains("_")) { //NOI18N
// Throw IAE
- throw new IllegalArgumentException(MessageFormat.format("locale={0} does not have country information set.", locale));
+ throw new IllegalArgumentException(MessageFormat.format("locale={0} does not have country information set.", locale)); //NOI18N
}
- System.out.println("Changing locale to " + locale + " ...");
-
// Set locale + code here
this.setLocale(locale);
this.setLocaleCode(locale.toString());