Class ParserSet
Parsers
that can be looked up by media type.
Description
Provides the following features:-
Finds parsers based on HTTP
Content-Type header values. - Sets common properties on all parsers in a single method call.
- Locks all parsers in a single method call.
- Clones existing groups and all parsers within the group in a single method call.
Match ordering
Parsers are matched againstAdding new entries will cause the entries to be prepended to the group. This allows for previous parsers to be overridden through subsequent calls.
For example, calling g.append(P1.
will result in the order
Example:
Notes:
- This class is thread safe and reusable.
See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Builder class.static class
An identifier that the previous entries in this group should be inherited.static class
An identifier that the previous entries in this group should not be inherited. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncopy()
Creates a copy of this parser group.static ParserSet.Builder
create()
Static creator.static ParserSet.Builder
Static creator.Same asgetParserMatch(String)
but returns just the matched parser.Same asgetParserMatch(MediaType)
but returns just the matched parser.getParserMatch
(String contentTypeHeader) Searches the group for a parser that can handle the specifiedContent-Type header value.getParserMatch
(MediaType mediaType) Same asgetParserMatch(String)
but matches using aMediaType
instance.Returns the parsers in this group.Returns the media types that all parsers in this group can handleboolean
isEmpty()
Returnstrue if this group contains no parsers.
-
Constructor Details
-
ParserSet
Constructor.- Parameters:
builder
- The builder for this bean.
-
-
Method Details
-
create
Static creator.- Parameters:
beanStore
- The bean store to use for creating beans.- Returns:
- A new builder for this object.
-
create
Static creator.- Returns:
- A new builder for this object.
-
copy
Creates a copy of this parser group.- Returns:
- A new copy of this parser group.
-
getParserMatch
Searches the group for a parser that can handle the specifiedContent-Type header value.The returned object includes both the parser and media type that matched.
- Parameters:
contentTypeHeader
- The HTTPContent-Type header value.- Returns:
- The parser and media type that matched the content type header, or
null if no match was made.
-
getParserMatch
Same asgetParserMatch(String)
but matches using aMediaType
instance.- Parameters:
mediaType
- The HTTPContent-Type header value as a media type.- Returns:
- The parser and media type that matched the media type, or
null if no match was made.
-
getParser
Same asgetParserMatch(String)
but returns just the matched parser.- Parameters:
contentTypeHeader
- The HTTPContent-Type header string.- Returns:
- The parser that matched the content type header, or
null if no match was made.
-
getParser
Same asgetParserMatch(MediaType)
but returns just the matched parser.- Parameters:
mediaType
- The HTTP media type.- Returns:
- The parser that matched the media type, or
null if no match was made.
-
getSupportedMediaTypes
Returns the media types that all parsers in this group can handleEntries are ordered in the same order as the parsers in the group.
- Returns:
- An unmodifiable list of media types.
-
getParsers
Returns the parsers in this group.- Returns:
- An unmodifiable list of parsers in this group.
-
isEmpty
Returnstrue if this group contains no parsers.- Returns:
true if this group contains no parsers.
-