From bd7cfe95f4d15719f31e17d9aee6830066644948 Mon Sep 17 00:00:00 2001
From: Ugnich Anton
Date: Sun, 25 Dec 2011 00:05:24 +0700
Subject: Initial commit
---
src/com/juick/json/Message.java | 70 +++++++++++++++++++++++++++++++++++++++++
src/com/juick/json/Place.java | 58 ++++++++++++++++++++++++++++++++++
src/com/juick/json/User.java | 38 ++++++++++++++++++++++
3 files changed, 166 insertions(+)
create mode 100644 src/com/juick/json/Message.java
create mode 100644 src/com/juick/json/Place.java
create mode 100644 src/com/juick/json/User.java
(limited to 'src')
diff --git a/src/com/juick/json/Message.java b/src/com/juick/json/Message.java
new file mode 100644
index 00000000..83a8624f
--- /dev/null
+++ b/src/com/juick/json/Message.java
@@ -0,0 +1,70 @@
+/*
+ * Juick
+ * Copyright (C) 2008-2011, Ugnich Anton
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+package com.juick.json;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+/**
+ *
+ * @author Ugnich Anton
+ */
+public class Message extends com.juick.Message {
+
+ public static Message parseJSON(JSONObject json) throws JSONException {
+ Message jmsg = new Message();
+ jmsg.MID = json.getInt("mid");
+ if (json.has("rid")) {
+ jmsg.RID = json.getInt("rid");
+ }
+ jmsg.Text = json.getString("body").replace(""", "\"");
+ jmsg.User = com.juick.json.User.parseJSON(json.getJSONObject("user"));
+
+ try {
+ DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ df.setTimeZone(TimeZone.getTimeZone("UTC"));
+ jmsg.Timestamp = df.parse(json.getString("timestamp"));
+ } catch (ParseException e) {
+ }
+
+ if (json.has("tags")) {
+ JSONArray tags = json.getJSONArray("tags");
+ for (int n = 0; n < tags.length(); n++) {
+ jmsg.tags.add(tags.getString(n).replace(""", "\""));
+ }
+ }
+
+ if (json.has("replies")) {
+ jmsg.replies = json.getInt("replies");
+ }
+
+ if (json.has("photo")) {
+ jmsg.Photo = json.getJSONObject("photo").getString("small");
+ }
+ if (json.has("video")) {
+ jmsg.Video = json.getJSONObject("video").getString("mp4");
+ }
+
+ return jmsg;
+ }
+}
diff --git a/src/com/juick/json/Place.java b/src/com/juick/json/Place.java
new file mode 100644
index 00000000..63a5929c
--- /dev/null
+++ b/src/com/juick/json/Place.java
@@ -0,0 +1,58 @@
+/*
+ * Juick
+ * Copyright (C) 2008-2011, Ugnich Anton
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+package com.juick.json;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+/**
+ *
+ * @author Ugnich Anton
+ */
+public class Place extends com.juick.Place {
+
+ public static Place parseJSON(JSONObject json) throws JSONException {
+ Place jplace = new Place();
+
+ jplace.pid = json.getInt("pid");
+ jplace.lat = json.getDouble("lat");
+ jplace.lon = json.getDouble("lon");
+ jplace.name = json.getString("name").replace(""", "\"");
+ if (json.has("description")) {
+ jplace.description = json.getString("description").replace(""", "\"");
+ }
+ if (json.has("users")) {
+ jplace.users = json.getInt("users");
+ }
+ if (json.has("messages")) {
+ jplace.messages = json.getInt("messages");
+ }
+ if (json.has("distance")) {
+ jplace.distance = json.getInt("distance");
+ }
+ if (json.has("tags")) {
+ JSONArray tags = json.getJSONArray("tags");
+ for (int n = 0; n < tags.length(); n++) {
+ jplace.tags.add(tags.getString(n).replace(""", "\""));
+ }
+ }
+
+ return jplace;
+ }
+}
diff --git a/src/com/juick/json/User.java b/src/com/juick/json/User.java
new file mode 100644
index 00000000..b4e0e7e8
--- /dev/null
+++ b/src/com/juick/json/User.java
@@ -0,0 +1,38 @@
+/*
+ * Juick
+ * Copyright (C) 2008-2011, Ugnich Anton
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+package com.juick.json;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+/**
+ *
+ * @author Ugnich Anton
+ */
+public class User extends com.juick.User {
+
+ public static User parseJSON(JSONObject json) throws JSONException {
+ User juser = new User();
+ juser.UID = json.getInt("uid");
+ juser.UName = json.getString("uname");
+ if (json.has("fullname")) {
+ juser.FullName = json.getString("fullname");
+ }
+ return juser;
+ }
+}
--
cgit v1.2.3
From cbcc5a5e4c1edd4689c756a2548a5087201ee74e Mon Sep 17 00:00:00 2001
From: Ugnich Anton
Date: Sun, 22 Jan 2012 23:01:24 +0700
Subject: toJSON()
---
src/com/juick/json/Message.java | 54 ++++++++++++++++++++++++++++++++++++++---
src/com/juick/json/Place.java | 28 ++++++++++++++++++---
src/com/juick/json/User.java | 25 ++++++++++++++++---
3 files changed, 98 insertions(+), 9 deletions(-)
(limited to 'src')
diff --git a/src/com/juick/json/Message.java b/src/com/juick/json/Message.java
index 83a8624f..da817a01 100644
--- a/src/com/juick/json/Message.java
+++ b/src/com/juick/json/Message.java
@@ -29,10 +29,10 @@ import org.json.JSONObject;
*
* @author Ugnich Anton
*/
-public class Message extends com.juick.Message {
+public class Message {
- public static Message parseJSON(JSONObject json) throws JSONException {
- Message jmsg = new Message();
+ public static com.juick.Message parseJSON(JSONObject json) throws JSONException {
+ com.juick.Message jmsg = new com.juick.Message();
jmsg.MID = json.getInt("mid");
if (json.has("rid")) {
jmsg.RID = json.getInt("rid");
@@ -67,4 +67,52 @@ public class Message extends com.juick.Message {
return jmsg;
}
+
+ public static JSONObject toJSON(com.juick.Message msg) {
+ JSONObject json = new JSONObject();
+
+ try {
+ if (msg.MID > 0) {
+ json.put("mid", msg.MID);
+ }
+ if (msg.RID > 0) {
+ json.put("rid", msg.RID);
+ }
+ if (msg.Text != null) {
+ json.put("body", msg.Text);
+ }
+ if (msg.Timestamp != null) {
+ json.put("timestamp", msg.Timestamp);
+ }
+ if (msg.User != null) {
+ json.put("user", com.juick.json.User.toJSON(msg.User));
+ }
+ if (msg.tags != null && msg.tags.size() > 0) {
+ json.put("tags", new JSONArray(msg.tags));
+ }
+ if (msg.replies > 0) {
+ json.put("replies", msg.replies);
+ }
+ if (msg.place != null) {
+ json.put("place", com.juick.json.Place.toJSON(msg.place));
+ }
+ if (msg.AttachmentType != null) {
+ String fname = msg.MID + (msg.RID > 0 ? "-" + msg.RID : "") + "." + msg.AttachmentType;
+ if (msg.AttachmentType.equals("jpg")) {
+ JSONObject photo = new JSONObject();
+ photo.put("thumbnail", "http://i.juick.com/ps/" + fname);
+ photo.put("small", "http://i.juick.com/photo-512/" + fname);
+ photo.put("medium", "http://i.juick.com/photo-1024/" + fname);
+ json.put("photo", photo);
+ } else {
+ JSONObject video = new JSONObject();
+ video.put("mp4", "http://i.juick.com/video/" + fname);
+ json.put("video", video);
+ }
+ }
+ } catch (JSONException e) {
+ }
+
+ return json;
+ }
}
diff --git a/src/com/juick/json/Place.java b/src/com/juick/json/Place.java
index 63a5929c..4e3e5579 100644
--- a/src/com/juick/json/Place.java
+++ b/src/com/juick/json/Place.java
@@ -25,10 +25,10 @@ import org.json.JSONObject;
*
* @author Ugnich Anton
*/
-public class Place extends com.juick.Place {
+public class Place {
- public static Place parseJSON(JSONObject json) throws JSONException {
- Place jplace = new Place();
+ public static com.juick.Place parseJSON(JSONObject json) throws JSONException {
+ com.juick.Place jplace = new com.juick.Place();
jplace.pid = json.getInt("pid");
jplace.lat = json.getDouble("lat");
@@ -55,4 +55,26 @@ public class Place extends com.juick.Place {
return jplace;
}
+
+ public static JSONObject toJSON(com.juick.Place place) {
+ JSONObject json = new JSONObject();
+
+ try {
+ if (place.pid > 0) {
+ json.put("pid", place.pid);
+ }
+ if (place.lat >= -90 && place.lat <= 90) {
+ json.put("lat", place.lat);
+ }
+ if (place.lon >= -180 && place.lon <= 180) {
+ json.put("lon", place.lon);
+ }
+ if (place.name != null) {
+ json.put("name", place.name);
+ }
+ } catch (JSONException e) {
+ }
+
+ return json;
+ }
}
diff --git a/src/com/juick/json/User.java b/src/com/juick/json/User.java
index b4e0e7e8..43ee4803 100644
--- a/src/com/juick/json/User.java
+++ b/src/com/juick/json/User.java
@@ -24,10 +24,10 @@ import org.json.JSONObject;
*
* @author Ugnich Anton
*/
-public class User extends com.juick.User {
+public class User {
- public static User parseJSON(JSONObject json) throws JSONException {
- User juser = new User();
+ public static com.juick.User parseJSON(JSONObject json) throws JSONException {
+ com.juick.User juser = new com.juick.User();
juser.UID = json.getInt("uid");
juser.UName = json.getString("uname");
if (json.has("fullname")) {
@@ -35,4 +35,23 @@ public class User extends com.juick.User {
}
return juser;
}
+
+ public static JSONObject toJSON(com.juick.User user) {
+ JSONObject json = new JSONObject();
+
+ try {
+ if (user.UID > 0) {
+ json.put("uid", user.UID);
+ }
+ if (user.UName != null) {
+ json.put("uname", user.UName);
+ }
+ if (user.FullName != null) {
+ json.put("fullname", user.FullName);
+ }
+ } catch (JSONException e) {
+ }
+
+ return json;
+ }
}
--
cgit v1.2.3
From c1e53e34484d31584c58fa45c330e770d65879a4 Mon Sep 17 00:00:00 2001
From: Ugnich Anton
Date: Sun, 4 Nov 2012 22:51:24 +0700
Subject: New Juick Java API
---
src/com/juick/json/Message.java | 16 ++++++++--------
src/com/juick/json/Place.java | 9 ---------
2 files changed, 8 insertions(+), 17 deletions(-)
(limited to 'src')
diff --git a/src/com/juick/json/Message.java b/src/com/juick/json/Message.java
index da817a01..c1beebc4 100644
--- a/src/com/juick/json/Message.java
+++ b/src/com/juick/json/Message.java
@@ -50,12 +50,12 @@ public class Message {
if (json.has("tags")) {
JSONArray tags = json.getJSONArray("tags");
for (int n = 0; n < tags.length(); n++) {
- jmsg.tags.add(tags.getString(n).replace(""", "\""));
+ jmsg.Tags.add(tags.getString(n).replace(""", "\""));
}
}
if (json.has("replies")) {
- jmsg.replies = json.getInt("replies");
+ jmsg.Replies = json.getInt("replies");
}
if (json.has("photo")) {
@@ -87,14 +87,14 @@ public class Message {
if (msg.User != null) {
json.put("user", com.juick.json.User.toJSON(msg.User));
}
- if (msg.tags != null && msg.tags.size() > 0) {
- json.put("tags", new JSONArray(msg.tags));
+ if (msg.Tags != null && msg.Tags.size() > 0) {
+ json.put("tags", new JSONArray(msg.Tags));
}
- if (msg.replies > 0) {
- json.put("replies", msg.replies);
+ if (msg.Replies > 0) {
+ json.put("replies", msg.Replies);
}
- if (msg.place != null) {
- json.put("place", com.juick.json.Place.toJSON(msg.place));
+ if (msg.Place != null) {
+ json.put("place", com.juick.json.Place.toJSON(msg.Place));
}
if (msg.AttachmentType != null) {
String fname = msg.MID + (msg.RID > 0 ? "-" + msg.RID : "") + "." + msg.AttachmentType;
diff --git a/src/com/juick/json/Place.java b/src/com/juick/json/Place.java
index 4e3e5579..f195e7d7 100644
--- a/src/com/juick/json/Place.java
+++ b/src/com/juick/json/Place.java
@@ -34,9 +34,6 @@ public class Place {
jplace.lat = json.getDouble("lat");
jplace.lon = json.getDouble("lon");
jplace.name = json.getString("name").replace(""", "\"");
- if (json.has("description")) {
- jplace.description = json.getString("description").replace(""", "\"");
- }
if (json.has("users")) {
jplace.users = json.getInt("users");
}
@@ -46,12 +43,6 @@ public class Place {
if (json.has("distance")) {
jplace.distance = json.getInt("distance");
}
- if (json.has("tags")) {
- JSONArray tags = json.getJSONArray("tags");
- for (int n = 0; n < tags.length(); n++) {
- jplace.tags.add(tags.getString(n).replace(""", "\""));
- }
- }
return jplace;
}
--
cgit v1.2.3
From 40fe707e6566faa02eeba2e8f4830dbbd3992f4a Mon Sep 17 00:00:00 2001
From: Ugnich Anton
Date: Thu, 20 Jun 2013 18:52:48 +0700
Subject: Users.arrayToString
---
src/com/juick/json/Users.java | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
create mode 100644 src/com/juick/json/Users.java
(limited to 'src')
diff --git a/src/com/juick/json/Users.java b/src/com/juick/json/Users.java
new file mode 100644
index 00000000..eda89ccb
--- /dev/null
+++ b/src/com/juick/json/Users.java
@@ -0,0 +1,31 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.juick.json;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ *
+ * @author ugnich
+ */
+public class Users {
+
+ public static String arrayToString(ArrayList users) {
+ String json = "[";
+
+ Iterator i = users.iterator();
+ while (i.hasNext()) {
+ com.juick.User u = i.next();
+ if (json.length() > 1) {
+ json += ",";
+ }
+ json += "{\"uid\":" + u.UID + ",\"uname\":\"" + u.UName + "\"}";
+ }
+
+ json += "]";
+ return json;
+ }
+}
--
cgit v1.2.3
From 8d1d8d845beb6bc6c99d90722169b77c3dff91e7 Mon Sep 17 00:00:00 2001
From: Ugnich Anton
Date: Fri, 30 Aug 2013 13:48:38 +0700
Subject: Messages
---
src/com/juick/json/Message.java | 12 +++++++-----
src/com/juick/json/Messages.java | 27 +++++++++++++++++++++++++++
src/com/juick/json/User.java | 6 ++++++
src/com/juick/json/Users.java | 2 +-
4 files changed, 41 insertions(+), 6 deletions(-)
create mode 100644 src/com/juick/json/Messages.java
(limited to 'src')
diff --git a/src/com/juick/json/Message.java b/src/com/juick/json/Message.java
index c1beebc4..18cc375e 100644
--- a/src/com/juick/json/Message.java
+++ b/src/com/juick/json/Message.java
@@ -83,6 +83,8 @@ public class Message {
}
if (msg.Timestamp != null) {
json.put("timestamp", msg.Timestamp);
+ } else if (msg.TimestampString != null) {
+ json.put("timestamp", msg.TimestampString);
}
if (msg.User != null) {
json.put("user", com.juick.json.User.toJSON(msg.User));
@@ -98,16 +100,16 @@ public class Message {
}
if (msg.AttachmentType != null) {
String fname = msg.MID + (msg.RID > 0 ? "-" + msg.RID : "") + "." + msg.AttachmentType;
- if (msg.AttachmentType.equals("jpg")) {
+ if (msg.AttachmentType.equals("mp4")) {
+ JSONObject video = new JSONObject();
+ video.put("mp4", "http://i.juick.com/video/" + fname);
+ json.put("video", video);
+ } else {
JSONObject photo = new JSONObject();
photo.put("thumbnail", "http://i.juick.com/ps/" + fname);
photo.put("small", "http://i.juick.com/photo-512/" + fname);
photo.put("medium", "http://i.juick.com/photo-1024/" + fname);
json.put("photo", photo);
- } else {
- JSONObject video = new JSONObject();
- video.put("mp4", "http://i.juick.com/video/" + fname);
- json.put("video", video);
}
}
} catch (JSONException e) {
diff --git a/src/com/juick/json/Messages.java b/src/com/juick/json/Messages.java
new file mode 100644
index 00000000..a1879b09
--- /dev/null
+++ b/src/com/juick/json/Messages.java
@@ -0,0 +1,27 @@
+package com.juick.json;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ *
+ * @author ugnich
+ */
+public class Messages {
+
+ public static String arrayToString(ArrayList messages) {
+ String json = "[";
+
+ Iterator i = messages.iterator();
+ while (i.hasNext()) {
+ com.juick.Message m = i.next();
+ if (json.length() > 1) {
+ json += ",";
+ }
+ json += Message.toJSON(m).toString();
+ }
+
+ json += "]";
+ return json;
+ }
+}
diff --git a/src/com/juick/json/User.java b/src/com/juick/json/User.java
index 43ee4803..dd3143c6 100644
--- a/src/com/juick/json/User.java
+++ b/src/com/juick/json/User.java
@@ -49,6 +49,12 @@ public class User {
if (user.FullName != null) {
json.put("fullname", user.FullName);
}
+ if (user.JID != null) {
+ json.put("jid", user.JID);
+ }
+ if (user.MessagesCount > 0) {
+ json.put("MessagesCount", user.MessagesCount);
+ }
} catch (JSONException e) {
}
diff --git a/src/com/juick/json/Users.java b/src/com/juick/json/Users.java
index eda89ccb..0e486f74 100644
--- a/src/com/juick/json/Users.java
+++ b/src/com/juick/json/Users.java
@@ -22,7 +22,7 @@ public class Users {
if (json.length() > 1) {
json += ",";
}
- json += "{\"uid\":" + u.UID + ",\"uname\":\"" + u.UName + "\"}";
+ json += User.toJSON(u).toString();
}
json += "]";
--
cgit v1.2.3
From e46184f115a5648bc6ba4a9e74a504d2b6b2f027 Mon Sep 17 00:00:00 2001
From: Ugnich Anton
Date: Thu, 19 Sep 2013 14:26:26 +0700
Subject: Message.ReplyTo
---
src/com/juick/json/Message.java | 6 ++++++
1 file changed, 6 insertions(+)
(limited to 'src')
diff --git a/src/com/juick/json/Message.java b/src/com/juick/json/Message.java
index 18cc375e..70beda88 100644
--- a/src/com/juick/json/Message.java
+++ b/src/com/juick/json/Message.java
@@ -37,6 +37,9 @@ public class Message {
if (json.has("rid")) {
jmsg.RID = json.getInt("rid");
}
+ if (json.has("replyto")) {
+ jmsg.ReplyTo = json.getInt("replyto");
+ }
jmsg.Text = json.getString("body").replace(""", "\"");
jmsg.User = com.juick.json.User.parseJSON(json.getJSONObject("user"));
@@ -78,6 +81,9 @@ public class Message {
if (msg.RID > 0) {
json.put("rid", msg.RID);
}
+ if (msg.ReplyTo > 0) {
+ json.put("replyto", msg.ReplyTo);
+ }
if (msg.Text != null) {
json.put("body", msg.Text);
}
--
cgit v1.2.3
From 8019c7bb6a181d5c36bca40fcbf8b5042d825191 Mon Sep 17 00:00:00 2001
From: Ugnich Anton
Date: Tue, 19 Nov 2013 08:46:14 +0700
Subject: bugfix in URL: "photos"
---
src/com/juick/json/Message.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'src')
diff --git a/src/com/juick/json/Message.java b/src/com/juick/json/Message.java
index 70beda88..c765a5d8 100644
--- a/src/com/juick/json/Message.java
+++ b/src/com/juick/json/Message.java
@@ -113,8 +113,8 @@ public class Message {
} else {
JSONObject photo = new JSONObject();
photo.put("thumbnail", "http://i.juick.com/ps/" + fname);
- photo.put("small", "http://i.juick.com/photo-512/" + fname);
- photo.put("medium", "http://i.juick.com/photo-1024/" + fname);
+ photo.put("small", "http://i.juick.com/photos-512/" + fname);
+ photo.put("medium", "http://i.juick.com/photos-1024/" + fname);
json.put("photo", photo);
}
}
--
cgit v1.2.3
From 94dba01c5581e43b618d6828ed1b378fd63461a8 Mon Sep 17 00:00:00 2001
From: Ugnich Anton
Date: Thu, 19 Dec 2013 01:01:34 +0700
Subject: Message.FriendsOnly, Message.ReadOnly
---
src/com/juick/json/Message.java | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
(limited to 'src')
diff --git a/src/com/juick/json/Message.java b/src/com/juick/json/Message.java
index c765a5d8..4ab1901a 100644
--- a/src/com/juick/json/Message.java
+++ b/src/com/juick/json/Message.java
@@ -40,6 +40,10 @@ public class Message {
if (json.has("replyto")) {
jmsg.ReplyTo = json.getInt("replyto");
}
+
+ jmsg.FriendsOnly = json.has("friendsonly");
+ jmsg.ReadOnly = json.has("readonly");
+
jmsg.Text = json.getString("body").replace(""", "\"");
jmsg.User = com.juick.json.User.parseJSON(json.getJSONObject("user"));
@@ -64,9 +68,6 @@ public class Message {
if (json.has("photo")) {
jmsg.Photo = json.getJSONObject("photo").getString("small");
}
- if (json.has("video")) {
- jmsg.Video = json.getJSONObject("video").getString("mp4");
- }
return jmsg;
}
@@ -84,6 +85,12 @@ public class Message {
if (msg.ReplyTo > 0) {
json.put("replyto", msg.ReplyTo);
}
+ if (msg.FriendsOnly) {
+ json.put("friendsonly", 1);
+ }
+ if (msg.ReadOnly) {
+ json.put("readonly", 1);
+ }
if (msg.Text != null) {
json.put("body", msg.Text);
}
@@ -106,17 +113,11 @@ public class Message {
}
if (msg.AttachmentType != null) {
String fname = msg.MID + (msg.RID > 0 ? "-" + msg.RID : "") + "." + msg.AttachmentType;
- if (msg.AttachmentType.equals("mp4")) {
- JSONObject video = new JSONObject();
- video.put("mp4", "http://i.juick.com/video/" + fname);
- json.put("video", video);
- } else {
- JSONObject photo = new JSONObject();
- photo.put("thumbnail", "http://i.juick.com/ps/" + fname);
- photo.put("small", "http://i.juick.com/photos-512/" + fname);
- photo.put("medium", "http://i.juick.com/photos-1024/" + fname);
- json.put("photo", photo);
- }
+ JSONObject photo = new JSONObject();
+ photo.put("thumbnail", "http://i.juick.com/ps/" + fname);
+ photo.put("small", "http://i.juick.com/photos-512/" + fname);
+ photo.put("medium", "http://i.juick.com/photos-1024/" + fname);
+ json.put("photo", photo);
}
} catch (JSONException e) {
}
--
cgit v1.2.3
From 5f4602b34ccc3f899edd45e5e541cbb7307c9585 Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Sat, 31 Oct 2015 01:35:22 +0300
Subject: moved to Gradle
---
build.gradle | 9 +
build.xml | 74 --
lib/org.json.jar | Bin 80177 -> 0 bytes
nbproject/build-impl.xml | 1056 ----------------------------
nbproject/genfiles.properties | 8 -
nbproject/project.properties | 75 --
nbproject/project.xml | 25 -
src/com/juick/json/Message.java | 127 ----
src/com/juick/json/Messages.java | 27 -
src/com/juick/json/Place.java | 71 --
src/com/juick/json/User.java | 63 --
src/com/juick/json/Users.java | 31 -
src/main/java/com/juick/json/Message.java | 127 ++++
src/main/java/com/juick/json/Messages.java | 27 +
src/main/java/com/juick/json/Place.java | 71 ++
src/main/java/com/juick/json/User.java | 63 ++
src/main/java/com/juick/json/Users.java | 31 +
17 files changed, 328 insertions(+), 1557 deletions(-)
create mode 100644 build.gradle
delete mode 100644 build.xml
delete mode 100644 lib/org.json.jar
delete mode 100644 nbproject/build-impl.xml
delete mode 100644 nbproject/genfiles.properties
delete mode 100644 nbproject/project.properties
delete mode 100644 nbproject/project.xml
delete mode 100644 src/com/juick/json/Message.java
delete mode 100644 src/com/juick/json/Messages.java
delete mode 100644 src/com/juick/json/Place.java
delete mode 100644 src/com/juick/json/User.java
delete mode 100644 src/com/juick/json/Users.java
create mode 100644 src/main/java/com/juick/json/Message.java
create mode 100644 src/main/java/com/juick/json/Messages.java
create mode 100644 src/main/java/com/juick/json/Place.java
create mode 100644 src/main/java/com/juick/json/User.java
create mode 100644 src/main/java/com/juick/json/Users.java
(limited to 'src')
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 00000000..483a3727
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,9 @@
+apply plugin: "java"
+
+repositories {
+ mavenCentral()
+}
+
+dependencies {
+ compile 'org.json:json:20140107'
+}
diff --git a/build.xml b/build.xml
deleted file mode 100644
index 75e8988b..00000000
--- a/build.xml
+++ /dev/null
@@ -1,74 +0,0 @@
-
-
-
-
-
-
-
-
-
-
- Builds, tests, and runs the project com.juick.json.
-
-
-
diff --git a/lib/org.json.jar b/lib/org.json.jar
deleted file mode 100644
index 911ca8f1..00000000
Binary files a/lib/org.json.jar and /dev/null differ
diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml
deleted file mode 100644
index 87d29507..00000000
--- a/nbproject/build-impl.xml
+++ /dev/null
@@ -1,1056 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set src.dir
- Must set test.src.dir
- Must set build.dir
- Must set dist.dir
- Must set build.classes.dir
- Must set dist.javadoc.dir
- Must set build.test.classes.dir
- Must set build.test.results.dir
- Must set build.classes.excludes
- Must set dist.jar
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set JVM to use for profiling in profiler.info.jvm
- Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- To run this application from the command line without Ant, try:
-
-
-
-
-
-
- java -cp "${run.classpath.with.dist.jar}" ${main.class}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- To run this application from the command line without Ant, try:
-
- java -jar "${dist.jar.resolved}"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set debug.class
-
-
-
-
- Must select one file in the IDE or set debug.class
-
-
-
-
- Must set fix.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set profile.class
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Some tests failed; see details above.
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set test.includes
-
-
-
- Some tests failed; see details above.
-
-
-
-
- Must select one file in the IDE or set test.class
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties
deleted file mode 100644
index 225dc8f1..00000000
--- a/nbproject/genfiles.properties
+++ /dev/null
@@ -1,8 +0,0 @@
-build.xml.data.CRC32=749f2a7f
-build.xml.script.CRC32=5813f931
-build.xml.stylesheet.CRC32=28e38971@1.44.1.45
-# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
-# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=749f2a7f
-nbproject/build-impl.xml.script.CRC32=9781d004
-nbproject/build-impl.xml.stylesheet.CRC32=0ae3a408@1.44.1.45
diff --git a/nbproject/project.properties b/nbproject/project.properties
deleted file mode 100644
index 75ed7362..00000000
--- a/nbproject/project.properties
+++ /dev/null
@@ -1,75 +0,0 @@
-annotation.processing.enabled=true
-annotation.processing.enabled.in.editor=false
-annotation.processing.run.all.processors=true
-annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
-application.title=com.juick.json
-application.vendor=ugnich
-build.classes.dir=${build.dir}/classes
-build.classes.excludes=**/*.java,**/*.form
-# This directory is removed when the project is cleaned:
-build.dir=build
-build.generated.dir=${build.dir}/generated
-build.generated.sources.dir=${build.dir}/generated-sources
-# Only compile against the classpath explicitly listed here:
-build.sysclasspath=ignore
-build.test.classes.dir=${build.dir}/test/classes
-build.test.results.dir=${build.dir}/test/results
-# Uncomment to specify the preferred debugger connection transport:
-#debug.transport=dt_socket
-debug.classpath=\
- ${run.classpath}
-debug.test.classpath=\
- ${run.test.classpath}
-# This directory is removed when the project is cleaned:
-dist.dir=dist
-dist.jar=${dist.dir}/com.juick.json.jar
-dist.javadoc.dir=${dist.dir}/javadoc
-endorsed.classpath=
-excludes=
-file.reference.org.json.jar=lib/org.json.jar
-includes=**
-jar.compress=false
-javac.classpath=\
- ${reference.com_juick.jar}:\
- ${file.reference.org.json.jar}
-# Space-separated list of extra javac options
-javac.compilerargs=
-javac.deprecation=false
-javac.processorpath=\
- ${javac.classpath}
-javac.source=1.6
-javac.target=1.6
-javac.test.classpath=\
- ${javac.classpath}:\
- ${build.classes.dir}
-javac.test.processorpath=\
- ${javac.test.classpath}
-javadoc.additionalparam=
-javadoc.author=false
-javadoc.encoding=${source.encoding}
-javadoc.noindex=false
-javadoc.nonavbar=false
-javadoc.notree=false
-javadoc.private=false
-javadoc.splitindex=true
-javadoc.use=true
-javadoc.version=false
-javadoc.windowtitle=
-meta.inf.dir=${src.dir}/META-INF
-mkdist.disabled=true
-platform.active=default_platform
-project.com_juick=../com.juick
-reference.com_juick.jar=${project.com_juick}/dist/com.juick.jar
-run.classpath=\
- ${javac.classpath}:\
- ${build.classes.dir}
-# Space-separated list of JVM arguments used when running the project
-# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
-# or test-sys-prop.name=value to set system properties for unit tests):
-run.jvmargs=
-run.test.classpath=\
- ${javac.test.classpath}:\
- ${build.test.classes.dir}
-source.encoding=UTF-8
-src.dir=src
-test.src.dir=test
diff --git a/nbproject/project.xml b/nbproject/project.xml
deleted file mode 100644
index e1aed871..00000000
--- a/nbproject/project.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
- org.netbeans.modules.java.j2seproject
-
-
- com.juick.json
-
-
-
-
-
-
-
-
-
- com_juick
- jar
-
- jar
- clean
- jar
-
-
-
-
diff --git a/src/com/juick/json/Message.java b/src/com/juick/json/Message.java
deleted file mode 100644
index 4ab1901a..00000000
--- a/src/com/juick/json/Message.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Juick
- * Copyright (C) 2008-2011, Ugnich Anton
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-package com.juick.json;
-
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.*;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-/**
- *
- * @author Ugnich Anton
- */
-public class Message {
-
- public static com.juick.Message parseJSON(JSONObject json) throws JSONException {
- com.juick.Message jmsg = new com.juick.Message();
- jmsg.MID = json.getInt("mid");
- if (json.has("rid")) {
- jmsg.RID = json.getInt("rid");
- }
- if (json.has("replyto")) {
- jmsg.ReplyTo = json.getInt("replyto");
- }
-
- jmsg.FriendsOnly = json.has("friendsonly");
- jmsg.ReadOnly = json.has("readonly");
-
- jmsg.Text = json.getString("body").replace(""", "\"");
- jmsg.User = com.juick.json.User.parseJSON(json.getJSONObject("user"));
-
- try {
- DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- df.setTimeZone(TimeZone.getTimeZone("UTC"));
- jmsg.Timestamp = df.parse(json.getString("timestamp"));
- } catch (ParseException e) {
- }
-
- if (json.has("tags")) {
- JSONArray tags = json.getJSONArray("tags");
- for (int n = 0; n < tags.length(); n++) {
- jmsg.Tags.add(tags.getString(n).replace(""", "\""));
- }
- }
-
- if (json.has("replies")) {
- jmsg.Replies = json.getInt("replies");
- }
-
- if (json.has("photo")) {
- jmsg.Photo = json.getJSONObject("photo").getString("small");
- }
-
- return jmsg;
- }
-
- public static JSONObject toJSON(com.juick.Message msg) {
- JSONObject json = new JSONObject();
-
- try {
- if (msg.MID > 0) {
- json.put("mid", msg.MID);
- }
- if (msg.RID > 0) {
- json.put("rid", msg.RID);
- }
- if (msg.ReplyTo > 0) {
- json.put("replyto", msg.ReplyTo);
- }
- if (msg.FriendsOnly) {
- json.put("friendsonly", 1);
- }
- if (msg.ReadOnly) {
- json.put("readonly", 1);
- }
- if (msg.Text != null) {
- json.put("body", msg.Text);
- }
- if (msg.Timestamp != null) {
- json.put("timestamp", msg.Timestamp);
- } else if (msg.TimestampString != null) {
- json.put("timestamp", msg.TimestampString);
- }
- if (msg.User != null) {
- json.put("user", com.juick.json.User.toJSON(msg.User));
- }
- if (msg.Tags != null && msg.Tags.size() > 0) {
- json.put("tags", new JSONArray(msg.Tags));
- }
- if (msg.Replies > 0) {
- json.put("replies", msg.Replies);
- }
- if (msg.Place != null) {
- json.put("place", com.juick.json.Place.toJSON(msg.Place));
- }
- if (msg.AttachmentType != null) {
- String fname = msg.MID + (msg.RID > 0 ? "-" + msg.RID : "") + "." + msg.AttachmentType;
- JSONObject photo = new JSONObject();
- photo.put("thumbnail", "http://i.juick.com/ps/" + fname);
- photo.put("small", "http://i.juick.com/photos-512/" + fname);
- photo.put("medium", "http://i.juick.com/photos-1024/" + fname);
- json.put("photo", photo);
- }
- } catch (JSONException e) {
- }
-
- return json;
- }
-}
diff --git a/src/com/juick/json/Messages.java b/src/com/juick/json/Messages.java
deleted file mode 100644
index a1879b09..00000000
--- a/src/com/juick/json/Messages.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.juick.json;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-/**
- *
- * @author ugnich
- */
-public class Messages {
-
- public static String arrayToString(ArrayList messages) {
- String json = "[";
-
- Iterator i = messages.iterator();
- while (i.hasNext()) {
- com.juick.Message m = i.next();
- if (json.length() > 1) {
- json += ",";
- }
- json += Message.toJSON(m).toString();
- }
-
- json += "]";
- return json;
- }
-}
diff --git a/src/com/juick/json/Place.java b/src/com/juick/json/Place.java
deleted file mode 100644
index f195e7d7..00000000
--- a/src/com/juick/json/Place.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Juick
- * Copyright (C) 2008-2011, Ugnich Anton
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-package com.juick.json;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-/**
- *
- * @author Ugnich Anton
- */
-public class Place {
-
- public static com.juick.Place parseJSON(JSONObject json) throws JSONException {
- com.juick.Place jplace = new com.juick.Place();
-
- jplace.pid = json.getInt("pid");
- jplace.lat = json.getDouble("lat");
- jplace.lon = json.getDouble("lon");
- jplace.name = json.getString("name").replace(""", "\"");
- if (json.has("users")) {
- jplace.users = json.getInt("users");
- }
- if (json.has("messages")) {
- jplace.messages = json.getInt("messages");
- }
- if (json.has("distance")) {
- jplace.distance = json.getInt("distance");
- }
-
- return jplace;
- }
-
- public static JSONObject toJSON(com.juick.Place place) {
- JSONObject json = new JSONObject();
-
- try {
- if (place.pid > 0) {
- json.put("pid", place.pid);
- }
- if (place.lat >= -90 && place.lat <= 90) {
- json.put("lat", place.lat);
- }
- if (place.lon >= -180 && place.lon <= 180) {
- json.put("lon", place.lon);
- }
- if (place.name != null) {
- json.put("name", place.name);
- }
- } catch (JSONException e) {
- }
-
- return json;
- }
-}
diff --git a/src/com/juick/json/User.java b/src/com/juick/json/User.java
deleted file mode 100644
index dd3143c6..00000000
--- a/src/com/juick/json/User.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Juick
- * Copyright (C) 2008-2011, Ugnich Anton
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-package com.juick.json;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-/**
- *
- * @author Ugnich Anton
- */
-public class User {
-
- public static com.juick.User parseJSON(JSONObject json) throws JSONException {
- com.juick.User juser = new com.juick.User();
- juser.UID = json.getInt("uid");
- juser.UName = json.getString("uname");
- if (json.has("fullname")) {
- juser.FullName = json.getString("fullname");
- }
- return juser;
- }
-
- public static JSONObject toJSON(com.juick.User user) {
- JSONObject json = new JSONObject();
-
- try {
- if (user.UID > 0) {
- json.put("uid", user.UID);
- }
- if (user.UName != null) {
- json.put("uname", user.UName);
- }
- if (user.FullName != null) {
- json.put("fullname", user.FullName);
- }
- if (user.JID != null) {
- json.put("jid", user.JID);
- }
- if (user.MessagesCount > 0) {
- json.put("MessagesCount", user.MessagesCount);
- }
- } catch (JSONException e) {
- }
-
- return json;
- }
-}
diff --git a/src/com/juick/json/Users.java b/src/com/juick/json/Users.java
deleted file mode 100644
index 0e486f74..00000000
--- a/src/com/juick/json/Users.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package com.juick.json;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-/**
- *
- * @author ugnich
- */
-public class Users {
-
- public static String arrayToString(ArrayList users) {
- String json = "[";
-
- Iterator i = users.iterator();
- while (i.hasNext()) {
- com.juick.User u = i.next();
- if (json.length() > 1) {
- json += ",";
- }
- json += User.toJSON(u).toString();
- }
-
- json += "]";
- return json;
- }
-}
diff --git a/src/main/java/com/juick/json/Message.java b/src/main/java/com/juick/json/Message.java
new file mode 100644
index 00000000..4ab1901a
--- /dev/null
+++ b/src/main/java/com/juick/json/Message.java
@@ -0,0 +1,127 @@
+/*
+ * Juick
+ * Copyright (C) 2008-2011, Ugnich Anton
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+package com.juick.json;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+/**
+ *
+ * @author Ugnich Anton
+ */
+public class Message {
+
+ public static com.juick.Message parseJSON(JSONObject json) throws JSONException {
+ com.juick.Message jmsg = new com.juick.Message();
+ jmsg.MID = json.getInt("mid");
+ if (json.has("rid")) {
+ jmsg.RID = json.getInt("rid");
+ }
+ if (json.has("replyto")) {
+ jmsg.ReplyTo = json.getInt("replyto");
+ }
+
+ jmsg.FriendsOnly = json.has("friendsonly");
+ jmsg.ReadOnly = json.has("readonly");
+
+ jmsg.Text = json.getString("body").replace(""", "\"");
+ jmsg.User = com.juick.json.User.parseJSON(json.getJSONObject("user"));
+
+ try {
+ DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ df.setTimeZone(TimeZone.getTimeZone("UTC"));
+ jmsg.Timestamp = df.parse(json.getString("timestamp"));
+ } catch (ParseException e) {
+ }
+
+ if (json.has("tags")) {
+ JSONArray tags = json.getJSONArray("tags");
+ for (int n = 0; n < tags.length(); n++) {
+ jmsg.Tags.add(tags.getString(n).replace(""", "\""));
+ }
+ }
+
+ if (json.has("replies")) {
+ jmsg.Replies = json.getInt("replies");
+ }
+
+ if (json.has("photo")) {
+ jmsg.Photo = json.getJSONObject("photo").getString("small");
+ }
+
+ return jmsg;
+ }
+
+ public static JSONObject toJSON(com.juick.Message msg) {
+ JSONObject json = new JSONObject();
+
+ try {
+ if (msg.MID > 0) {
+ json.put("mid", msg.MID);
+ }
+ if (msg.RID > 0) {
+ json.put("rid", msg.RID);
+ }
+ if (msg.ReplyTo > 0) {
+ json.put("replyto", msg.ReplyTo);
+ }
+ if (msg.FriendsOnly) {
+ json.put("friendsonly", 1);
+ }
+ if (msg.ReadOnly) {
+ json.put("readonly", 1);
+ }
+ if (msg.Text != null) {
+ json.put("body", msg.Text);
+ }
+ if (msg.Timestamp != null) {
+ json.put("timestamp", msg.Timestamp);
+ } else if (msg.TimestampString != null) {
+ json.put("timestamp", msg.TimestampString);
+ }
+ if (msg.User != null) {
+ json.put("user", com.juick.json.User.toJSON(msg.User));
+ }
+ if (msg.Tags != null && msg.Tags.size() > 0) {
+ json.put("tags", new JSONArray(msg.Tags));
+ }
+ if (msg.Replies > 0) {
+ json.put("replies", msg.Replies);
+ }
+ if (msg.Place != null) {
+ json.put("place", com.juick.json.Place.toJSON(msg.Place));
+ }
+ if (msg.AttachmentType != null) {
+ String fname = msg.MID + (msg.RID > 0 ? "-" + msg.RID : "") + "." + msg.AttachmentType;
+ JSONObject photo = new JSONObject();
+ photo.put("thumbnail", "http://i.juick.com/ps/" + fname);
+ photo.put("small", "http://i.juick.com/photos-512/" + fname);
+ photo.put("medium", "http://i.juick.com/photos-1024/" + fname);
+ json.put("photo", photo);
+ }
+ } catch (JSONException e) {
+ }
+
+ return json;
+ }
+}
diff --git a/src/main/java/com/juick/json/Messages.java b/src/main/java/com/juick/json/Messages.java
new file mode 100644
index 00000000..a1879b09
--- /dev/null
+++ b/src/main/java/com/juick/json/Messages.java
@@ -0,0 +1,27 @@
+package com.juick.json;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ *
+ * @author ugnich
+ */
+public class Messages {
+
+ public static String arrayToString(ArrayList messages) {
+ String json = "[";
+
+ Iterator i = messages.iterator();
+ while (i.hasNext()) {
+ com.juick.Message m = i.next();
+ if (json.length() > 1) {
+ json += ",";
+ }
+ json += Message.toJSON(m).toString();
+ }
+
+ json += "]";
+ return json;
+ }
+}
diff --git a/src/main/java/com/juick/json/Place.java b/src/main/java/com/juick/json/Place.java
new file mode 100644
index 00000000..f195e7d7
--- /dev/null
+++ b/src/main/java/com/juick/json/Place.java
@@ -0,0 +1,71 @@
+/*
+ * Juick
+ * Copyright (C) 2008-2011, Ugnich Anton
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+package com.juick.json;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+/**
+ *
+ * @author Ugnich Anton
+ */
+public class Place {
+
+ public static com.juick.Place parseJSON(JSONObject json) throws JSONException {
+ com.juick.Place jplace = new com.juick.Place();
+
+ jplace.pid = json.getInt("pid");
+ jplace.lat = json.getDouble("lat");
+ jplace.lon = json.getDouble("lon");
+ jplace.name = json.getString("name").replace(""", "\"");
+ if (json.has("users")) {
+ jplace.users = json.getInt("users");
+ }
+ if (json.has("messages")) {
+ jplace.messages = json.getInt("messages");
+ }
+ if (json.has("distance")) {
+ jplace.distance = json.getInt("distance");
+ }
+
+ return jplace;
+ }
+
+ public static JSONObject toJSON(com.juick.Place place) {
+ JSONObject json = new JSONObject();
+
+ try {
+ if (place.pid > 0) {
+ json.put("pid", place.pid);
+ }
+ if (place.lat >= -90 && place.lat <= 90) {
+ json.put("lat", place.lat);
+ }
+ if (place.lon >= -180 && place.lon <= 180) {
+ json.put("lon", place.lon);
+ }
+ if (place.name != null) {
+ json.put("name", place.name);
+ }
+ } catch (JSONException e) {
+ }
+
+ return json;
+ }
+}
diff --git a/src/main/java/com/juick/json/User.java b/src/main/java/com/juick/json/User.java
new file mode 100644
index 00000000..dd3143c6
--- /dev/null
+++ b/src/main/java/com/juick/json/User.java
@@ -0,0 +1,63 @@
+/*
+ * Juick
+ * Copyright (C) 2008-2011, Ugnich Anton
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+package com.juick.json;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+/**
+ *
+ * @author Ugnich Anton
+ */
+public class User {
+
+ public static com.juick.User parseJSON(JSONObject json) throws JSONException {
+ com.juick.User juser = new com.juick.User();
+ juser.UID = json.getInt("uid");
+ juser.UName = json.getString("uname");
+ if (json.has("fullname")) {
+ juser.FullName = json.getString("fullname");
+ }
+ return juser;
+ }
+
+ public static JSONObject toJSON(com.juick.User user) {
+ JSONObject json = new JSONObject();
+
+ try {
+ if (user.UID > 0) {
+ json.put("uid", user.UID);
+ }
+ if (user.UName != null) {
+ json.put("uname", user.UName);
+ }
+ if (user.FullName != null) {
+ json.put("fullname", user.FullName);
+ }
+ if (user.JID != null) {
+ json.put("jid", user.JID);
+ }
+ if (user.MessagesCount > 0) {
+ json.put("MessagesCount", user.MessagesCount);
+ }
+ } catch (JSONException e) {
+ }
+
+ return json;
+ }
+}
diff --git a/src/main/java/com/juick/json/Users.java b/src/main/java/com/juick/json/Users.java
new file mode 100644
index 00000000..0e486f74
--- /dev/null
+++ b/src/main/java/com/juick/json/Users.java
@@ -0,0 +1,31 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.juick.json;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ *
+ * @author ugnich
+ */
+public class Users {
+
+ public static String arrayToString(ArrayList users) {
+ String json = "[";
+
+ Iterator i = users.iterator();
+ while (i.hasNext()) {
+ com.juick.User u = i.next();
+ if (json.length() > 1) {
+ json += ",";
+ }
+ json += User.toJSON(u).toString();
+ }
+
+ json += "]";
+ return json;
+ }
+}
--
cgit v1.2.3
From 655b821e274ca4be078389475a8bb33139c55a4f Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Wed, 4 Nov 2015 15:24:53 +0300
Subject: refactoring
---
build.gradle | 2 +-
src/main/java/com/juick/json/JSONSerializer.java | 53 ++++++++
src/main/java/com/juick/json/Message.java | 127 --------------------
.../java/com/juick/json/MessageSerializer.java | 133 +++++++++++++++++++++
src/main/java/com/juick/json/Messages.java | 27 -----
src/main/java/com/juick/json/Place.java | 71 -----------
src/main/java/com/juick/json/PlaceSerializer.java | 73 +++++++++++
src/main/java/com/juick/json/User.java | 63 ----------
src/main/java/com/juick/json/UserSerializer.java | 66 ++++++++++
src/main/java/com/juick/json/Users.java | 31 -----
10 files changed, 326 insertions(+), 320 deletions(-)
create mode 100644 src/main/java/com/juick/json/JSONSerializer.java
delete mode 100644 src/main/java/com/juick/json/Message.java
create mode 100644 src/main/java/com/juick/json/MessageSerializer.java
delete mode 100644 src/main/java/com/juick/json/Messages.java
delete mode 100644 src/main/java/com/juick/json/Place.java
create mode 100644 src/main/java/com/juick/json/PlaceSerializer.java
delete mode 100644 src/main/java/com/juick/json/User.java
create mode 100644 src/main/java/com/juick/json/UserSerializer.java
delete mode 100644 src/main/java/com/juick/json/Users.java
(limited to 'src')
diff --git a/build.gradle b/build.gradle
index 483a3727..a8ba383f 100644
--- a/build.gradle
+++ b/build.gradle
@@ -5,5 +5,5 @@ repositories {
}
dependencies {
- compile 'org.json:json:20140107'
+ compile 'org.json:json:20150729'
}
diff --git a/src/main/java/com/juick/json/JSONSerializer.java b/src/main/java/com/juick/json/JSONSerializer.java
new file mode 100644
index 00000000..8ac72cb0
--- /dev/null
+++ b/src/main/java/com/juick/json/JSONSerializer.java
@@ -0,0 +1,53 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.juick.json;
+
+import java.util.Iterator;
+import java.util.List;
+import org.json.JSONObject;
+
+/**
+ *
+ * @author vt
+ * @param
+ */
+public abstract class JSONSerializer {
+
+ /**
+ *
+ * @param json
+ * @return
+ */
+ public abstract T deserialize(JSONObject json);
+
+ /**
+ *
+ * @param obj
+ * @return
+ */
+ public abstract JSONObject serialize(T obj);
+
+ /**
+ *
+ * @param objs
+ * @return
+ */
+ public String serializeList(List objs) {
+ String json = "[";
+
+ Iterator i = objs.iterator();
+ while (i.hasNext()) {
+ T m = i.next();
+ if (json.length() > 1) {
+ json += ",";
+ }
+ json += serialize(m).toString();
+ }
+
+ json += "]";
+ return json;
+ }
+}
diff --git a/src/main/java/com/juick/json/Message.java b/src/main/java/com/juick/json/Message.java
deleted file mode 100644
index 4ab1901a..00000000
--- a/src/main/java/com/juick/json/Message.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Juick
- * Copyright (C) 2008-2011, Ugnich Anton
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-package com.juick.json;
-
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.*;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-/**
- *
- * @author Ugnich Anton
- */
-public class Message {
-
- public static com.juick.Message parseJSON(JSONObject json) throws JSONException {
- com.juick.Message jmsg = new com.juick.Message();
- jmsg.MID = json.getInt("mid");
- if (json.has("rid")) {
- jmsg.RID = json.getInt("rid");
- }
- if (json.has("replyto")) {
- jmsg.ReplyTo = json.getInt("replyto");
- }
-
- jmsg.FriendsOnly = json.has("friendsonly");
- jmsg.ReadOnly = json.has("readonly");
-
- jmsg.Text = json.getString("body").replace(""", "\"");
- jmsg.User = com.juick.json.User.parseJSON(json.getJSONObject("user"));
-
- try {
- DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- df.setTimeZone(TimeZone.getTimeZone("UTC"));
- jmsg.Timestamp = df.parse(json.getString("timestamp"));
- } catch (ParseException e) {
- }
-
- if (json.has("tags")) {
- JSONArray tags = json.getJSONArray("tags");
- for (int n = 0; n < tags.length(); n++) {
- jmsg.Tags.add(tags.getString(n).replace(""", "\""));
- }
- }
-
- if (json.has("replies")) {
- jmsg.Replies = json.getInt("replies");
- }
-
- if (json.has("photo")) {
- jmsg.Photo = json.getJSONObject("photo").getString("small");
- }
-
- return jmsg;
- }
-
- public static JSONObject toJSON(com.juick.Message msg) {
- JSONObject json = new JSONObject();
-
- try {
- if (msg.MID > 0) {
- json.put("mid", msg.MID);
- }
- if (msg.RID > 0) {
- json.put("rid", msg.RID);
- }
- if (msg.ReplyTo > 0) {
- json.put("replyto", msg.ReplyTo);
- }
- if (msg.FriendsOnly) {
- json.put("friendsonly", 1);
- }
- if (msg.ReadOnly) {
- json.put("readonly", 1);
- }
- if (msg.Text != null) {
- json.put("body", msg.Text);
- }
- if (msg.Timestamp != null) {
- json.put("timestamp", msg.Timestamp);
- } else if (msg.TimestampString != null) {
- json.put("timestamp", msg.TimestampString);
- }
- if (msg.User != null) {
- json.put("user", com.juick.json.User.toJSON(msg.User));
- }
- if (msg.Tags != null && msg.Tags.size() > 0) {
- json.put("tags", new JSONArray(msg.Tags));
- }
- if (msg.Replies > 0) {
- json.put("replies", msg.Replies);
- }
- if (msg.Place != null) {
- json.put("place", com.juick.json.Place.toJSON(msg.Place));
- }
- if (msg.AttachmentType != null) {
- String fname = msg.MID + (msg.RID > 0 ? "-" + msg.RID : "") + "." + msg.AttachmentType;
- JSONObject photo = new JSONObject();
- photo.put("thumbnail", "http://i.juick.com/ps/" + fname);
- photo.put("small", "http://i.juick.com/photos-512/" + fname);
- photo.put("medium", "http://i.juick.com/photos-1024/" + fname);
- json.put("photo", photo);
- }
- } catch (JSONException e) {
- }
-
- return json;
- }
-}
diff --git a/src/main/java/com/juick/json/MessageSerializer.java b/src/main/java/com/juick/json/MessageSerializer.java
new file mode 100644
index 00000000..0879f13a
--- /dev/null
+++ b/src/main/java/com/juick/json/MessageSerializer.java
@@ -0,0 +1,133 @@
+/*
+ * Juick
+ * Copyright (C) 2008-2011, Ugnich Anton
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+package com.juick.json;
+
+import com.juick.Message;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+/**
+ *
+ * @author Ugnich Anton
+ */
+public class MessageSerializer extends JSONSerializer {
+
+ UserSerializer userSerializer = new UserSerializer();
+ PlaceSerializer placeSerializer = new PlaceSerializer();
+
+ @Override
+ public Message deserialize(JSONObject json) throws JSONException {
+ com.juick.Message jmsg = new com.juick.Message();
+ jmsg.MID = json.getInt("mid");
+ if (json.has("rid")) {
+ jmsg.RID = json.getInt("rid");
+ }
+ if (json.has("replyto")) {
+ jmsg.ReplyTo = json.getInt("replyto");
+ }
+
+ jmsg.FriendsOnly = json.has("friendsonly");
+ jmsg.ReadOnly = json.has("readonly");
+
+ jmsg.Text = json.getString("body").replace(""", "\"");
+ jmsg.User = userSerializer.deserialize(json.getJSONObject("user"));
+
+ try {
+ DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ df.setTimeZone(TimeZone.getTimeZone("UTC"));
+ jmsg.Timestamp = df.parse(json.getString("timestamp"));
+ } catch (ParseException e) {
+ }
+
+ if (json.has("tags")) {
+ JSONArray tags = json.getJSONArray("tags");
+ for (int n = 0; n < tags.length(); n++) {
+ jmsg.Tags.add(tags.getString(n).replace(""", "\""));
+ }
+ }
+
+ if (json.has("replies")) {
+ jmsg.Replies = json.getInt("replies");
+ }
+
+ if (json.has("photo")) {
+ jmsg.Photo = json.getJSONObject("photo").getString("small");
+ }
+
+ return jmsg;
+ }
+
+ @Override
+ public JSONObject serialize(Message msg) {
+ JSONObject json = new JSONObject();
+
+ try {
+ if (msg.MID > 0) {
+ json.put("mid", msg.MID);
+ }
+ if (msg.RID > 0) {
+ json.put("rid", msg.RID);
+ }
+ if (msg.ReplyTo > 0) {
+ json.put("replyto", msg.ReplyTo);
+ }
+ if (msg.FriendsOnly) {
+ json.put("friendsonly", 1);
+ }
+ if (msg.ReadOnly) {
+ json.put("readonly", 1);
+ }
+ if (msg.Text != null) {
+ json.put("body", msg.Text);
+ }
+ if (msg.Timestamp != null) {
+ json.put("timestamp", msg.Timestamp);
+ } else if (msg.TimestampString != null) {
+ json.put("timestamp", msg.TimestampString);
+ }
+ if (msg.User != null) {
+ json.put("user", userSerializer.serialize(msg.User));
+ }
+ if (msg.Tags != null && msg.Tags.size() > 0) {
+ json.put("tags", new JSONArray(msg.Tags));
+ }
+ if (msg.Replies > 0) {
+ json.put("replies", msg.Replies);
+ }
+ if (msg.Place != null) {
+ json.put("place", placeSerializer.serialize(msg.Place));
+ }
+ if (msg.AttachmentType != null) {
+ String fname = msg.MID + (msg.RID > 0 ? "-" + msg.RID : "") + "." + msg.AttachmentType;
+ JSONObject photo = new JSONObject();
+ photo.put("thumbnail", "http://i.juick.com/ps/" + fname);
+ photo.put("small", "http://i.juick.com/photos-512/" + fname);
+ photo.put("medium", "http://i.juick.com/photos-1024/" + fname);
+ json.put("photo", photo);
+ }
+ } catch (JSONException e) {
+ }
+
+ return json;
+ }
+}
diff --git a/src/main/java/com/juick/json/Messages.java b/src/main/java/com/juick/json/Messages.java
deleted file mode 100644
index a1879b09..00000000
--- a/src/main/java/com/juick/json/Messages.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.juick.json;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-/**
- *
- * @author ugnich
- */
-public class Messages {
-
- public static String arrayToString(ArrayList messages) {
- String json = "[";
-
- Iterator i = messages.iterator();
- while (i.hasNext()) {
- com.juick.Message m = i.next();
- if (json.length() > 1) {
- json += ",";
- }
- json += Message.toJSON(m).toString();
- }
-
- json += "]";
- return json;
- }
-}
diff --git a/src/main/java/com/juick/json/Place.java b/src/main/java/com/juick/json/Place.java
deleted file mode 100644
index f195e7d7..00000000
--- a/src/main/java/com/juick/json/Place.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Juick
- * Copyright (C) 2008-2011, Ugnich Anton
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-package com.juick.json;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-/**
- *
- * @author Ugnich Anton
- */
-public class Place {
-
- public static com.juick.Place parseJSON(JSONObject json) throws JSONException {
- com.juick.Place jplace = new com.juick.Place();
-
- jplace.pid = json.getInt("pid");
- jplace.lat = json.getDouble("lat");
- jplace.lon = json.getDouble("lon");
- jplace.name = json.getString("name").replace(""", "\"");
- if (json.has("users")) {
- jplace.users = json.getInt("users");
- }
- if (json.has("messages")) {
- jplace.messages = json.getInt("messages");
- }
- if (json.has("distance")) {
- jplace.distance = json.getInt("distance");
- }
-
- return jplace;
- }
-
- public static JSONObject toJSON(com.juick.Place place) {
- JSONObject json = new JSONObject();
-
- try {
- if (place.pid > 0) {
- json.put("pid", place.pid);
- }
- if (place.lat >= -90 && place.lat <= 90) {
- json.put("lat", place.lat);
- }
- if (place.lon >= -180 && place.lon <= 180) {
- json.put("lon", place.lon);
- }
- if (place.name != null) {
- json.put("name", place.name);
- }
- } catch (JSONException e) {
- }
-
- return json;
- }
-}
diff --git a/src/main/java/com/juick/json/PlaceSerializer.java b/src/main/java/com/juick/json/PlaceSerializer.java
new file mode 100644
index 00000000..f433f7f0
--- /dev/null
+++ b/src/main/java/com/juick/json/PlaceSerializer.java
@@ -0,0 +1,73 @@
+/*
+ * Juick
+ * Copyright (C) 2008-2011, Ugnich Anton
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+package com.juick.json;
+
+import com.juick.Place;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+/**
+ *
+ * @author Ugnich Anton
+ */
+public class PlaceSerializer extends JSONSerializer {
+
+ @Override
+ public Place deserialize(JSONObject json) throws JSONException {
+ Place jplace = new Place();
+
+ jplace.pid = json.getInt("pid");
+ jplace.lat = json.getDouble("lat");
+ jplace.lon = json.getDouble("lon");
+ jplace.name = json.getString("name").replace(""", "\"");
+ if (json.has("users")) {
+ jplace.users = json.getInt("users");
+ }
+ if (json.has("messages")) {
+ jplace.messages = json.getInt("messages");
+ }
+ if (json.has("distance")) {
+ jplace.distance = json.getInt("distance");
+ }
+
+ return jplace;
+ }
+
+ @Override
+ public JSONObject serialize(Place place) {
+ JSONObject json = new JSONObject();
+
+ try {
+ if (place.pid > 0) {
+ json.put("pid", place.pid);
+ }
+ if (place.lat >= -90 && place.lat <= 90) {
+ json.put("lat", place.lat);
+ }
+ if (place.lon >= -180 && place.lon <= 180) {
+ json.put("lon", place.lon);
+ }
+ if (place.name != null) {
+ json.put("name", place.name);
+ }
+ } catch (JSONException e) {
+ }
+
+ return json;
+ }
+}
diff --git a/src/main/java/com/juick/json/User.java b/src/main/java/com/juick/json/User.java
deleted file mode 100644
index dd3143c6..00000000
--- a/src/main/java/com/juick/json/User.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Juick
- * Copyright (C) 2008-2011, Ugnich Anton
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-package com.juick.json;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-/**
- *
- * @author Ugnich Anton
- */
-public class User {
-
- public static com.juick.User parseJSON(JSONObject json) throws JSONException {
- com.juick.User juser = new com.juick.User();
- juser.UID = json.getInt("uid");
- juser.UName = json.getString("uname");
- if (json.has("fullname")) {
- juser.FullName = json.getString("fullname");
- }
- return juser;
- }
-
- public static JSONObject toJSON(com.juick.User user) {
- JSONObject json = new JSONObject();
-
- try {
- if (user.UID > 0) {
- json.put("uid", user.UID);
- }
- if (user.UName != null) {
- json.put("uname", user.UName);
- }
- if (user.FullName != null) {
- json.put("fullname", user.FullName);
- }
- if (user.JID != null) {
- json.put("jid", user.JID);
- }
- if (user.MessagesCount > 0) {
- json.put("MessagesCount", user.MessagesCount);
- }
- } catch (JSONException e) {
- }
-
- return json;
- }
-}
diff --git a/src/main/java/com/juick/json/UserSerializer.java b/src/main/java/com/juick/json/UserSerializer.java
new file mode 100644
index 00000000..07f87616
--- /dev/null
+++ b/src/main/java/com/juick/json/UserSerializer.java
@@ -0,0 +1,66 @@
+/*
+ * Juick
+ * Copyright (C) 2008-2011, Ugnich Anton
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+package com.juick.json;
+
+import com.juick.User;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+/**
+ *
+ * @author Ugnich Anton
+ */
+public class UserSerializer extends JSONSerializer {
+
+ @Override
+ public User deserialize(JSONObject json) throws JSONException {
+ User juser = new User();
+ juser.UID = json.getInt("uid");
+ juser.UName = json.getString("uname");
+ if (json.has("fullname")) {
+ juser.FullName = json.getString("fullname");
+ }
+ return juser;
+ }
+
+ @Override
+ public JSONObject serialize(User user) {
+ JSONObject json = new JSONObject();
+
+ try {
+ if (user.UID > 0) {
+ json.put("uid", user.UID);
+ }
+ if (user.UName != null) {
+ json.put("uname", user.UName);
+ }
+ if (user.FullName != null) {
+ json.put("fullname", user.FullName);
+ }
+ if (user.JID != null) {
+ json.put("jid", user.JID);
+ }
+ if (user.MessagesCount > 0) {
+ json.put("MessagesCount", user.MessagesCount);
+ }
+ } catch (JSONException e) {
+ }
+
+ return json;
+ }
+}
diff --git a/src/main/java/com/juick/json/Users.java b/src/main/java/com/juick/json/Users.java
deleted file mode 100644
index 0e486f74..00000000
--- a/src/main/java/com/juick/json/Users.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package com.juick.json;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-/**
- *
- * @author ugnich
- */
-public class Users {
-
- public static String arrayToString(ArrayList users) {
- String json = "[";
-
- Iterator i = users.iterator();
- while (i.hasNext()) {
- com.juick.User u = i.next();
- if (json.length() > 1) {
- json += ",";
- }
- json += User.toJSON(u).toString();
- }
-
- json += "]";
- return json;
- }
-}
--
cgit v1.2.3
From 331363c89936be9df126d10e16107b99a18877d1 Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Sun, 10 Jan 2016 19:58:19 +0300
Subject: refactoring
---
.../java/com/juick/json/MessageSerializer.java | 20 ++++++++++----------
src/main/java/com/juick/json/UserSerializer.java | 22 +++++++++++-----------
2 files changed, 21 insertions(+), 21 deletions(-)
(limited to 'src')
diff --git a/src/main/java/com/juick/json/MessageSerializer.java b/src/main/java/com/juick/json/MessageSerializer.java
index 0879f13a..85986415 100644
--- a/src/main/java/com/juick/json/MessageSerializer.java
+++ b/src/main/java/com/juick/json/MessageSerializer.java
@@ -38,9 +38,9 @@ public class MessageSerializer extends JSONSerializer {
@Override
public Message deserialize(JSONObject json) throws JSONException {
com.juick.Message jmsg = new com.juick.Message();
- jmsg.MID = json.getInt("mid");
+ jmsg.setMID(json.getInt("mid"));
if (json.has("rid")) {
- jmsg.RID = json.getInt("rid");
+ jmsg.setRID(json.getInt("rid"));
}
if (json.has("replyto")) {
jmsg.ReplyTo = json.getInt("replyto");
@@ -50,7 +50,7 @@ public class MessageSerializer extends JSONSerializer {
jmsg.ReadOnly = json.has("readonly");
jmsg.Text = json.getString("body").replace(""", "\"");
- jmsg.User = userSerializer.deserialize(json.getJSONObject("user"));
+ jmsg.setUser(userSerializer.deserialize(json.getJSONObject("user")));
try {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -82,11 +82,11 @@ public class MessageSerializer extends JSONSerializer {
JSONObject json = new JSONObject();
try {
- if (msg.MID > 0) {
- json.put("mid", msg.MID);
+ if (msg.getMID() > 0) {
+ json.put("mid", msg.getMID());
}
- if (msg.RID > 0) {
- json.put("rid", msg.RID);
+ if (msg.getRID() > 0) {
+ json.put("rid", msg.getRID());
}
if (msg.ReplyTo > 0) {
json.put("replyto", msg.ReplyTo);
@@ -105,8 +105,8 @@ public class MessageSerializer extends JSONSerializer {
} else if (msg.TimestampString != null) {
json.put("timestamp", msg.TimestampString);
}
- if (msg.User != null) {
- json.put("user", userSerializer.serialize(msg.User));
+ if (msg.getUser() != null) {
+ json.put("user", userSerializer.serialize(msg.getUser()));
}
if (msg.Tags != null && msg.Tags.size() > 0) {
json.put("tags", new JSONArray(msg.Tags));
@@ -118,7 +118,7 @@ public class MessageSerializer extends JSONSerializer {
json.put("place", placeSerializer.serialize(msg.Place));
}
if (msg.AttachmentType != null) {
- String fname = msg.MID + (msg.RID > 0 ? "-" + msg.RID : "") + "." + msg.AttachmentType;
+ String fname = msg.getMID() + (msg.getRID() > 0 ? "-" + msg.getRID() : "") + "." + msg.AttachmentType;
JSONObject photo = new JSONObject();
photo.put("thumbnail", "http://i.juick.com/ps/" + fname);
photo.put("small", "http://i.juick.com/photos-512/" + fname);
diff --git a/src/main/java/com/juick/json/UserSerializer.java b/src/main/java/com/juick/json/UserSerializer.java
index 07f87616..4485812a 100644
--- a/src/main/java/com/juick/json/UserSerializer.java
+++ b/src/main/java/com/juick/json/UserSerializer.java
@@ -30,10 +30,10 @@ public class UserSerializer extends JSONSerializer {
@Override
public User deserialize(JSONObject json) throws JSONException {
User juser = new User();
- juser.UID = json.getInt("uid");
- juser.UName = json.getString("uname");
+ juser.setUID(json.getInt("uid"));
+ juser.setUName(json.getString("uname"));
if (json.has("fullname")) {
- juser.FullName = json.getString("fullname");
+ juser.setFullName(json.getString("fullname"));
}
return juser;
}
@@ -43,17 +43,17 @@ public class UserSerializer extends JSONSerializer {
JSONObject json = new JSONObject();
try {
- if (user.UID > 0) {
- json.put("uid", user.UID);
+ if (user.getUID() > 0) {
+ json.put("uid", user.getUID());
}
- if (user.UName != null) {
- json.put("uname", user.UName);
+ if (user.getUName() != null) {
+ json.put("uname", user.getUName());
}
- if (user.FullName != null) {
- json.put("fullname", user.FullName);
+ if (user.getFullName() != null) {
+ json.put("fullname", user.getFullName());
}
- if (user.JID != null) {
- json.put("jid", user.JID);
+ if (user.getJID() != null) {
+ json.put("jid", user.getJID());
}
if (user.MessagesCount > 0) {
json.put("MessagesCount", user.MessagesCount);
--
cgit v1.2.3
From ee0e13e7243abecf242236c224551774195524a3 Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Sun, 10 Jan 2016 20:10:19 +0300
Subject: refactoring, part 2
---
src/main/java/com/juick/json/MessageSerializer.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
(limited to 'src')
diff --git a/src/main/java/com/juick/json/MessageSerializer.java b/src/main/java/com/juick/json/MessageSerializer.java
index 85986415..dccf1b3a 100644
--- a/src/main/java/com/juick/json/MessageSerializer.java
+++ b/src/main/java/com/juick/json/MessageSerializer.java
@@ -49,7 +49,7 @@ public class MessageSerializer extends JSONSerializer {
jmsg.FriendsOnly = json.has("friendsonly");
jmsg.ReadOnly = json.has("readonly");
- jmsg.Text = json.getString("body").replace(""", "\"");
+ jmsg.setText(json.getString("body").replace(""", "\""));
jmsg.setUser(userSerializer.deserialize(json.getJSONObject("user")));
try {
@@ -97,8 +97,8 @@ public class MessageSerializer extends JSONSerializer {
if (msg.ReadOnly) {
json.put("readonly", 1);
}
- if (msg.Text != null) {
- json.put("body", msg.Text);
+ if (msg.getText() != null) {
+ json.put("body", msg.getText());
}
if (msg.Timestamp != null) {
json.put("timestamp", msg.Timestamp);
--
cgit v1.2.3
From 9a50ad8dea5e9ebc5eb1c5efb19aa7a784283e14 Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Sat, 16 Jan 2016 18:25:11 +0300
Subject: date and tests
---
build.gradle | 1 +
.../java/com/juick/json/MessageSerializer.java | 16 ++++++++----
src/test/java/com/juick/JsonTests.java | 30 ++++++++++++++++++++++
3 files changed, 42 insertions(+), 5 deletions(-)
create mode 100644 src/test/java/com/juick/JsonTests.java
(limited to 'src')
diff --git a/build.gradle b/build.gradle
index 2e438790..456e86c8 100644
--- a/build.gradle
+++ b/build.gradle
@@ -6,4 +6,5 @@ repositories {
dependencies {
compile 'org.json:json:20151123'
+ testCompile 'junit:junit:4.12'
}
diff --git a/src/main/java/com/juick/json/MessageSerializer.java b/src/main/java/com/juick/json/MessageSerializer.java
index dccf1b3a..da87d4be 100644
--- a/src/main/java/com/juick/json/MessageSerializer.java
+++ b/src/main/java/com/juick/json/MessageSerializer.java
@@ -22,6 +22,9 @@ import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -31,10 +34,14 @@ import org.json.JSONObject;
* @author Ugnich Anton
*/
public class MessageSerializer extends JSONSerializer {
+
+ private final static Logger LOGGER = Logger.getLogger(MessageSerializer.class.getName());
UserSerializer userSerializer = new UserSerializer();
PlaceSerializer placeSerializer = new PlaceSerializer();
+ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
@Override
public Message deserialize(JSONObject json) throws JSONException {
com.juick.Message jmsg = new com.juick.Message();
@@ -55,7 +62,7 @@ public class MessageSerializer extends JSONSerializer {
try {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
df.setTimeZone(TimeZone.getTimeZone("UTC"));
- jmsg.Timestamp = df.parse(json.getString("timestamp"));
+ jmsg.setDate(df.parse(json.getString("timestamp")));
} catch (ParseException e) {
}
@@ -100,10 +107,8 @@ public class MessageSerializer extends JSONSerializer {
if (msg.getText() != null) {
json.put("body", msg.getText());
}
- if (msg.Timestamp != null) {
- json.put("timestamp", msg.Timestamp);
- } else if (msg.TimestampString != null) {
- json.put("timestamp", msg.TimestampString);
+ if (msg.getDate() != null) {
+ json.put("timestamp", df.format(msg.getDate()));
}
if (msg.getUser() != null) {
json.put("user", userSerializer.serialize(msg.getUser()));
@@ -126,6 +131,7 @@ public class MessageSerializer extends JSONSerializer {
json.put("photo", photo);
}
} catch (JSONException e) {
+ LOGGER.log(Level.SEVERE, "JSON Exception", e);
}
return json;
diff --git a/src/test/java/com/juick/JsonTests.java b/src/test/java/com/juick/JsonTests.java
new file mode 100644
index 00000000..5d78a2d6
--- /dev/null
+++ b/src/test/java/com/juick/JsonTests.java
@@ -0,0 +1,30 @@
+package com.juick;
+
+import static org.junit.Assert.assertEquals;
+
+import com.juick.json.MessageSerializer;
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.juick.Message;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+
+public class JsonTests {
+ @Test
+ public void DateTest() {
+ Message msg = new Message();
+ SimpleDateFormat df= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ try {
+ msg.setDate(df.parse("2015-01-01 00:00:00"));
+ MessageSerializer serializer = new MessageSerializer();
+ String json = serializer.serialize(msg).toString();
+ assertEquals("{\"timestamp\":\"2015-01-01 00:00:00\"}", json);
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+
+ }
+}
\ No newline at end of file
--
cgit v1.2.3
From 1a39696a6eaf4ea41447e4426ccdcfacec657554 Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Sat, 16 Jan 2016 19:03:54 +0300
Subject: update test for date and time
---
src/test/java/com/juick/JsonTests.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'src')
diff --git a/src/test/java/com/juick/JsonTests.java b/src/test/java/com/juick/JsonTests.java
index 5d78a2d6..890360c1 100644
--- a/src/test/java/com/juick/JsonTests.java
+++ b/src/test/java/com/juick/JsonTests.java
@@ -18,10 +18,10 @@ public class JsonTests {
Message msg = new Message();
SimpleDateFormat df= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
- msg.setDate(df.parse("2015-01-01 00:00:00"));
+ msg.setDate(df.parse("2015-01-01 05:02:10"));
MessageSerializer serializer = new MessageSerializer();
String json = serializer.serialize(msg).toString();
- assertEquals("{\"timestamp\":\"2015-01-01 00:00:00\"}", json);
+ assertEquals("{\"timestamp\":\"2015-01-01 05:02:10\"}", json);
} catch (ParseException e) {
e.printStackTrace();
}
--
cgit v1.2.3
From 143513cec90ab176e5c174fb4ed98c249652bda6 Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Sat, 16 Jan 2016 19:13:30 +0300
Subject: refactoring
---
src/main/java/com/juick/json/JSONSerializer.java | 3 ++-
src/main/java/com/juick/json/MessageSerializer.java | 16 ++++++++--------
2 files changed, 10 insertions(+), 9 deletions(-)
(limited to 'src')
diff --git a/src/main/java/com/juick/json/JSONSerializer.java b/src/main/java/com/juick/json/JSONSerializer.java
index 8ac72cb0..142cacf0 100644
--- a/src/main/java/com/juick/json/JSONSerializer.java
+++ b/src/main/java/com/juick/json/JSONSerializer.java
@@ -5,6 +5,7 @@
*/
package com.juick.json;
+import java.text.ParseException;
import java.util.Iterator;
import java.util.List;
import org.json.JSONObject;
@@ -21,7 +22,7 @@ public abstract class JSONSerializer {
* @param json
* @return
*/
- public abstract T deserialize(JSONObject json);
+ public abstract T deserialize(JSONObject json) throws ParseException;
/**
*
diff --git a/src/main/java/com/juick/json/MessageSerializer.java b/src/main/java/com/juick/json/MessageSerializer.java
index da87d4be..4818722f 100644
--- a/src/main/java/com/juick/json/MessageSerializer.java
+++ b/src/main/java/com/juick/json/MessageSerializer.java
@@ -40,10 +40,15 @@ public class MessageSerializer extends JSONSerializer {
UserSerializer userSerializer = new UserSerializer();
PlaceSerializer placeSerializer = new PlaceSerializer();
- SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ final SimpleDateFormat df;
+
+ public MessageSerializer() {
+ df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ df.setTimeZone(TimeZone.getTimeZone("UTC"));
+ }
@Override
- public Message deserialize(JSONObject json) throws JSONException {
+ public Message deserialize(JSONObject json) throws JSONException, ParseException {
com.juick.Message jmsg = new com.juick.Message();
jmsg.setMID(json.getInt("mid"));
if (json.has("rid")) {
@@ -59,12 +64,7 @@ public class MessageSerializer extends JSONSerializer {
jmsg.setText(json.getString("body").replace(""", "\""));
jmsg.setUser(userSerializer.deserialize(json.getJSONObject("user")));
- try {
- DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- df.setTimeZone(TimeZone.getTimeZone("UTC"));
- jmsg.setDate(df.parse(json.getString("timestamp")));
- } catch (ParseException e) {
- }
+ jmsg.setDate(df.parse(json.getString("timestamp")));
if (json.has("tags")) {
JSONArray tags = json.getJSONArray("tags");
--
cgit v1.2.3
From 9dfad84fa487960fde4cc4b0ac6760c8dd5f4ac9 Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Sat, 16 Jan 2016 19:16:41 +0300
Subject: fix tests
---
src/test/java/com/juick/JsonTests.java | 2 ++
1 file changed, 2 insertions(+)
(limited to 'src')
diff --git a/src/test/java/com/juick/JsonTests.java b/src/test/java/com/juick/JsonTests.java
index 890360c1..ba01e80c 100644
--- a/src/test/java/com/juick/JsonTests.java
+++ b/src/test/java/com/juick/JsonTests.java
@@ -11,12 +11,14 @@ import com.juick.Message;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
+import java.util.TimeZone;
public class JsonTests {
@Test
public void DateTest() {
Message msg = new Message();
SimpleDateFormat df= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ df.setTimeZone(TimeZone.getTimeZone("UTC"));
try {
msg.setDate(df.parse("2015-01-01 05:02:10"));
MessageSerializer serializer = new MessageSerializer();
--
cgit v1.2.3
From fc46d9c1f8c9967f9c648f09a3714e8c3a4ed75a Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Fri, 8 Apr 2016 16:23:55 +0300
Subject: update api
---
src/main/java/com/juick/json/UserSerializer.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'src')
diff --git a/src/main/java/com/juick/json/UserSerializer.java b/src/main/java/com/juick/json/UserSerializer.java
index 4485812a..390f4bf6 100644
--- a/src/main/java/com/juick/json/UserSerializer.java
+++ b/src/main/java/com/juick/json/UserSerializer.java
@@ -55,8 +55,8 @@ public class UserSerializer extends JSONSerializer {
if (user.getJID() != null) {
json.put("jid", user.getJID());
}
- if (user.MessagesCount > 0) {
- json.put("MessagesCount", user.MessagesCount);
+ if (user.getUnreadCount() > 0) {
+ json.put("unreadCount", user.getUnreadCount());
}
} catch (JSONException e) {
}
--
cgit v1.2.3