From e30aa02aacf4d3a9deb21dc5ae36abaa579c7f43 Mon Sep 17 00:00:00 2001 From: Erika Savell Date: Tue, 25 Apr 2017 17:19:04 +1200 Subject: [PATCH] Commented and javadoc-ed RegattaData and BoatData #story[9] --- mock/src/main/java/seng302/Data/BoatData.java | 45 ++++++++++++++++ mock/src/main/java/seng302/Data/RaceData.java | 2 +- .../main/java/seng302/Data/RegattaData.java | 54 ++++++++++++++----- 3 files changed, 88 insertions(+), 13 deletions(-) diff --git a/mock/src/main/java/seng302/Data/BoatData.java b/mock/src/main/java/seng302/Data/BoatData.java index 7e02bdf9..d8a5594b 100644 --- a/mock/src/main/java/seng302/Data/BoatData.java +++ b/mock/src/main/java/seng302/Data/BoatData.java @@ -32,6 +32,10 @@ public class 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() { 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) { 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) { //Type attribute Attr attrType = doc.createAttribute("Type"); @@ -94,6 +106,11 @@ public class BoatData { 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) { //SourceID attribute Attr attrSourceID = doc.createAttribute("SourceID"); @@ -101,6 +118,10 @@ public class BoatData { boat.setAttributeNode(attrSourceID); } + /** + * Creates and appends shapeID attribute of a boat + * @param boat element being added to + */ private void appendShapeID(Element boat) { //ShapeID attribute Attr attrShapeID = doc.createAttribute("ShapeID"); @@ -108,6 +129,10 @@ public class BoatData { boat.setAttributeNode(attrShapeID); } + /** + * Creates and appends hull name attribute of a boat + * @param boat element being added to + */ private void appendHullNum(Element boat) { //HullNum attribute Attr attrHullNum = doc.createAttribute("HullNum"); @@ -115,6 +140,11 @@ public class BoatData { 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) { //StoweName attribute Attr attrStoweName = doc.createAttribute("StoweName"); @@ -122,6 +152,11 @@ public class BoatData { 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) { //ShortName attribute Attr attrShortName = doc.createAttribute("ShortName"); @@ -129,6 +164,11 @@ public class BoatData { 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) { //BoatName attribute Attr attrBoatName = doc.createAttribute("BoatName"); @@ -136,6 +176,11 @@ public class BoatData { 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) { //GPSCoord for element Element GPSCoord = doc.createElement("GPSposition"); diff --git a/mock/src/main/java/seng302/Data/RaceData.java b/mock/src/main/java/seng302/Data/RaceData.java index 36abaf16..096998b5 100644 --- a/mock/src/main/java/seng302/Data/RaceData.java +++ b/mock/src/main/java/seng302/Data/RaceData.java @@ -36,7 +36,7 @@ public class RaceData { /** * 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() { diff --git a/mock/src/main/java/seng302/Data/RegattaData.java b/mock/src/main/java/seng302/Data/RegattaData.java index ef51deea..1fa7ed8d 100644 --- a/mock/src/main/java/seng302/Data/RegattaData.java +++ b/mock/src/main/java/seng302/Data/RegattaData.java @@ -29,6 +29,11 @@ public class RegattaData { this.regattaDataSource = regattaDataSource; } + + /** + * Creates an AC35 officially formatted xml description of a regatta + * @return String containing xml-formatted regatta description + */ public String createXML() { 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() { //regattaID element Element regattaID = doc.createElement("RegattaID"); @@ -71,6 +91,9 @@ public class RegattaData { rootElement.appendChild(regattaID); } + /** + * Creates and appends regatta name element + */ private void appendRegattaName() { //regattaName element Element regattaName = doc.createElement("RegattaName"); @@ -78,6 +101,9 @@ public class RegattaData { rootElement.appendChild(regattaName); } + /** + * Creates and appends course name element + */ private void appendCourseName() { //courseName element Element courseName = doc.createElement("CourseName"); @@ -85,6 +111,9 @@ public class RegattaData { rootElement.appendChild(courseName); } + /** + * Creates and appends central latitude element + */ private void appendCentralLatitude() { //centralLatitude element Element centralLat = doc.createElement("CentralLatitude"); @@ -92,6 +121,9 @@ public class RegattaData { rootElement.appendChild(centralLat); } + /** + * Creates and appends central longitude element + */ private void appendCentralLongitude() { //centralLongitude element Element centralLong = doc.createElement("CentralLongitude"); @@ -99,6 +131,9 @@ public class RegattaData { rootElement.appendChild(centralLong); } + /** + * Creates and appends central altitude element + */ private void appendCentralAltitude() { //centralAltitude element Element centralAlt = doc.createElement("CentralAltitude"); @@ -106,14 +141,19 @@ public class RegattaData { rootElement.appendChild(centralAlt); } + /** + * Creates and appends utc offset element + */ private void appedUtcOffset() { //utcOffset element Element utcOffset = doc.createElement("UtcOffset"); utcOffset.appendChild(doc.createTextNode(Double.toString(regattaDataSource.getRegatta().getUtcOffset()))); rootElement.appendChild(utcOffset); - } + /** + * Creates and appends magnetic variation element + */ private void appendMagneticVariation() { //magneticVariation element Element magneticVariation = doc.createElement("MagneticVariation"); @@ -122,14 +162,4 @@ public class RegattaData { } - private void appendChildElements() { - appendRegattaID(); - appendRegattaName(); - appendCourseName(); - appendCentralLatitude(); - appendCentralLongitude(); - appendCentralAltitude(); - appedUtcOffset(); - appendMagneticVariation(); - } }