Package org.forgerock.http.header
Class HeaderFactory<H extends Header>
- java.lang.Object
-
- org.forgerock.http.header.HeaderFactory<H>
-
- Type Parameters:
H- The type ofHeaderproduced by the factory.
- Direct Known Subclasses:
AuthorizationHeader.Factory
public abstract class HeaderFactory<H extends Header> extends Object
Creates instances ofHeaderclasses from String representation.
-
-
Field Summary
Fields Modifier and Type Field Description static Map<String,HeaderFactory<?>>FACTORIESA map of header names to knownHeaderFactoryimplementations.static Map<Class<? extends Header>,String>HEADER_NAMESA map ofHeadertypes 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 StringgetHeaderName()Get the associated header name.Hparse(Object value)Create a header instance from a provided object representation.protected abstract Hparse(String value)Create a header instance from String representation, which may contain multiple values if the header supports them.protected abstract Hparse(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
-
-