Class AcceptLanguage
- java.lang.Object
-
- org.apache.tomcat.util.http.parser.AcceptLanguage
-
public class AcceptLanguage extends java.lang.ObjectRepresents a single language entry from an Accept-Language header.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAcceptLanguage(java.util.Locale locale, double quality)Constructs a new AcceptLanguage.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.LocalegetLocale()Returns the locale.doublegetQuality()Returns the quality value.static java.util.List<AcceptLanguage>parse(java.io.StringReader input)Parses an Accept-Language header value.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
-
getLocale
public java.util.Locale getLocale()
Returns the locale.- Returns:
- The locale of this language entry
-
getQuality
public double getQuality()
Returns the quality value.- Returns:
- The quality value of this language entry
-
parse
public static java.util.List<AcceptLanguage> parse(java.io.StringReader input) throws java.io.IOException
Parses an Accept-Language header value.- Parameters:
input- The StringReader containing the header value- Returns:
- A list of AcceptLanguage entries in the order they appear in the header
- Throws:
java.io.IOException- If an I/O error occurs while reading the input
-
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. Parsing stops as soon as the maximum number of entries has been read. This limits the number of Locale objects created when the caller has no use for entries beyond the limit (e.g. when a container level limit means the request is going to be rejected).- 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 sorted by quality. 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
-
-