|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.xtvdclient.xtvd.datatypes.AbstractDataType
net.sf.xtvdclient.xtvd.datatypes.Xtvd
public class Xtvd
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 |
---|
public static final java.lang.String NAMESPACE_ATTRIBUTES
Constructor Detail |
---|
public Xtvd()
public Xtvd(DateTime from, DateTime to, double schemaVersion)
from
- The from
value to set.to
- The to
value to set.schemaVersion
- The schemaVersion
value to set.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)
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.Method Detail |
---|
public java.lang.String toString()
XML
representation
of the XTVD document
.
toString
in class java.lang.Object
public final DateTime getFrom()
from
.
public final void setFrom(DateTime from)
from
.
from
- The value to set.public final DateTime getTo()
to
.
public final void setTo(DateTime to)
to
.
to
- The value to set.public final double getSchemaVersion()
schemaVersion
.
public final void setSchemaVersion(double schemaVersion)
schemaVersion
.
schemaVersion
- The value to set.public final java.util.Map getStations()
stations
.
public final void setStations(java.util.Map<java.lang.Integer,Station> stations)
stations
.
stations
- The value to set.public final java.util.Map<java.lang.String,Lineup> getLineups()
lineups
.
public final void setLineups(java.util.Map<java.lang.String,Lineup> lineups)
lineups
.
lineups
- The value to set.public final java.util.Collection<Schedule> getSchedules()
schedules
.
public final void setSchedules(java.util.Collection<Schedule> schedules)
schedules
.
schedules
- The value to set.public final java.util.Map<java.lang.String,Program> getPrograms()
programs
.
public final void setPrograms(java.util.Map<java.lang.String,Program> programs)
programs
.
programs
- The value to set.public final java.util.Map<java.lang.String,Crew> getProductionCrew()
productionCrew
.
public final void setProductionCrew(java.util.Map<java.lang.String,Crew> productionCrew)
productionCrew
.
productionCrew
- The value to set.public final java.util.Map<java.lang.String,ProgramGenre> getGenres()
genres
.
public final void setGenres(java.util.Map<java.lang.String,ProgramGenre> genres)
genres
.
genres
- The value to set.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |