@Header(value="Accept-Language") public class AcceptLanguage extends BasicStringRangeArrayHeader
List of acceptable human languages for response.
Accept-Language: en-US
Accept-Language = "Accept-Language" ":" 1#( language-range [ ";" "q" "=" qvalue ] ) language-range = ( ( 1*8ALPHA *( "-" 1*8ALPHA ) ) | "*" )
Each language-range MAY be given an associated quality value which represents an estimate of the user's preference for the languages specified by that range. The quality value defaults to "q=1". For example...
Accept-Language: da, en-gb;q=0.8, en;q=0.7
...would mean: "I prefer Danish, but will accept British English and other types of English."
A language-range matches a language-tag if it exactly equals the tag, or if it exactly equals a prefix of the tag such that the first tag character following the prefix is "-".
The special range "*", if present in the Accept-Language field, matches every tag not matched by any other range present in the Accept-Language field.
Note: This use of a prefix matching rule does not imply that language tags are assigned to languages in such a way that it is always true that if a user understands a language with a certain tag, then this user will also understand all languages with tags for which this tag is a prefix. The prefix rule simply allows the use of prefix tags if this is the case.
The language quality factor assigned to a language-tag by the Accept-Language field is the quality value of the longest language- range in the field that matches the language-tag.
If no language- range in the field matches the tag, the language quality factor assigned is 0.
If no Accept-Language header is present in the request, the server SHOULD assume that all languages are equally acceptable.
If an Accept-Language header is present, then all languages which are assigned a quality factor greater than 0 are acceptable.
It might be contrary to the privacy expectations of the user to send an Accept-Language header with the complete linguistic preferences of the user in every request. For a discussion of this issue, see section 15.1.4.
As intelligibility is highly dependent on the individual user, it is recommended that client applications make the choice of linguistic preference available to the user. If the choice is not made available, then the Accept-Language header field MUST NOT be given in the request.
Note: When making the choice of linguistic preference available to the user, we remind implementors of the fact that users are not familiar with the details of language matching as described above, and should provide appropriate guidance. As an example, users might assume that on selecting "en-gb", they will be served any kind of English document if British English is not available. A user agent might suggest in such a case to add "en" to get the best matching behavior.
Constructor and Description |
---|
AcceptLanguage(Object value)
Constructor
|
AcceptLanguage(String value)
Constructor
|
Modifier and Type | Method and Description |
---|---|
static AcceptLanguage |
of(Object value)
Convenience creator.
|
static AcceptLanguage |
of(String value)
Returns a parsed and cached header.
|
static AcceptLanguage |
of(Supplier<?> value)
Convenience creator using supplier.
|
asRanges, getRange, getRanges, getValue, match, of, of
assertName, assertValue, canCast, cast, eqIC, equals, getElements, getName, getRawValue, hashCode, isSupplier, of, ofPair, toString, unwrap
public AcceptLanguage(Object value)
value
- The header value.
String
- Converted using StringRanges.of(String)
.
Supplier
of anything on this list.
public AcceptLanguage(String value)
value
- The header value.public static AcceptLanguage of(String value)
value
- The header value.AcceptLanguage
object.public static AcceptLanguage of(Object value)
value
- The header value.
String
- Converted using StringRanges.of(String)
.
AcceptLanguage
object.public static AcceptLanguage of(Supplier<?> value)
Header value is re-evaluated on each call to BasicStringRangeArrayHeader.getValue()
.
value
- The header value supplier.
String
- Converted using StringRanges.of(String)
.
AcceptLanguage
object.Copyright © 2016–2020 The Apache Software Foundation. All rights reserved.