@NotThreadSafe public class HttpHeaderMap extends Object implements IHasSize, ICommonsIterable<Map.Entry<String,ICommonsList<String>>>, ICloneable<HttpHeaderMap>, IClearable, Serializable
| Modifier and Type | Field and Description |
|---|---|
static boolean |
DEFAULT_QUOTE_IF_NECESSARY
Default quote if necessary: true
|
static String |
SEPARATOR_KEY_VALUE
The separator between key and value
|
| 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)
Deprecated.
Use
forEachHeaderLine(Consumer, boolean) instead |
void |
forEachHeaderLine(Consumer<? super String> aConsumer,
boolean bUnifyValue)
Invoke the provided consumer for every header line.
|
void |
forEachHeaderLine(Consumer<? super String> aConsumer,
boolean bUnifyValue,
boolean bQuoteIfNecessary)
Invoke the provided consumer for every header line.
|
void |
forEachSingleHeader(BiConsumer<? super String,? super String> aConsumer)
Deprecated.
Use
forEachSingleHeader(BiConsumer, boolean) instead |
void |
forEachSingleHeader(BiConsumer<? super String,? super String> aConsumer,
boolean bUnifyValue)
Invoke the provided consumer for every name/value pair.
|
void |
forEachSingleHeader(BiConsumer<? super String,? super String> aConsumer,
boolean bUnifyValue,
boolean bQuoteIfNecessary)
Invoke the provided consumer for every name/value pair.
|
ICommonsList<String> |
getAllHeaderLines()
Deprecated.
Use
getAllHeaderLines(boolean) instead |
ICommonsList<String> |
getAllHeaderLines(boolean bUnifyValue)
Get all header lines as a list of strings.
|
ICommonsList<String> |
getAllHeaderLines(boolean bUnifyValue,
boolean bQuoteIfNecessary)
Get all header lines as a list of strings.
|
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 |
getUnifiedValue(String sValue)
Avoid having header values spanning multiple lines.
|
static String |
getUnifiedValue(String sValue,
boolean bQuoteIfNecessary)
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)
Set 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, findFirstIndex, findFirstMapped, findFirstMapped, findLastIndex, forEach, forEachBreakable, forEachByIndex, getCount, getCountforEach, spliteratorpublic static final String SEPARATOR_KEY_VALUE
public static final boolean DEFAULT_QUOTE_IF_NECESSARY
public HttpHeaderMap()
public HttpHeaderMap(@Nonnull HttpHeaderMap aOther)
aOther - Map to copy from. May not be null.@Nonnull public static String getUnifiedValue(@Nullable String sValue)
sValue - The source header value. May be null.null.@Nonnull public static String getUnifiedValue(@Nullable String sValue, boolean bQuoteIfNecessary)
sValue - The source header value. May be null.bQuoteIfNecessary - true if automatic quoting according to RFC 2616,
chapter 2.2 should be used if necessary.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()@Deprecated public void forEachSingleHeader(@Nonnull BiConsumer<? super String,? super String> aConsumer)
forEachSingleHeader(BiConsumer, boolean) insteadaConsumer - Consumer with key and unified value to be invoked. May not be
null.public void forEachSingleHeader(@Nonnull BiConsumer<? super String,? super String> aConsumer, boolean bUnifyValue)
aConsumer - Consumer with key and unified value to be invoked. May not be
null.bUnifyValue - true to unify the values, false if notgetUnifiedValue(String,boolean)public void forEachSingleHeader(@Nonnull BiConsumer<? super String,? super String> aConsumer, boolean bUnifyValue, boolean bQuoteIfNecessary)
aConsumer - Consumer with key and unified value to be invoked. May not be
null.bUnifyValue - true to unify the values, false if notbQuoteIfNecessary - true to automatically quote values if it is necessary,
false to not do it. This is only used, if "unify
values" is true.getUnifiedValue(String, boolean)@Deprecated public void forEachHeaderLine(@Nonnull Consumer<? super String> aConsumer)
forEachHeaderLine(Consumer, boolean) insteadaConsumer - Consumer with the assembled line to be invoked. May not be
null.getUnifiedValue(String,boolean)public void forEachHeaderLine(@Nonnull Consumer<? super String> aConsumer, boolean bUnifyValue)
aConsumer - Consumer with the assembled line to be invoked. May not be
null.bUnifyValue - true to unify the values, false if notgetUnifiedValue(String,boolean)public void forEachHeaderLine(@Nonnull Consumer<? super String> aConsumer, boolean bUnifyValue, boolean bQuoteIfNecessary)
aConsumer - Consumer with the assembled line to be invoked. May not be
null.bUnifyValue - true to unify the values, false if not.bQuoteIfNecessary - true to automatically quote values if it is necessary,
false to not do it. This is only used, if "unify
values" is true.getUnifiedValue(String,boolean)@Deprecated @Nonnull @ReturnsMutableCopy public ICommonsList<String> getAllHeaderLines()
getAllHeaderLines(boolean) instead@Nonnull @ReturnsMutableCopy public ICommonsList<String> getAllHeaderLines(boolean bUnifyValue)
bUnifyValue - true to unify the values, false if notnull but maybe an empty list.@Nonnull @ReturnsMutableCopy public ICommonsList<String> getAllHeaderLines(boolean bUnifyValue, boolean bQuoteIfNecessary)
bUnifyValue - true to unify the values, false if notbQuoteIfNecessary - true to automatically quote values if it is necessary,
false to not do it. This is only used, if "unify
values" is true.null but maybe an empty list.public void setContentLength(long nLength)
@Nonnull @ReturnsMutableCopy public HttpHeaderMap getClone()
getClone in interface ICloneable<HttpHeaderMap>Copyright © 2014–2019 Philip Helger. All rights reserved.