Package org.forgerock.http.header
Class HeaderFactory<H extends Header>
- java.lang.Object
-
- org.forgerock.http.header.HeaderFactory<H>
-
- Type Parameters:
H
- The type ofHeader
produced by the factory.
- Direct Known Subclasses:
AuthorizationHeader.Factory
public abstract class HeaderFactory<H extends Header> extends Object
Creates instances ofHeader
classes from String representation.
-
-
Field Summary
Fields Modifier and Type Field Description static Map<String,HeaderFactory<?>>
FACTORIES
A map of header names to knownHeaderFactory
implementations.static Map<Class<? extends Header>,String>
HEADER_NAMES
A map ofHeader
types to the names of the headers they implement.
-
Constructor Summary
Constructors Constructor Description HeaderFactory()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract Class<H>
getHeaderClass()
Get the associated header class.protected abstract String
getHeaderName()
Get the associated header name.H
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.
-
-
-
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 ofHeader
, 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
-
-