Class AcceptLanguage2
java.lang.Object
org.apache.tomcat.util.http.parser.AcceptLanguage2
Parser for
AcceptLanguage that parses an Accept-Language header
value using the deprecated Locale(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.
-
Method Summary
Modifier and TypeMethodDescriptionstatic List<AcceptLanguage> parse(StringReader input, int maxElements) Parses an Accept-Language header value, reading at most the specified number of entries.
-
Method Details
-
parse
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:
IOException- If an I/O error occurs while reading the input
-