com.google.gdata.wireformats.input
Class CharacterParser<T>

java.lang.Object
  extended by com.google.gdata.wireformats.input.AbstractParser<T>
      extended by com.google.gdata.wireformats.input.CharacterParser<T>
All Implemented Interfaces:
InputParser<T>
Direct Known Subclasses:
ElementParser, XmlInputParser

public abstract class CharacterParser<T>
extends AbstractParser<T>

The CharacterParser class is abstract base class to support the implementation of an 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.


Field Summary
 
Fields inherited from class com.google.gdata.wireformats.input.AbstractParser
altFormat, resultType
 
Constructor Summary
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.
 
Method Summary
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>
R
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>
R
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.
 
Methods inherited from class com.google.gdata.wireformats.input.AbstractParser
createResult, createResult, getAltFormat, getResultType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CharacterParser

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.

Parameters:
altFormat - representation handled by this parser
resultClass - base type of results produced by parser.
Method Detail

getCharset

protected java.lang.String getCharset(InputProperties inProps)
Returns the expected character set encoding for content based upon the input properties content type.

Parameters:
inProps - input properties
Returns:
expected character set encoding

parse

public <R extends T> R parse(ParseSource parseSource,
                             InputProperties inProps,
                             java.lang.Class<R> targetClass)
                  throws java.io.IOException,
                         ServiceException
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.

Parameters:
parseSource - providing the source of the data
inProps - properties describing the input data
targetClass - specific type of result expected from the parse
Throws:
java.io.IOException
ServiceException

parse

public abstract <R extends T> R parse(java.io.Reader inputReader,
                                      InputProperties inProps,
                                      java.lang.Class<R> resultClass)
                           throws java.io.IOException,
                                  ServiceException
Parses character content with the specified properties to produce a result of an expected type. Concrete subclasses will provide an implementation of this method that constructs a result type instance of the result class and then parses into it from the provided Reader.

Type Parameters:
R - expected result type
Parameters:
inputReader - reader to parse data from
inProps - input properties
resultClass - class to instantiate and parse result into.
Returns:
result object from parse
Throws:
java.io.IOException - if an error occurred reading data while parsing
ServiceException - if an error occurred within the content