Back to project page trivial-lists.
The source code is released under:
MIT License
If you think the Android project trivial-lists listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package org.hbabcock.triviallists; /* www .j a va 2s . c o m*/ import java.util.UUID; import org.json.JSONException; import org.json.JSONObject; public class Item { private static final String JSON_CATEGORY_ID = "category_id"; private static final String JSON_COUNT = "count"; private static final String JSON_ID = "id"; private static final String JSON_NAME = "name"; private UUID mCategoryId; private int mCount; private UUID mId; private String mName; public Item(String name, Category c){ mCategoryId = c.getId(); mCount = 0; mId = UUID.randomUUID(); mName = name; } public Item(JSONObject json) throws JSONException { mCategoryId = UUID.fromString(json.getString(JSON_CATEGORY_ID)); mCount = json.getInt(JSON_COUNT); mId = UUID.fromString(json.getString(JSON_ID)); mName = json.getString(JSON_NAME); } public UUID getCategoryId(){ return mCategoryId; } public int getCount(){ return mCount; } public UUID getId(){ return mId; } public String getName(){ return mName; } public void setCount(int count){ mCount = count; } public void setName(String name){ mName = name; } public JSONObject toJSON() throws JSONException { JSONObject json = new JSONObject(); json.put(JSON_CATEGORY_ID, mCategoryId.toString()); json.put(JSON_COUNT, mCount); json.put(JSON_ID, mId.toString()); json.put(JSON_NAME, mName); return json; } }