Package com.azure.core.util
Class Header
- java.lang.Object
-
- com.azure.core.util.Header
-
- Direct Known Subclasses:
HttpHeader
public class Header extends Object
Represents a single header to be set on a request.If multiple header values are added to a request with the same name (case-insensitive), then the values will be appended at the end of the same
Header
with commas separating them.
-
-
Constructor Summary
Constructors Constructor Description Header(String name, String value)
Create a Header instance using the provided name and value.Header(String name, String... values)
Create a Header instance using the provided name and values.Header(String name, List<String> values)
Create a Header instance using the provided name and values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addValue(String value)
Add a new value to the end of the Header.String
getName()
Gets the header name.String
getValue()
Gets the combined, comma-separated value of thisHeader
, taking into account all values provided.String[]
getValues()
Gets the comma separated value as an array.List<String>
getValuesList()
Returns all values associated with this header, represented as an unmodifiable list of strings.String
toString()
Gets the String representation of the header.
-
-
-
Constructor Detail
-
Header
public Header(String name, String value)
Create a Header instance using the provided name and value.- Parameters:
name
- the name of the header.value
- the value of the header.- Throws:
NullPointerException
- ifname
is null.
-
Header
public Header(String name, String... values)
Create a Header instance using the provided name and values.- Parameters:
name
- the name of the header.values
- the values of the header.- Throws:
NullPointerException
- ifname
is null.
-
Header
public Header(String name, List<String> values)
Create a Header instance using the provided name and values.- Parameters:
name
- the name of the header.values
- the values of the header.- Throws:
NullPointerException
- ifname
is null.
-
-
Method Detail
-
getValue
public String getValue()
Gets the combined, comma-separated value of thisHeader
, taking into account all values provided.- Returns:
- the value of this Header
-
getValues
public String[] getValues()
Gets the comma separated value as an array. Changes made to this array will not be reflected in the headers.- Returns:
- the values of this
Header
that are separated by a comma
-
getValuesList
public List<String> getValuesList()
Returns all values associated with this header, represented as an unmodifiable list of strings.- Returns:
- An unmodifiable list containing all values associated with this header.
-
addValue
public void addValue(String value)
Add a new value to the end of the Header.- Parameters:
value
- the value to add
-
-