JSON parse error using gson - java

I am trying to parse the data into a class.
But the problem is that one of the values is in Json format.
Hence I am getting a MalformedJsonException.
This is the Json string:
{
"name": "Check on Server Health ",
"state": "ABORTED",
"startTime": 1332962596131,
"triggeredBy": "GUI_MANUAL",
"completionPct": 25,
"currentStep": "sayHello",
"processDefId": "SW21SW",
"jobRetries": 0,
"businessKey": -1,
"comments": "couldn't instantiate class com.mikewidgets.helloWorld.HelloWorldTask",
"endTime": null,
"status": "DELAY , ERR",
"mtId": "MOTOROLA",
"instParms": "{"message":"start-workflow","sender":"CLI_APP","receiver":"BPM_ENG","parameters":{"workflowId":"SW21SW","mikesname":"Mikeeeeeeey","wf_HostName":"localhost","triggeredBy":"GUI_MANUAL","replyQueue":"temp-queue: //ID: SW-Demo01-51605-1332362748085-0: 2246: 1"},"userId":"Ab","mtId":"MOTOROLA","messageType":"MESSAGE_MSG"}",
"execId": "292",
"startUserId": "Ab"
}
This is the bean class I am using:
import com.google.gson.JsonElement;
public class WfActive {
private String name;
private String state;
private String startTime;
private String status;
private String endTime;
private String comments;
private String triggeredBy;
private String execId;
private JsonElement instParms;
private String startUserId;
private String mtId;
private String businessKey;
private String completionPct;
private String jobRetries;
private String processDefId;
private String currentStep;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
public String getComments() {
return comments;
}
public void setComments(String comments) {
this.comments = comments;
}
public String getTriggeredBy() {
return triggeredBy;
}
public void setTriggeredBy(String triggeredBy) {
this.triggeredBy = triggeredBy;
}
public String getExecId() {
return execId;
}
public void setExecId(String execId) {
this.execId = execId;
}
public JsonElement getInstParms() {
return instParms;
}
public void setInstParms(JsonElement instParms) {
this.instParms = instParms;
}
public String getStartUserId() {
return startUserId;
}
public void setStartUserId(String startUserId) {
this.startUserId = startUserId;
}
public String getMtId() {
return mtId;
}
public void setMtId(String mtId) {
this.mtId = mtId;
}
public String getBusinessKey() {
return businessKey;
}
public void setBusinessKey(String businessKey) {
this.businessKey = businessKey;
}
public String getCompletionPct() {
return completionPct;
}
public void setCompletionPct(String completionPct) {
this.completionPct = completionPct;
}
public String getJobRetries() {
return jobRetries;
}
public void setJobRetries(String jobRetries) {
this.jobRetries = jobRetries;
}
public String getProcessDefId() {
return processDefId;
}
public void setProcessDefId(String processDefId) {
this.processDefId = processDefId;
}
public String getCurrentStep() {
return currentStep;
}
public void setCurrentStep(String currentStep) {
this.currentStep = currentStep;
}
}
But I am getting a Malformed exception at :
LA","instParms":"{"message":"start-workf // this is inside instParms
What is my mistake and how do I correct it?
Please forgive the big code, the interesting part is "instParms"

Your JSON data is malformed (middle line below):
"mtId": "MOTOROLA",
"instParms": "{"message":"start-workflow","sender":"CLI_APP","receiver":"BPM_ENG","parameters":{"workflowId":"SW21SW","mikesname":"Mikeeeeeeey","wf_HostName":"localhost","triggeredBy":"GUI_MANUAL","replyQueue":"temp-queue: //ID: SW-Demo01-51605-1332362748085-0: 2246: 1"},"userId":"Ab","mtId":"MOTOROLA","messageType":"MESSAGE_MSG"}",
"execId": "292",
Second double quote in the value of instParms should be escaped. Alternatively, one could use single quotes instead if you know that single quotes aren't used in the value.
This is valid:
"mtId": "MOTOROLA",
"instParms": '{"message":"start-workflow","sender":"CLI_APP","receiver":"BPM_ENG","parameters":{"workflowId":"SW21SW","mikesname":"Mikeeeeeeey","wf_HostName":"localhost","triggeredBy":"GUI_MANUAL","replyQueue":"temp-queue: //ID: SW-Demo01-51605-1332362748085-0: 2246: 1"},"userId":"Ab","mtId":"MOTOROLA","messageType":"MESSAGE_MSG"}',
"execId": "292",
and so is this:
"mtId": "MOTOROLA",
"instParms": "{\"message\":\"start-workflow\",\"sender\":\"CLI_APP\",\"receiver\":\"BPM_ENG\",\"parameters\":{\"workflowId\":\"SW21SW\",\"mikesname\":\"Mikeeeeeeey\",\"wf_HostName\":\"localhost\",\"triggeredBy\":\"GUI_MANUAL\",\"replyQueue\":\"temp-queue: //ID: SW-Demo01-51605-1332362748085-0: 2246: 1\"},\"userId\":\"Ab\",\"mtId\":\"MOTOROLA\",\"messageType\":\"MESSAGE_MSG\"}",
"execId": "292",
Another alternative would be to embed the value of instParms as a subobject rather than a stirng:
"mtId": "MOTOROLA",
"instParms": {
"message": "start-workflow",
"sender": "CLI_APP",
"receiver": "BPM_ENG",
"parameters": {
"workflowId": "SW21SW",
"mikesname": "Mikeeeeeeey",
"wf_HostName":"localhost",
"triggeredBy":"GUI_MANUAL",
"replyQueue":"temp-queue: //ID: SW-Demo01-51605-1332362748085-0: 2246: 1"
},
"userId": "Ab",
"mtId": "MOTOROLA",
"messageType": "MESSAGE_MSG"
},
"execId": "292",
This is arguably the best solution (unless there is some other compelling reason to keep the string representation).

You can't readily fix it in the code consuming the JSON, nor should you. You need to fix the other end, which is generating invalid JSON. It looks like just an erroneous quote prior to the { on the value for instParms and after the } at the end of it. That, or the entire instParms value really is meant to be a string, and the string hasn't been properly escaped (quotes preceded with backslashes, etc.).

Related

Json Parsing and assign to DTO using Jackson

Facing some issue while parsing JSON into DTO.
In Json Getting Response as below
{
"errorMsg": null,
"flag": "S",
"message": "",
"coi_Number": "1234567",
"expiryDate": "7/12/2019 12:00:00 AM"
}
In DTO :
#JsonProperty("errorMsg")
private Object errorMsg;
#JsonProperty("flag")
private String flag;
#JsonProperty("message")
private String message;
#JsonProperty("coi_Number")
private String coiNumber;
#JsonProperty("expiryDate")
private String expiryDate;
#JsonProperty("errorMsg")
public Object getErrorMsg() {
return errorMsg;
}
#JsonProperty("errorMsg")
public void setErrorMsg(Object errorMsg) {
this.errorMsg = errorMsg;
}
#JsonProperty("flag")
public String getFlag() {
return flag;
}
#JsonProperty("flag")
public void setFlag(String flag) {
this.flag = flag;
}
#JsonProperty("message")
public String getMessage() {
return message;
}
#JsonProperty("message")
public void setMessage(String message) {
this.message = message;
}
#JsonProperty("coi_Number")
public String getCoiNumber() {
return coiNumber;
}
#JsonProperty("coi_Number")
public void setCoiNumber(String coiNumber) {
this.coiNumber = coiNumber;
}
#JsonProperty("expiryDate")
public String getExpiryDate() {
return expiryDate;
}
#JsonProperty("expiryDate")
public void setExpiryDate(String expiryDate) {
this.expiryDate = expiryDate;
}
Getting value as null. Please suggest what is the way to resolve it using Spring MVC.
In response getting value but after setting value in DTO getting coiNumber as null.
Try changing private String coiNumber to coi_Number
In response, you are getting key as "coi_Number" but in the entity, you are using this.
Solution 1:
#JsonProperty("coi_Number")
private String coiNumber;
Try changing the above to
#JsonProperty("coi_Number")
private String coi_Number
Solution 2:
If the above solution 1 doesn't work then try changing
#JsonProperty("coi_Number")
to
#JsonProperty("coi_number")

UnrecognizedPropertyException: Unrecognized field "sections"

I'm using Jackson as part of a spring boot app. I am turning JSON into Java, and I am getting this error. I did some research, but I still don't understand what is going wrong or how to fix it.
Here is the JSON fragment:
"dataBlock": {
"sections": [
{
"info": "",
"prompt": "",
"name": "First Section",
"sequence": 0,
"fields": [],
"gatingConditions": [],
"guid": "480d160c-c34f-4022-97b0-e8a1f28c49ae",
"id": -2
}
],
"prompt": "",
"id": -1,
"name": ""
}
So my Java object for this "dataBlock" element:
public class DataBlockObject {
private int id;
private String prompt;
private String name;
private List<SectionObject> sections;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getPrompt() {
return prompt;
}
public void setPrompt(String prompt) {
this.prompt = prompt;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<SectionObject> getSections() {
return sections;
}
public void setSections(List<SectionObject> sections) {
this.sections = sections;
}
}
And the Section object is this:
public class SectionObject {
private int id;
private String name;
private String prompt;
private String info;
private int sequence;
private List<FieldObject> fields;
private List<GatingConditionObject> gatingConditions;
private String guid;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPrompt() {
return prompt;
}
public void setPrompt(String prompt) {
this.prompt = prompt;
}
public String getInfo() {
return info;
}
public void setInfo(String info) {
this.info = info;
}
public int getSequence() {
return sequence;
}
public void setSequence(int sequence) {
this.sequence = sequence;
}
public List<FieldObject> getFields() {
return fields;
}
public void setFields(List<FieldObject> fields) {
this.fields = fields;
}
public List<GatingConditionObject> getGatingConditions() {
return gatingConditions;
}
public void setGatingConditions(List<GatingConditionObject> gatingConditions) {
this.gatingConditions = gatingConditions;
}
public String getGuid() {
return guid;
}
public void setGuid(String guid) {
this.guid = guid;
}
}
So it seems to me that Jackson would make a DataBlockObject, map the obvious elemenets, and create an array that I have clearly marked as a List named sections. -- just like the JSON shows.
Now the error is:
Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "sections" (class com.gridunity.workflow.bean.json.SectionObject), not marked as ignorable (8 known properties: "gatingConditions", "sequence", "prompt", "fields", "id", "info", "guid", "name"])
Now according to that error it would seem that one of my 8 elements should be named "sections" - But that's not one of my elements. It clearly has a problem with my List of Sections, but I cant figure out what it is.
Can someone explain WHY this is happening, especially sence it looks like I have my structure correct, and how to fix this. I have seen this on other posts:
objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
But that seems incredibly wrong as I know all of my properties.
It looks like the JSON itself has another sections field in one or more of the dataBlock.sections items. If you don't have control over the construction of the JSON object, you'll need to add a #JsonIgnoreProperties annotation on the SectionObject class so that when the JSON object has fields that aren't specified in the POJO, it won't throw an error during deserialization.
#JsonIgnoreProperties(ignoreUnknown = true)
public class SectionObject {
// class members and methods here
}

json data should be print in specified textview

I have json data regarding student details,That i want to print in respective textviews. i'm new to json services please help me to print the this data on screen.I'm using getters and setters for subject score so further i want to use them dynamically.
here is my json data
{
"studentInfo": {
"studentName": "srini#gmail.com",
"studentId": "abc",
"date": 14102017,
"JanuaryScoreCard" : {
"english" : "44",
"Science" : "45",
"maths": "66",
"social" : "56",
"hindi" : "67",
"kannada" : "78",
},
"MarchScoreCard" : {
" english " : "54",
" Science " : "56",
" maths ": "70",
" social " : "87",
" hindi " : "98",
" kannada " : "56"
},
"comments" : ""
}
I'm Something to print but could not,i don't where i'm going wrong
public void init()
{
try {
parseJSON();
} catch (JSONException e)
{
e.printStackTrace();
}
}
public void parseJSON() throws JSONException{
jsonObject = new JSONObject(strJson);
JSONObject object = jsonObject.getJSONObject("studentInfo");
patientName = object.getString("studentName");
patientID = object.getString("studentId");
mName.setText(studentName);
mUserId.setText(studentId);
}
You can use JSON parser and then you can print any data you want from that,
Use GSON for this, here is an example https://www.javacodegeeks.com/2011/01/android-json-parsing-gson-tutorial.html
Here is a basic JSON Parsing process
public void parseJson() {
String your_response = "replace this with your response";
try {
JSONObject jsonObject = new JSONObject(your_response);
JSONObject studentInfoJsonObject = jsonObject.getJSONObject("studentInfo");
StudentInfo studentInfo1 = new StudentInfo();
studentInfo1.setStudentName(studentInfoJsonObject.optString("studentName"));
studentInfo1.setStudentId(studentInfoJsonObject.optString("studentId"));
studentInfo1.setDate(studentInfoJsonObject.optString("date"));
studentInfo1.setComments(studentInfoJsonObject.optString("comments"));
JSONObject januaryScoreCardJsonObject = studentInfoJsonObject.optJSONObject("JanuaryScoreCard");
JanuaryScoreCard januaryScoreCard1 = new JanuaryScoreCard();
januaryScoreCard1.setEnglish(januaryScoreCardJsonObject.optString("english"));
januaryScoreCard1.setHindi(januaryScoreCardJsonObject.optString("hindi"));
januaryScoreCard1.setMaths(januaryScoreCardJsonObject.optString("maths"));
januaryScoreCard1.setSocial(januaryScoreCardJsonObject.optString("social"));
januaryScoreCard1.setKannada(januaryScoreCardJsonObject.optString("kannada"));
januaryScoreCard1.setScience(januaryScoreCardJsonObject.optString("Science"));
JSONObject marchScoreCardJsonObject = studentInfoJsonObject.optJSONObject("JanuaryScoreCard");
MarchScoreCard marchScoreCard = new MarchScoreCard();
marchScoreCard.setEnglish(marchScoreCardJsonObject.optString("english"));
marchScoreCard.setHindi(marchScoreCardJsonObject.optString("hindi"));
marchScoreCard.setMaths(marchScoreCardJsonObject.optString("maths"));
marchScoreCard.setSocial(marchScoreCardJsonObject.optString("social"));
marchScoreCard.setKannada(marchScoreCardJsonObject.optString("kannada"));
marchScoreCard.setScience(marchScoreCardJsonObject.optString("Science"));
studentInfo1.setJanuaryScoreCard(januaryScoreCard1);
studentInfo1.setMarchScoreCard(marchScoreCard);
} catch (JSONException e) {
e.printStackTrace();
}
}
Student Info Class
public class StudentInfo {
private String studentName;
private String studentId;
private String date;
private String comments;
private JanuaryScoreCard januaryScoreCard;
private MarchScoreCard marchScoreCard;
public JanuaryScoreCard getJanuaryScoreCard() {
return januaryScoreCard;
}
public void setJanuaryScoreCard(JanuaryScoreCard januaryScoreCard) {
this.januaryScoreCard = januaryScoreCard;
}
public MarchScoreCard getMarchScoreCard() {
return marchScoreCard;
}
public void setMarchScoreCard(MarchScoreCard marchScoreCard) {
this.marchScoreCard = marchScoreCard;
}
public String getStudentName() {
return studentName;
}
public void setStudentName(String studentName) {
this.studentName = studentName;
}
public String getStudentId() {
return studentId;
}
public void setStudentId(String studentId) {
this.studentId = studentId;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getComments() {
return comments;
}
public void setComments(String comments) {
this.comments = comments;
}
}
and Here is January class
public class JanuaryScoreCard {
private String english;
private String Science;
private String maths;
private String kannada;
private String social;
private String hindi;
public String getEnglish() {
return english;
}
public void setEnglish(String english) {
this.english = english;
}
public String getScience() {
return Science;
}
public void setScience(String science) {
Science = science;
}
public String getMaths() {
return maths;
}
public void setMaths(String maths) {
this.maths = maths;
}
public String getKannada() {
return kannada;
}
public void setKannada(String kannada) {
this.kannada = kannada;
}
public String getSocial() {
return social;
}
public void setSocial(String social) {
this.social = social;
}
public String getHindi() {
return hindi;
}
public void setHindi(String hindi) {
this.hindi = hindi;
}
}
and Here is March Class
public class MarchScoreCard{
private String english;
private String Science;
private String maths;
private String kannada;
private String social;
private String hindi;
public String getEnglish() {
return english;
}
public void setEnglish(String english) {
this.english = english;
}
public String getScience() {
return Science;
}
public void setScience(String science) {
Science = science;
}
public String getMaths() {
return maths;
}
public void setMaths(String maths) {
this.maths = maths;
}
public String getKannada() {
return kannada;
}
public void setKannada(String kannada) {
this.kannada = kannada;
}
public String getSocial() {
return social;
}
public void setSocial(String social) {
this.social = social;
}
public String getHindi() {
return hindi;
}
public void setHindi(String hindi) {
this.hindi = hindi;
}
}
You need to parse this json Data , For this you need Create appropriate bean classes and put data while parsing json into this bean classes object and create List .
Then you need to create ListView and Adapter for populate data into Screen or Activity.

How to solve the issue "Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $"

I am getting "Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $" when I am retrieve the list from database.How to fix this issue where I am mistaken in my code..thanks in advance.
Json response I am getting is below,
[{
"eventId":1,
"ringeeUserId":2,
"text":"Reception1",
"place":"Erode",
"eventDate":"2015-10-03",
"startTime":"09:00 AM",
"endTime":"12:00 PM",
"isActive":0,
"isDelete":0,
"eventUserRelationBOs":[]
}]
EventBO class file is below,
package com.ringeeapp.service.businessobjects;
import java.io.Serializable;
import java.util.List;
public class EventBO implements Serializable {
private static final long serialVersionUID = 281625146097131515L;
private long eventId;
private long ringeeUserId;
private String text;
private String place;
private String eventDate;
private String startTime;
private String endTime;
private int isActive;
private int isDelete;
private List<EventUserRelationBO> eventUserRelationBOs;
public long getEventId() {
return eventId;
}
public void setEventId(long eventId) {
this.eventId = eventId;
}
public long getRingeeUserId() {
return ringeeUserId;
}
public void setRingeeUserId(long ringeeUserId) {
this.ringeeUserId = ringeeUserId;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public String getPlace() {
return place;
}
public void setPlace(String place) {
this.place = place;
}
public String getEventDate() {
return eventDate;
}
public void setEventDate(String eventDate) {
this.eventDate = eventDate;
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
public int getIsDelete() {
return isDelete;
}
public void setIsDelete(int isDelete) {
this.isDelete = isDelete;
}
public int getIsActive() {
return isActive;
}
public void setIsActive(int isActive) {
this.isActive = isActive;
}
public List<EventUserRelationBO> getEventUserRelationBOs() {
return eventUserRelationBOs;
}
public void setEventUserRelationBOs(List<EventUserRelationBO> eventUserRelationBOs) {
this.eventUserRelationBOs = eventUserRelationBOs;
}
}
The below code that process json data
public #ResponseBody String getAllInvites(#RequestParam("userBO") String userBo) {
List<EventBO> eventBOs = new ArrayList<EventBO>();
UserBO userBO = gson.fromJson(userBo, UserBO.class);
try {
eventBOs = manageEventServiceImpl.getAllInvites(userBO);
log.info("getting all events for user " + userBO.getRingeeUserId());
} catch (UserServiceException serExp) {
log.error("Error while getting event for userId id" + userBO.getRingeeUserId(), serExp);
}
return gson.toJson(eventBOs);
}
You have an array of EventBO, but trying to read as object. If you unmarshal like this:
EventBO bo = gson.fromJson(JSON, EventBO.class);
than you will receive error "java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $"
But if you change code to:
EventBO[] list = gson.fromJson(JSON, EventBO[].class);
you successfully unmarshal this json
P.S. Tested with Gson 2.4
Kotlin
Late answer and i don't think many face this issue but, i was dealing with a dumb server, that returned the data however it wanted, strange huh?
yes,
//response 1
{
"genre":"drama,thriller"
}
//response 2
{
"genre":null
}
//response 3
{
"genre":["drama", "action", "blah", "blah"]
}
You can think how unfair this is.
i so changed my genre's data type to Any?
like
data class Model(...
....
val genre:Any?
...
)
now to use it, i do something like this
movieInfo.mInfo.genre?.let {
if (it is String) {
tv_genre.text = it
} else if (it is List<*>) {
val builder = StringBuilder()
it.forEach {
if (it is String) {
builder.append(it)
}
}
tv_genre.text = builder.toString()
}
}

Error when using DocumentReferences with Ektorp and JSF

I have been getting an error with DocumentReferences in a small JSF project i created to learn CouchDB/Ektorp .
I belive everything is working as is should in the CRUD, the id of the parent document is stored as a string, similar to the tutorial project.
But when I retrieve the parent object from the database I get this error:
org.codehaus.jackson.map.JsonMappingException: Can not instantiate value of type
[simple type, class com.pro.documents.Apple] from JSON String; no single-String
constructor/factory method (through reference chain: com.pro.documents.Eiere["apple"])
Here is the rest of the code:
{
"_id": "_design/Eiere",
"_rev": "17-ebb06b0d3102622a3d9849b9399cd94f",
"language": "javascript",
"views": {
"all": {
"map": "function(doc){if (doc.type == 'eiere') {emit(doc._id, doc);}}"
},
"ektorp_docrefs_apple": {
"map": "function(doc){ if(doc.eiere){emit([doc.eiere, 'apple', doc.kategori], null);}}"
}
}
}
{
"_id": "_design/Apple",
"_rev": "8-e04d8b5633776545b9eacdc998db4aea",
"language": "javascript",
"views": {
"all": {
"map": "function(doc){ if(doc.type == 'apple'){emit(doc._id, doc);}}"
}
}
}
public class Eiere extends CouchDbDocument {
#TypeDiscriminator
private String type;
private String navn;
private String telefon;
#DocumentReferences(backReference = "eiere", fetch = FetchType.LAZY, descendingSortOrder = true)
private Set<Apple> apple;
private Date dateCreated;
public Set<Apple> getApple() {
return apple;
}
public void setApple(Set<Apple> apples) {
this.apple = apples;
}
public void addApple(Apple c) {
Assert.notNull(c, "Apple may not be null");
if (getApple() == null) {
apple = new TreeSet<Apple>();
}
c.setEiere(this.getId());
apple.add(c);
}
public String getType() {
if (type == null) {
type = "eiere";
}
return type;
}
public void setType(String type) {
this.type = type;
}
public String getNavn() {
return navn;
}
public void setNavn(String navn) {
this.navn = navn;
}
public String getTelefon() {
return telefon;
}
public void setTelefon(String telefon) {
this.telefon = telefon;
}
public Date getDateCreated() {
return dateCreated;
}
public void setDateCreated(Date dateCreated) {
this.dateCreated = dateCreated;
}
}
public class Apple extends CouchDbDocument implements Comparable<Apple>{
private static final long serialVersionUID = 1L;
#TypeDiscriminator
private String type;
private List<String> prices;
private String kategori;
private String eiere;
private Date dateCreated;
public String getType() {
if(type == null){
type = "apple";
}
return type;
}
public void setType(String type) {
this.type = type;
}
public List<String> getPrices() {
if(prices == null){
prices = new ArrayList<String>();
prices.add(0, " ");
prices.add(1, " ");
prices.add(2, " ");
}
return prices;
}
public void setPrices(List<String> prices) {
this.prices = prices;
}
public String getKategori() {
return kategori;
}
public void setKategori(String kategori) {
this.kategori = kategori;
}
public String getEiere() {
return eiere;
}
public void setEiere(String eiere) {
this.eiere = eiere;
}
#Override
public String toString() {
return prices.toString();
}
public Date getDateCreated() {
return dateCreated;
}
public void setDateCreated(Date dateCreated) {
this.dateCreated = dateCreated;
}
#Override
public int compareTo(Apple other) {
if (other == this) return 0;
if (dateCreated != null) {
return - dateCreated.compareTo(other.dateCreated);
}
return 0;
}
}
Any help or advice to help me understand what I'm doing wrong will be much appreciated.
Edit: If there is any information that I could add that would make my problem clearer or help in determining the cause of it please let me know.
Br.

Categories

Resources