Class HeaderFactory<H extends Header>

    • Field Detail

      • HEADER_NAMES

        public static final Map<Class<? extends Header>,​String> HEADER_NAMES
        A map of Header types to the names of the headers they implement.
      • FACTORIES

        public static final Map<String,​HeaderFactory<?>> FACTORIES
        A map of header names to known HeaderFactory implementations.
    • Constructor Detail

      • HeaderFactory

        public HeaderFactory()
    • Method Detail

      • parse

        protected abstract H parse​(String value)
                            throws MalformedHeaderException
        Create a header instance from String representation, which may contain multiple values if the header supports them.
        Parameters:
        value - The string representation.
        Returns:
        The parsed header.
        Throws:
        MalformedHeaderException - When the value cannot be parsed.
      • parse

        protected abstract H parse​(List<String> values)
                            throws MalformedHeaderException
        Create a header instance from a list of String representations, each of which may in turn contain multiple values if the header supports them.
        Parameters:
        values - The string representations.
        Returns:
        The parsed header.
        Throws:
        MalformedHeaderException - When the value cannot be parsed.
      • parse

        public H parse​(Object value)
                throws MalformedHeaderException
        Create a header instance from a provided object representation.

        Subclasses may wish to override this method in order to support other types of value.

        Parameters:
        value - An object representation - may be a string, a collection of strings, an array of strings, an instance of Header, or some other object type supported by the subclass.
        Returns:
        The parsed header.
        Throws:
        MalformedHeaderException - When the value cannot be parsed.
      • getHeaderClass

        protected abstract Class<H> getHeaderClass()
        Get the associated header class.
        Returns:
        the header class
      • getHeaderName

        protected abstract String getHeaderName()
        Get the associated header name.
        Returns:
        the header name