net.sf.xtvdclient.xtvd.datatypes
Class Xtvd

java.lang.Object
  extended by net.sf.xtvdclient.xtvd.datatypes.AbstractDataType
      extended by net.sf.xtvdclient.xtvd.datatypes.Xtvd
All Implemented Interfaces:
java.lang.Comparable

public class Xtvd
extends AbstractDataType

A bean that represents an XTVD XML document. This class may be used to easily transform the XTVD XML to any other XML schema or other custom format (for an example see net.sf.xtvdclient.gui.XTVDTree).

The following code skeleton shows one way to transform the XTVD XML to any other format starting out with a schedule record:

   import java.util.Iterator;
   import net.sf.xtvdclient.xtvd.*;
   import net.sf.xtvdclient.xtvd.datatypes.*;
 

BufferedReader reader = new BufferedReader( new InputStreamReader( new FileInputStream( "xtvd.xml" ), "UTF-8" ) ); Xtvd xtvd = new Xtvd(); Parser parser = ParserFactory.getXtvdParser( reader, xtvd ); parser.parseXTVD(); reader.close();

for ( Iterator schedules = xtvd.getSchedules().iterator(); schedules.hasNext(); ) { Schedule schedule = (Schedule) schedules.next(); // Do schedule record processing

Station station = (Station) xtvd.getStations().get( new Integer( schedule.getStation() ) ); // Do station record processing

for ( Iterator lineups = xtvd.getLineups().entrySet().iterator(); lineups.hasNext(); ) { Lineup lineup = (Lineup) ( (java.util.Map.Entry) lineups.next() ).getValue(); for ( Iterator maps = lineup.getMaps().iterator(); maps.hasNext(); ) { Map map = (Map) maps.next(); if ( map.getStation() == station.getStationId() ) { // Do lineup processing } } }

Program program = (Program) xtvd.getPrograms().get( schedules.getProgram() ); // Do program record processing

Crew crew = (Crew) xtvd.getProductionCrew().get( program.getId() ); if ( crew != null ) { for ( Iterator iterator = crew.getMember().iterator(); iterator.hasNext(); ) { CrewMember member = (CrewMember) iterator.next();

// Add crew member processing } }

ProgramGenre programGenre = (ProgramGenre) xtvd.getGenres().get( program.getId() ); if ( programGenre != null ) { for ( Iterator iterator = programGenre.getGenre().iterator(); iterator.hasNext(); ) { Genre genre = (Genre) iterator.next();

// Add genre processing } } }

Note: After profiling the application, it was found that keeping all the objects in memory to build a complete instance of this class required 1.5M of memory for a 4M XTVD XML document. Hence, using the XtvdParser by itself should not create too many memory problems.


Field Summary
static java.lang.String NAMESPACE_ATTRIBUTES
          The namespaces and schema URI's to specify as the xtvd root element attributes.
 
Fields inherited from class net.sf.xtvdclient.xtvd.datatypes.AbstractDataType
END_OF_LINE
 
Constructor Summary
Xtvd()
          Default constructor.
Xtvd(DateTime from, DateTime to, double schemaVersion)
          Create a new instance of the class with the specified values for the attribute values.
Xtvd(DateTime from, DateTime to, double schemaVersion, java.util.Map<java.lang.Integer,Station> stations, java.util.Map<java.lang.String,Lineup> lineups, java.util.Collection<Schedule> schedules, java.util.Map<java.lang.String,Program> programs, java.util.Map<java.lang.String,Crew> productionCrew, java.util.Map<java.lang.String,ProgramGenre> genres)
          Create a new instance of the class with all the values specified.
 
Method Summary
 DateTime getFrom()
          Returns from.
 java.util.Map<java.lang.String,ProgramGenre> getGenres()
          Returns genres.
 java.util.Map<java.lang.String,Lineup> getLineups()
          Returns lineups.
 java.util.Map<java.lang.String,Crew> getProductionCrew()
          Returns productionCrew.
 java.util.Map<java.lang.String,Program> getPrograms()
          Returns programs.
 java.util.Collection<Schedule> getSchedules()
          Returns schedules.
 double getSchemaVersion()
          Returns schemaVersion.
 java.util.Map getStations()
          Returns stations.
 DateTime getTo()
          Returns to.
 void setFrom(DateTime from)
          Set from.
 void setGenres(java.util.Map<java.lang.String,ProgramGenre> genres)
          Set genres.
 void setLineups(java.util.Map<java.lang.String,Lineup> lineups)
          Set lineups.
 void setProductionCrew(java.util.Map<java.lang.String,Crew> productionCrew)
          Set productionCrew.
 void setPrograms(java.util.Map<java.lang.String,Program> programs)
          Set programs.
 void setSchedules(java.util.Collection<Schedule> schedules)
          Set schedules.
 void setSchemaVersion(double schemaVersion)
          Set schemaVersion.
 void setStations(java.util.Map<java.lang.Integer,Station> stations)
          Set stations.
 void setTo(DateTime to)
          Set to.
 java.lang.String toString()
          Over-ridden implementation.
 
Methods inherited from class net.sf.xtvdclient.xtvd.datatypes.AbstractDataType
compareTo, equals, replaceSpecialCharacters, replaceSpecialCharacters
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NAMESPACE_ATTRIBUTES

public static final java.lang.String NAMESPACE_ATTRIBUTES
The namespaces and schema URI's to specify as the xtvd root element attributes.

"xmlns=\'urn:TMSWebServices\' xmlns:xsi=\'http://www.w3.org/2001/XMLSchema-instance\' xsi:schemaLocation=\'urn:TMSWebServices http://docs.tms.tribune.com/tech/xml/schemas/tmsxtvd.xsd\'"

See Also:
Constant Field Values
Constructor Detail

Xtvd

public Xtvd()
Default constructor. Not particularly useful.


Xtvd

public Xtvd(DateTime from,
            DateTime to,
            double schemaVersion)
Create a new instance of the class with the specified values for the attribute values.

Parameters:
from - The from value to set.
to - The to value to set.
schemaVersion - The schemaVersion value to set.

Xtvd

public Xtvd(DateTime from,
            DateTime to,
            double schemaVersion,
            java.util.Map<java.lang.Integer,Station> stations,
            java.util.Map<java.lang.String,Lineup> lineups,
            java.util.Collection<Schedule> schedules,
            java.util.Map<java.lang.String,Program> programs,
            java.util.Map<java.lang.String,Crew> productionCrew,
            java.util.Map<java.lang.String,ProgramGenre> genres)
Create a new instance of the class with all the values specified.

Parameters:
from - The from value to set.
to - The to value to set.
schemaVersion - The schemaVersion value to set.
stations - The stations reference to set.
lineups - The lineups reference to set.
schedules - The schedules reference to set.
programs - The programs reference to set.
productionCrew - The productionCrew reference to set.
genres - The genres reference to set.
Since:
ddclient version 1.3
Method Detail

toString

public java.lang.String toString()
Over-ridden implementation. Return the original XML representation of the XTVD document.

Overrides:
toString in class java.lang.Object
Returns:
The XTVD XML document that this class represents.

getFrom

public final DateTime getFrom()
Returns from.

Returns:
The value/reference of/to from.

setFrom

public final void setFrom(DateTime from)
Set from.

Parameters:
from - The value to set.

getTo

public final DateTime getTo()
Returns to.

Returns:
The value/reference of/to to.

setTo

public final void setTo(DateTime to)
Set to.

Parameters:
to - The value to set.

getSchemaVersion

public final double getSchemaVersion()
Returns schemaVersion.

Returns:
The value/reference of/to schemaVersion.

setSchemaVersion

public final void setSchemaVersion(double schemaVersion)
Set schemaVersion.

Parameters:
schemaVersion - The value to set.

getStations

public final java.util.Map getStations()
Returns stations.

Returns:
The value/reference of/to stations.

setStations

public final void setStations(java.util.Map<java.lang.Integer,Station> stations)
Set stations.

Parameters:
stations - The value to set.

getLineups

public final java.util.Map<java.lang.String,Lineup> getLineups()
Returns lineups.

Returns:
The value/reference of/to lineups.
Since:
ddclient version 1.3

setLineups

public final void setLineups(java.util.Map<java.lang.String,Lineup> lineups)
Set lineups.

Parameters:
lineups - The value to set.
Since:
ddclient version 1.3

getSchedules

public final java.util.Collection<Schedule> getSchedules()
Returns schedules.

Returns:
The value/reference of/to schedules.

setSchedules

public final void setSchedules(java.util.Collection<Schedule> schedules)
Set schedules.

Parameters:
schedules - The value to set.

getPrograms

public final java.util.Map<java.lang.String,Program> getPrograms()
Returns programs.

Returns:
The value/reference of/to programs.

setPrograms

public final void setPrograms(java.util.Map<java.lang.String,Program> programs)
Set programs.

Parameters:
programs - The value to set.

getProductionCrew

public final java.util.Map<java.lang.String,Crew> getProductionCrew()
Returns productionCrew.

Returns:
The value/reference of/to productionCrew.

setProductionCrew

public final void setProductionCrew(java.util.Map<java.lang.String,Crew> productionCrew)
Set productionCrew.

Parameters:
productionCrew - The value to set.

getGenres

public final java.util.Map<java.lang.String,ProgramGenre> getGenres()
Returns genres.

Returns:
The value/reference of/to genres.

setGenres

public final void setGenres(java.util.Map<java.lang.String,ProgramGenre> genres)
Set genres.

Parameters:
genres - The value to set.