net.sf.xtvdclient.xtvd.parser
Class AbstractParser

java.lang.Object
  extended by net.sf.xtvdclient.xtvd.parser.AbstractParser
All Implemented Interfaces:
Parser
Direct Known Subclasses:
RDBMSParser, WriterParser, XtvdParser

public abstract class AbstractParser
extends java.lang.Object
implements Parser

An abstract base class for all XTVD parsers. All parsers are implemented using a factory design pattern and are based upon Streaming API for XML (StAX).

See Also:
ParserFactory

Field Summary
protected  java.io.Writer log
          A Writer that is used to write log messages to.
protected  javax.xml.stream.XMLStreamReader reader
          An instance of the XML reader used to pull-parse the XTVD XML data.
protected  java.text.SimpleDateFormat sdf
          The formatter used to format time stamps that are used to log the parsing process.
 
Fields inherited from interface net.sf.xtvdclient.xtvd.parser.Parser
END_OF_LINE
 
Constructor Summary
protected AbstractParser()
          Default constructor.
protected AbstractParser(java.io.Reader reader)
          Create a new instance of the parser that reads the data from the specified InputStream.
 
Method Summary
protected  Crew getCrew()
          Parse the crew record in the XML data stream and create a new net.sf.xtvdclient.xtvd.Crew object with the values.
protected  Crew getCrew(Crew crew)
          Parse the crew record in the XML data stream and populate the values of the instance variables of the specified Crew object.
protected  Genre getGenre()
          Parse the genre record from the XML stream and create a new net.sf.xtvdclient.xtvd.Genre object with that data.
protected  Genre getGenre(Genre genre)
          Parse the genre record from the XML stream and populate the Genre object fields with that data.
protected  Lineup getLineup()
          Parse the lineup record in the XML data stream and create a new net.sf.xtvdclient.xtvd.Lineup object with the parsed values from the XML stream.
protected  Lineup getLineup(Lineup lineup)
          Parse the lineup record in the XML data stream and populate the values of the instance variables of the specified Lineup object.
 java.io.Writer getLog()
          Returns log.
protected  Map getMap()
          Parse the map record from the XML stream and create a new net.sf.xtvdclient.xtvd.Map object with that data.
protected  Map getMap(Map map)
          Parse the map record from the XML stream and populate the instance variables of the specified Map object with the parsed data.
protected  CrewMember getMember()
          Parse the member record from the XML stream and create a new CrewMember object with that data.
protected  CrewMember getMember(CrewMember member)
          Parse the member record from the XML stream and populate the CrewMember object with that data.
protected  java.util.Collection getMessages()
          Skip all the SOAP envelopes, and move the the messages element in the XML stream.
protected  Part getPart()
          Parse the part record from the XML stream and create a new net.sf.xtvdclient.xtvd.Part object with that data.
protected  Part getPart(Part part)
          Parse the part record from the XML stream and populate the Part object fields with that data.
protected  Program getProgram()
          Parse the program record in the XML data stream and create a Program object with the data.
protected  Program getProgram(Program program)
          Parse the program record in the XML data stream and populate the values of the instance variables of the specified Program object.
protected  ProgramGenre getProgramGenre()
          Parse the programGenre record in the XML data stream and create a new instance of ProgramGenre with the values.
protected  ProgramGenre getProgramGenre(ProgramGenre programGenre)
          Parse the programGenre record in the XML data stream and populate the values of the instance variables of the specified ProgramGenre object.
protected  Schedule getSchedule()
          Parse the schedule record in the XML data stream and create a new Schedule object with the parsed values from the XML stream.
protected  Schedule getSchedule(Schedule schedule)
          Parse the schedule record in the XML data stream and populate the values of the instance variables of the specified Schedule object.
protected  Station getStation()
          Parse the station record in the XML data stream and return a new instance of Station with the values.
protected  Station getStation(Station station)
          Parse the station record in the XML data stream and populate the values of the instance variables of the specified Station object.
abstract  void parseXTVD()
          Parse the XTVD document and extract the information from the top-level elements.
 void setLog(java.io.Writer log)
          Set log.
 void toStartTag()
          Advance the reader to the next starting XML element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

reader

protected javax.xml.stream.XMLStreamReader reader
An instance of the XML reader used to pull-parse the XTVD XML data.


log

protected java.io.Writer log
A Writer that is used to write log messages to. By default this is set to System.err. Please use setLog(Writer) if you wish to specify another log stream.


sdf

protected java.text.SimpleDateFormat sdf
The formatter used to format time stamps that are used to log the parsing process.

Constructor Detail

AbstractParser

protected AbstractParser()
Default constructor. Not to be directly invoked.


AbstractParser

protected AbstractParser(java.io.Reader reader)
                  throws DataDirectException
