public class Headers extends Object
Constructor and Description |
---|
Headers()
Default constructor
|
Headers(Headers h)
Copy Constructor
|
Headers(Map<String,List<String>> headers)
Constructor that creates a new instance using a given Map
|
Modifier and Type | Method and Description |
---|---|
void |
add(String headerName,
List<String> values)
Adds a List of values for a header name to this object.
|
void |
add(String headerName,
String value)
Adds a value for a header name to this object.
|
void |
addAll(Headers headers)
Adds all the entries in a Headers object to this object
|
void |
addAllFromMap(Map<String,String> headers)
Adds values from a Map to this object
|
void |
addAllFromMultiMap(Map<String,List<String>> headers)
Adds values from a simulated Multi-Map to this object
|
Map<String,List<String>> |
asMultimap()
Returns a simulated MultiMap of the headers
|
Map<String,String> |
asSimpleMap()
Returns a Map of the headers, giving only one value for each header name
|
boolean |
has(String headerName)
Use to check if the given name is present in headers
|
Set<String> |
names()
Returns a Set containing all header names
|
List<String> |
remove(String headerName)
Removes the mapping for a header name if it is present.
|
String |
value(String headerName)
Returns the first value associated with a given header name, or null if the header name is not found
|
List<String> |
values(String headerName)
Returns a List of all values associated with a given header name, or null if the header name is not found
|
public Headers()
public Headers(Map<String,List<String>> headers)
headers
- The Map to use for creating an instance of this classpublic Headers(Headers h)
public boolean has(String headerName)
headerName
- public Set<String> names()
public String value(String headerName)
headerName
- The header name to find the associated value forpublic List<String> values(String headerName)
headerName
- The header name to find the associated values forpublic Map<String,String> asSimpleMap()
public Map<String,List<String>> asMultimap()
public void add(String headerName, String value)
Neither headerName nor value can be null
headerName
- The header name to add the value againstvalue
- The value to addpublic void add(String headerName, List<String> values)
Neither headerName nor values can be null
headerName
- The header name to add the values againstvalues
- The List of values to addpublic void addAllFromMap(Map<String,String> headers)
headers
- A Map containing header names and values as Entry pairspublic void addAllFromMultiMap(Map<String,List<String>> headers)
headers
- A Map containing header names and values as Entry pairspublic void addAll(Headers headers)
headers
- The object whose values are to be added to this objectpublic List<String> remove(String headerName)
Returns the value to which this map previously associated the key, or null if the map contained no mapping for the key.
headerName
- The header name to remove the associated values forCopyright © 2020. All rights reserved.