Java tutorial
/* * Copyright (C) 2010-2013 The SINA WEIBO Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.phelps.liteweibo.model.weibo; import java.util.ArrayList; import org.json.JSONArray; import org.json.JSONObject; /** * ?? * * @author SINA * @date 2013-11-27 */ public class Group { public static final String GROUP_ID_ALL = "1"; /** ?ID **/ public String id; /** ?ID **/ public String idStr; /** ?? **/ public String name; /** ? **/ public String mode; /** ? **/ public int visible; /** **/ public int like_count; /** ? **/ public int member_count; /** ?? **/ public String description; /** Tag ? **/ public ArrayList<Tag> tags; /** ?? **/ public String profile_image_url; /** ? **/ public User user; /** **/ public String createAtTime; public static Group parse(JSONObject jsonObject) { if (null == jsonObject) { return null; } Group group = new Group(); group.user = User.parse(jsonObject.optJSONObject("user")); group.id = jsonObject.optString("id"); group.idStr = jsonObject.optString("idstr"); group.name = jsonObject.optString("name"); group.mode = jsonObject.optString("mode"); group.visible = jsonObject.optInt("visible"); group.like_count = jsonObject.optInt("like_count"); group.member_count = jsonObject.optInt("member_count"); group.description = jsonObject.optString("description"); group.profile_image_url = jsonObject.optString("profile_image_url"); group.createAtTime = jsonObject.optString("create_time", ""); JSONArray jsonArray = jsonObject.optJSONArray("tags"); if (jsonArray != null && jsonObject.length() > 0) { int length = jsonArray.length(); group.tags = new ArrayList<Tag>(length); for (int ix = 0; ix < length; ix++) { group.tags.add(Tag.parse(jsonArray.optJSONObject(ix))); } } return group; } }