Package org.apache.juneau.http.header
Class BasicStringHeader
java.lang.Object
org.apache.juneau.http.header.BasicHeader
org.apache.juneau.http.header.BasicStringHeader
- All Implemented Interfaces:
Serializable
,Cloneable
,Header
,NameValuePair
- Direct Known Subclasses:
AcceptRanges
,Authorization
,BasicMediaRangesHeader
,BasicMediaTypeHeader
,CacheControl
,ClientVersion
,Connection
,ContentEncoding
,ContentRange
,Expect
,Forwarded
,From
,Host
,Origin
,Pragma
,ProxyAuthenticate
,ProxyAuthorization
,Range
,Server
,Trailer
,TransferEncoding
,UserAgent
,Vary
,Warning
,WwwAuthenticate
Category of headers that consist of a single string value.
Example
Host: www.myhost.com:8080
See Also:
-
Constructor Summary
ConstructorDescriptionBasicStringHeader
(String name, String value) Constructor.BasicStringHeader
(String name, Supplier<String> value) Constructor with delayed value. -
Method Summary
Modifier and TypeMethodDescriptionProvides the ability to perform fluent-style assertions on this header.asString()
Returns the value of this header as a string.getValue()
static BasicStringHeader
Static creator.static BasicStringHeader
Static creator with delayed value.static BasicStringHeader
Creates aHeader
from a name/value pair string (e.g.Return the value if present, otherwise returnother .Methods inherited from class org.apache.juneau.http.header.BasicHeader
assertName, assertStringValue, equals, equalsIgnoreCase, get, getElements, getName, hashCode, isNotEmpty, isPresent, of, of, toString
-
Constructor Details
-
BasicStringHeader
Constructor.- Parameters:
name
- The header name.value
- The header value.
Can benull .- Throws:
IllegalArgumentException
- If name isnull or empty.
-
BasicStringHeader
Constructor with delayed value.Header value is re-evaluated on each call to
getValue()
.- Parameters:
name
- The header name.value
- The supplier of the header value.
Can benull .- Throws:
IllegalArgumentException
- If name isnull or empty.
-
-
Method Details
-
of
Static creator.- Parameters:
name
- The header name.value
- The header value.
Can benull .- Returns:
- A new header bean, or
null if the value isnull . - Throws:
IllegalArgumentException
- If name isnull or empty.
-
of
Static creator with delayed value.Header value is re-evaluated on each call to
getValue()
.- Parameters:
name
- The header name.value
- The supplier of the header value.
Can benull .- Returns:
- A new header bean, or
null if the value isnull . - Throws:
IllegalArgumentException
- If name isnull or empty.
-
ofPair
Creates aHeader
from a name/value pair string (e.g."Foo: bar" )- Parameters:
pair
- The pair string.- Returns:
- A new header bean.
-
getValue
- Specified by:
getValue
in interfaceNameValuePair
- Overrides:
getValue
in classBasicHeader
-
asString
Description copied from class:BasicHeader
Returns the value of this header as a string.- Overrides:
asString
in classBasicHeader
- Returns:
- The value of this header as a string, or
Optional.empty()
if the value isnull
-
assertString
Provides the ability to perform fluent-style assertions on this header.Examples:
// Validates the content type header is provided. client .get(URL ) .run() .getHeader("Content-Type" ).assertString().exists();- Returns:
- A new fluent assertion object.
- Throws:
AssertionError
- If assertion failed.
-
orElse
Return the value if present, otherwise returnother .This is a shortened form for calling
asString().orElse( .other )- Overrides:
orElse
in classBasicHeader
- Parameters:
other
- The value to be returned if there is no value present, can benull .- Returns:
- The value, if present, otherwise
other .
-