Package org.jdrupes.httpcodec.types
Interface Converter<T>
- Type Parameters:
T
- the type to be converted
- All Known Subinterfaces:
MultiValueConverter<T,
V>
- All Known Implementing Classes:
CommentedValue.CommentedValueConverter
,DefaultMultiValueConverter
,Directive.DirectiveConverter
,Etag.EtagConverter
,InstantConverter
,MediaBase.MediaTypePairConverter
,MediaRange.MediaRangeConverter
,MediaType.MediaTypeConverter
,ParameterizedValue.ParameterizedValueConverter
,ParameterizedValue.ParamValueConverterBase
,SetCookieStringConverter
public interface Converter<T>
Implemented by classes that convert between a value and its
string representation in the HTTP header field.
-
Method Summary
Modifier and TypeMethodDescriptionasFieldValue
(T value) Returns the representation of this value in a header field.default String
asHeaderField
(String fieldName, T value) Returns the string representation of this header field as it appears in an HTTP message.fromFieldValue
(String text) Parses the given text and returns the parsed value.
-
Method Details
-
asFieldValue
Returns the representation of this value in a header field.- Parameters:
value
- the value to be converted- Returns:
- the representation
-
asHeaderField
Returns the string representation of this header field as it appears in an HTTP message.Note that the returned string may span several lines (may contain CR/LF), if the converter is a
MultiValueConverter
with separate values, but never has a trailing CR/LF.- Parameters:
fieldName
- the field namevalue
- the value- Returns:
- the field as it occurs in a header
-
fromFieldValue
Parses the given text and returns the parsed value.- Parameters:
text
- the value from the header field- Returns:
- the parsed value
- Throws:
ParseException
- if the value cannot be parsed
-