From 83f14ed743a7dc7de1c072195da58aa38fc12905 Mon Sep 17 00:00:00 2001 From: Stefan Suhren Date: Mon, 23 Nov 2015 23:13:23 +0100 Subject: Add xml saving and loading --- .../in/inf/se/notepadMinusMinus/model/Grade.java | 22 +++++++++++++--- .../in/inf/se/notepadMinusMinus/model/Grades.java | 29 ++++++++++++++++++++++ 2 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 src/de/fhswf/in/inf/se/notepadMinusMinus/model/Grades.java (limited to 'src/de/fhswf/in/inf/se/notepadMinusMinus/model') diff --git a/src/de/fhswf/in/inf/se/notepadMinusMinus/model/Grade.java b/src/de/fhswf/in/inf/se/notepadMinusMinus/model/Grade.java index 0b1528f..3e87d5c 100644 --- a/src/de/fhswf/in/inf/se/notepadMinusMinus/model/Grade.java +++ b/src/de/fhswf/in/inf/se/notepadMinusMinus/model/Grade.java @@ -3,8 +3,16 @@ */ package de.fhswf.in.inf.se.notepadMinusMinus.model; +import java.math.BigDecimal; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlValue; + import javafx.beans.property.IntegerProperty; +import javafx.beans.property.ObjectProperty; import javafx.beans.property.SimpleIntegerProperty; +import javafx.beans.property.SimpleObjectProperty; import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; @@ -14,6 +22,7 @@ import javafx.beans.property.StringProperty; * @author $Author: $ * @version $Revision: $, $Date: $ UTC */ +@XmlRootElement(name = "grade") public class Grade { private IntegerProperty semester = new SimpleIntegerProperty(); @@ -22,7 +31,7 @@ public class Grade private IntegerProperty ects = new SimpleIntegerProperty(); - private IntegerProperty grade = new SimpleIntegerProperty(); + private ObjectProperty grade = new SimpleObjectProperty<>(); private IntegerProperty attempt = new SimpleIntegerProperty(); @@ -31,6 +40,7 @@ public class Grade return this.semester; } + @XmlAttribute(name = "semester") public final int getSemester() { return this.semesterProperty().get(); @@ -46,6 +56,7 @@ public class Grade return this.modulename; } + @XmlAttribute(name = "modulename", required = true) public final String getModulename() { return this.modulenameProperty().get(); @@ -61,6 +72,7 @@ public class Grade return this.ects; } + @XmlAttribute(name = "ects") public final int getEcts() { return this.ectsProperty().get(); @@ -71,17 +83,18 @@ public class Grade this.ectsProperty().set(ects); } - public final IntegerProperty gradeProperty() + public final ObjectProperty gradeProperty() { return this.grade; } - public final int getGrade() + @XmlValue + public final BigDecimal getGrade() { return this.gradeProperty().get(); } - public final void setGrade(final int grade) + public final void setGrade(final BigDecimal grade) { this.gradeProperty().set(grade); } @@ -91,6 +104,7 @@ public class Grade return this.attempt; } + @XmlAttribute(name = "attempt") public final int getAttempt() { return this.attemptProperty().get(); diff --git a/src/de/fhswf/in/inf/se/notepadMinusMinus/model/Grades.java b/src/de/fhswf/in/inf/se/notepadMinusMinus/model/Grades.java new file mode 100644 index 0000000..9518aee --- /dev/null +++ b/src/de/fhswf/in/inf/se/notepadMinusMinus/model/Grades.java @@ -0,0 +1,29 @@ +package de.fhswf.in.inf.se.notepadMinusMinus.model; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "grades") +public class Grades +{ + protected List grades; + + @XmlElement(name = "grade", required = true) + public List getGrades() + { + if (grades == null) + { + grades = new ArrayList(); + } + return this.grades; + } + + public void setGrades(List consumption) + { + this.grades = consumption; + } + +} -- cgit v1.2.3-70-g09d2