Commented and javadoc-ed RegattaData and BoatData

#story[9]
main
Erika Savell 9 years ago
parent 19224ba840
commit e30aa02aac

@ -32,6 +32,10 @@ public class BoatData {
this.boatData = boatData; this.boatData = boatData;
} }
/**
* Creates an AC35 officially formatted xml description of boats competing in a race
* @return String containing xml-formatted boats description
*/
public String createXML() { public String createXML() {
try { try {
@ -70,6 +74,10 @@ public class BoatData {
} }
/**
* Runs through competing boats, creating an element for each
* @param boatsElement boats element to be added to
*/
private void appendIndividualBoats(Element boatsElement) { private void appendIndividualBoats(Element boatsElement) {
for (int i=0; i < boatData.size(); i++) { for (int i=0; i < boatData.size(); i++) {
@ -87,6 +95,10 @@ public class BoatData {
} }
} }
/**
* Creates and appends type attribute of a boat
* @param boat element being added to
*/
private void appendType(Element boat) { private void appendType(Element boat) {
//Type attribute //Type attribute
Attr attrType = doc.createAttribute("Type"); Attr attrType = doc.createAttribute("Type");
@ -94,6 +106,11 @@ public class BoatData {
boat.setAttributeNode(attrType); boat.setAttributeNode(attrType);
} }
/**
* Creates and appends sourceID attribute of a boat
* @param boat element being added to
* @param i boat number
*/
private void appendSourceID(Element boat, int i) { private void appendSourceID(Element boat, int i) {
//SourceID attribute //SourceID attribute
Attr attrSourceID = doc.createAttribute("SourceID"); Attr attrSourceID = doc.createAttribute("SourceID");
@ -101,6 +118,10 @@ public class BoatData {
boat.setAttributeNode(attrSourceID); boat.setAttributeNode(attrSourceID);
} }
/**
* Creates and appends shapeID attribute of a boat
* @param boat element being added to
*/
private void appendShapeID(Element boat) { private void appendShapeID(Element boat) {
//ShapeID attribute //ShapeID attribute
Attr attrShapeID = doc.createAttribute("ShapeID"); Attr attrShapeID = doc.createAttribute("ShapeID");
@ -108,6 +129,10 @@ public class BoatData {
boat.setAttributeNode(attrShapeID); boat.setAttributeNode(attrShapeID);
} }
/**
* Creates and appends hull name attribute of a boat
* @param boat element being added to
*/
private void appendHullNum(Element boat) { private void appendHullNum(Element boat) {
//HullNum attribute //HullNum attribute
Attr attrHullNum = doc.createAttribute("HullNum"); Attr attrHullNum = doc.createAttribute("HullNum");
@ -115,6 +140,11 @@ public class BoatData {
boat.setAttributeNode(attrHullNum); boat.setAttributeNode(attrHullNum);
} }
/**
* Creates and appends stow name attribute of a boat
* @param boat element being added to
* @param i boat number
*/
private void appendStoweName(Element boat, int i) { private void appendStoweName(Element boat, int i) {
//StoweName attribute //StoweName attribute
Attr attrStoweName = doc.createAttribute("StoweName"); Attr attrStoweName = doc.createAttribute("StoweName");
@ -122,6 +152,11 @@ public class BoatData {
boat.setAttributeNode(attrStoweName); boat.setAttributeNode(attrStoweName);
} }
/**
* Creates and appends short name attribute of a boat
* @param boat element being added to
* @param i boat number
*/
private void appendShortName(Element boat, int i) { private void appendShortName(Element boat, int i) {
//ShortName attribute //ShortName attribute
Attr attrShortName = doc.createAttribute("ShortName"); Attr attrShortName = doc.createAttribute("ShortName");
@ -129,6 +164,11 @@ public class BoatData {
boat.setAttributeNode(attrShortName); boat.setAttributeNode(attrShortName);
} }
/**
* Creates and appends boat name attribute of a boat
* @param boat element being added to
* @param i boat number
*/
private void appendBoatName(Element boat, int i) { private void appendBoatName(Element boat, int i) {
//BoatName attribute //BoatName attribute
Attr attrBoatName = doc.createAttribute("BoatName"); Attr attrBoatName = doc.createAttribute("BoatName");
@ -136,6 +176,11 @@ public class BoatData {
boat.setAttributeNode(attrBoatName); boat.setAttributeNode(attrBoatName);
} }
/**
* Creates and appends gps attributes of a boat
* @param boat element being added to
* @param i boat number
*/
private void appendGPSCoords(Element boat, int i) { private void appendGPSCoords(Element boat, int i) {
//GPSCoord for element //GPSCoord for element
Element GPSCoord = doc.createElement("GPSposition"); Element GPSCoord = doc.createElement("GPSposition");

@ -36,7 +36,7 @@ public class RaceData {
/** /**
* Creates an AC35 officially formatted xml description of a race. * Creates an AC35 officially formatted xml description of a race.
* @return String containing xml - formatted race description * @return String containing xml-formatted race description
*/ */
public String createXML() { public String createXML() {

@ -29,6 +29,11 @@ public class RegattaData {
this.regattaDataSource = regattaDataSource; this.regattaDataSource = regattaDataSource;
} }
/**
* Creates an AC35 officially formatted xml description of a regatta
* @return String containing xml-formatted regatta description
*/
public String createXML() { public String createXML() {
try { try {
@ -62,8 +67,23 @@ public class RegattaData {
} }
} }
/**
* Creates all necessary child elements and appends them to the xml doc
*/
private void appendChildElements() {
appendRegattaID();
appendRegattaName();
appendCourseName();
appendCentralLatitude();
appendCentralLongitude();
appendCentralAltitude();
appedUtcOffset();
appendMagneticVariation();
}
/**
* Creates and appends regatta id element
*/
private void appendRegattaID() { private void appendRegattaID() {
//regattaID element //regattaID element
Element regattaID = doc.createElement("RegattaID"); Element regattaID = doc.createElement("RegattaID");
@ -71,6 +91,9 @@ public class RegattaData {
rootElement.appendChild(regattaID); rootElement.appendChild(regattaID);
} }
/**
* Creates and appends regatta name element
*/
private void appendRegattaName() { private void appendRegattaName() {
//regattaName element //regattaName element
Element regattaName = doc.createElement("RegattaName"); Element regattaName = doc.createElement("RegattaName");
@ -78,6 +101,9 @@ public class RegattaData {
rootElement.appendChild(regattaName); rootElement.appendChild(regattaName);
} }
/**
* Creates and appends course name element
*/
private void appendCourseName() { private void appendCourseName() {
//courseName element //courseName element
Element courseName = doc.createElement("CourseName"); Element courseName = doc.createElement("CourseName");
@ -85,6 +111,9 @@ public class RegattaData {
rootElement.appendChild(courseName); rootElement.appendChild(courseName);
} }
/**
* Creates and appends central latitude element
*/
private void appendCentralLatitude() { private void appendCentralLatitude() {
//centralLatitude element //centralLatitude element
Element centralLat = doc.createElement("CentralLatitude"); Element centralLat = doc.createElement("CentralLatitude");
@ -92,6 +121,9 @@ public class RegattaData {
rootElement.appendChild(centralLat); rootElement.appendChild(centralLat);
} }
/**
* Creates and appends central longitude element
*/
private void appendCentralLongitude() { private void appendCentralLongitude() {
//centralLongitude element //centralLongitude element
Element centralLong = doc.createElement("CentralLongitude"); Element centralLong = doc.createElement("CentralLongitude");
@ -99,6 +131,9 @@ public class RegattaData {
rootElement.appendChild(centralLong); rootElement.appendChild(centralLong);
} }
/**
* Creates and appends central altitude element
*/
private void appendCentralAltitude() { private void appendCentralAltitude() {
//centralAltitude element //centralAltitude element
Element centralAlt = doc.createElement("CentralAltitude"); Element centralAlt = doc.createElement("CentralAltitude");
@ -106,14 +141,19 @@ public class RegattaData {
rootElement.appendChild(centralAlt); rootElement.appendChild(centralAlt);
} }
/**
* Creates and appends utc offset element
*/
private void appedUtcOffset() { private void appedUtcOffset() {
//utcOffset element //utcOffset element
Element utcOffset = doc.createElement("UtcOffset"); Element utcOffset = doc.createElement("UtcOffset");
utcOffset.appendChild(doc.createTextNode(Double.toString(regattaDataSource.getRegatta().getUtcOffset()))); utcOffset.appendChild(doc.createTextNode(Double.toString(regattaDataSource.getRegatta().getUtcOffset())));
rootElement.appendChild(utcOffset); rootElement.appendChild(utcOffset);
} }
/**
* Creates and appends magnetic variation element
*/
private void appendMagneticVariation() { private void appendMagneticVariation() {
//magneticVariation element //magneticVariation element
Element magneticVariation = doc.createElement("MagneticVariation"); Element magneticVariation = doc.createElement("MagneticVariation");
@ -122,14 +162,4 @@ public class RegattaData {
} }
private void appendChildElements() {
appendRegattaID();
appendRegattaName();
appendCourseName();
appendCentralLatitude();
appendCentralLongitude();
appendCentralAltitude();
appedUtcOffset();
appendMagneticVariation();
}
} }

Loading…
Cancel
Save