Package io.muserver

Class ParameterizedHeaderWithValue


  • public class ParameterizedHeaderWithValue
    extends java.lang.Object

    A utility class to parse headers that are of the format name; param1=value; param2="quoted string" such as Content-Type, Accepts, Content-Disposition etc.

    More explicitly, a header that starts with a value, then has an optional list of semi-colon separated name/value pairs.

    See Also:
    ParameterizedHeader
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)  
      static java.util.List<ParameterizedHeaderWithValue> fromString​(java.lang.String input)
      Converts headers that are values followed by optional parameters into a list of values with parameters.
      int hashCode()  
      java.lang.String parameter​(java.lang.String name)  
      java.lang.String parameter​(java.lang.String name, java.lang.String defaultValue)  
      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.
      java.lang.String value()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Method Detail

      • value

        public java.lang.String value()
        Returns:
        Gets the first value of the header (without parameters), such as the media type in a Content-Type header
      • 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 get
        defaultValue - The value to return if no parameter was set
        Returns:
        Gets a single parameter, or null if there is no value
      • fromString

        public static java.util.List<ParameterizedHeaderWithValue> fromString​(java.lang.String input)

        Converts headers that are values followed by optional parameters into a list of values with parameters.

        Null or blank strings return an empty list.

        Parameters:
        input - The value to parse
        Returns:
        A list of ParameterizedHeaderWithValue objects
        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 class java.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 class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object