public final class HttpAcceptHeader extends Object
The quality values returned are floats from 0.0f to 1.0f.
For more info on Quality values see: Hypertext Transfer Protocol -- HTTP/1.1 - 3.9 Quality Values.
For more information on Accept HTTP headers, see: Hypertext Transfer Protocol -- HTTP/1.1 - 14 Header Field Definitions.
Implementation note: for efficiency the results are cached and reused.
Modifier and Type | Method and Description |
---|---|
static boolean |
accepts(Map<String,Float> accept,
String value)
Indicates whether the given 'Accept' header accepts the specified value.
|
static boolean |
accepts(String accept,
String value)
Indicates whether the given 'Accept' header accepts the specified value.
|
protected void |
clear()
Clears the internal cache.
|
static Map<String,Float> |
get(String accept)
Returns the list of accepted content types mapped to their quality level.
|
protected static Map<String,Float> |
parse(String accept)
Parses the accept header and returns the corresponding map.
|
public static Map<String,Float> get(String accept)
accept
- The 'Accept' HTTP/1.1 header.public static boolean accepts(String accept, String value)
To be acceptable the value must
accept
- The 'Accept' or 'Accept-*' HTTP/1.1 header.value
- The value to look for.true
if the specified value has a Q value strictly greater than 0;
false
otherwise.public static boolean accepts(Map<String,Float> accept, String value)
To be acceptable the value must
accept
- An accept map produced by this class.value
- The value to look for.true
if the specified value has a Q value strictly greater than 0;
false
otherwise.protected static Map<String,Float> parse(String accept)
accept
- The 'Accept' or 'Accept-*' HTTP/1.1 header.protected void clear()
Copyright © 2016 Allette Systems. All rights reserved.