Package org.forgerock.http.header
Class ContentTypeHeader
java.lang.Object
org.forgerock.http.protocol.Header
org.forgerock.http.header.ContentTypeHeader
Processes the
Content-Type
message header. For more
information, see RFC 2616
ยง14.17.-
Field Summary
-
Constructor Summary
ConstructorDescriptionConstructs a new empty header whose type, charset, and boundary are allnull
.ContentTypeHeader
(String type, String charset, String boundary) Deprecated.ContentTypeHeader
(String type, String charset, String boundary, Map<String, String> additionalParameters) Deprecated.Replaced byContentTypeHeader(String, Map)
ContentTypeHeader
(String type, Map<String, Directive> directives) Constructs a new header based on message type and any message directives. -
Method Summary
Modifier and TypeMethodDescriptionDeprecated.Replaced bygetDirectives()
Returns the encapsulation boundary ornull
if none specified.Returns the character set encoding used to encode the message, ornull
if no character set was specified.Returns all directives in the message, keyed off the directive name, or an empty map if none specified.getName()
Returns the name of the header, as it would canonically appear within an HTTP message.getType()
Returns the media type of the underlying data ornull
if none specified.Returns the header as a list of strings.static ContentTypeHeader
Constructs a new header, initialized from the specified string value.static ContentTypeHeader
Constructs a new header, initialized from the specified message.Methods inherited from class org.forgerock.http.protocol.Header
equals, getFirstValue, hashCode, toString
-
Field Details
-
NAME
The name of this header.- See Also:
-
-
Constructor Details
-
ContentTypeHeader
public ContentTypeHeader()Constructs a new empty header whose type, charset, and boundary are allnull
. -
ContentTypeHeader
Deprecated.Replaced byContentTypeHeader(String, Map)
Constructs a new header based on message type, charset and boundary.- Parameters:
type
- The type/sub-type of the message.charset
- The character set used in encoding the message.boundary
- The boundary value provided in multipart messages.
-
ContentTypeHeader
@Deprecated public ContentTypeHeader(String type, String charset, String boundary, Map<String, String> additionalParameters) Deprecated.Replaced byContentTypeHeader(String, Map)
Constructs a new header based on message type, charset, boundary and any additional message parameters.- Parameters:
type
- The type/sub-type of the message.charset
- The character set used in encoding the message.boundary
- The boundary value provided in multipart messages.additionalParameters
- Any additional parameters provided in the message or an empty map if there are none.
-
ContentTypeHeader
Constructs a new header based on message type and any message directives.- Parameters:
type
- The type/sub-type of the message.directives
- Any directives provided in the message or an empty map if there are none.
-
-
Method Details
-
valueOf
Constructs a new header, initialized from the specified message.- Parameters:
message
- The message to initialize the header from.- Returns:
- The parsed header.
-
valueOf
Constructs a new header, initialized from the specified string value.- Parameters:
string
- The value to initialize the header from.- Returns:
- The parsed header.
-
getType
Returns the media type of the underlying data ornull
if none specified.- Returns:
- The media type of the underlying data or
null
if none specified.
-
getCharset
Returns the character set encoding used to encode the message, ornull
if no character set was specified.- Returns:
- The character set encoding used to encode the message or
null
if empty. - Throws:
IllegalCharsetNameException
- if the given charset name is illegal.UnsupportedCharsetException
- if no support for the named charset is available.
-
getBoundary
Returns the encapsulation boundary ornull
if none specified.- Returns:
- The encapsulation boundary or
null
if none specified.
-
getAdditionalParameters
Deprecated.Replaced bygetDirectives()
Returns any additional parameters (other than charset and boundary) in the message or an empty map if none specified. The values will be unquoted in all cases to be consistent with existing behaviour.- Returns:
- Any additional parameters (other than charset and boundary) in the message or an empty map if none specified. The values will be unquoted in all cases to be consistent with existing behaviour.
-
getDirectives
Returns all directives in the message, keyed off the directive name, or an empty map if none specified.- Returns:
- All directives in the message, keyed off the directive name, or an empty map if none specified.
-
getName
Description copied from class:Header
Returns the name of the header, as it would canonically appear within an HTTP message. -
getValues
Description copied from class:Header
Returns the header as a list of strings. If the header has no values then it must return an empty list, never null. EachString
should represent the value component of the key-value pair that makes up the HTTP header - as such, for someHeader
implementations each String in thisList
may contain multiple token-separated values.The
List
returned from this method should not be expected to be mutable. However, some subclasses ofHeader
may choose to implement it as such.
-
ContentTypeHeader(String, Map)