Parser API
The parser API is designed to be easily extensible by developers.
If you are writing your own parser, you will typically subclass directly from either {@link org.apache.juneau.parser.ReaderParser}
or {@link org.apache.juneau.parser.InputStreamParser}.
The {@link org.apache.juneau.parser.ParserGroup} class represents a group of parser registered with the media types they handle.
The ParserGroup
class provides the following features:
Content-Type
header values.
Refer to {@link org.apache.juneau.parser.ParserGroup} for additional information.
Defining a new parser is quite simple if you subclass directly from {@link org.apache.juneau.parser.ReaderParser} or {@link org.apache.juneau.parser.InputStreamParser}. In each case, you simply need to implement a single method and specify a {@link org.apache.juneau.annotation.Consumes} annotation.
The following example shows a simple parser that converts input streams to images using standard JRE classes.
Parsers that take advantage of the entire {@link org.apache.juneau.CoreApi} interface to be able to parse arbitrary beans and POJOs is considerably more complex and outside the scope of this document. If developing such a parser, the best course of action would be to replicate what occurs in the {@link org.apache.juneau.json.JsonParser} class.