Class AcceptLanguage2
- java.lang.Object
-
- org.apache.tomcat.util.http.parser.AcceptLanguage2
-
public final class AcceptLanguage2 extends java.lang.ObjectParser forAcceptLanguagethat parses an Accept-Language header value using the deprecatedLocale(String, String, String)constructor, combined with a custom BCP 47 subtag parser that maps the language tag components onto the language/country/variant triple that the deprecated constructor accepts. This is done for better efficiency.Known, accepted degradations compared with
Locale.forLanguageTag():- Unicode, other and private use extensions (e.g.
-u-ca-buddhist,-x-priv) are discarded rather than recorded on the Locale. - Script subtags (e.g.
-Hant-) cannot be represented by the deprecated constructor and are mapped to the Locale variant, in upper case, instead of to the Locale script. - Tags that are syntactically invalid after the language subtag retain
the components parsed up to that point rather than being replaced with
Locale.ROOT.
- Unicode, other and private use extensions (e.g.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.List<AcceptLanguage>parse(java.io.StringReader input, int maxElements)Parses an Accept-Language header value, reading at most the specified number of entries.
-
-
-
Method Detail
-
parse
public static java.util.List<AcceptLanguage> parse(java.io.StringReader input, int maxElements) throws java.io.IOException
Parses an Accept-Language header value, reading at most the specified number of entries. SeeAcceptLanguage.parse(StringReader, int).- Parameters:
input- The StringReader containing the header valuemaxElements- The maximum number of entries to parse or-1for no limit- Returns:
- A list of AcceptLanguage entries. If the limit was reached, the
returned list has exactly
maxElementsentries and any remaining entries were not parsed. - Throws:
java.io.IOException- If an I/O error occurs while reading the input
-
-