@ -4,6 +4,7 @@ import org.w3c.dom.Element;
import org.w3c.dom.NodeList ;
import org.xml.sax.InputSource ;
import org.xml.sax.SAXException ;
import seng302.GPSCoordinate ;
import seng302.XMLReader ;
import javax.xml.parsers.ParserConfigurationException ;
@ -15,6 +16,15 @@ import java.io.InputStream;
* /
public class RegattaXMLReader extends XMLReader {
private Regatta regatta ;
int regattaID ;
String regattaName ;
int raceID = 0 ;
String courseName ;
double centralLatitude ;
double centralLongitude ;
double centralAltitude ;
float utcOffset ;
float magneticVariation ;
/ * *
* Constructor for Regatta XML
@ -59,20 +69,93 @@ public class RegattaXMLReader extends XMLReader {
}
private void makeRegatta ( Element attributes ) {
int regattaID = Integer . parseInt ( getTextValueOfNode ( attributes , "RegattaID" ) ) ;
String regattaName = getTextValueOfNode ( attributes , "RegattaName" ) ;
String courseName = getTextValueOfNode ( attributes , "CourseName" ) ;
double centralLatitude = Double . parseDouble ( getTextValueOfNode ( attributes , "CentralLatitude" ) ) ;
double centralLongitude = Double . parseDouble ( getTextValueOfNode ( attributes , "CentralLongitude" ) ) ;
System . out . println ( String . format ( "central lat %s long %s" , centralLatitude , centralLongitude ) ) ;
double centralAltitude = Double . parseDouble ( getTextValueOfNode ( attributes , "CentralAltitude" ) ) ;
float utcOffset = Float . parseFloat ( getTextValueOfNode ( attributes , "UtcOffset" ) ) ;
float magneticVariation = Float . parseFloat ( getTextValueOfNode ( attributes , "MagneticVariation" ) ) ;
regatta = new Regatta ( regattaID , regattaName , courseName , centralLatitude , centralLongitude , centralAltitude , utcOffset , magneticVariation ) ;
this . regattaID = Integer . parseInt ( getTextValueOfNode ( attributes , "RegattaID" ) ) ;
this . regattaName = getTextValueOfNode ( attributes , "RegattaName" ) ;
this . courseName = getTextValueOfNode ( attributes , "CourseName" ) ;
this . centralLatitude = Double . parseDouble ( getTextValueOfNode ( attributes , "CentralLatitude" ) ) ;
this . centralLongitude = Double . parseDouble ( getTextValueOfNode ( attributes , "CentralLongitude" ) ) ;
this . centralAltitude = Double . parseDouble ( getTextValueOfNode ( attributes , "CentralAltitude" ) ) ;
this . utcOffset = Float . parseFloat ( getTextValueOfNode ( attributes , "UtcOffset" ) ) ;
this . magneticVariation = Float . parseFloat ( getTextValueOfNode ( attributes , "MagneticVariation" ) ) ;
}
public Regatta getRegatta ( ) {
return regatta ;
}
public int getRegattaID ( ) {
return regattaID ;
}
public void setRegattaID ( int ID ) {
this . regattaID = ID ;
}
public String getRegattaName ( ) {
return regattaName ;
}
public void setRegattaName ( String regattaName ) {
this . regattaName = regattaName ;
}
public int getRaceID ( ) {
return raceID ;
}
public void setRaceID ( int raceID ) {
this . raceID = raceID ;
}
public String getCourseName ( ) {
return courseName ;
}
public void setCourseName ( String courseName ) {
this . courseName = courseName ;
}
public double getCentralLatitude ( ) {
return centralLatitude ;
}
public void setCentralLatitude ( double centralLatitude ) {
this . centralLatitude = centralLatitude ;
}
public double getCentralLongitude ( ) {
return centralLongitude ;
}
public void setCentralLongitude ( double centralLongitude ) {
this . centralLongitude = centralLongitude ;
}
public double getCentralAltitude ( ) {
return centralAltitude ;
}
public void setCentralAltitude ( double centralAltitude ) {
this . centralAltitude = centralAltitude ;
}
public float getUtcOffset ( ) {
return utcOffset ;
}
public void setUtcOffset ( float utcOffset ) {
this . utcOffset = utcOffset ;
}
public float getMagneticVariation ( ) {
return magneticVariation ;
}
public void setMagneticVariation ( float magneticVariation ) {
this . magneticVariation = magneticVariation ;
}
public GPSCoordinate getGPSCoordinate ( ) {
return new GPSCoordinate ( centralLatitude , centralLongitude ) ;
}
}