net.sf.xtvdclient.xtvd.parser
Class XtvdParser

java.lang.Object
  extended by net.sf.xtvdclient.xtvd.parser.AbstractParser
      extended by net.sf.xtvdclient.xtvd.parser.XtvdParser
All Implemented Interfaces:
Parser

public class XtvdParser
extends AbstractParser

A parser implementation that is used to parse the specified XML stream, and then create a Xtvd object that represents the XML data. This is useful for creating an object representation of the data.

Note: After profiling the application, it was found that keeping all the objects in memory to build a complete instance of Xtvd required 1.5M of memory for a 4M XTVD XML document.

Since:
ddclient version 1.2

Field Summary
protected  Xtvd xtvd
          The instance of Xtvd that will be populated by this parser.
 
Fields inherited from class net.sf.xtvdclient.xtvd.parser.AbstractParser
log, reader, sdf
 
Fields inherited from interface net.sf.xtvdclient.xtvd.parser.Parser
END_OF_LINE
 
Constructor Summary
protected XtvdParser(java.io.Reader in, Xtvd xtvd)
          Create a new instance of the parser that reads the data from the specified Reader.
 
Method Summary
protected  void parseGenres()
          Parse the genres top-level element from the AbstractParser.reader, create a Map from the data, and set the Xtvd.genres reference.
protected  void parseLineups()
          Parse the lineups top-level element from the AbstractParser.reader, create a Collection with the data, and set the Xtvd.lineups reference.
protected  void parseProductionCrew()
          Parse the productionCrew top-level element from the AbstractParser.reader, create a Map with the data, and set the Xtvd.productionCrew reference.
protected  void parsePrograms()
          Parse the programs top-level element from the AbstractParser.reader, create a Map with the data, and set the Xtvd.programs reference.
protected  void parseRootElement()
          Parse an root xtvd record from the AbstractParser.reader, and populate the attribute values for the xtvd class.
protected  void parseSchedules()
          Parse the schedules top-level element from the AbstractParser.reader, create a Collection with the data, and set the Xtvd.schedules reference.
protected  void parseStations()
          Parse an individual station record from the AbstractParser.reader, create a Map of all the Station records, and set the corresponding Xtvd.stations reference.
 void parseXTVD()
          Read the xml data from the AbstractParser.reader, parse the XTVD document and populate the xtvd class fields.
 
Methods inherited from class net.sf.xtvdclient.xtvd.parser.AbstractParser
getCrew, getCrew, getGenre, getGenre, getLineup, getLineup, getLog, getMap, getMap, getMember, getMember, getMessages, getPart, getPart, getProgram, getProgram, getProgramGenre, getProgramGenre, getSchedule, getSchedule, getStation, getStation, setLog, toStartTag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

xtvd

protected Xtvd xtvd
The instance of Xtvd that will be populated by this parser.

Constructor Detail

XtvdParser

protected XtvdParser(java.io.Reader in,
                     Xtvd xtvd)
              throws DataDirectException
Create a new instance of the parser that reads the data from the specified Reader. Also initialise the xtvd instance variable.

Parameters:
Reader - in - The Reader from which the XML data is to be parsed. Make sure that the reader object has the character encoding properly set to UTF-8.
Xtvd - xtvd - The instance of Xtvd that is to be populated. The instance variables in the passed in object will be populated by the parser.
Throws:
DataDirectException - - If errors are encountered while initialising the parser or reading the data.
Method Detail

parseXTVD

public void parseXTVD()
               throws DataDirectException
Read the xml data from the AbstractParser.reader, parse the XTVD document and populate the xtvd class fields.

Specified by:
parseXTVD in interface Parser
Specified by:
parseXTVD in class AbstractParser
Throws:
DataDirectException - - If errors are encountered while parsing the XML data stream.
See Also:
parseRootElement(), parseStations(), #getLineup(net.sf.xtvdclient.xtvd.Lineup), AbstractParser.getSchedule(net.sf.xtvdclient.xtvd.datatypes.Schedule), AbstractParser.getProgram(net.sf.xtvdclient.xtvd.datatypes.Program), #getCrew(net.sf.xtvdclient.xtvd.Crew), AbstractParser.getProgramGenre(net.sf.xtvdclient.xtvd.datatypes.ProgramGenre)

parseRootElement

protected void parseRootElement()
Parse an root xtvd record from the AbstractParser.reader, and populate the attribute values for the xtvd class.


parseStations

protected void parseStations()
                      throws DataDirectException
Parse an individual station record from the AbstractParser.reader, create a Map of all the Station records, and set the corresponding Xtvd.stations reference.

Throws:
DataDirectException - - If errors are encountered while reading or writing the XML data.
See Also:
AbstractParser.getStation(), Xtvd#setStations(net.sf.xtvdclient.xtvd.Map)

parseLineups

protected void parseLineups()
                     throws DataDirectException
Parse the lineups top-level element from the AbstractParser.reader, create a Collection with the data, and set the Xtvd.lineups reference.

Throws:
DataDirectException - - If errors are encountered while reading or writing the XML data.
See Also:
AbstractParser.getLineup(), Xtvd#setLineups(net.sf.xtvdclient.xtvd.Map)

parseSchedules

protected void parseSchedules()
                       throws DataDirectException
Parse the schedules top-level element from the AbstractParser.reader, create a Collection with the data, and set the Xtvd.schedules reference.

Throws:
DataDirectException - - If errors are encountered while reading or writing the XML data.
See Also:
AbstractParser.getSchedule(), Xtvd.setSchedules(Collection)

parsePrograms

protected void parsePrograms()
                      throws DataDirectException
Parse the programs top-level element from the AbstractParser.reader, create a Map with the data, and set the Xtvd.programs reference.

Throws:
DataDirectException - - If errors are encountered while reading or writing the XML data.
See Also:
AbstractParser.getProgram(), Xtvd#setPrograms(net.sf.xtvdclient.xtvd.Map)

parseProductionCrew

protected void parseProductionCrew()
                            throws DataDirectException
Parse the productionCrew top-level element from the AbstractParser.reader, create a Map with the data, and set the Xtvd.productionCrew reference.

Throws:
DataDirectException - - If errors are encountered while reading or writing the XML data.
See Also:
AbstractParser.getCrew(), Xtvd#setProductionCrew(net.sf.xtvdclient.xtvd.Map)

parseGenres

protected void parseGenres()
                    throws DataDirectException
Parse the genres top-level element from the AbstractParser.reader, create a Map from the data, and set the Xtvd.genres reference.

Throws:
DataDirectException - - If errors are encountered while reading or writing the XML data.
See Also:
AbstractParser.getProgramGenre(), Xtvd#setGenres(net.sf.xtvdclient.xtvd.Map)