Package rocks.xmpp.extensions.shim.model
Class Headers
- java.lang.Object
-
- rocks.xmpp.extensions.shim.model.Headers
-
public final class Headers extends Object
The implementation of the<headers/>
element in thehttp://jabber.org/protocol/shim
namespace.This class is immutable.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
findValue(String name)
Tries to find a value among the headers associated with header name.List<Header>
getHeaders()
Gets the headers.static Headers
of(Collection<Header> headers)
Creates a headers element.static Headers
of(Map<String,String> headers)
Creates a headers element from a map.static Headers
of(Header... headers)
Creates a headers element.static Headers
ofTimePeriod(OffsetDateTime start, OffsetDateTime stop)
Creates a headers element with a time period.String
toString()
Headers
withHeader(String name, String value)
Creates a new headers extension with an additional header.Headers
withHeader(Header header)
Creates a new headers extension with an additional header.Headers
withoutHeader(String name)
Removes a header from this collection.
-
-
-
Field Detail
-
NAMESPACE
public static final String NAMESPACE
http://jabber.org/protocol/shim- See Also:
- Constant Field Values
-
-
Method Detail
-
of
public static Headers of(Header... headers)
Creates a headers element.- Parameters:
headers
- The headers.- Returns:
- The header.
-
of
public static Headers of(Collection<Header> headers)
Creates a headers element.- Parameters:
headers
- The headers.- Returns:
- The header.
-
of
public static Headers of(Map<String,String> headers)
Creates a headers element from a map.- Parameters:
headers
- The headers.- Returns:
- The header.
-
ofTimePeriod
public static Headers ofTimePeriod(OffsetDateTime start, OffsetDateTime stop)
Creates a headers element with a time period.- Parameters:
start
- The start date.stop
- The stop date.- Returns:
- The header.
- See Also:
- XEP-0149: Time Periods
-
findValue
public final String findValue(String name)
Tries to find a value among the headers associated with header name.- Parameters:
name
- The name of the header.- Returns:
- The found value or null if none could be found.
-
withHeader
public final Headers withHeader(String name, String value)
Creates a new headers extension with an additional header. If the header already exists (by their name), it is replaced; otherwise it's added.- Parameters:
name
- The header name.value
- The header value.- Returns:
- The headers.
-
withHeader
public final Headers withHeader(Header header)
Creates a new headers extension with an additional header. If the header already exists (by their name), it is replaced; otherwise it's added.- Parameters:
header
- The header.- Returns:
- The headers.
-
withoutHeader
public final Headers withoutHeader(String name)
Removes a header from this collection.- Parameters:
name
- The header name.- Returns:
- The headers.
-
-