Create a new instance of the parser that reads the data from the specified InputStream.

Parameters:
Reader - reader - The Reader from which the XML data is to be parsed.
Throws:
net.sf.xtvdclient.gui.DataDirectException - - If errors are encountered while initialising the parser or reading the data.
DataDirectException
Method Detail

parseXTVD

public abstract void parseXTVD()
                        throws DataDirectException
Parse the XTVD document and extract the information from the top-level elements. Concrete implementations of this class must be properly initialised with the appropriate means for saving the data extracted by this method.

Specified by:
parseXTVD in interface Parser
Throws:
DataDirectException - - If errors are encountered while parsing the XML data stream or while saving the parsed contents.
See Also:
getStation(Station), #getLineup(net.sf.xtvdclient.xtvd.Lineup), getSchedule(Schedule), getProgram(Program), #getCrew(net.sf.xtvdclient.xtvd.Crew), #getGenre(net.sf.xtvdclient.xtvd.Genre)

getMessages

protected java.util.Collection getMessages()
                                    throws DataDirectException
Skip all the SOAP envelopes, and move the the messages element in the XML stream. Extract any message elements in the response, and create a collection with the messages.

Returns:
Collection - A collection of messages if any messages are found. If not an empty collection is returned.
Throws:
DataDirectException - - If errors are encountered while parsing the XML stream.

getStation

protected Station getStation()
                      throws DataDirectException
Parse the station record in the XML data stream and return a new instance of Station with the values. Creates a new instance of Station, and then invokes getStation(Station).

Returns:
Station - The new instance of Station.
Throws:
DataDirectException - - If errors are encountered while parsing the XML stream.

getStation

protected Station getStation(Station station)
                      throws DataDirectException
Parse the station record in the XML data stream and populate the values of the instance variables of the specified Station object.

Parameters:
Station - station - The instance of Station whose fields are populated with the parsed data from the XML stream.
Returns:
Station - The modified instance of Station.
Throws:
DataDirectException - - If errors are encountered while parsing the XML stream.

getLineup

protected Lineup getLineup()
                    throws DataDirectException
Parse the lineup record in the XML data stream and create a new net.sf.xtvdclient.xtvd.Lineup object with the parsed values from the XML stream. Also extract the map child elements of the record, and create appropriate net.sf.xtvdclient.xtvd.Map instances.

Returns:
Lineup - The new instance of net.sf.xtvdclient.xtvd.Lineup.
Throws:
DataDirectException - - If errors are encountered while parsing the XML stream.
See Also:
#getLineup(net.sf.xtvdclient.xtvd.Lineup)

getLineup

protected Lineup getLineup(Lineup lineup)
                    throws DataDirectException
Parse the lineup record in the XML data stream and populate the values of the instance variables of the specified Lineup object. Also extract the map child elements of the record, and create appropriate net.sf.xtvdclient.xtvd.Map instances.

Parameters:
Lineup - station - The instance of Lineup whose fields are populated with the parsed data from the XML stream.
Returns:
Lineup - The modified instance of Lineup.
Throws:
DataDirectException - - If errors are encountered while parsing the XML stream.
See Also:
getMap()

getMap

protected Map getMap()
Parse the map record from the XML stream and create a new net.sf.xtvdclient.xtvd.Map object with that data.

Returns:
Map - The net.sf.xtvdclient.xtvd.Map object that was created with the parsed data.

getMap

protected Map getMap(Map map)
Parse the map record from the XML stream and populate the instance variables of the specified Map object with the parsed data.

Returns:
Map - The Map object that was modified with the parsed data.

getSchedule

protected Schedule getSchedule()
                        throws DataDirectException
Parse the schedule record in the XML data stream and create a new Schedule object with the parsed values from the XML stream. Also extract the part child element of the record, and create appropriate net.sf.xtvdclient.xtvd.Part instances.

Returns:
Schedule - The new instance of Schedule.
Throws:
DataDirectException - - If errors are encountered while parsing the XML stream.
See Also:
getSchedule(Schedule)

getSchedule

protected Schedule getSchedule(Schedule schedule)
                        throws DataDirectException
Parse the schedule record in the XML data stream and populate the values of the instance variables of the specified Schedule object. Also extract the part child element of the record, and create the appropriate net.sf.xtvdclient.xtvd.Part instance.

Parameters:
Schedule - schedule - The instance of Schedule whose fields are populated with the parsed data from the XML stream.
Returns:
Schedule - The modified instance of Schedule.
Throws:
DataDirectException - - If errors are encountered while parsing the XML stream.
See Also:
getPart()

getPart

protected Part getPart()
Parse the part record from the XML stream and create a new net.sf.xtvdclient.xtvd.Part object with that data.

