speedscheduler.io
Class XmlScheduleIO

java.lang.Object
  extended by speedscheduler.io.XmlScheduleIO
All Implemented Interfaces:
ScheduleIO

public class XmlScheduleIO
extends java.lang.Object
implements ScheduleIO

An implementation of ScheduleIO that persists Schedules to and loads Schedules from an XML file.


Nested Class Summary
private  class XmlScheduleIO.ScheduleHandler
           
 
Field Summary
private  int defaultMaxDownloadRate
           
private  int defaultMaxUploadRate
           
private static java.lang.String INDENT
           
private static java.lang.String[] SAX_PARSER_CLASSES
           
private  java.util.Vector schedules
           
protected  boolean schedulesLoaded
           
 
Constructor Summary
XmlScheduleIO()
           
 
Method Summary
 int getDefaultMaxDownloadSpeed()
           
 int getDefaultMaxUploadSpeed()
           
private  java.lang.String getSaveFileName()
          Helper function that tells us where to save the Schedules.
private  org.xml.sax.XMLReader getSaxParser()
          Finds an appropriate SAX driver class name
 java.util.Vector getSchedules()
           
private  boolean isValidSaxDriver(java.lang.String parserClassName)
          Checks a class name.
 void loadSchedules()
           
static void main(java.lang.String[] args)
          For unit testing only.
 void saveDefaultSpeeds(int defaultMaxUploadSpeed, int defaultMaxDownloadSpeed)
           
 void saveSchedules(java.util.Vector schedulesToSave, int defaultMaxUploadRate, int defaultMaxDownloadRate)
           
 java.lang.String scheduleToXml(Schedule schedule)
          Converts a schedul to an XML representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

schedulesLoaded

protected boolean schedulesLoaded

SAX_PARSER_CLASSES

private static final java.lang.String[] SAX_PARSER_CLASSES

INDENT

private static final java.lang.String INDENT
See Also:
Constant Field Values

defaultMaxUploadRate

private int defaultMaxUploadRate

defaultMaxDownloadRate

private int defaultMaxDownloadRate

schedules

private java.util.Vector schedules
Constructor Detail

XmlScheduleIO

public XmlScheduleIO()
Method Detail

saveSchedules

public void saveSchedules(java.util.Vector schedulesToSave,
                          int defaultMaxUploadRate,
                          int defaultMaxDownloadRate)
                   throws java.io.IOException
Specified by:
saveSchedules in interface ScheduleIO
Throws:
java.io.IOException
See Also:
ScheduleIO.saveSchedules(java.util.Vector, int, int)

saveDefaultSpeeds

public void saveDefaultSpeeds(int defaultMaxUploadSpeed,
                              int defaultMaxDownloadSpeed)
                       throws java.io.IOException
Specified by:
saveDefaultSpeeds in interface ScheduleIO
Throws:
java.io.IOException
See Also:
ScheduleIO.saveDefaultSpeeds(int, int)

scheduleToXml

public java.lang.String scheduleToXml(Schedule schedule)
Converts a schedul to an XML representation.

Parameters:
schedule - The Schedule to convert to XML.
Returns:

main

public static void main(java.lang.String[] args)
For unit testing only.


loadSchedules

public void loadSchedules()
                   throws java.io.IOException
Specified by:
loadSchedules in interface ScheduleIO
Throws:
java.io.IOException
See Also:
ScheduleIO.loadSchedules()

getSaxParser

private org.xml.sax.XMLReader getSaxParser()
                                    throws org.xml.sax.SAXException
Finds an appropriate SAX driver class name

Returns:
Throws:
org.xml.sax.SAXException

isValidSaxDriver

private boolean isValidSaxDriver(java.lang.String parserClassName)
Checks a class name. If it is a usable SAX parser, returns true.

Parameters:
parserClassName -
Returns:
true if the supplied driver class name is a usable SAX parser

getSchedules

public java.util.Vector getSchedules()
Specified by:
getSchedules in interface ScheduleIO
See Also:
ScheduleIO.getSchedules()

getDefaultMaxUploadSpeed

public int getDefaultMaxUploadSpeed()
Specified by:
getDefaultMaxUploadSpeed in interface ScheduleIO
See Also:
speedscheduler.ScheduleIO#getDefaultMaxUploadSpeed()

getDefaultMaxDownloadSpeed

public int getDefaultMaxDownloadSpeed()
Specified by:
getDefaultMaxDownloadSpeed in interface ScheduleIO
See Also:
speedscheduler.ScheduleIO#getDefaultMaxDownloadSpeed()

getSaveFileName

private java.lang.String getSaveFileName()
Helper function that tells us where to save the Schedules.