Class Headers

    • Constructor Detail

      • Headers

        public Headers()
        Constructs a Headers object that is case-insensitive for header names.
    • Method Detail

      • get

        public Header get​(Object key)
        Rich-type friendly get method.
        Specified by:
        get in interface Map<String,​Object>
        Parameters:
        key - The name of the header.
        Returns:
        The header object.
      • getFirst

        public String getFirst​(String key)
        Gets the first value of the header, or null if the header does not exist.
        Parameters:
        key - The name of the header.
        Returns:
        The first header value.
      • getFirst

        public String getFirst​(Class<? extends Header> key)
        Gets the first value of the header, or null if the header does not exist.
        Parameters:
        key - The name of the header.
        Returns:
        The first header value.
      • getAll

        public List<String> getAll​(String key)
        Gets all the values of the header, or an empty list if the header doesn't exist.
        Parameters:
        key - The name of the header.
        Returns:
        The values of the header.
      • get

        public <H extends Header> H get​(Class<H> headerType)
                                 throws MalformedHeaderException
        Returns the specified Header or {code null} if the header is not included in the message.
        Type Parameters:
        H - The type of header.
        Parameters:
        headerType - The type of header.
        Returns:
        The header instance, or null if none exists.
        Throws:
        MalformedHeaderException - When the header was not well formed, and so could not be parsed as its richly-typed class.
      • putAll

        public void putAll​(Map<? extends String,​? extends Object> m)
        A script compatible putAll method that will accept Header, String, Collection<String> and String[] values.
        Specified by:
        putAll in interface Map<String,​Object>
        Parameters:
        m - A map of header names to values.
      • put

        public Header put​(String key,
                          Object value)
        A script compatible put method that will accept a Header, String, Collection<String> and String[] value.
        Specified by:
        put in interface Map<String,​Object>
        Parameters:
        key - The name of the header.
        value - A Header, String, Collection<String> or String[].
        Returns:
        The previous Header value for this header, or null.
      • remove

        public Header remove​(Object key)
        Rich-type friendly remove method. Removes the Header object for the given header name.
        Specified by:
        remove in interface Map<String,​Object>
        Parameters:
        key - The header name.
        Returns:
        The header value before removal, or null.
      • put

        public Header put​(Header header)
        A put method to add a particular Header instance. Will overwrite any existing value for this header name.
        Parameters:
        header - The header instance.
        Returns:
        The previous Header value for the header with the same name, or null.
      • add

        public void add​(Header header)
        An add method to add a particular Header instance. Existing values for the header will be added to.
        Parameters:
        header - The header instance.
      • add

        public void add​(String key,
                        Object value)
        A script compatible add method that will accept a Header, String, Collection<String> and String[] value. Existing values for the header will be added to.
        Parameters:
        key - The name of the header.
        value - A Header, String, Collection<String> or String[].
      • addAll

        public void addAll​(Map<? extends String,​? extends Object> map)
        A script compatible addAll method that will accept a Header, String, Collection<String> and String[] value. Existing values for the headers will be added to.
        Parameters:
        map - A map of header names to values.
      • asMapOfHeaders

        public Map<String,​Header> asMapOfHeaders()
        The Headers class extends Map<String, Object> to support flexible parameters in scripting. This method allows access to the underlying Map<String, Header>.
        Returns:
        The map of header names to Header objects.
      • copyAsMultiMapOfStrings

        public Map<String,​List<String>> copyAsMultiMapOfStrings()
        Returns a copy of these headers as a multi-valued map of strings. Changes to the returned map will not be reflected in these headers, nor will changes in these headers be reflected in the returned map.
        Returns:
        a copy of these headers as a multi-valued map of strings.