|
@@ -8,6 +8,7 @@ import IRC.Server;
|
|
|
|
|
|
public class ISPdata {
|
|
public class ISPdata {
|
|
|
|
|
|
|
|
+ private String shortname;
|
|
private String website;
|
|
private String website;
|
|
private String description;
|
|
private String description;
|
|
private Server [] ircChan;
|
|
private Server [] ircChan;
|
|
@@ -17,13 +18,14 @@ public class ISPdata {
|
|
private String email;
|
|
private String email;
|
|
private String creationDate;
|
|
private String creationDate;
|
|
private String joinDate;
|
|
private String joinDate;
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
|
|
- public ISPdata(String website, String description, Server[] chatrooms, int progressStatus,
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public ISPdata(String shortName, String website, String description, Server[] chatrooms, int progressStatus,
|
|
int membersCount, int subscribersCount, String email, String creationDate, String joinDate) {
|
|
int membersCount, int subscribersCount, String email, String creationDate, String joinDate) {
|
|
super();
|
|
super();
|
|
|
|
+ this.shortname = shortName;
|
|
this.website = website;
|
|
this.website = website;
|
|
this.description = description;
|
|
this.description = description;
|
|
this.ircChan = chatrooms;
|
|
this.ircChan = chatrooms;
|
|
@@ -33,28 +35,67 @@ public class ISPdata {
|
|
this.email=email;
|
|
this.email=email;
|
|
this.creationDate = creationDate;
|
|
this.creationDate = creationDate;
|
|
this.joinDate = joinDate;
|
|
this.joinDate = joinDate;
|
|
|
|
+
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public ISPdata(JSONObject jo){
|
|
public ISPdata(JSONObject jo){
|
|
- this.website = jo.getString("website");
|
|
|
|
- JSONArray chatroomsJSON = jo.getJSONArray("chatrooms");
|
|
|
|
- Server [] chatrooms = new Server[chatroomsJSON.length()];
|
|
|
|
- for(int i = 0; i<chatroomsJSON.length(); ++i) {
|
|
|
|
- String servaddr = chatroomsJSON.getString(i);
|
|
|
|
- chatrooms[i] = new Server(servaddr);
|
|
|
|
-
|
|
|
|
|
|
+ this.shortname = getString(jo,"shortname");
|
|
|
|
+ this.website = getString(jo,"website","?");
|
|
|
|
+ Server [] chatrooms;
|
|
|
|
+ try {
|
|
|
|
+ JSONArray chatroomsJSON = jo.getJSONArray("chatrooms");
|
|
|
|
+ chatrooms = new Server[chatroomsJSON.length()];
|
|
|
|
+ for(int i = 0; i<chatroomsJSON.length(); ++i) {
|
|
|
|
+ String servaddr = chatroomsJSON.getString(i);
|
|
|
|
+ chatrooms[i] = new Server(servaddr);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }catch(JSONException jsonE) { // Si il n'y a pas de chatroom
|
|
|
|
+ chatrooms = new Server[0];
|
|
}
|
|
}
|
|
- this.progressStatus = jo.getInt("progressStatus");
|
|
|
|
- this.membersCount = jo.getInt("memberCount");
|
|
|
|
- this.subscribersCount = jo.getInt("subscriberCount");
|
|
|
|
|
|
+ this.progressStatus = getInt(jo,"progressStatus");
|
|
|
|
+ this.membersCount = getInt(jo,"memberCount",0);
|
|
|
|
+ this.subscribersCount = getInt(jo,"subscriberCount",0);
|
|
try {
|
|
try {
|
|
- this.joinDate = jo.getString("ffdnMemberSince");
|
|
|
|
|
|
+ this.joinDate = getString(jo,"ffdnMemberSince","?");
|
|
}catch (JSONException joe) {
|
|
}catch (JSONException joe) {
|
|
this.joinDate = "?";
|
|
this.joinDate = "?";
|
|
}
|
|
}
|
|
- this.creationDate = jo.getString("creationDate");
|
|
|
|
|
|
+ this.creationDate = getString(jo,"creationDate","?");
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private int getInt(JSONObject jo, String key, int DEFAULT) {
|
|
|
|
+ int res;
|
|
|
|
+ try {
|
|
|
|
+ res = jo.getInt(key);
|
|
|
|
+ }catch(JSONException jsone) {
|
|
|
|
+ res = DEFAULT;
|
|
|
|
+ }
|
|
|
|
+ return res;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private int getInt(JSONObject jo, String key) {
|
|
|
|
+ return getInt(jo,key,-1);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private String getString (JSONObject jo, String key, String DEFAULT) {
|
|
|
|
+ String res;
|
|
|
|
+ try {
|
|
|
|
+ res = jo.getString(key);
|
|
|
|
+ }catch(JSONException jsoe) {
|
|
|
|
+ res = DEFAULT;
|
|
|
|
+ }
|
|
|
|
+ return res;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private String getString (JSONObject jo, String key) {
|
|
|
|
+ return getString(jo, key, null);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
public String getWebsite() {
|
|
public String getWebsite() {
|
|
return website;
|
|
return website;
|
|
@@ -65,7 +106,7 @@ public class ISPdata {
|
|
return description;
|
|
return description;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
public Server[] getIrcChan() {
|
|
public Server[] getIrcChan() {
|
|
@@ -96,6 +137,15 @@ public class ISPdata {
|
|
public String getJoinDate() {
|
|
public String getJoinDate() {
|
|
return joinDate;
|
|
return joinDate;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public boolean hasShortName() {
|
|
|
|
+ return !(shortname==null || shortname.equals(""));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public String getShortname() {
|
|
|
|
+ return shortname;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|