/** * Parses a language tag array from the specified string values. * * @param values The string values. May be {@code null}. * * @return The language tag array, or {@code null} if the parsed string * array is null. * * @throws LangTagException If parsing failed. */ public static LangTag[] parseLangTagArray(final String ... values) throws LangTagException { if (values == null) return null; LangTag[] out = new LangTag[values.length]; for (int i=0; i < values.length; i++) { out[i] = LangTag.parse(values[i]); } return out; }
/** * Parses a language tag list from the specified string values. * * @param values The string values. May be {@code null}. * * @return The language tag list, or {@code null} if the parsed string * array is null. * * @throws LangTagException If parsing failed. */ public static List<LangTag> parseLangTagList(final String ... values) throws LangTagException { if (values == null) return null; List<LangTag> out = new ArrayList<LangTag>(values.length); for (String s: values) { out.add(LangTag.parse(s)); } return out; }
/** * Parses a language tag list from the specified string collection. * * @param collection The string collection. May be {@code null}. * * @return The language tag list, or {@code null} if the parsed string * collection is null. * * @throws LangTagException If parsing failed. */ public static List<LangTag> parseLangTagList(final Collection<String> collection) throws LangTagException { if (collection == null) return null; List<LangTag> out = new ArrayList<LangTag>(collection.size()); for (String s: collection) { out.add(LangTag.parse(s)); } return out; }
/** * Extracts the language tag, if any is found, from the specified * string. * * <p>Example: * * <pre> * "name#bg-BG" => "bg-BG" * "name#" => null * "name" => null * </pre> * * @param s The string. May contain a language tag. May be * {@code null}. * * @return The extracted language tag, {@code null} if not found. * * @throws LangTagException If the language tag is invalid. */ public static LangTag extract(final String s) throws LangTagException { if (s == null) return null; final int pos = s.indexOf('#'); if (pos < 0 || s.length() < pos + 1) return null; return LangTag.parse(s.substring(pos + 1)); }
langTag = LangTag.parse(parts[1]);
langTag = LangTag.parse(opt.substring("lang-".length())); break;