Skip to content

Commit d1cac03

Browse files
committed
优化注释
1 parent 937d74e commit d1cac03

13 files changed

Lines changed: 66 additions & 55 deletions

File tree

APIJSON(Android)/APIJSON(ADT)/res/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
<string name="demo_single">{\n&#160;&#160;&#160;\"User\":{\n&#160;&#160;&#160;&#160;&#160;&#160;\"id\":38710\n&#160;&#160;&#160;}\n}</string>
1010
<string name="demo_rely">{\n&#160;&#160;&#160;\"User\":{\n&#160;&#160;&#160;&#160;&#160;&#160;\"id\":70793\n&#160;&#160;&#160;},\n&#160;&#160;&#160;\"Work\":{\n&#160;&#160;&#160;&#160;&#160;&#160;\"userId\":\"User/id\"\n&#160;&#160;&#160;}\n}</string>
1111
<string name="demo_array">{\n&#160;&#160;&#160;\"User[]\":{\n&#160;&#160;&#160;&#160;&#160;&#160;\"count\":10,\n&#160;&#160;&#160;&#160;&#160;&#160;\"User\":{\n&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;\"sex\":0\n&#160;&#160;&#160;&#160;&#160;&#160;}\n&#160;&#160;&#160;}\n}</string>
12-
<string name="demo_complex">{\n&#160;&#160;&#160;\"[]\":{\n&#160;&#160;&#160;&#160;&#160;&#160;\"count\":5,\n&#160;&#160;&#160;&#160;&#160;&#160;\"User\":{\n&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;\"sex\":0\n&#160;&#160;&#160;&#160;&#160;&#160;},\n&#160;&#160;&#160;&#160;&#160;&#160;\"Work\":{\n&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;\"userId\":\"/User/id\"\n&#160;&#160;&#160;&#160;&#160;&#160;},\n&#160;&#160;&#160;&#160;&#160;&#160;\"Comment[]\":{\n&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;\"count\":3,\n&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;\"Comment\":{\n&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;\"workId\":\"[]/Work/id\"\n&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}\n&#160;&#160;&#160;&#160;&#160;&#160;}\n&#160;&#160;&#160;}\n}</string>
12+
<string name="demo_complex">{\n&#160;&#160;&#160;\"[]\":{\n&#160;&#160;&#160;&#160;&#160;&#160;\"count\":2,\n&#160;&#160;&#160;&#160;&#160;&#160;\"User\":{\n&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;\"sex\":0\n&#160;&#160;&#160;&#160;&#160;&#160;},\n&#160;&#160;&#160;&#160;&#160;&#160;\"Work\":{\n&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;\"userId\":\"/User/id\"\n&#160;&#160;&#160;&#160;&#160;&#160;},\n&#160;&#160;&#160;&#160;&#160;&#160;\"Comment[]\":{\n&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;\"count\":3,\n&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;\"Comment\":{\n&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;\"workId\":\"[]/Work/id\"\n&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}\n&#160;&#160;&#160;&#160;&#160;&#160;}\n&#160;&#160;&#160;}\n}</string>
1313

1414
</resources>

APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/JSONRequest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616

1717
import zuo.biao.apijson.StringUtil;
1818

19-
20-
/**auto formatted request JSONObject
19+
/**encapsulator for request JSONObject
2120
* @author Lemon
21+
* @see #toArray
22+
* @see RequestUtil
2223
* @use JSONRequest request = new JSONRequest(...);
2324
* <br> request.put(...);//not a must
24-
* <br> request.toArray(...);//not a must,you can use new JSONRequest(...).put("[]", request); instead
25-
* @see #toArray
25+
* <br> request.toArray(...);//not a must
2626
*/
2727
public class JSONRequest extends JSONObject {
2828

APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/JSONResponse.java

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,19 @@
1919

2020
import zuo.biao.apijson.JSON;
2121
import zuo.biao.apijson.StringUtil;
22+
import zuo.biao.apijson.client.ui.QueryActivity;
2223

2324
import com.alibaba.fastjson.JSONArray;
2425

25-
/**
26-
* TODO 格式化json,去除标记array内object位置的数字,转为[]形式,比如
27-
* "Comment[]":{"0":{"Comment":{...}}, ...}
28-
* 转为
29-
* "Comment[]":[{...}, ...]
26+
/**parser for response JSON String
27+
* @author Lemon
28+
* @see #getList
29+
* @see #getJSONArray
30+
* @see QueryActivity#onHttpResponse
31+
* @use JSONResponse response = new JSONResponse(...);
32+
* <br> JSONArray array = JSONResponse.getJSONArray(response.getJSONObject("[]"));//not a must
33+
* <br> User user = JSONResponse.getObject(response, User.class);//not a must
34+
* <br> List<Comment> list = JSONResponse.getList(response.getJSONObject("Comment[]"), Comment.class);//not a must
3035
*/
3136
public class JSONResponse extends JSONObject {
3237
private static final long serialVersionUID = -6707531287941223427L;
@@ -51,6 +56,13 @@ public Object get(String key) {
5156

5257

5358

59+
/**
60+
* @param clazz
61+
* @return
62+
*/
63+
public <T> T getObject(Class<T> clazz) {
64+
return getObject(this, clazz);
65+
}
5466
/**
5567
* @param object
5668
* @param clazz
@@ -59,16 +71,16 @@ public Object get(String key) {
5971
public static <T> T getObject(com.alibaba.fastjson.JSONObject object, Class<T> clazz) {
6072
return JSON.parseObject(JSON.toJSONString(clazz == null ? object : object.getJSONObject(clazz.getSimpleName())), clazz);
6173
}
62-
// /**
63-
// * @param json
64-
// * @param clazz
65-
// * @return
66-
// */
67-
// public static <T> T getObject(String json, Class<T> clazz) {
68-
// return getObject(JSON.parseObject(json, clazz), clazz);
69-
// }
70-
71-
74+
// /**
75+
// * @param json
76+
// * @param clazz
77+
// * @return
78+
// */
79+
// public static <T> T getObject(String json, Class<T> clazz) {
80+
// return getObject(JSON.parseObject(json, clazz), clazz);
81+
// }
82+
83+
7284
/**
7385
* arrayObject = this
7486
* @param clazz

APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/RequestUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import zuo.biao.apijson.client.model.User;
1919
import zuo.biao.apijson.client.model.Work;
2020

21-
/**
21+
/**create request JSONObjects
2222
* @author Lemon
2323
*/
2424
public class RequestUtil {
@@ -47,7 +47,7 @@ public static JSONObject newComplexRequest() {
4747
request.add(new JSONRequest(Comment.class.getSimpleName(), new JSONRequest("workId", "[]/Work/id")).
4848
toArray(3, 0, Comment.class.getSimpleName()));
4949

50-
return request.toArray(10, 1);
50+
return request.toArray(2, 1);
5151
}
5252

5353
}

APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/RequestUtil2.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import zuo.biao.apijson.client.model.User;
2525
import zuo.biao.apijson.client.model.Work;
2626

27-
/**
27+
/**RequestUtil is suggested
2828
* @author Lemon
2929
*/
3030
public class RequestUtil2 {

APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/model/BaseModel.java

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616

1717
import java.io.Serializable;
1818

19-
/**基础Model
20-
* *isCorrect可以用于BaseModel子类的数据校验
21-
* *implements Serializable 是为了网络传输字节流转换
19+
/**base model for reduce model codes
2220
* @author Lemon
2321
* @use extends BaseModel
2422
*/
@@ -34,18 +32,4 @@ public void setId(Long id) {
3432
this.id = id;
3533
}
3634

37-
// 导致JSON.toJSONString写入correct字段
38-
// /**数据正确性校验
39-
// * @param data
40-
// * @return
41-
// */
42-
// public static boolean isCorrect(BaseModel data) {
43-
// return data != null && data.isCorrect();
44-
// }
45-
//
46-
// /**数据正确性校验
47-
// * @return
48-
// */
49-
// public abstract boolean isCorrect();
50-
5135
}

APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/model/Work.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
package zuo.biao.apijson.client.model;
1616

17-
/**作品类,名字对应服务器数据库的table_name,变量名及其类型和table里的column一一对应
17+
/**作品类
1818
* @author Lemon
1919
*/
2020
public class Work extends BaseModel {

APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/model/package-info.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* the names of classes equal the names of tables in Server database one by one, so do the variables and columns
33
* (name) : model <=> table
44
* (name, type) : variable <=> column
5-
* @warn don't use any base types like int or char in models, use Integer and String instead
5+
* @warn don't use any base type like int or char in models, use Integer and String instead
66
*/
77
/**
88
* @author Lemon

APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/ui/QueryActivity.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
import com.alibaba.fastjson.JSONArray;
4848

49-
/**activity for request a query in Server
49+
/**activity for requesting a query in Server
5050
* @author Lemon
5151
*/
5252
public class QueryActivity extends Activity implements OnHttpResponseListener {
@@ -103,7 +103,7 @@ protected void onCreate(Bundle savedInstanceState) {
103103
etQueryUri = (EditText) findViewById(R.id.etQueryUri);
104104

105105
etQueryUri.setText(StringUtil.getString(StringUtil.isNotEmpty(url, true)
106-
? url : "http://192.168.1.104:8080/get/"));//TODO my computer ipv4 address,you need to change it
106+
? url : "http://192.168.1.104:8080/get/"));//TODO my computer ipv4 address,edit it to an available one
107107

108108

109109
query();
@@ -151,9 +151,11 @@ public void setRequest() {
151151
request = JSON.toJSONString(RequestUtil.newComplexRequest());
152152
break;
153153
}
154-
System.out.println("request = " + request);
154+
Log.d(TAG, "setRequest url = " + url + ";\n request = " + request);
155155
}
156156

157+
/**request a query from server,and the result will be received by onHttpResponse method
158+
*/
157159
private void query() {
158160
setRequest();
159161

@@ -165,8 +167,7 @@ private void query() {
165167
}
166168

167169

168-
169-
170+
170171
@Override
171172
public void onHttpResponse(int requestCode, final String resultJson, final Exception e) {
172173
Log.d(TAG, "onHttpResponse resultJson = " + resultJson);
@@ -222,7 +223,7 @@ private <T> void logList(List<T> list) {
222223

223224

224225

225-
/**打开网站
226+
/**open request URL String with a browser
226227
*/
227228
public void openWebSite() {
228229
setRequest();

APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/ui/SelectActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import android.view.View;
2323
import android.widget.Toast;
2424

25-
/**activity for select a request json
25+
/**activity for selecting a request
2626
* @author Lemon
2727
*/
2828
public class SelectActivity extends Activity {

0 commit comments

Comments
 (0)