public final class LangTagUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static LangTag |
extract(String s)
Extracts the language tag, if any is found, from the specified
string.
|
static <T> Map<LangTag,T> |
find(String baseName,
Map<String,T> map)
Finds all language-tagged entries with the specified base name.
|
static LangTag[] |
parseLangTagArray(String... values)
Parses a language tag array from the specified string values.
|
static List<LangTag> |
parseLangTagList(Collection<String> collection)
Parses a language tag list from the specified string collection.
|
static List<LangTag> |
parseLangTagList(String... values)
Parses a language tag list from the specified string values.
|
static List<String> |
strip(List<String> list)
Strips the language tags, if any are found, from the specified
string list.
|
static Set<String> |
strip(Set<String> set)
Strips the language tags, if any are found, from the specified
string set.
|
static String |
strip(String s)
Strips the language tag, if any is found, from the specified string.
|
static String[] |
toStringArray(Collection<LangTag> langTags)
Returns a string array representation of the specified language tags
collection.
|
static List<String> |
toStringList(Collection<LangTag> langTags)
Returns a string list representation of the specified language tags
collection.
|
public static String strip(String s)
null safe.
Example:
"name#bg-BG" => "name" "name" => "name"
s - The string. May contain a language tag. May be
null.public static Set<String> strip(Set<String> set)
null safe.
Example:
"name#bg-BG" => "name" "name" => "name"
set - The string set. May contain strings with language tags.
May be null.public static List<String> strip(List<String> list)
null safe.
Example:
"name#bg-BG" => "name" "name" => "name"
list - The string list. May contain strings with language tags.
May be null.public static LangTag extract(String s) throws LangTagException
Example:
"name#bg-BG" => "bg-BG" "name#" => null "name" => null
s - The string. May contain a language tag. May be
null.null if not found.LangTagException - If the language tag is invalid.public static <T> Map<LangTag,T> find(String baseName, Map<String,T> map)
Example:
Map to search for base name "month":
"month" => "January" "month#de" => "Januar" "month#fr" => "janvier" "month#pt" => "janeiro"
Result:
null => "January" "de" => "Januar" "fr" => "janvier" "pt" => "janeiro"
baseName - The base name to look for (without a language tag)
in the map keys. Must not be null.map - The map to search. Must not be null.null keyed entry will indicate no
language tag (base name only).public static List<String> toStringList(Collection<LangTag> langTags)
langTags - The language tags list. May be null.null if the original list is
null.public static String[] toStringArray(Collection<LangTag> langTags)
langTags - The language tags list. May be null.null if the original list is
null.public static List<LangTag> parseLangTagList(Collection<String> collection) throws LangTagException
collection - The string collection. May be null.null if the parsed string
collection is null.LangTagException - If parsing failed.public static List<LangTag> parseLangTagList(String... values) throws LangTagException
values - The string values. May be null.null if the parsed string
array is null.LangTagException - If parsing failed.public static LangTag[] parseLangTagArray(String... values) throws LangTagException
values - The string values. May be null.null if the parsed string
array is null.LangTagException - If parsing failed.Copyright © 2018 Connect2id Ltd.. All rights reserved.