Ashies

Note

Jul 13th, 2017
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.04 KB | None | 0 0
  1. package com.example.prince.notetoself;
  2.  
  3.  
  4. import org.json.JSONException;
  5. import org.json.JSONObject;
  6.  
  7. public class Note {
  8.     private String mDescription;
  9.     private boolean mIdea;
  10.     private boolean mImportant;
  11.     private String mTitle;
  12.     private boolean mTodo;
  13.  
  14.     public static final String JSON_TITLE="title";
  15.     public static final String JSON_DESCRIPTION="description";
  16.     public static final String JSON_IDEA="idea";
  17.     public static final String JSON_TODO="todo";
  18.     public static final String JSON_IMPORTANT="important";
  19.  
  20.     public Note(){}
  21.  
  22.     public Note(JSONObject jo) throws JSONException {       //object members packed as a single object
  23.     mTitle=jo.getString(JSON_TITLE);
  24.         mDescription=jo.getString(JSON_DESCRIPTION);
  25.         mIdea=jo.getBoolean(JSON_IDEA);
  26.         mTodo=jo.getBoolean(JSON_TODO);
  27.         mImportant=jo.getBoolean(JSON_IMPORTANT);
  28.     }
  29.  
  30.  
  31.     public JSONObject convertToJSON() throws JSONException {
  32.  
  33.         JSONObject jo = new JSONObject();
  34.         jo.put(JSON_TITLE, mTitle);
  35.         jo.put(JSON_DESCRIPTION, mDescription);
  36.         jo.put(JSON_IDEA, mIdea);
  37.         jo.put(JSON_IMPORTANT, mImportant);
  38.         jo.put(JSON_TODO, mTodo);
  39.  
  40.         return jo;
  41.     }
  42.  
  43.  
  44.  
  45.  
  46.  
  47.     public String getTitle() {
  48.         return this.mTitle;
  49.     }
  50.  
  51.     public void setTitle(String mTitle) {
  52.         this.mTitle = mTitle;
  53.     }
  54.  
  55.     public String getDescription() {
  56.         return this.mDescription;
  57.     }
  58.  
  59.     public void setDescription(String mDescription) {
  60.         this.mDescription = mDescription;
  61.     }
  62.  
  63.     public boolean isIdea() {
  64.         return this.mIdea;
  65.     }
  66.  
  67.     public void setIdea(boolean mIdea) {
  68.         this.mIdea = mIdea;
  69.     }
  70.  
  71.     public boolean isTodo() {
  72.         return this.mTodo;
  73.     }
  74.  
  75.     public void setTodo(boolean mTodo) {
  76.         this.mTodo = mTodo;
  77.     }
  78.  
  79.     public boolean isImportant() {
  80.         return this.mImportant;
  81.     }
  82.  
  83.     public void setImportant(boolean mImportant) {
  84.         this.mImportant = mImportant;
  85.     }
  86. }
Add Comment
Please, Sign In to add comment