Class LocaleParser
java.lang.Object
ch.tocco.nice2.textresources.api.locale.LocaleParser
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionparseLocalesString(String localesString) Works on a comma-separated list, for example "da, en-GB"@Nullable LocaleparseLocaleString(@Nullable String localeString) @Nullable LocaleparseLocaleStringNoEx(String localeString) Calls parseLocaleString() and swallows an IllegalArgumentException, returning null instead.voidOnly standard rules allowed, but still no ISO code validation.
-
Constructor Details
-
LocaleParser
public LocaleParser()Creates a non-strict parser. -
LocaleParser
public LocaleParser(boolean strict)
-
-
Method Details
-
setToStrictMode
public void setToStrictMode()Only standard rules allowed, but still no ISO code validation.It is a shortcut for: setLanguageCountrySeparators("_") setCheckCase(true) -
parseLocaleString
@Nullable public @Nullable Locale parseLocaleString(@Nullable @Nullable String localeString) throws IllegalArgumentException - Parameters:
localeString- Trim it.- Returns:
- A locale, or null when input is empty or null.
- Throws:
IllegalArgumentException- On invalid syntax, seesetToStrictMode().
-
parseLocaleStringNoEx
-
parseLocalesString
Works on a comma-separated list, for example "da, en-GB"- Parameters:
localesString- (may be null)- Returns:
- Ordered Set, may be empty
- Throws:
IllegalArgumentException- on first parse or validation error
-