aboutsummaryrefslogtreecommitdiff
path: root/juick-core/src/main/java/com/juick/json
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-11-15 14:21:27 +0300
committerGravatar Vitaly Takmazov2016-11-15 14:21:27 +0300
commit51d9de02265d6cc9d6045d79497d2a987ae2f7f7 (patch)
treed7dd2e534452cab45b8ebdba1e52c498951c5035 /juick-core/src/main/java/com/juick/json
parent32a6feb195171e06d60117ad758cc8beb50e5ca3 (diff)
core classes are now serializeable with JAXB (to use as babbler extension)
Diffstat (limited to 'juick-core/src/main/java/com/juick/json')
-rw-r--r--juick-core/src/main/java/com/juick/json/MessageSerializer.java26
-rw-r--r--juick-core/src/main/java/com/juick/json/UserSerializer.java12
2 files changed, 19 insertions, 19 deletions
diff --git a/juick-core/src/main/java/com/juick/json/MessageSerializer.java b/juick-core/src/main/java/com/juick/json/MessageSerializer.java
index 3ef903f0..ebc3b0b0 100644
--- a/juick-core/src/main/java/com/juick/json/MessageSerializer.java
+++ b/juick-core/src/main/java/com/juick/json/MessageSerializer.java
@@ -51,12 +51,12 @@ public class MessageSerializer extends JSONSerializer<Message> {
@Override
public Message deserialize(JSONObject json) throws JSONException, ParseException {
com.juick.Message jmsg = new com.juick.Message();
- jmsg.setMID(json.getInt("mid"));
+ jmsg.setMid(json.getInt("mid"));
if (json.has("rid")) {
- jmsg.setRID(json.getInt("rid"));
+ jmsg.setRid(json.getInt("rid"));
}
if (json.has("replyto")) {
- jmsg.ReplyTo = json.getInt("replyto");
+ jmsg.setReplyto(json.getInt("replyto"));
}
jmsg.FriendsOnly = json.has("friendsonly");
@@ -70,7 +70,7 @@ public class MessageSerializer extends JSONSerializer<Message> {
if (json.has("tags")) {
JSONArray tags = json.getJSONArray("tags");
for (int n = 0; n < tags.length(); n++) {
- jmsg.Tags.add(new Tag(tags.getString(n).replace("&quot;", "\"")));
+ jmsg.getTags().add(new Tag(tags.getString(n).replace("&quot;", "\"")));
}
}
@@ -90,14 +90,14 @@ public class MessageSerializer extends JSONSerializer<Message> {
JSONObject json = new JSONObject();
try {
- if (msg.getMID() > 0) {
- json.put("mid", msg.getMID());
+ if (msg.getMid() > 0) {
+ json.put("mid", msg.getMid());
}
- if (msg.getRID() > 0) {
- json.put("rid", msg.getRID());
+ if (msg.getRid() > 0) {
+ json.put("rid", msg.getRid());
}
- if (msg.ReplyTo > 0) {
- json.put("replyto", msg.ReplyTo);
+ if (msg.getReplyto() > 0) {
+ json.put("replyto", msg.getReplyto());
}
if (msg.FriendsOnly) {
json.put("friendsonly", 1);
@@ -114,8 +114,8 @@ public class MessageSerializer extends JSONSerializer<Message> {
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.stream().map(Tag::getName).collect(Collectors.toList())));
+ if (msg.getTags() != null && msg.getTags().size() > 0) {
+ json.put("tags", new JSONArray(msg.getTags().stream().map(Tag::getName).collect(Collectors.toList())));
}
if (msg.Replies > 0) {
json.put("replies", msg.Replies);
@@ -124,7 +124,7 @@ public class MessageSerializer extends JSONSerializer<Message> {
json.put("place", placeSerializer.serialize(msg.Place));
}
if (msg.AttachmentType != null) {
- String fname = msg.getMID() + (msg.getRID() > 0 ? "-" + msg.getRID() : "") + "." + msg.AttachmentType;
+ String fname = msg.getMid() + (msg.getRid() > 0 ? "-" + msg.getRid() : "") + "." + msg.AttachmentType;
JSONObject photo = new JSONObject();
String protocol = getUriScheme() == URIScheme.Plain ? "http:" : "https:";
photo.put("thumbnail", protocol + "//i.juick.com/ps/" + fname);
diff --git a/juick-core/src/main/java/com/juick/json/UserSerializer.java b/juick-core/src/main/java/com/juick/json/UserSerializer.java
index 390f4bf6..08d21d39 100644
--- a/juick-core/src/main/java/com/juick/json/UserSerializer.java
+++ b/juick-core/src/main/java/com/juick/json/UserSerializer.java
@@ -30,8 +30,8 @@ public class UserSerializer extends JSONSerializer<User> {
@Override
public User deserialize(JSONObject json) throws JSONException {
User juser = new User();
- juser.setUID(json.getInt("uid"));
- juser.setUName(json.getString("uname"));
+ juser.setUid(json.getInt("uid"));
+ juser.setName(json.getString("uname"));
if (json.has("fullname")) {
juser.setFullName(json.getString("fullname"));
}
@@ -43,11 +43,11 @@ public class UserSerializer extends JSONSerializer<User> {
JSONObject json = new JSONObject();
try {
- if (user.getUID() > 0) {
- json.put("uid", user.getUID());
+ if (user.getUid() > 0) {
+ json.put("uid", user.getUid());
}
- if (user.getUName() != null) {
- json.put("uname", user.getUName());
+ if (user.getName() != null) {
+ json.put("uname", user.getName());
}
if (user.getFullName() != null) {
json.put("fullname", user.getFullName());