Class HeaderFactory<H extends Header>

java.lang.Object
org.forgerock.http.header.HeaderFactory<H>
Type Parameters:
H - The type of Header produced by the factory.
Direct Known Subclasses:
AuthorizationHeader.Factory

public abstract class HeaderFactory<H extends Header> extends Object
Creates instances of Header classes from String representation.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Map<String,HeaderFactory<?>>
    A map of header names to known HeaderFactory implementations.
    static final Map<Class<? extends Header>,String>
    A map of Header types to the names of the headers they implement.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract Class<H>
    Get the associated header class.
    protected abstract String
    Get the associated header name.
    parse(Object value)
    Create a header instance from a provided object representation.
    protected abstract H
    parse(String value)
    Create a header instance from String representation, which may contain multiple values if the header supports them.
    protected abstract H
    parse(List<String> values)
    Create a header instance from a list of String representations, each of which may in turn contain multiple values if the header supports them.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • 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 Details

    • HeaderFactory

      public HeaderFactory()
  • Method Details

    • 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