package org.krakenapps.socialweb.facebook.jsonobject; import java.util.ArrayList; import java.util.Set; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import org.krakenapps.socialweb.facebook.graphapi.objectcode.Permissions; import org.krakenapps.socialweb.facebook.jsonobject.fieldelement.From; import org.krakenapps.socialweb.facebook.jsonobject.fieldelement.Like; public class Note implements FacebookGraphObject{ private String id; private From from; private String subject; private String message; private ArrayList<Comment> comments; private String created_time; private String updated_time; private String icon; FbConnection fbConnection; private class FbConnection{ public String CONN_comments = "comments"; public String CONN_likes = "likes"; private ArrayList<Comment> comments; private Like likes; public FbConnection(){ comments =null; likes =null; } } public Note(){ fbConnection = new FbConnection(); } public String getId() { return id; } public void setId(String id) { this.id = id; } public From getFrom() { return from; } public void setFrom(From from) { this.from = from; } public String getSubject() { return subject; } public void setSubject(String subject) { this.subject = subject; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } public ArrayList<Comment> getComments() { return comments; } public void setComments(ArrayList<Comment> comments) { this.comments = comments; } public String getCreated_time() { return created_time; } public void setCreated_time(String created_time) { this.created_time = created_time; } public String getUpdated_time() { return updated_time; } public void setUpdated_time(String updated_time) { this.updated_time = updated_time; } public String getIcon() { return icon; } public void setIcon(String icon) { this.icon = icon; } @Override public int parseJson(JSONObject json) { try { id = json.getString("string"); JSONObject fromObject = json.getJSONObject("from"); from = new From(fromObject.getString("id"),fromObject.getString("name")); subject = json.getString("subject"); message = json.getString("message"); comments = new ArrayList<Comment>(); JSONObject commentObject = json.getJSONObject("comments"); JSONArray commentArray = commentObject.getJSONArray("data"); for(int i =0 ; i<commentObject.getInt("count"); i++){ Comment tmp = new Comment(); tmp.setId(commentArray.getJSONObject(i).getString("id")); tmp.setFrom(new From(commentArray.getJSONObject(i).getJSONObject("from").getString("id"), commentArray.getJSONObject(i).getJSONObject("from").getString("name"))); tmp.setMessage(commentArray.getJSONObject(i).getString("message")); tmp.setCreateTime(commentArray.getJSONObject(i).getString("created_time")); comments.add(tmp); } created_time = json.getString("created_time"); updated_time = json.getString("updated_time"); icon = json.getString("icon"); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } return 0; } /* (non-Javadoc) * @see org.krakenapps.socialweb.facebook.jsonobject.FacebookGraphObject#parseJson(org.json.JSONObject, java.util.Set) */ @Override public int parseJson(JSONObject json, Set<Permissions> permit) { // TODO Auto-generated method stub return 0; } }