@NotThreadSafe public class HttpHeaderMap extends Object implements IHasSize, ICommonsIterable<Map.Entry<String,ICommonsList<String>>>, ICloneable<HttpHeaderMap>, IClearable
| Constructor and Description |
|---|
HttpHeaderMap()
Default constructor.
|
HttpHeaderMap(HttpHeaderMap aOther)
Copy constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAllHeaders(HttpHeaderMap aOther)
Add all headers from the passed map.
|
void |
addDateHeader(String sName,
LocalDate aLD)
Add the passed header as a date header.
|
void |
addDateHeader(String sName,
LocalDateTime aLDT)
Add the passed header as a date header.
|
void |
addDateHeader(String sName,
long nMillis)
Add the passed header as a date header.
|
void |
addDateHeader(String sName,
ZonedDateTime aDT)
Add the passed header as a date header.
|
void |
addHeader(String sName,
String sValue)
Add the passed header as is.
|
void |
addIntHeader(String sName,
int nValue)
Add the passed header as a number.
|
void |
addLongHeader(String sName,
long nValue)
Add the passed header as a number.
|
boolean |
containsHeaders(String sName) |
boolean |
equals(Object o) |
void |
forEachHeaderLine(Consumer<? super String> aConsumer) |
void |
forEachSingleHeader(BiConsumer<? super String,? super String> aConsumer)
Invoke the provided consumer for every name/value pair.
|
ICommonsList<String> |
getAllHeaderLines() |
ICommonsOrderedSet<String> |
getAllHeaderNames() |
ICommonsOrderedMap<String,ICommonsList<String>> |
getAllHeaders() |
ICommonsList<String> |
getAllHeaderValues(String sName)
Get all header values of a certain header name
|
HttpHeaderMap |
getClone() |
static String |
getDateTimeAsString(LocalDateTime aLDT) |
static String |
getDateTimeAsString(ZonedDateTime aDT) |
String |
getFirstHeaderValue(String sName)
Get the first header value of a certain header name
|
String |
getHeaderCombined(String sName,
String sDelimiter)
Get the header value as a combination of all contained values
|
static String |
getUnifiedName(String s)
Unify the parameter name by lower casing it.
|
static String |
getUnifiedValue(String sValue)
Avoid having header values spanning multiple lines.
|
int |
hashCode() |
boolean |
isEmpty() |
Iterator<Map.Entry<String,ICommonsList<String>>> |
iterator() |
EChange |
removeAll()
Remove all contained headers.
|
EChange |
removeHeader(String sName,
String sValue) |
EChange |
removeHeaders(String sName)
Remove all header values with the provided name
|
EChange |
removeHeadersIf(Predicate<? super String> aNameFilter)
Remove all header values where the name matches the provided filter.
|
void |
setAllHeaders(HttpHeaderMap aOther)
Add all headers from the passed map.
|
void |
setContentLength(long nLength) |
void |
setContentType(String sContentType) |
void |
setDateHeader(String sName,
LocalDate aLD)
Set the passed header as a date header.
|
void |
setDateHeader(String sName,
LocalDateTime aLDT)
Set the passed header as a date header.
|
void |
setDateHeader(String sName,
long nMillis)
Set the passed header as a date header.
|
void |
setDateHeader(String sName,
ZonedDateTime aDT)
Set the passed header as a date header.
|
void |
setHeader(String sName,
String sValue)
Set the passed header as is.
|
void |
setIntHeader(String sName,
int nValue)
Set the passed header as a number.
|
void |
setLongHeader(String sName,
long nValue)
Set the passed header as a number.
|
int |
size() |
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitisNotEmptycontainsAny, containsNone, containsOnly, findAll, findAllInstanceOf, findAllMapped, findAllMapped, findAllMapped, findFirst, findFirst, findFirstMapped, findFirstMapped, forEach, forEachBreakable, forEachByIndex, getCount, getCountforEach, spliteratorpublic HttpHeaderMap()
public HttpHeaderMap(@Nonnull HttpHeaderMap aOther)
aOther - Map to copy from. May not be null.@Nonnull @Nonempty public static String getUnifiedName(@Nonnull @Nonempty String s)
s - Name to unify. May neither be null nor empty.null.@Nonnull public static String getUnifiedValue(@Nullable String sValue)
sValue - The source header value. May be null.null.@Nonnull public EChange removeAll()
removeAll in interface IClearableEChange.public void setHeader(@Nonnull @Nonempty String sName, @Nullable String sValue)
sName - Header name. May neither be null nor empty.sValue - The value to be set. May be null in which case nothing
happens.public void addHeader(@Nonnull @Nonempty String sName, @Nullable String sValue)
sName - Header name. May neither be null nor empty.sValue - The value to be set. May be null in which case nothing
happens.@Nonnull public static String getDateTimeAsString(@Nonnull ZonedDateTime aDT)
@Nonnull public static String getDateTimeAsString(@Nonnull LocalDateTime aLDT)
public void setDateHeader(@Nonnull @Nonempty String sName, long nMillis)
sName - Header name. May neither be null nor empty.nMillis - The milliseconds to set as a date.public void setDateHeader(@Nonnull @Nonempty String sName, @Nonnull LocalDate aLD)
sName - Header name. May neither be null nor empty.aLD - The LocalDate to set as a date. The time is set to start of day. May
not be null.public void setDateHeader(@Nonnull @Nonempty String sName, @Nonnull LocalDateTime aLDT)
sName - Header name. May neither be null nor empty.aLDT - The LocalDateTime to set as a date. May not be null.public void setDateHeader(@Nonnull @Nonempty String sName, @Nonnull ZonedDateTime aDT)
sName - Header name. May neither be null nor empty.aDT - The DateTime to set as a date. May not be null.public void addDateHeader(@Nonnull @Nonempty String sName, long nMillis)
sName - Header name. May neither be null nor empty.nMillis - The milliseconds to set as a date.public void addDateHeader(@Nonnull @Nonempty String sName, @Nonnull LocalDate aLD)
sName - Header name. May neither be null nor empty.aLD - The LocalDate to set as a date. The time is set to start of day. May
not be null.public void addDateHeader(@Nonnull @Nonempty String sName, @Nonnull LocalDateTime aLDT)
sName - Header name. May neither be null nor empty.aLDT - The LocalDateTime to set as a date. May not be null.public void addDateHeader(@Nonnull @Nonempty String sName, @Nonnull ZonedDateTime aDT)
sName - Header name. May neither be null nor empty.aDT - The DateTime to set as a date. May not be null.public void setIntHeader(@Nonnull @Nonempty String sName, int nValue)
sName - Header name. May neither be null nor empty.nValue - The value to be set. May not be null.public void addIntHeader(@Nonnull @Nonempty String sName, int nValue)
sName - Header name. May neither be null nor empty.nValue - The value to be set. May not be null.public void setLongHeader(@Nonnull @Nonempty String sName, long nValue)
sName - Header name. May neither be null nor empty.nValue - The value to be set. May not be null.public void addLongHeader(@Nonnull @Nonempty String sName, long nValue)
sName - Header name. May neither be null nor empty.nValue - The value to be set. May not be null.public void setAllHeaders(@Nonnull HttpHeaderMap aOther)
aOther - The header map to add. May not be null.public void addAllHeaders(@Nonnull HttpHeaderMap aOther)
aOther - The header map to add. May not be null.@Nonnull @ReturnsMutableCopy public ICommonsOrderedMap<String,ICommonsList<String>> getAllHeaders()
@Nonnull @ReturnsMutableCopy public ICommonsOrderedSet<String> getAllHeaderNames()
null.@Nonnull @ReturnsMutableCopy public ICommonsList<String> getAllHeaderValues(@Nullable String sName)
sName - The name to be searched.null but
maybe empty.@Nullable public String getFirstHeaderValue(@Nullable String sName)
sName - The name to be searched.null.@Nullable public String getHeaderCombined(@Nullable String sName, @Nonnull String sDelimiter)
sName - The header name to retrieve. May be null.sDelimiter - The delimiter to be used. May not be null.null if no such header is contained.@Nonnull public EChange removeHeadersIf(@Nonnull Predicate<? super String> aNameFilter)
aNameFilter - The name filter to be applied. May not be null.EChange@Nonnull public EChange removeHeaders(@Nullable String sName)
sName - The name to be removed. May be null.EChange@Nonnegative public int size()
public boolean isEmpty()
isEmpty in interface IHasSizetrue if no items are present, false if at
least a single item is present.IHasSize.size(),
IHasSize.isNotEmpty()public void forEachSingleHeader(@Nonnull BiConsumer<? super String,? super String> aConsumer)
aConsumer - Consumer to be invoked. May not be null.@Nonnull @ReturnsMutableCopy public ICommonsList<String> getAllHeaderLines()
public void setContentLength(long nLength)
@Nonnull @ReturnsMutableCopy public HttpHeaderMap getClone()
getClone in interface ICloneable<HttpHeaderMap>Copyright © 2014–2017 Philip Helger. All rights reserved.