| 1 |
package net.oni2.moddepot.model; |
| 2 |
|
| 3 |
import net.oni2.moddepot.JSONHelpers; |
| 4 |
|
| 5 |
import org.json.JSONException; |
| 6 |
import org.json.JSONObject; |
| 7 |
|
| 8 |
/** |
| 9 |
* @author Christian Illy |
| 10 |
*/ |
| 11 |
public class Node { |
| 12 |
private int uid; // User ID of editor |
| 13 |
private int nid; // Node ID |
| 14 |
|
| 15 |
private NodeField_Body body; |
| 16 |
|
| 17 |
private String data; // ??? |
| 18 |
private int last_comment_uid; // User ID of author of last comment |
| 19 |
private String last_comment_name; // Name of author of last comment |
| 20 |
private long last_comment_timestamp; // Timestamp of post time of last |
| 21 |
// comment |
| 22 |
private int comment_count; // Number of comments |
| 23 |
private String type; // Type of node ("story", "page", "mod" ...) |
| 24 |
private long changed; // Timestamp of last change |
| 25 |
private String title; // Title of node |
| 26 |
private long created; // Timestamp of node creation |
| 27 |
private String name; // Name of user who created the node |
| 28 |
private String path; // URI of node |
| 29 |
private int revision_uid; // User ID of author of last revision |
| 30 |
private int tnid; // ??? |
| 31 |
private int vid; // Revision VID of latest revision |
| 32 |
private int status; // ??? perhaps published etc? |
| 33 |
private String log; // ??? |
| 34 |
private int cid; // ??? |
| 35 |
private int picture; // ??? |
| 36 |
private int sticky; // Is sticky on news overview? |
| 37 |
private int promote; // (???) Is promoted? |
| 38 |
private long revision_timestamp; // Timestamp of last revision |
| 39 |
private int translate; // ??? |
| 40 |
private String language; // Languagecode of content |
| 41 |
private String comment; // ??? |
| 42 |
|
| 43 |
/** |
| 44 |
* @param json |
| 45 |
* JSON object of Node to parse |
| 46 |
* @throws JSONException |
| 47 |
* On key not found / wrong type |
| 48 |
*/ |
| 49 |
public Node(JSONObject json) throws JSONException { |
| 50 |
uid = json.getInt("uid"); |
| 51 |
nid = json.getInt("nid"); |
| 52 |
|
| 53 |
Object bodyObj = json.get("body"); |
| 54 |
if (bodyObj instanceof JSONObject) { |
| 55 |
JSONObject jBody = ((JSONObject) bodyObj).getJSONArray("und").getJSONObject(0); |
| 56 |
body = new NodeField_Body(jBody); |
| 57 |
} |
| 58 |
data = JSONHelpers.getStringOrNull(json, "data"); |
| 59 |
last_comment_uid = json.getInt("last_comment_uid"); |
| 60 |
last_comment_name = JSONHelpers.getStringOrNull(json, |
| 61 |
"last_comment_name"); |
| 62 |
last_comment_timestamp = json.getLong("last_comment_timestamp"); |
| 63 |
comment_count = json.getInt("comment_count"); |
| 64 |
type = JSONHelpers.getStringOrNull(json, "type"); |
| 65 |
changed = json.getLong("changed"); |
| 66 |
title = JSONHelpers.getStringOrNull(json, "title"); |
| 67 |
created = json.getLong("created"); |
| 68 |
name = JSONHelpers.getStringOrNull(json, "name"); |
| 69 |
path = JSONHelpers.getStringOrNull(json, "path"); |
| 70 |
revision_uid = json.getInt("revision_uid"); |
| 71 |
tnid = json.getInt("tnid"); |
| 72 |
vid = json.getInt("vid"); |
| 73 |
status = json.getInt("status"); |
| 74 |
log = JSONHelpers.getStringOrNull(json, "log"); |
| 75 |
cid = json.getInt("cid"); |
| 76 |
picture = json.getInt("picture"); |
| 77 |
sticky = json.getInt("sticky"); |
| 78 |
promote = json.getInt("promote"); |
| 79 |
revision_timestamp = json.getLong("revision_timestamp"); |
| 80 |
translate = json.getInt("translate"); |
| 81 |
language = JSONHelpers.getStringOrNull(json, "language"); |
| 82 |
comment = JSONHelpers.getStringOrNull(json, "comment"); |
| 83 |
} |
| 84 |
|
| 85 |
/** |
| 86 |
* @return the uid |
| 87 |
*/ |
| 88 |
public int getUid() { |
| 89 |
return uid; |
| 90 |
} |
| 91 |
|
| 92 |
/** |
| 93 |
* @return the nid |
| 94 |
*/ |
| 95 |
public int getNid() { |
| 96 |
return nid; |
| 97 |
} |
| 98 |
|
| 99 |
/** |
| 100 |
* @return the body |
| 101 |
*/ |
| 102 |
public NodeField_Body getBody() { |
| 103 |
return body; |
| 104 |
} |
| 105 |
|
| 106 |
/** |
| 107 |
* @return the data |
| 108 |
*/ |
| 109 |
public String getData() { |
| 110 |
return data; |
| 111 |
} |
| 112 |
|
| 113 |
/** |
| 114 |
* @return the last_comment_uid |
| 115 |
*/ |
| 116 |
public int getLast_comment_uid() { |
| 117 |
return last_comment_uid; |
| 118 |
} |
| 119 |
|
| 120 |
/** |
| 121 |
* @return the last_comment_name |
| 122 |
*/ |
| 123 |
public String getLast_comment_name() { |
| 124 |
return last_comment_name; |
| 125 |
} |
| 126 |
|
| 127 |
/** |
| 128 |
* @return the last_comment_timestamp |
| 129 |
*/ |
| 130 |
public long getLast_comment_timestamp() { |
| 131 |
return last_comment_timestamp; |
| 132 |
} |
| 133 |
|
| 134 |
/** |
| 135 |
* @return the comment_count |
| 136 |
*/ |
| 137 |
public int getComment_count() { |
| 138 |
return comment_count; |
| 139 |
} |
| 140 |
|
| 141 |
/** |
| 142 |
* @return the type |
| 143 |
*/ |
| 144 |
public String getType() { |
| 145 |
return type; |
| 146 |
} |
| 147 |
|
| 148 |
/** |
| 149 |
* @return the changed |
| 150 |
*/ |
| 151 |
public long getChanged() { |
| 152 |
return changed; |
| 153 |
} |
| 154 |
|
| 155 |
/** |
| 156 |
* @return the title |
| 157 |
*/ |
| 158 |
public String getTitle() { |
| 159 |
return title; |
| 160 |
} |
| 161 |
|
| 162 |
/** |
| 163 |
* @return the created |
| 164 |
*/ |
| 165 |
public long getCreated() { |
| 166 |
return created; |
| 167 |
} |
| 168 |
|
| 169 |
/** |
| 170 |
* @return the name |
| 171 |
*/ |
| 172 |
public String getName() { |
| 173 |
return name; |
| 174 |
} |
| 175 |
|
| 176 |
/** |
| 177 |
* @return the path |
| 178 |
*/ |
| 179 |
public String getPath() { |
| 180 |
return path; |
| 181 |
} |
| 182 |
|
| 183 |
/** |
| 184 |
* @return the revision_uid |
| 185 |
*/ |
| 186 |
public int getRevision_uid() { |
| 187 |
return revision_uid; |
| 188 |
} |
| 189 |
|
| 190 |
/** |
| 191 |
* @return the tnid |
| 192 |
*/ |
| 193 |
public int getTnid() { |
| 194 |
return tnid; |
| 195 |
} |
| 196 |
|
| 197 |
/** |
| 198 |
* @return the vid |
| 199 |
*/ |
| 200 |
public int getVid() { |
| 201 |
return vid; |
| 202 |
} |
| 203 |
|
| 204 |
/** |
| 205 |
* @return the status |
| 206 |
*/ |
| 207 |
public int getStatus() { |
| 208 |
return status; |
| 209 |
} |
| 210 |
|
| 211 |
/** |
| 212 |
* @return the log |
| 213 |
*/ |
| 214 |
public String getLog() { |
| 215 |
return log; |
| 216 |
} |
| 217 |
|
| 218 |
/** |
| 219 |
* @return the cid |
| 220 |
*/ |
| 221 |
public int getCid() { |
| 222 |
return cid; |
| 223 |
} |
| 224 |
|
| 225 |
/** |
| 226 |
* @return the picture |
| 227 |
*/ |
| 228 |
public int getPicture() { |
| 229 |
return picture; |
| 230 |
} |
| 231 |
|
| 232 |
/** |
| 233 |
* @return the sticky |
| 234 |
*/ |
| 235 |
public int getSticky() { |
| 236 |
return sticky; |
| 237 |
} |
| 238 |
|
| 239 |
/** |
| 240 |
* @return the promote |
| 241 |
*/ |
| 242 |
public int getPromote() { |
| 243 |
return promote; |
| 244 |
} |
| 245 |
|
| 246 |
/** |
| 247 |
* @return the revision_timestamp |
| 248 |
*/ |
| 249 |
public long getRevision_timestamp() { |
| 250 |
return revision_timestamp; |
| 251 |
} |
| 252 |
|
| 253 |
/** |
| 254 |
* @return the translate |
| 255 |
*/ |
| 256 |
public int getTranslate() { |
| 257 |
return translate; |
| 258 |
} |
| 259 |
|
| 260 |
/** |
| 261 |
* @return the language |
| 262 |
*/ |
| 263 |
public String getLanguage() { |
| 264 |
return language; |
| 265 |
} |
| 266 |
|
| 267 |
/** |
| 268 |
* @return the comment |
| 269 |
*/ |
| 270 |
public String getComment() { |
| 271 |
return comment; |
| 272 |
} |
| 273 |
|
| 274 |
} |