public abstract class CharacterParser<T> extends AbstractParser<T>
InputParser
for character-based content types.
It encapsulates the code for mapping from an InputStream
to an
Reader
based upon the input content type and then delegates to the
abstract parse(Reader, InputProperties, Class)
method to handle
the actual parsing of the character data.
altFormat, resultType
Modifier | Constructor and Description |
---|---|
protected |
CharacterParser(AltFormat altFormat,
java.lang.Class<T> resultClass)
Constructs a new CharacterParser that parses content in a particular
alt format and returns instances of the specified type.
|
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
getCharset(InputProperties inProps)
Returns the expected character set encoding for content based upon the
input properties content type.
|
<R extends T> |
parse(ParseSource parseSource,
InputProperties inProps,
java.lang.Class<R> targetClass)
The parse method will use the character encoding found in the output
properties instance to construct an appropriate
Reader and then
delegate to the parse(Reader, InputProperties, Class) method
to perform the parsing. |
abstract <R extends T> |
parse(java.io.Reader inputReader,
InputProperties inProps,
java.lang.Class<R> resultClass)
Parses character content with the specified properties to produce a result
of an expected type.
|
createResult, createResult, getAltFormat, getResultType
protected CharacterParser(AltFormat altFormat, java.lang.Class<T> resultClass)
altFormat
- representation handled by this parserresultClass
- base type of results produced by parser.protected java.lang.String getCharset(InputProperties inProps)
inProps
- input propertiespublic <R extends T> R parse(ParseSource parseSource, InputProperties inProps, java.lang.Class<R> targetClass) throws java.io.IOException, ServiceException
Reader
and then
delegate to the parse(Reader, InputProperties, Class)
method
to perform the parsing.parseSource
- providing the source of the datainProps
- properties describing the input datatargetClass
- specific type of result expected from the parsejava.io.IOException
ServiceException
public abstract <R extends T> R parse(java.io.Reader inputReader, InputProperties inProps, java.lang.Class<R> resultClass) throws java.io.IOException, ServiceException
Reader
.R
- expected result typeinputReader
- reader to parse data frominProps
- input propertiesresultClass
- class to instantiate and parse result into.java.io.IOException
- if an error occurred reading data while parsingServiceException
- if an error occurred within the content