| Modifier and Type | Class and Description |
|---|---|
protected static class |
LocaleFilter.FilterType
Type of locale filter.
|
| Constructor and Description |
|---|
LocaleFilter()
Public constructor.
|
LocaleFilter(String string)
Public constructor.
|
| Modifier and Type | Method and Description |
|---|---|
static LocaleFilter |
any()
Creates a filter of the Any type.
|
static LocaleFilter |
anyExcept(LocaleId... localeIds)
Creates a filter filtering out the given locales.
|
static LocaleFilter |
anyOf(LocaleId... localeIds)
Creates a filter allowing only the given locales.
|
static LocaleFilter |
build(String string)
Builds a filter from a configuration string.
|
LocaleFilter |
exclude(List<LocaleId> localeIds)
Disallows the locales from a given list of locales.
|
LocaleFilter |
exclude(LocaleFilter filter)
Disallows all locales allowed in a given locale filter.
|
LocaleFilter |
exclude(LocaleId... localeIds)
Disallows the locales from a given array of locales.
|
LocaleFilter |
exclude(LocaleId localeId)
Disallows a given locale.
|
LocaleFilter |
exclude(Set<LocaleId> localeIds)
Disallows the locales from a given set of locales.
|
LocaleFilter |
excludeLanguage(String... languages)
Disallows the locales which language matches any of the languages from a given array.
|
LocaleFilter |
excludeLanguage(String language)
Disallows the locales which language matches a given language.
|
LocaleFilter |
excludePattern(String regex)
Disallows all locales matching a given regular expression.
|
LocaleFilter |
excludePattern(String regex,
int flags)
Disallows all locales matching a given regular expression with a given set of regex flags.
|
LocaleFilter |
excludeRegion(String... regions)
Disallows the locales which region matches any of the regions from a given array.
|
LocaleFilter |
excludeRegion(String region)
Disallows the locales which region matches a given region.
|
LocaleFilter |
excludeUserPart(String... userParts)
Disallows the locales which user part matches any of the user parts from a given array.
|
LocaleFilter |
excludeUserPart(String userPart)
Disallows the locales which user part matches a given user part.
|
Set<LocaleId> |
filter(LocaleId... localeIds)
Creates a subset of the locales from a given array, which are allowed by this locale filter.
|
LocaleFilter |
fromString(String string)
Configures this locale filter from a given configuration string.
|
List<LocaleId> |
getExcludes()
Gets a list of disallowed locales.
|
List<String> |
getExplicitLocaleIds()
If the filter contains only explicitly listed locales (no regex patterns or masks), then returns the list of
locale tags of those locales.
|
static String |
getExplicitLocaleIds(String string)
Determines if a given string contains only explicitly listed locales.
|
List<LocaleId> |
getIncludes()
Gets a list of allowed locales.
|
List<String> |
getLanguageExcludes()
Gets a list of disallowed languages.
|
List<String> |
getLanguageIncludes()
Gets a list of allowed languages.
|
List<Pattern> |
getPatternExcludes()
Gets a list of compiled regular expressions for disallowed locales.
|
List<Pattern> |
getPatternIncludes()
Gets a list of compiled regular expressions for allowed locales.
|
List<String> |
getRegionExcludes()
Gets a list of disallowed regions.
|
List<String> |
getRegionIncludes()
Gets a list of allowed regions.
|
protected LocaleFilter.FilterType |
getType()
Helper method.
|
List<String> |
getUserPartExcludes()
Gets a list of disallowed user parts.
|
List<String> |
getUserPartIncludes()
Gets a list of allowed user parts.
|
LocaleFilter |
include(List<LocaleId> localeIds)
Allows the locales from a given list of locales.
|
LocaleFilter |
include(LocaleFilter filter)
Allows all locales allowed in a given locale filter.
|
LocaleFilter |
include(LocaleId... localeIds)
Allows the locales from a given array of locales.
|
LocaleFilter |
include(LocaleId localeId)
Allows a given locale.
|
LocaleFilter |
include(Set<LocaleId> localeIds)
Allows the locales from a given set of locales.
|
LocaleFilter |
includeLanguage(String... languages)
Allows the locales which language matches any of the languages from a given array.
|
LocaleFilter |
includeLanguage(String language)
Allows the locales which language matches a given language.
|
LocaleFilter |
includePattern(String regex)
Allows all locales matching a given regular expression.
|
LocaleFilter |
includePattern(String regex,
int flags)
Allows all locales matching a given regular expression with a given set of regex flags.
|
LocaleFilter |
includeRegion(String... regions)
Allows the locales which region matches any of the regions from a given array.
|
LocaleFilter |
includeRegion(String region)
Allows the locales which region matches a given region.
|
LocaleFilter |
includeUserPart(String... userParts)
Allows the locales which user part matches any of the user parts from a given array.
|
LocaleFilter |
includeUserPart(String userPart)
Allows the locales which user part matches a given user part.
|
boolean |
isEmpty()
Detects if after construction this locale filter was configured with includeXX(), excludeXX().
|
boolean |
matches(LocaleId localeId)
Returns true if a given locale is allowed by this locale filter.
|
static LocaleFilter |
none()
Creates a filter of the None type.
|
LocaleFilter |
reset()
Resets this locale filter to its original right-after-construction state (all settings made with includeXX(),
excludeXX() are neglected).
|
protected void |
setType(LocaleFilter.FilterType type)
Helper method.
|
String |
toString()
Constructs a configuration string for this locale filter.
|
public LocaleFilter()
public LocaleFilter(String string)
string - the configuration string of locale filter. See fromString(java.lang.String) for details.public static LocaleFilter any()
public static LocaleFilter none()
public static LocaleFilter anyOf(LocaleId... localeIds)
localeIds - an array of allowed LocaleId objects.public static LocaleFilter anyExcept(LocaleId... localeIds)
localeIds - an array of the LocaleId objects to disallow.public static LocaleFilter build(String string)
fromString(java.lang.String) for details on the string format.string - the parameters string.public LocaleFilter include(LocaleId localeId)
localeId - the given locale.public LocaleFilter include(LocaleId... localeIds)
localeIds - the given array of locales.public LocaleFilter include(Set<LocaleId> localeIds)
localeIds - the given set of locales.public LocaleFilter include(List<LocaleId> localeIds)
localeIds - the given list of locales.public LocaleFilter include(LocaleFilter filter)
filter - the given locale filter.public LocaleFilter includePattern(String regex, int flags)
regex - the given regular expression.flags - the given set of regex flags.public LocaleFilter includePattern(String regex)
regex - the given regular expression.public LocaleFilter includeLanguage(String... languages)
languages - the given array of languages.public LocaleFilter includeLanguage(String language)
language - the given language.public LocaleFilter includeRegion(String... regions)
regions - the given array of regions.public LocaleFilter includeRegion(String region)
region - the given region.public LocaleFilter includeUserPart(String... userParts)
userParts - the given array of user parts.public LocaleFilter includeUserPart(String userPart)
userPart - the given user part.public LocaleFilter exclude(LocaleId localeId)
localeId - the given locale.public LocaleFilter exclude(LocaleId... localeIds)
localeIds - the given array of locales.public LocaleFilter exclude(Set<LocaleId> localeIds)
localeIds - the given set of locales.public LocaleFilter exclude(List<LocaleId> localeIds)
localeIds - the given list of locales.public LocaleFilter exclude(LocaleFilter filter)
filter - the given locale filter.public LocaleFilter excludePattern(String regex, int flags)
regex - the given regular expression.flags - the given set of regex flags.public LocaleFilter excludePattern(String regex)
regex - the given regular expression.public LocaleFilter excludeLanguage(String... languages)
languages - the given array of languages.public LocaleFilter excludeLanguage(String language)
language - the given language.public LocaleFilter excludeRegion(String... regions)
regions - the given array of regions.public LocaleFilter excludeRegion(String region)
region - the given region.public LocaleFilter excludeUserPart(String... userParts)
userParts - the given array of user parts.public LocaleFilter excludeUserPart(String userPart)
userPart - the given user part.public LocaleFilter reset()
public boolean matches(LocaleId localeId)
localeId - the given locale.public Set<LocaleId> filter(LocaleId... localeIds)
localeIds - the given array.public List<LocaleId> getIncludes()
public List<LocaleId> getExcludes()
public List<String> getLanguageIncludes()
public List<String> getRegionIncludes()
public List<String> getUserPartIncludes()
public List<String> getLanguageExcludes()
public List<String> getRegionExcludes()
public List<String> getUserPartExcludes()
public List<Pattern> getPatternIncludes()
public List<Pattern> getPatternExcludes()
protected LocaleFilter.FilterType getType()
protected void setType(LocaleFilter.FilterType type)
type - None or Any locale filter type.public boolean isEmpty()
public LocaleFilter fromString(String string)
string - the given configuration string.
The string consists of locale descriptors. The locale descriptors are delimited with a comma or space.
* -- field mask, can be used in either language, region, or user part fields of a locale descriptor.
! -- exclude prefix.
@ -- regex prefix.
^ -- regex flags prefix.
Examples:
public String toString()
public List<String> getExplicitLocaleIds()
public static String getExplicitLocaleIds(String string)
string - the given locale filter configuration string. See fromString(java.lang.String) for details.Copyright © 2022. All rights reserved.