I am struggling to find a good example on how to read and write data in my android app using GSON. Could someone please show me or point me to a good example? I am using this for data persistence between activities.
My professor gave this example to for writing:
Vector v = new Vector(10.0f, 20.0f);
Gson gson = new Gson();
String s = gson.toJson(v);
How would I go about saving that to a file?
How to save your JSON into a file on internal storage:
String filename = "myfile.txt";
Vector v = new Vector(10.0f, 20.0f);
Gson gson = new Gson();
String s = gson.toJson(v);
FileOutputStream outputStream;
try {
outputStream = openFileOutput(filename, Context.MODE_PRIVATE);
outputStream.write(s.getBytes());
outputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
How to read it back:
FileInputStream fis = context.openFileInput("myfile.txt", Context.MODE_PRIVATE);
InputStreamReader isr = new InputStreamReader(fis);
BufferedReader bufferedReader = new BufferedReader(isr);
StringBuilder sb = new StringBuilder();
String line;
while ((line = bufferedReader.readLine()) != null) {
sb.append(line);
}
String json = sb.toString();
Gson gson = new Gson();
Vector v = gson.fromJson(json, Vector.class);
Simple Gson example:
public class Main {
public class Power {
private String name;
private Long damage;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Long getDamage() {
return damage;
}
public void setDamage(Long damage) {
this.damage = damage;
}
public Power() {
super();
}
public Power(String name, Long damage) {
super();
this.name = name;
this.damage = damage;
}
#Override
public String toString() {
return "Power [name=" + name + ", damage=" + damage + "]";
}
}
public class Warrior {
private String name;
private Power power;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Power getPower() {
return power;
}
public void setPower(Power power) {
this.power = power;
}
public Warrior() {
super();
}
public Warrior(String name, Power power) {
super();
this.name = name;
this.power = power;
}
#Override
public String toString() {
return "Warrior [name=" + name + ", power=" + power.toString() + "]";
}
}
public static void main(String[] args) {
Main m = new Main();
m.run();
}
private void run() {
Warrior jake = new Warrior("Jake the dog", new Power("Rubber hand", 123l));
String jsonJake = new Gson().toJson(jake);
System.out.println("Json:"+jsonJake);
Warrior returnToWarrior = new Gson().fromJson(jsonJake, Warrior.class);
System.out.println("Object:"+returnToWarrior.toString());
}
}
Anyways checkout the documentation.
And to persist something in your application you can start with something simple like ORMlite.
Hope this help! :]
UPDATE:
If you really want write the json in a file:
File myFile = new File("/sdcard/myjsonstuff.txt");
myFile.createNewFile();
FileOutputStream fOut = new FileOutputStream(myFile);
OutputStreamWriter myOutWriter =new OutputStreamWriter(fOut);
myOutWriter.append(myJsonString);
myOutWriter.close();
fOut.close();
And if you want to read:
File myFile = new File("/sdcard/myjsonstuff.txt");
FileInputStream fIn = new FileInputStream(myFile);
BufferedReader myReader = new BufferedReader(new InputStreamReader(fIn));
String aDataRow = "";
String aBuffer = ""; //Holds the text
while ((aDataRow = myReader.readLine()) != null)
{
aBuffer += aDataRow ;
}
myReader.close();
Also add: <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
to your manifest.
But, seriously is so much better use a ORM and store the records in the db. I don't know why you need save the json data in a file, but if I was you, I will use the ORM way.
Maybe in more recent version, but toJson accepts writer that directly writes to file.
ex.:
Vector v = new Vector(10.0f, 20.0f);
Gson gson = new GsonBuilder().create();
Writer writerJ = new FileWriter("keep.json");
gson.toJson(v,writerJ);
Save your class in SharedPrefrences using
public static void saveYourClassInSharedPref(ClassToSave ClassToSave) {
try{
String json = "";
if(ClassToSave != null){
json = new Gson().toJson(ClassToSave);
}
SharedPref.save(KeysSharedPrefs.ClassToSave, json);
}catch (Exception ex){
ex.printStackTrace();
}
}
public static ClassToSave readYourClassFromSharedPref() {
ClassToSave ClassToSave;
try{
String json = SharedPref.read(KeysSharedPrefs.ClassToSave, "");
if(!json.isEmpty()){
ClassToSave = new Gson().fromJson(json, ClassToSave.class);
return ClassToSave;
}
}catch (Exception ex){
ex.printStackTrace();
}
return null;
}
where SharedPref.java
public class SharedPref {
public static String read(String valueKey, String valueDefault) {
SharedPreferences prefs = PreferenceManager
.getDefaultSharedPreferences(App.context);
return prefs.getString(valueKey, valueDefault);
}
public static void save(String valueKey, String value) {
SharedPreferences prefs = PreferenceManager
.getDefaultSharedPreferences(App.context);
SharedPreferences.Editor edit = prefs.edit();
edit.putString(valueKey, value);
edit.commit();
}
}
You can also do this entirely with streams and avoid an intermediate object:
Vector v;
// This should be reused, so private static final
Gson gson = new GsonBuilder().create();
// Read from file:
try (InputStream fileIn = context.openFileInput("myfile.txt", Context.MODE_PRIVATE);
BufferedInputStream bufferedIn = new BufferedInputStream(fileIn, 65536);
Reader reader = new InputStreamReader(bufferedIn, StandardCharsets.UTF_8)) {
gson.fromJson(reader, Vector.class);
}
v = new Vector(10.0f, 20.0f);
// Write to file
try (OutputStream fileOut = context.openFileOutput(filename, Context.MODE_PRIVATE);
OutputStream bufferedOut = new BufferedOutputStream(fileOut, 65536);
Writer writer = new OutputStreamWriter(bufferedOut)) {
gson.toJson(v, writer);
}
Choose buffer sizes appropriately. 64k is flash-friendly, but silly if you only have 1k of data. try-with-resources might also not be supported by some versions of Android.
Related
I am kind of stuck, I usually know how to create single csv, it looks like I am missing or disconnecting from this code. I am not able to create multiple csv file from Pojo class. The file usually is more than 15mb, but I need to split into multiple csv file like 5mb each. Any suggestion would be great helped. Here is sample code that I am trying but failing.
public static void main(String[] args) throws IOException {
getOrderList();
}
public static void getOrderList() throws IOException {
List<Orders> ordersList = new ArrayList<>();
Orders orders = new Orders();
orders.setOrderNumber("1");
orders.setProductName("mickey");
Orders orders1 = new Orders();
orders1.setOrderNumber("2");
orders1.setProductName("mini");
ordersList.add(orders);
ordersList.add(orders1);
Object [] FILE_HEADER = {"orderNumber","productName"};
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
int rowCount = 0;
int fileCount = 1;
try {
BufferedWriter fileWriter = new BufferedWriter(new OutputStreamWriter(byteArrayOutputStream));
CSVPrinter csvFilePrinter = new CSVPrinter(fileWriter,
CSVFormat.DEFAULT.withRecordSeparator("\n"));
csvFilePrinter.printRecord(FILE_HEADER);
for (Orders patient : ordersList) {
rowCount++;
patient.getOrderNumber();
patient.getProductName();
if (rowCount <= 1) {
csvFilePrinter.printRecord(patient);
csvFilePrinter.flush();
}
if (rowCount > 1 ) {
csvFilePrinter.printRecord(patient);
fileCount++;
csvFilePrinter.flush();
}
}
} catch (IOException e) {
throw new RuntimeException("Cannot generate csv file", e);
}
byte[] csvOutput = byteArrayOutputStream.toByteArray();
OutputStream outputStream = null;
outputStream = new FileOutputStream("demos" + fileCount + ".csv");
byteArrayOutputStream = new ByteArrayOutputStream();
byteArrayOutputStream.write(csvOutput);
byteArrayOutputStream.writeTo(outputStream);
}
public static class Orders {
private String orderNumber;
private String productName;
public String getOrderNumber() {
return orderNumber;
}
public void setOrderNumber(String orderNumber) {
this.orderNumber = orderNumber;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
}
I am trying to save the state of my app to shared prefrences. The information that I want to save is an arraylist of custom objects where each object (PatientInfo) contains a few string and 2 more custom arraylist (SkinPhotoInfo, TreatmentsInfo). I was able to save and load an array list of custom objects, but I was'nt able to save the arraylist that has arraylists in it.
Anyone got an idea of what is the easiest way to do it? The object itself is allready parcable if it helps in any way.
P. S. When is the best time to save to shared prefrences - onPause or onDelete?
Thank you for your help!!
PatientInfo:
public class PatientInfo implements Parcelable {
String name;
String skinType;
String notes;
String image;
ArrayList<SkinPhotoInfo> skinPhotos;
ArrayList<TreatmentsInfo> treatments;
Boolean showDeleteButton;
#Override
public int describeContents() {
return 0;
}
#Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(name);
dest.writeString(skinType);
dest.writeString(notes);
dest.writeValue(image);
dest.writeValue(skinPhotos);
dest.writeValue(treatments);
}
public static final Creator<PatientInfo> CREATOR = new Creator<PatientInfo>()
{
#Override
public PatientInfo createFromParcel(Parcel source) {
PatientInfo ret = new PatientInfo();
ret.name = source.readString();
ret.skinType = source.readString();
ret.notes = source.readString();
ret.image = (String)source.readString();
ret.skinPhotos = source.readArrayList(null);
ret.treatments = source.readArrayList(null);
return ret;
}
#Override
public PatientInfo[] newArray(int size) {
return new PatientInfo[size];
}
};
public PatientInfo() {
this.name = "";
this.skinType = "";
this.image = "";
this.skinPhotos = new ArrayList<SkinPhotoInfo>();
this.showDeleteButton = false;
this.treatments = new ArrayList<TreatmentsInfo>();
}}
SkinPhotoInfo:
public class SkinPhotoInfo implements Parcelable {
String photoDate;
Boolean showDeleteButton;
Uri imageUri;
#Override
public int describeContents() {
return 0;
}
#Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(photoDate);
dest.writeByte((byte)(showDeleteButton ? 1 : 0)); // If showDeleteButton == true, byte == 1
dest.writeValue(imageUri);
}
public static final Creator<SkinPhotoInfo> CREATOR = new Creator<SkinPhotoInfo>()
{
#Override
public SkinPhotoInfo createFromParcel(Parcel source) {
SkinPhotoInfo ret = new SkinPhotoInfo();
ret.skinImageThumnail = (Bitmap)source.readValue(Bitmap.class.getClassLoader());
ret.photoDate = source.readString();
ret.showDeleteButton = source.readByte() != 1;
ret.imageUri = (Uri) source.readValue(Uri.class.getClassLoader());
return ret;
}
#Override
public SkinPhotoInfo[] newArray(int size) {
return new SkinPhotoInfo[size];
}
};
public SkinPhotoInfo(Uri imageUri, String photoDate) {
this.imageUri = imageUri;
this.photoDate = photoDate;
showDeleteButton = false;
}}
TreatmentsInfo:
public class TreatmentsInfo implements Parcelable {
String treatmentDate;
String treatmentName;
String pattern = "MM-dd-yy";
Boolean showDeleteButton;
#Override
public int describeContents() {
return 0;
}
#Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(treatmentDate);
dest.writeString(treatmentName);
dest.writeString(pattern);
dest.writeByte((byte)(showDeleteButton ? 1 : 0)); // If showDeleteButton == true, byte == 1
}
public static final Creator<TreatmentsInfo> CREATOR = new Creator<TreatmentsInfo>()
{
#Override
public TreatmentsInfo createFromParcel(Parcel source) {
TreatmentsInfo ret = new TreatmentsInfo();
ret.treatmentDate = source.readString();
ret.treatmentName = source.readString();
ret.pattern = source.readString();
ret.showDeleteButton = source.readByte() != 1;
return ret;
}
#Override
public TreatmentsInfo[] newArray(int size) {
return new TreatmentsInfo[size];
}
};
public TreatmentsInfo(){
this.treatmentDate = "";
this.treatmentName = "";
this.showDeleteButton = false;
this.pattern = "";
}
public TreatmentsInfo(String treatmentDate, String treatmentName) {
this.treatmentDate = treatmentDate;
this.treatmentName = treatmentName;
this.showDeleteButton = false;
}}
Use Gson library and save the arraylist as string.
Snippet below is save as file but you can use it in sharedpreference as well:
public static void saveGroupChatFile(File file, List<GCRoom> list) throws IOException {
String data = new Gson().toJson(list);
FileOutputStream fout = new FileOutputStream(file, false);
OutputStreamWriter osw = new OutputStreamWriter(fout);
osw.write(data);
osw.close();
}
public static List<GCRoom> readGroupChatFile(File file) throws IOException {
Type listType = new TypeToken<List<GCRoom>>() {
}.getType();
JsonReader reader = new JsonReader(new FileReader(file));
return new Gson().fromJson(reader, listType);
}
As for the library:
implementation 'com.google.code.gson:gson:2.8.5'
You can do something like:
String json = new Gson().toJson(YourObject);
To save in the Shared Preferences.
To retrieve the json and transform it to YourObejct, just do:
String json = myPrefsObject.getString(TAG, "");
return new Gson().fromJson(json, YourObject.class);
As for the PS question, the answer is onPause.
Let me know if you need something else
GSON provides method to convert objects to string and vice versa.
Use toJson() to convert object to string
PatientInfo patientInfo = new PatientInfo();
Gson gson = new Gson();
String objectAsString = gson.toJson(patientInfo);
Use fromJson() to convert string to object
Gson gson = new Gson();
PatientInfo patientinfo = gson.fromJson(data, PatientInfo.class);
//data is object that that you saved in shared preference after converting to string
Convert response to gson and use it as list and thus simply convert list setvalue and use putArray() to that set
public class staticpref{
private static SharedPreferences prefs;
private static SharedPreferences.Editor editor;
public static void putArray(String key, Set<String> arrayList){
editor.putStringSet(key, arrayList);
editor.commit();
}
public static Set getArray(String key,Set<String> defvalue){
return prefs.getStringSet(key,defvalue);
}
}
or you can make static class for getting and array you have to convert gson to arraylist and like this
String strResponse = anyjsonResponse;
Modelclass model= new Gson().fromJson(strResponse, Modelclass .class);
List<String> datalist= model.anyvalue();
Putandgetarray.addArrayList(datalist);
static methods for achieving this
public class Putandgetarray{
public static void addArrayList(List<data> dataList){
String strputdata = new Gson().toJson(dataList, new TypeToken<List<MutedChat>>() {}.getType());
SharedPreferenceUtils.putString("key", strputdata);
}
public static List<data> getArrayList(){
Type type = new TypeToken<List<data>>(){}.getType();
String strreturndata=SharedPreferenceUtils.getString("key","");
return new Gson().fromJson(strreturndata, type);
}
}
In sharedPreferece you can put only putStringSet(String key, #Nullable Set values); in sharedpreference
I have timestamp which is basically "ddMMYYHHMMss". what i want to do is everytime i run the program the seconds value change but my checksum remains the same. can anyone help me with this. i want the checksum should change everytime the seconds(time) changes.
public class Checksum {
public static void main(String[] args) throws IOException {
File f = new File("D:/test.txt");
PrintWriter pw = new PrintWriter(f);
if(!f.exists()){
f.createNewFile();
}
Date d = new Date();
SimpleDateFormat sd = new SimpleDateFormat("ddMMYYHHmmss");
String formatteddate = sd.format(d);
System.out.println(formatteddate);
pw.println(formatteddate);
pw.close();
BufferedReader br = new BufferedReader(new FileReader(f));
String line = null;
while((line = br.readLine()) != null){
break;
}
br.close();
System.out.println("MD5 : " + toHex(Hash.MD5.checksum(line)));
System.out.println("SHA1 : " + toHex(Hash.SHA1.checksum(line)));
System.out.println("SHA256 : " + toHex(Hash.SHA256.checksum(line)));
System.out.println("SHA512 : " + toHex(Hash.SHA512.checksum(line)));
}
private static String toHex(byte[] bytes) {
return DatatypeConverter.printHexBinary(bytes);
}
}
class CheckSumGenerator {
public enum Hash {
MD5("MD5"), SHA1("SHA1"), SHA256("SHA-256"), SHA512("SHA-512");
private String name;
Hash(String name) {
this.name = name;
}
public String getName() {
return name;
}
public byte[] checksum(String input) {
try {
MessageDigest digest = MessageDigest.getInstance(getName());
byte[] block = new byte[4096];
int length;
if (input.length()> 0) {
digest.update(block, 0, input.length());
}
return digest.digest();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
}
You never actually pass your input into the digest.update(...) call. You always pass the same empty byte array: block = new byte[4096]; Therefore it will always return the same
I want to parse a JSON object from an endpoint (this one here: https://api.coinmarketcap.com/v1/ticker/bitcoin/) and store the value in a variable at a specific attribute, which in this case is the name.
This the ERROR i get:
java.lang.IllegalStateException: Expected a name but was STRING...
AsyncTask.execute(new Runnable() {
#Override
public void run() {
// All your networking logic
// should be here
try {
String u = "https://api.coinmarketcap.com/v1/ticker/bitcoin";
URL coinMarketCapApi = new URL(u);
HttpsURLConnection myConnection = (HttpsURLConnection) coinMarketCapApi.openConnection();
myConnection.setRequestProperty("User-Agent", "my-rest-app-v0.1");
if (myConnection.getResponseCode() == 200) {
// Success
InputStream responseBody = myConnection.getInputStream();
InputStreamReader responseBodyReader =
new InputStreamReader(responseBody, "UTF-8");
JsonReader jsonReader = new JsonReader(responseBodyReader);
jsonReader.beginArray();
while (jsonReader.hasNext()) {
String key = jsonReader.nextName();
if (key.equals("name")) {
String value = jsonReader.nextName();
break; // Break out of the loop
} else {
jsonReader.skipValue();
}
}
jsonReader.close();
myConnection.disconnect();
} else {
// Error handling code goes here
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
});
you can convert the InputStream to String and then Create JSONArray from that string. like
StringWriter writer = new StringWriter();
IOUtils.copy(inputStream, writer, encoding);
String theString = writer.toString();
JSONArray jsonarray = new JSONArray(theString);
This way you don't have to manually construct the array.
Use this depandency for JSONArray
https://mvnrepository.com/artifact/org.json/json
You can fix the problem using gson.
https://github.com/google/gson
com.google.gson.stream.JsonReader jsonReader =
new com.google.gson.stream.JsonReader(new InputStreamReader(responseBody));
ArrayList<Coin> coins = new Gson().fromJson(jsonReader, Coin.class);
coins.forEach(coin -> System.out.println(coin.name));
public class Coin{
private String id;
private String name;
private String symbol;
private int rank;
#SerializedName("price_usd")
private double priceUsd;
...........
public String getId() {
return id;
}
public String getName() {
return name;
}
public String getSymbol() {
return symbol;
}
public int getRank() {
return rank;
}
public double getPriceUsd() {
return priceUsd;
}
..........
}
my propblem is, that I have a List that is an ArrayList that is filled with my Objects called Daten, which I save in a .json-file
PopUp pop = new PopUp();
Gson gson = new GsonBuilder().create();
JsonWriter writer = new JsonWriter(new FileWriter(new File(System.getProperty("user.home"), "/Wirtschaft.json")));
gson.toJson(allEntries, List.class, writer);
try {
writer.flush();
writer.close();
pop.show("Saved!");
} catch (IOException e) {
pop.show("Trying to save data failed!");
}
To use the list of Daten again I read everything from the .json-file and save it in a List<Daten>
Gson gson = new GsonBuilder().create();
List<Daten> allSaves = new ArrayList<>();
if (new File(System.getProperty("user.home"), "/Wirtschaft.json").exists()) {
JsonReader jReader = new JsonReader(new FileReader(new File(System.getProperty("user.home"), "/Wirtschaft.json")));
BufferedReader br = new BufferedReader(new FileReader(new File(System.getProperty("user.home"), "/Wirtschaft.json")));
if (br.readLine() != null) {
allSaves = gson.fromJson(jReader, List.class);
}
br.close();
jReader.close();
}
return allSaves;
Now I want to display this List in a TableView like this:
ObservableList<Daten> listEntries = FXCollections.observableArrayList(Daten.readData());
columnGewicht.setCellValueFactory(new PropertyValueFactory<>("gewicht"));
columnPreis.setCellValueFactory(new PropertyValueFactory<>("preisProStueck"));
columnGewinn.setCellValueFactory(new PropertyValueFactory<>("gewinn"));
columnEB.setCellValueFactory(new PropertyValueFactory<>("eb"));
columnAKK.setCellValueFactory(new PropertyValueFactory<>("akk"));
columnSB.setCellValueFactory(new PropertyValueFactory<>("sb"));
columnGK.setCellValueFactory(new PropertyValueFactory<>("gk"));
columnBoni.setCellValueFactory(new PropertyValueFactory<>("boni"));
table.setItems(listEntries);
Problem is, that the TableView remains empty when I use the code above, but if I don't use the Daten that I wrote in that file like above, it works and shows everything in the TableView, even if I choose the same numbers etc.:
List<Daten> list = new ArrayList<>();
list.add(new Daten(100, 6, 421, 3, 4, 1, 6, 0));
ObservableList<Daten> listEntries = FXCollections.observableArrayList(list);
columnGewicht.setCellValueFactory(new PropertyValueFactory<>("gewicht"));
columnPreis.setCellValueFactory(new PropertyValueFactory<>("preisProStueck"));
columnGewinn.setCellValueFactory(new PropertyValueFactory<>("gewinn"));
columnEB.setCellValueFactory(new PropertyValueFactory<>("eb"));
columnAKK.setCellValueFactory(new PropertyValueFactory<>("akk"));
columnSB.setCellValueFactory(new PropertyValueFactory<>("sb"));
columnGK.setCellValueFactory(new PropertyValueFactory<>("gk"));
columnBoni.setCellValueFactory(new PropertyValueFactory<>("boni"));
table.setItems(listEntries);
How can I fix this, that the TableView does not show my Data that I read from the file? Like there can not be something wrong with the TableView, if this other methode works... I am unfortunately clueless.
Thanks in advance!
EDIT:
Here is the Class for Daten:
public class Daten {
private Double gewicht;
private Double preisProStueck;
private Double gewinn;
private Double eb;
private Double akk;
private Double sb;
private Double gk;
private Integer boni;
Daten(double gewicht, double preisProStueck, double gewinn, double EB, double AKK, double SB, double GK, int boni) {
this.gewicht = gewicht;
this.preisProStueck = preisProStueck;
this.gewinn = gewinn;
this.eb = EB;
this.akk = AKK;
this.sb = SB;
this.gk = GK;
this.boni = boni;
}
static List<Daten> readData() throws IOException {
Gson gson = new GsonBuilder().create();
List<Daten> allSaves = new ArrayList<>();
if (new File(System.getProperty("user.home"), "/Wirtschaft.json").exists()) {
JsonReader jReader = new JsonReader(new FileReader(new File(System.getProperty("user.home"), "/Wirtschaft.json")));
BufferedReader br = new BufferedReader(new FileReader(new File(System.getProperty("user.home"), "/Wirtschaft.json")));
if (br.readLine() != null) {
allSaves = gson.fromJson(jReader, List.class);
}
br.close();
jReader.close();
}
return allSaves;
}
private static void writeData(List<Daten> allEntries) throws IOException {
PopUp pop = new PopUp();
Gson gson = new GsonBuilder().create();
JsonWriter writer = new JsonWriter(new FileWriter(new File(System.getProperty("user.home"), "/Wirtschaft.json")));
gson.toJson(allEntries, List.class, writer);
try {
writer.flush();
writer.close();
pop.show("Zeugs wurde gespeichert!");
} catch (IOException e) {
pop.show("Trying to save data failed!");
}
}
static void addData(Daten data) throws IOException {
List<Daten> list = readData();
list.add(data);
writeData(list);
}
public Double getGewicht() {
return gewicht;
}
public void setGewicht(Double gewicht) {
this.gewicht = gewicht;
}
public Double getPreisProStueck() {
return preisProStueck;
}
public void setPreisProStueck(Double preisProStueck) {
this.preisProStueck = preisProStueck;
}
public Double getGewinn() {
return gewinn;
}
public void setGewinn(Double gewinn) {
this.gewinn = gewinn;
}
public Double getEb() {
return eb;
}
public void setEb(Double eb) {
this.eb = eb;
}
public Double getAkk() {
return akk;
}
public void setAkk(Double akk) {
this.akk = akk;
}
public Double getSb() {
return sb;
}
public void setSb(Double sb) {
this.sb = sb;
}
public Double getGk() {
return gk;
}
public void setGk(Double gk) {
this.gk = gk;
}
public Integer getBoni() {
return boni;
}
public void setBoni(Integer boni) {
this.boni = boni;
}}