Class HttpField
- Direct Known Subclasses:
HostPortHttpField, HttpCookieUtils.SetCookieHttpField, HttpField.IntValueHttpField, HttpField.LongValueHttpField, PreEncodedHttpField
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final QuotedStringTokenizerA constantQuotedStringTokenizerconfigured for quoting/tokenizing a singleparameteras defined by RFC9110static final QuotedStringTokenizerA constantQuotedStringTokenizerconfigured for quoting/tokenizingparameterslists as defined by RFC9110 -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newHttpFieldwith the given name string and value string.HttpField(HttpHeader header, String value) Creates a newHttpFieldwith the givenHttpHeaderand value string.HttpField(HttpHeader header, String name, String value) Creates a newHttpFieldwith the givenHttpHeader, name string and value string.HttpField(HttpHeader header, HttpHeaderValue value) Creates a newHttpFieldwith the givenHttpHeaderand value. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns whether this field value, possibly multi-valued, contains the specified search string, case-insensitively.static booleanReturns whether the given value, possibly multi-valued, contains the specified search string, case-insensitively.booleancontainsLast(String search) Look for a value as the last value in a possible multivalued field Parameters and specifically quality parameters are not considered.static booleancontainsLast(String value, String search) Look for the last value in a possible multivalued field Parameters and specifically quality parameters are not considered.booleanGet theHttpHeaderof this field, ornull.intlongGet the field name in lower-case.getName()Get the field name.getValue()Get the field value.Returns a list of the field values.static StringgetValueParameters(String valueParams, Map<String, String> parameters) Returns the field value and its parameters.String[]inthashCode()booleanReturns whether this field name is the same as the given string.booleanisSameName(HttpField field) Returns whether this field has the same name as the given field.static StringstripParameters(String value) Returns the field value, stripped of its parameters.toString()static StringvalueParameters(String value, Map<String, String> parameters) Deprecated.withoutValue(String value) Return aHttpFieldwithout a given value (case-insensitive)Return aHttpFieldwith a given value (case-insensitive) ensuredwithValues(String... values) Return aHttpFieldwith given values (case-insensitive) ensured
-
Field Details
-
PARAMETER_TOKENIZER
A constantQuotedStringTokenizerconfigured for quoting/tokenizingparameterslists as defined by RFC9110 -
NAME_VALUE_TOKENIZER
A constantQuotedStringTokenizerconfigured for quoting/tokenizing a singleparameteras defined by RFC9110
-
-
Constructor Details
-
HttpField
Creates a new
HttpFieldwith the givenHttpHeader, name string and value string.A
nullfield value may be passed as parameter, and will be converted to the empty string. This allows the direct constructions of fields that have no value, and/orHttpFieldsubclasses that overridegetValue().- Parameters:
header- theHttpHeaderreferencing a well-known HTTP header name; may benullin case of an unknown or custom HTTP header namename- the field name; ifnull, thenHttpHeader.asString()is usedvalue- the field value; ifnull, the empty string will be used
-
HttpField
Creates a new
HttpFieldwith the givenHttpHeaderand value string.- Parameters:
header- the non-nullHttpHeaderreferencing a well-known HTTP header namevalue- the field value; ifnull, the empty string will be used
-
HttpField
Creates a new
HttpFieldwith the givenHttpHeaderand value.- Parameters:
header- the non-nullHttpHeaderreferencing a well-known HTTP header namevalue- the field value; ifnull, the empty string will be used
-
HttpField
-
-
Method Details
-
getValueParameters
Returns the field value and its parameters.
A field value may have parameters, typically separated by
;, for exampleContent-Type: text/plain; charset=UTF-8 Accept: text/html, text/plain; q=0.5- Parameters:
valueParams- the field value, possibly with parametersparameters- An output map to populate with the parameters, ornullto strip the parameters- Returns:
- the field value without parameters
- See Also:
-
stripParameters
-
valueParameters
Deprecated.usegetValueParameters(String, Map)instead -
contains
Returns whether this field value, possibly multi-valued, contains the specified search string, case-insensitively.
Only values, and not parameters, are compared with the search string.
- Parameters:
search- the string to search for- Returns:
- whether this field value, possibly multi-valued, contains the specified search string
-
contains
Returns whether the given value, possibly multi-valued, contains the specified search string, case-insensitively.
Only values, and not parameters, are compared with the search string.
- Parameters:
value- the value string to search intosearch- the string to search for- Returns:
- whether the given value, possibly multi-valued, contains the specified search string
-
containsLast
Look for a value as the last value in a possible multivalued field Parameters and specifically quality parameters are not considered.- Parameters:
search- Values to search for (case-insensitive)- Returns:
- True iff the value is contained in the field value entirely or as the last element of a quoted comma separated list.
-
containsLast
Look for the last value in a possible multivalued field Parameters and specifically quality parameters are not considered.- Parameters:
value- The field value to search in.search- Values to search for (case-insensitive)- Returns:
- True iff the value is contained in the field value entirely or as the last element of a quoted comma separated list.
-
hashCode
-
equals
-
getHeader
Get theHttpHeaderof this field, ornull.- Returns:
- the
HttpHeaderof this field, ornull
-
getIntValue
public int getIntValue()- Returns:
- the value of this field as an
int - Throws:
NumberFormatException- if the value cannot be parsed as anint
-
getLongValue
public long getLongValue()- Returns:
- the value of this field as an
long - Throws:
NumberFormatException- if the value cannot be parsed as anlong
-
getLowerCaseName
Get the field name in lower-case.- Returns:
- the field name in lower-case
-
getName
-
getValue
-
getValues
- Returns:
- the field values as a
String[] - See Also:
-
getValueList
Returns a list of the field values.
If the field value is multi-valued, the encoded field value is split into multiple values using
QuotedCSVand the different values returned in a list.If the field value is single-valued, the value is wrapped into a list.
- Returns:
- a list of the field values
-
isSameName
Returns whether this field has the same name as the given field.
The comparison of field name is case-insensitive via
is(String).- Parameters:
field- the field to compare the name to- Returns:
- whether this field has the same name as the given field
-
is
Returns whether this field name is the same as the given string.
The comparison of field name is case-insensitive.
- Parameters:
name- the field name to compare to- Returns:
- whether this field name is the same as the given string
-
withoutValue
Return aHttpFieldwithout a given value (case-insensitive) -
withValue
-
withValues
-
toString
-
getValueParameters(String, Map)instead