Package io.muserver
Class ParameterizedHeader
- java.lang.Object
-
- io.muserver.ParameterizedHeader
-
public class ParameterizedHeader extends java.lang.Object
A utility class to parse headers that are of the format
param1, param2=value, param3="quoted string"
such as Cache-Control etc.- See Also:
ParameterizedHeaderWithValue
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
static ParameterizedHeader
fromString(java.lang.String input)
Converts a comma-separated list of param names (with optional values) into a Parameterized Headerint
hashCode()
boolean
hasParameter(java.lang.String name)
java.lang.String
parameter(java.lang.String name)
java.lang.String
parameter(java.lang.String name, java.lang.String defaultValue)
java.util.List<java.lang.String>
parameterNames()
java.util.Map<java.lang.String,java.lang.String>
parameters()
java.lang.String
toString()
Converts the HeaderValue into a string, suitable for printing in an HTTP header.
-
-
-
Method Detail
-
parameters
public java.util.Map<java.lang.String,java.lang.String> parameters()
- Returns:
- Gets all the parameters
-
parameter
public java.lang.String parameter(java.lang.String name)
- Parameters:
name
- The name of the parameter to get- Returns:
- Gets a single parameter, or null if there is no value
-
parameter
public java.lang.String parameter(java.lang.String name, java.lang.String defaultValue)
- Parameters:
name
- The name of the parameter to getdefaultValue
- The value to return if no parameter was set- Returns:
- Gets a single parameter, or null if there is no value
-
hasParameter
public boolean hasParameter(java.lang.String name)
- Parameters:
name
- The name of the parameter to look up- Returns:
- True if the parameter exists (with or without a value); otherwise false
-
parameterNames
public java.util.List<java.lang.String> parameterNames()
- Returns:
- Gets the parameters in the order declared (without the parameter values)
-
fromString
public static ParameterizedHeader fromString(java.lang.String input)
Converts a comma-separated list of param names (with optional values) into a Parameterized Header
Null or blank strings return value with an empty parameter map.
- Parameters:
input
- The value to parse- Returns:
- An object containing a map of name/value pairs (where values may be null)
- Throws:
java.lang.IllegalArgumentException
- The value cannot be parsed
-
toString
public java.lang.String toString()
Converts the HeaderValue into a string, suitable for printing in an HTTP header.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A String, such as "some-value" or "content-type:text/html;charset=UTF-8"
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-