Sdílet prostřednictvím


Header Class

  • java.lang.Object
    • com.azure.core.util.Header

public class Header

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

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

Modifier and Type Method and 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 this Header, 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.

Methods inherited from java.lang.Object

Constructor Details

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.

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.

Header

public Header(String name, List values)

Create a Header instance using the provided name and values.

Parameters:

name - the name of the header.
values - the values of the header.

Method Details

addValue

public void addValue(String value)

Add a new value to the end of the Header.

Parameters:

value - the value to add

getName

public String getName()

Gets the header name.

Returns:

the name of this Header

getValue

public String getValue()

Gets the combined, comma-separated value of this Header, 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 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.

toString

public String toString()

Gets the String representation of the header.

Overrides:

Header.toString()

Returns:

the String representation of this Header.

Applies to