Exporter begonnen
This commit is contained in:
parent
ae93f365d5
commit
a0224b9870
@ -1,2 +1,25 @@
|
|||||||
package tourplaner.business;public class Exporter {
|
package tourplaner.business;
|
||||||
|
|
||||||
|
import tourplaner.object.Data;
|
||||||
|
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class Exporter {
|
||||||
|
|
||||||
|
private Data data;
|
||||||
|
private String path;
|
||||||
|
|
||||||
|
public Exporter(Data data, String path) {
|
||||||
|
this.data = data;
|
||||||
|
this.path = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void doExport() throws IOException {
|
||||||
|
JsonHelper.getJsonFromObj(data, new FileWriter(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void doImport(){
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,8 @@ package tourplaner.business;
|
|||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
|
import java.io.FileWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hilfsklasse für Json (Gson)
|
* Hilfsklasse für Json (Gson)
|
||||||
*/
|
*/
|
||||||
@ -28,6 +30,24 @@ public class JsonHelper {
|
|||||||
return getJObj(json).get("route").getAsJsonObject().get(gets).getAsDouble();
|
return getJObj(json).get("route").getAsJsonObject().get(gets).getAsDouble();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Erzeugt ein Json aus einem Object
|
||||||
|
* @param obj Das Objekt
|
||||||
|
* @return Json des Objektes
|
||||||
|
*/
|
||||||
|
public static String getJsonFromObj(Object obj){
|
||||||
|
return new Gson().toJson(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Erzeugt ein Json aus einem Object
|
||||||
|
* @param obj Das Objekt
|
||||||
|
* @param writer File in das geschrieben werden soll
|
||||||
|
*/
|
||||||
|
public static void getJsonFromObj(Object obj , FileWriter writer){
|
||||||
|
new Gson().toJson(obj, writer);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Json String to JsonObject
|
* Json String to JsonObject
|
||||||
* @param json Json string
|
* @param json Json string
|
||||||
|
@ -1,2 +1,21 @@
|
|||||||
package tourplaner.object;public class Data {
|
package tourplaner.object;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class Data {
|
||||||
|
private ArrayList<Log> logs;
|
||||||
|
private ArrayList<Tour> touren;
|
||||||
|
|
||||||
|
public Data(ArrayList<Log> logs, ArrayList<Tour> touren){
|
||||||
|
this.logs = logs;
|
||||||
|
this.touren = touren;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Log> getLogs() {
|
||||||
|
return logs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Tour> getTouren() {
|
||||||
|
return touren;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user