Returns:
Part - The net.sf.xtvdclient.xtvd.Part object that was created with the parsed data.
See Also:
#getPart(net.sf.xtvdclient.xtvd.Part)

getPart

protected Part getPart(Part part)
Parse the part record from the XML stream and populate the Part object fields with that data.

Parameters:
Part - part - The Part object whose instance variables are to be set with the parsed data.
Returns:
Part - The modified Part object. parsed data.

getProgram

protected Program getProgram()
                      throws DataDirectException
Parse the program record in the XML data stream and create a Program object with the data.

Returns:
Program - The new instance of Program that was created.
Throws:
DataDirectException - - If errors are encountered while parsing the XML stream.
See Also:
getProgram(Program)

getProgram

protected Program getProgram(Program program)
                      throws DataDirectException
Parse the program record in the XML data stream and populate the values of the instance variables of the specified Program object.

Parameters:
Program - program - The instance of Program whose fields are populated with the parsed data from the XML stream.
Returns:
Program - The modified instance of Program.
Throws:
DataDirectException - - If errors are encountered while parsing the XML stream.

getCrew

protected Crew getCrew()
                throws DataDirectException
Parse the crew record in the XML data stream and create a new net.sf.xtvdclient.xtvd.Crew object with the values.

Returns:
Crew - The new instance of net.sf.xtvdclient.xtvd.Crew.
Throws:
DataDirectException - - If errors are encountered while parsing the XML stream.
See Also:
#getCrew(net.sf.xtvdclient.xtvd.Crew)

getCrew

protected Crew getCrew(Crew crew)
                throws DataDirectException
Parse the crew record in the XML data stream and populate the values of the instance variables of the specified Crew object.

Parameters:
Crew - crew - The instance of Crew whose fields are populated with the parsed data from the XML stream.
Returns:
Crew - The modified instance of Crew.
Throws:
DataDirectException - - If errors are encountered while parsing the XML stream.

getMember

protected CrewMember getMember()
                        throws DataDirectException
Parse the member record from the XML stream and create a new CrewMember object with that data.

Returns:
CrewMember - The CrewMember object that was created with the parsed data.
Throws:
DataDirectException - - If errors are encountered while parsing the stream.

getMember

protected CrewMember getMember(CrewMember member)
                        throws DataDirectException
Parse the member record from the XML stream and populate the CrewMember object with that data.

Parameters:
CrewMember - member - The CrewMember object whose fields are to be populated with the parsed data.
Returns:
CrewMember - The modified CrewMember object.
Throws:
DataDirectException - - If errors are encountered while parsing the stream.

getProgramGenre

protected ProgramGenre getProgramGenre()
                                throws DataDirectException
Parse the programGenre record in the XML data stream and create a new instance of ProgramGenre with the values.

Returns:
ProgramGenre - The new instance of ProgramGenre.
Throws:
net.sf.xtvdclient.gui.DataDirectException - - If errors are encountered while parsing the XML stream.
DataDirectException
See Also:
getProgramGenre(ProgramGenre)

getProgramGenre

protected ProgramGenre getProgramGenre(ProgramGenre programGenre)
                                throws DataDirectException
Parse the programGenre record in the XML data stream and populate the values of the instance variables of the specified ProgramGenre object.

Parameters:
ProgramGenre - programGenre - The instance of ProgramGenre whose fields are populated with the parsed data from the XML stream.
Returns:
ProgramGenre - The modified instance of ProgramGenre.
Throws:
DataDirectException - - If errors are encountered while parsing the XML stream.
See Also:
getGenre()

getGenre

protected Genre getGenre()
                  throws DataDirectException
Parse the genre record from the XML stream and create a new net.sf.xtvdclient.xtvd.Genre object with that data.

Returns:
Genre - The net.sf.xtvdclient.xtvd.Genre object that was created with the parsed data.
Throws:
DataDirectException - - If errors are encountered while parsing the stream.

getGenre

protected Genre getGenre(Genre genre)
                  throws DataDirectException
Parse the genre record from the XML stream and populate the Genre object fields with that data.

Parameters:
Genre - genre - The Genre object whose fields are to be set with the parsed data.
Returns:
Genre - The modified Genre object.
Throws:
DataDirectException - - If errors are encountered while parsing the stream.

toStartTag

public void toStartTag()
                throws DataDirectException
Advance the reader to the next starting XML element.

Throws:
DataDirectException - - If errors are encountered while parsing the stream.

getLog

public final java.io.Writer getLog()
Returns log.

Specified by:
getLog in interface Parser
Returns:
Writer - The value/reference of/to log.

setLog

public final void setLog(java.io.Writer log)
Set log.

Specified by:
setLog in interface Parser
Parameters:
Writer - log - The value to set.