diff --git a/.gitignore b/.gitignore
index f5eca4efe..5fef19ddc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,12 +1,13 @@
.DS_Store
-APIJSON(Android)/APIJSON(ADT)/APIJSONApp/APIJSONApp/bin
-APIJSON(Android)/APIJSON(ADT)/APIJSONApp/APIJSONApp/gen
-APIJSON(Android)/APIJSON(ADT)/APIJSONApp/QRCodeLibrary/bin
-APIJSON(Android)/APIJSON(ADT)/APIJSONApp/QRCodeLibrary/gen
-APIJSON(Android)/APIJSON(ADT)/APIJSONApp/ZBLibrary/bin
-APIJSON(Android)/APIJSON(ADT)/APIJSONApp/ZBLibrary/gen
-APIJSON(Android)/APIJSON(ADT)/APIJSONLibrary/bin
-APIJSON(Android)/APIJSON(ADT)/APIJSONLibrary/gen
-APIJSON(Android)/APIJSON(ADT)/APIJSONTest/bin
-APIJSON(Android)/APIJSON(ADT)/APIJSONTest/gen
-APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/.idea
+APIJSON-Android/APIJSON-ADT/APIJSONApp/APIJSONApp/bin
+APIJSON-Android/APIJSON-ADT/APIJSONApp/APIJSONApp/gen
+APIJSON-Android/APIJSON-ADT/APIJSONApp/QRCodeLibrary/bin
+APIJSON-Android/APIJSON-ADT/APIJSONApp/QRCodeLibrary/gen
+APIJSON-Android/APIJSON-ADT/APIJSONApp/ZBLibrary/bin
+APIJSON-Android/APIJSON-ADT/APIJSONApp/ZBLibrary/gen
+APIJSON-Android/APIJSON-ADT/APIJSONLibrary/bin
+APIJSON-Android/APIJSON-ADT/APIJSONLibrary/gen
+APIJSON-Android/APIJSON-ADT/APIJSONTest/bin
+APIJSON-Android/APIJSON-ADT/APIJSONTest/gen
+APIJSON-Android/APIJSON-AndroidStudio/APIJSONApp/.idea
+APIJSON-JavaScript/.idea
diff --git a/APIJSON(Android)/APIJSON(ADT)/APIJSONApp/APIJSONApp/src/apijson/demo/client/manager/DataManager.java b/APIJSON(Android)/APIJSON(ADT)/APIJSONApp/APIJSONApp/src/apijson/demo/client/manager/DataManager.java
deleted file mode 100755
index 06559dc1e..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/APIJSONApp/APIJSONApp/src/apijson/demo/client/manager/DataManager.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon)
-
-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 apijson.demo.client.manager;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-
-import apijson.demo.client.application.APIJSONApplication;
-import apijson.demo.client.model.User;
-import zuo.biao.library.util.JSON;
-import zuo.biao.library.util.Log;
-import zuo.biao.library.util.StringUtil;
-
-/**数据工具类
- * @author Lemon
- */
-public class DataManager {
- private final String TAG = "DataManager";
-
- private Context context;
- private DataManager(Context context) {
- this.context = context;
- }
-
- private static DataManager instance = new DataManager(APIJSONApplication.getInstance());
- public static DataManager getInstance() {
- return instance;
- }
-
- //用户 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
- private String PATH_USER = "PATH_USER";
-
- public final String KEY_USER = "KEY_USER";
- public final String KEY_USER_ID = "KEY_USER_ID";
- public final String KEY_USER_NAME = "KEY_USER_NAME";
- public final String KEY_USER_PHONE = "KEY_USER_PHONE";
-
- public final String KEY_CURRENT_USER_ID = "KEY_CURRENT_USER_ID";
- public final String KEY_LAST_USER_ID = "KEY_LAST_USER_ID";
-
-
- /**判断是否为当前用户
- * @param userId
- * @return
- */
- public boolean isCurrentUser(long userId) {
- return userId > 0 && userId == getCurrentUserId();
- }
-
- /**获取当前用户id
- * @return
- */
- public long getCurrentUserId() {
- User user = getCurrentUser();
- return user == null ? 0 : user.getId();
- }
-
- /**获取当前用户的手机号
- * @return
- */
- public String getCurrentUserPhone() {
- User user = getCurrentUser();
- return user == null ? "" : user.getPhone();
- }
- /**获取当前用户
- * @return
- */
- public User getCurrentUser() {
- SharedPreferences sdf = context.getSharedPreferences(PATH_USER, Context.MODE_PRIVATE);
- return sdf == null ? null : getUser(sdf.getLong(KEY_CURRENT_USER_ID, 0));
- }
-
-
- /**获取最后一次登录的用户的手机号
- * @return
- */
- public String getLastUserPhone() {
- User user = getLastUser();
- return user == null ? "" : user.getPhone();
- }
-
- /**获取最后一次登录的用户
- * @return
- */
- public User getLastUser() {
- SharedPreferences sdf = context.getSharedPreferences(PATH_USER, Context.MODE_PRIVATE);
- return sdf == null ? null : getUser(sdf.getLong(KEY_LAST_USER_ID, 0));
- }
-
- /**获取用户
- * @param userId
- * @return
- */
- public User getUser(long userId) {
- SharedPreferences sdf = context.getSharedPreferences(PATH_USER, Context.MODE_PRIVATE);
- if (sdf == null) {
- Log.e(TAG, "get sdf == null >> return;");
- return null;
- }
- Log.i(TAG, "getUser userId = " + userId);
- return JSON.parseObject(sdf.getString(StringUtil.getTrimedString(userId), null), User.class);
- }
-
-
- /**保存当前用户,只在登录或注销时调用
- * @param user user == null >> user = new User();
- */
- public void saveCurrentUser(User user) {
- SharedPreferences sdf = context.getSharedPreferences(PATH_USER, Context.MODE_PRIVATE);
- if (sdf == null) {
- Log.e(TAG, "saveUser sdf == null >> return;");
- return;
- }
- if (user == null) {
- Log.w(TAG, "saveUser user == null >> user = new User();");
- user = new User();
- }
- SharedPreferences.Editor editor = sdf.edit();
- editor.remove(KEY_LAST_USER_ID).putLong(KEY_LAST_USER_ID, getCurrentUserId());
- editor.remove(KEY_CURRENT_USER_ID).putLong(KEY_CURRENT_USER_ID, user.getId());
- editor.commit();
-
- saveUser(sdf, user);
- }
-
- /**保存用户
- * @param user
- */
- public void saveUser(User user) {
- saveUser(context.getSharedPreferences(PATH_USER, Context.MODE_PRIVATE), user);
- }
- /**保存用户
- * @param sdf
- * @param user
- */
- public void saveUser(SharedPreferences sdf, User user) {
- if (sdf == null || user == null) {
- Log.e(TAG, "saveUser sdf == null || user == null >> return;");
- return;
- }
- String key = StringUtil.getTrimedString(user.getId());
- Log.i(TAG, "saveUser key = user.getId() = " + user.getId());
- sdf.edit().remove(key).putString(key, JSON.toJSONString(user)).commit();
- }
-
- /**删除用户
- * @param sdf
- * @param userId
- */
- public void removeUser(SharedPreferences sdf, long userId) {
- if (sdf == null) {
- Log.e(TAG, "removeUser sdf == null >> return;");
- return;
- }
- sdf.edit().remove(StringUtil.getTrimedString(userId)).commit();
- }
-
- /**设置当前用户手机号
- * @param phone
- */
- public void setCurrentUserPhone(String phone) {
- User user = getCurrentUser();
- if (user == null) {
- user = new User();
- }
- user.setPhone(phone);
- saveUser(user);
- }
-
- /**设置当前用户姓名
- * @param name
- */
- public void setCurrentUserName(String name) {
- User user = getCurrentUser();
- if (user == null) {
- user = new User();
- }
- user.setName(name);
- saveUser(user);
- }
-
- //用户 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
-
-
-}
diff --git a/APIJSON(Android)/APIJSON(ADT)/APIJSONApp/APIJSONApp/src/apijson/demo/client/model/Verify.java b/APIJSON(Android)/APIJSON(ADT)/APIJSONApp/APIJSONApp/src/apijson/demo/client/model/Verify.java
deleted file mode 100644
index 6dc5924b2..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/APIJSONApp/APIJSONApp/src/apijson/demo/client/model/Verify.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon)
-
-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 apijson.demo.client.model;
-
-import zuo.biao.library.util.StringUtil;
-
-
-/**验证码类
- * @author Lemon
- */
-public class Verify extends apijson.demo.server.model.Verify {
- private static final long serialVersionUID = 4298571449155754300L;
-
- public Verify() {
- super();
- }
- public Verify(long phone) {
- super(phone);
- }
- public Verify(String verify) {
- this();
- setVerify(verify);
- }
-
- @Override
- public Long getId() {
- return value(super.getId());
- }
-
- /**服务器用id作为phone
- * @return
- */
- public String getPhone() {
- return "" + getId();
- }
- public Verify setPhone(String phone) {
- setId(Long.valueOf(0 + StringUtil.getNumber(phone)));
- return this;
- }
- public Verify setPhone(Long phone) {
- setId(Long.valueOf(0 + StringUtil.getNumber(phone)));
- return this;
- }
-
-}
diff --git a/APIJSON(Android)/APIJSON(ADT)/APIJSONApp/APIJSONApp/src/apijson/demo/server/model/UserPrivacy.java b/APIJSON(Android)/APIJSON(ADT)/APIJSONApp/APIJSONApp/src/apijson/demo/server/model/UserPrivacy.java
deleted file mode 100644
index a2bd27412..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/APIJSONApp/APIJSONApp/src/apijson/demo/server/model/UserPrivacy.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package apijson.demo.server.model;
-
-import static zuo.biao.apijson.RequestRole.ADMIN;
-import static zuo.biao.apijson.RequestRole.OWNER;
-import static zuo.biao.apijson.RequestRole.UNKNOWN;
-
-import zuo.biao.apijson.MethodAccess;
-
-/**会员隐私信息表
- * @author Lemon
- */
-@MethodAccess(
- GET = {},
- HEAD = {},
- POST_GET = {OWNER, ADMIN},
- POST_HEAD = {OWNER, ADMIN},
- POST = {UNKNOWN, ADMIN},
- DELETE = {ADMIN}
- )
-public class UserPrivacy extends BaseModel {
- private static final long serialVersionUID = 1L;
-
- private String phone; //手机
- private String password; //登录密码,隐藏字段
- private String payPassword; //支付密码,隐藏字段
- private Double balance; //余额
-
- public UserPrivacy() {
- super();
- }
-
- public UserPrivacy(long id) {
- this();
- setId(id);
- }
-
- public UserPrivacy(Long id, String password) {
- this();
- setId(id);
- setPassword(password);
- }
-
-
-
- public String getPhone() {
- return phone;
- }
- public UserPrivacy setPhone(String phone) {
- this.phone = phone;
- return this;
- }
-
- /**get_password会转为password
- * @return
- */
- public String get__password() {
- return password;
- }
- public UserPrivacy setPassword(String password) {
- this.password = password;
- return this;
- }
-
- /**get_PayPassword会转为PayPassword
- * @return
- */
- public String get__payPassword() {
- return payPassword;
- }
- public UserPrivacy setPayPassword(String payPassword) {
- this.payPassword = payPassword;
- return this;
- }
-
- public Double getBalance() {
- return balance;
- }
- public UserPrivacy setBalance(Double balance) {
- this.balance = balance;
- return this;
- }
-
-}
diff --git a/APIJSON(Android)/APIJSON(ADT)/APIJSONApp/APIJSONApp/src/apijson/demo/server/model/Wallet.java b/APIJSON(Android)/APIJSON(ADT)/APIJSONApp/APIJSONApp/src/apijson/demo/server/model/Wallet.java
deleted file mode 100644
index c70aa7e37..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/APIJSONApp/APIJSONApp/src/apijson/demo/server/model/Wallet.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON)
-
-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 apijson.demo.server.model;
-
-import static zuo.biao.apijson.RequestRole.ADMIN;
-import static zuo.biao.apijson.RequestRole.OWNER;
-
-import java.math.BigDecimal;
-
-import zuo.biao.apijson.MethodAccess;
-
-/**钱包类,已用UserPrivacy替代
- * @author Lemon
- * @see
- *
POST_GET:
-{
- "Wallet":{
- "disallow":"!",
- "necessary":"id"
- }
-}
- *
- *
POST:post/wallet
-{
- "Wallet":{
- "disallow":"!",
- "necessary":"id"
- },
- "necessary":"payPassword"
-}
- *
- *
PUT:put/wallet
-{
- "Wallet":{
- "disallow":"!",
- "necessary":"id,balance+"
- },
- "necessary":"payPassword"
-}
- *
- *
DELETE:delete/wallet
-{
- "Wallet":{
- "disallow":"!",
- "necessary":"id"
- },
- "necessary":"payPassword"
-}
- *
- */
-@Deprecated
-@MethodAccess(
- GET = {},
- HEAD = {},
- POST_GET = {OWNER, ADMIN},
- POST_HEAD = {OWNER, ADMIN},
- POST = {ADMIN},
- DELETE = {ADMIN}
- )
-public class Wallet extends BaseModel {
- private static final long serialVersionUID = 1L;
-
- public BigDecimal balance;
-
- /**默认构造方法,JSON等解析时必须要有
- */
- public Wallet() {
- super();
- }
- public Wallet(long id) {
- this();
- setId(id);
- }
-
-
- public Wallet setUserId(long userId) {
- setId(userId);
- return this;
- }
-
- public BigDecimal getBalance() {
- return balance;
- }
- public Wallet setBalance(BigDecimal balance) {
- this.balance = balance;
- return this;
- }
-
-}
diff --git a/APIJSON(Android)/APIJSON(ADT)/APIJSONLibrary/src/zuo/biao/apijson/JSONObject.java b/APIJSON(Android)/APIJSON(ADT)/APIJSONLibrary/src/zuo/biao/apijson/JSONObject.java
deleted file mode 100644
index 4d3581764..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/APIJSONLibrary/src/zuo/biao/apijson/JSONObject.java
+++ /dev/null
@@ -1,453 +0,0 @@
-/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON)
-
-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 zuo.biao.apijson;
-
-import static zuo.biao.apijson.StringUtil.UTF_8;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import java.net.URLEncoder;
-import java.util.Set;
-
-/**use this class instead of com.alibaba.fastjson.JSONObject, not encode in default cases
- * @author Lemon
- */
-public class JSONObject extends com.alibaba.fastjson.JSONObject {
- private static final long serialVersionUID = 1L;
-
- /**ordered
- */
- public JSONObject() {
- super(true);
- }
- /**transfer Object to JSONObject
- * encode = false;
- * @param object
- * @see {@link #JSONObject(Object, boolean)}
- */
- public JSONObject(Object object) {
- this(object, false);
- }
- /**transfer Object to JSONObject
- * @param object
- * @param encode
- * @see {@link #JSONObject(String, boolean)}
- */
- public JSONObject(Object object, boolean encode) {
- this(toJSONString(object), encode);
- }
- /**parse JSONObject with JSON String
- * encode = false;
- * @param json
- * @see {@link #JSONObject(String, boolean)}
- */
- public JSONObject(String json) {
- this(json, false);
- }
- /**parse JSONObject with JSON String
- * @param json
- * @param encode
- * @see {@link #JSONObject(com.alibaba.fastjson.JSONObject, boolean)}
- */
- public JSONObject(String json, boolean encode) {
- this(parseObject(json), encode);
- }
- /**transfer com.alibaba.fastjson.JSONObject to JSONObject
- * encode = false;
- * @param object
- * @see {@link #JSONObject(com.alibaba.fastjson.JSONObject, boolean)}
- */
- public JSONObject(com.alibaba.fastjson.JSONObject object) {
- this(object, false);
- }
- /**transfer com.alibaba.fastjson.JSONObject to JSONObject
- * @param object
- * @param encode
- * @see {@link #add(com.alibaba.fastjson.JSONObject, boolean)}
- */
- public JSONObject(com.alibaba.fastjson.JSONObject object, boolean encode) {
- this();
- add(object, encode);
- }
-
-
-
-
- /**put key-value in object into this
- * encode = false;
- * @param object
- * @return {@link #add(com.alibaba.fastjson.JSONObject, boolean)}
- */
- public JSONObject add(com.alibaba.fastjson.JSONObject object) {
- return add(object, false);
- }
- /**put key-value in object into this
- * @param object
- * @param encode
- * @return this
- */
- public JSONObject add(com.alibaba.fastjson.JSONObject object, boolean encode) {
- //TODO putAll(object);
-
- Set set = object == null ? null : object.keySet();
- if (set != null) {
- for (String key : set) {
- put(key, object.get(key), encode);
- }
- }
- return this;
- }
-
-
-
- /**
- * @param key if decode && key instanceof String, key = URLDecoder.decode((String) key, UTF_8)
- * @param decode if decode && value instanceof String, value = URLDecoder.decode((String) value, UTF_8)
- * @return
- */
- public Object get(Object key, boolean decode) {
- if (decode) {
- if (key instanceof String) {
- if (((String) key).endsWith("+") || ((String) key).endsWith("-")) {
- try {//多层encode导致内部Comment[]传到服务端decode后最终变为Comment%5B%5D
- key = URLDecoder.decode((String) key, UTF_8);
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- return null;
- }
- }
- }
- Object value = super.get(key);
- if (value instanceof String) {
- try {
- value = URLDecoder.decode((String) value, UTF_8);
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- }
- return value;
- }
- return super.get(key);
- }
-
- /**
- * encode = false
- * @param value must be annotated by {@link APIJSONRequest}
- * @return {@link #put(String, boolean)}
- */
- public Object put(Object value) {
- return put(value, false);
- }
- /**
- * key = value.getClass().getSimpleName()
- * @param value must be annotated by {@link APIJSONRequest}
- * @param encode
- * @return {@link #put(String, Object, boolean)}
- */
- public Object put(Object value, boolean encode) {
- return put(null, value, encode);
- }
- /**
- * @param key if StringUtil.isNotEmpty(key, true) == false,
- *
key = value == null ? null : value.getClass().getSimpleName();
- *
>> if decode && key instanceof String, key = URLDecoder.decode((String) key, UTF_8)
- * @param value URLEncoder.encode((String) value, UTF_8);
- * @param encode if value instanceof String, value = URLEncoder.encode((String) value, UTF_8);
- * @return
- */
- public Object put(String key, Object value, boolean encode) {
- if (StringUtil.isNotEmpty(key, true) == false) {
- Class> clazz = value == null ? null : value.getClass();
- if (clazz == null || clazz.getAnnotation(MethodAccess.class) == null) {
- throw new IllegalArgumentException("put StringUtil.isNotEmpty(key, true) == false" +
- " && clazz == null || clazz.getAnnotation(MethodAccess.class) == null" +
- " \n key为空时仅支持 类型被@MethodAccess注解 的value !!!" +
- " \n 如果一定要这么用,请对 " + clazz.getName() + " 注解!" +
- " \n 如果是类似 key[]:{} 结构的请求,建议add(...)方法!");
- }
- key = value.getClass().getSimpleName();
- }
- if (encode) {
- if (key.endsWith("+") || key.endsWith("-")) {
- try {//多层encode导致内部Comment[]传到服务端decode后最终变为Comment%5B%5D
- key = URLEncoder.encode(key, UTF_8);
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- }
- if (value instanceof String) {//只在value instanceof String时encode key?{@link #get(Object, boolean)}内做不到
- try {
- value = URLEncoder.encode((String) value, UTF_8);
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- }
- }
- return super.put(key, value);
- }
-
-
-
- //judge <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- public static final String KEY_ARRAY = "[]";
-
- /**判断是否为Array的key
- * @param key
- * @return
- */
- public static boolean isArrayKey(String key) {
- return key != null && key.endsWith(KEY_ARRAY);
- }
- /**判断是否为对应Table的key
- * @param key
- * @return
- */
- public static boolean isTableKey(String key) {
- return StringUtil.isBigWord(key);
- }
- //judge >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
- //JSONObject内关键词 key <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
- //@key关键字都放这个类 <<<<<<<<<<<<<<<<<<<<<<
- /**
- * 角色,拥有对某些数据的某些操作的权限
- */
- public static final String KEY_ROLE = "@role";
- /**
- * 数据库,Table在非默认schema内时需要声明
- */
- public static final String KEY_SCHEMA = "@schema";
- /**
- * 查询的Table字段或SQL函数
- */
- public static final String KEY_COLUMN = "@column";
- /**
- * 分组方式
- */
- public static final String KEY_GROUP = "@group";
- /**
- * 聚合函数条件,一般和@group一起用
- */
- public static final String KEY_HAVING = "@having";
- /**
- * 排序方式
- */
- public static final String KEY_ORDER = "@order";
- //@key关键字都放这个类 >>>>>>>>>>>>>>>>>>>>>>
-
-
- /**set role of request sender
- * @param role
- * @return this
- */
- public JSONObject setRole(String role) {
- put(KEY_ROLE, role);
- return this;
- }
-
- /**set schema where table was put
- * @param schema
- * @return this
- */
- public JSONObject setSchema(String schema) {
- put(KEY_SCHEMA, schema);
- return this;
- }
-
- /**set keys need to be returned
- * @param keys key0, key1, key2 ...
- * @return {@link #setColumn(String)}
- */
- public JSONObject setColumn(String... keys) {
- return setColumn(StringUtil.getString(keys, true));
- }
- /**set keys need to be returned
- * @param keys "key0,key1,key2..."
- * @return
- */
- public JSONObject setColumn(String keys) {
- put(KEY_COLUMN, keys);
- return this;
- }
-
- /**set keys for group by
- * @param keys key0, key1, key2 ...
- * @return {@link #setGroup(String)}
- */
- public JSONObject setGroup(String... keys) {
- return setGroup(StringUtil.getString(keys, true));
- }
- /**set keys for group by
- * @param keys "key0,key1,key2..."
- * @return
- */
- public JSONObject setGroup(String keys) {
- put(KEY_GROUP, keys);
- return this;
- }
-
- /**set keys for having
- * @param keys count(key0) > 1, sum(key1) <= 5, function2(key2) ? value2 ...
- * @return {@link #setHaving(String)}
- */
- public JSONObject setHaving(String... keys) {
- return setHaving(StringUtil.getString(keys, true));
- }
- /**set keys for having
- * @param keys "key0,key1,key2..."
- * @return
- */
- public JSONObject setHaving(String keys) {
- put(KEY_HAVING, keys);
- return this;
- }
-
- /**set keys for order by
- * @param keys key0, key1+, key2- ...
- * @return {@link #setOrder(String)}
- */
- public JSONObject setOrder(String... keys) {
- return setOrder(StringUtil.getString(keys, true));
- }
- /**set keys for order by
- * @param keys "key0,key1+,key2-..."
- * @return
- */
- public JSONObject setOrder(String keys) {
- put(KEY_ORDER, keys);
- return this;
- }
-
-
- //JSONObject内关键词 key >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
-
- //Request,默认encode <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
-
- /**
- * encode = true
- * @param value
- * @param parts path = keys[0] + "/" + keys[1] + "/" + keys[2] + ...
- * @return #put(key+"@", StringUtil.getString(keys, "/"), true)
- */
- public Object putPath(String key, String... keys) {
- return put(key+"@", StringUtil.getString(keys, "/"), true);
- }
-
- /**
- * encode = true
- * @param key
- * @param isNull
- * @return {@link #putNull(String, boolean, boolean)}
- */
- public JSONObject putNull(String key, boolean isNull) {
- return putNull(key, isNull, true);
- }
- /**
- * @param key
- * @param isNull
- * @param encode
- * @return put(key+"{}", SQL.isNull(isNull), encode);
- */
- public JSONObject putNull(String key, boolean isNull, boolean encode) {
- put(key+"{}", SQL.isNull(isNull), encode);
- return this;
- }
- /**
- * trim = false
- * @param key
- * @param isEmpty
- * @return {@link #putEmpty(String, boolean, boolean)}
- */
- public JSONObject putEmpty(String key, boolean isEmpty) {
- return putEmpty(key, isEmpty, false);
- }
- /**
- * encode = true
- * @param key
- * @param isEmpty
- * @return {@link #putEmpty(String, boolean, boolean, boolean)}
- */
- public JSONObject putEmpty(String key, boolean isEmpty, boolean trim) {
- return putEmpty(key, isEmpty, trim, true);
- }
- /**
- * @param key
- * @param isEmpty
- * @param encode
- * @return put(key+"{}", SQL.isEmpty(key, isEmpty, trim), encode);
- */
- public JSONObject putEmpty(String key, boolean isEmpty, boolean trim, boolean encode) {
- put(key+"{}", SQL.isEmpty(key, isEmpty, trim), encode);
- return this;
- }
- /**
- * encode = true
- * @param key
- * @param compare <=0, >5 ...
- * @return {@link #putLength(String, String, boolean)}
- */
- public JSONObject putLength(String key, String compare) {
- return putLength(key, compare, true);
- }
- /**
- * @param key
- * @param compare <=0, >5 ...
- * @param encode
- * @return put(key+"{}", SQL.length(key) + compare, encode);
- */
- public JSONObject putLength(String key, String compare, boolean encode) {
- put(key+"{}", SQL.length(key) + compare, encode);
- return this;
- }
-
- /**设置搜索
- * type = SEARCH_TYPE_CONTAIN_FULL
- * @param key
- * @param value
- * @return {@link #putSearch(String, String, int)}
- */
- public JSONObject putSearch(String key, String value) {
- return putSearch(key, value, SQL.SEARCH_TYPE_CONTAIN_FULL);
- }
- /**设置搜索
- * encode = true
- * @param key
- * @param value
- * @param type
- * @return {@link #putSearch(String, String, int, boolean)}
- */
- public JSONObject putSearch(String key, String value, int type) {
- return putSearch(key, value, type, true);
- }
- /**设置搜索
- * @param key
- * @param value
- * @param type
- * @param encode
- * @return put(key+"$", SQL.search(value, type), encode);
- */
- public JSONObject putSearch(String key, String value, int type, boolean encode) {
- put(key+"$", SQL.search(value, type), encode);
- return this;
- }
-
- //Request,默认encode >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-}
diff --git a/APIJSON(Android)/APIJSON(ADT)/APIJSONLibrary/src/zuo/biao/apijson/JSONResponse.java b/APIJSON(Android)/APIJSON(ADT)/APIJSONLibrary/src/zuo/biao/apijson/JSONResponse.java
deleted file mode 100644
index 1135a3f9e..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/APIJSONLibrary/src/zuo/biao/apijson/JSONResponse.java
+++ /dev/null
@@ -1,500 +0,0 @@
-/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON)
-
-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 zuo.biao.apijson;
-
-import java.util.List;
-import java.util.Set;
-
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-
-/**parser for response JSON String
- * @author Lemon
- * @see #getList
- * @see #toArray
- * @use JSONResponse response = new JSONResponse(json);
- *
JSONArray array = JSONResponse.toArray(response.getJSONObject("[]"));//not a must
- *
User user = JSONResponse.getObject(response, User.class);//not a must
- *
List list = JSONResponse.getList(response.getJSONObject("Comment[]"), Comment.class);//not a must
- */
-public class JSONResponse extends zuo.biao.apijson.JSONObject {
- private static final long serialVersionUID = 1L;
-
- private static final String TAG = "JSONResponse";
-
- public JSONResponse() {
- super();
- }
- public JSONResponse(String json) {
- this(parseObject(json));
- }
- public JSONResponse(JSONObject object) {
- super(format(object));
- }
-
- //状态信息,非GET请求获得的信息<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
- public static final int CODE_SUCCEED = 200;
- public static final int CODE_PARTIAL_SUCCEED = 206;
- public static final int CODE_UNSUPPORTED_ENCODING = 400;
- public static final int CODE_ILLEGAL_ACCESS = 401;
- public static final int CODE_UNSUPPORTED_OPERATION = 403;
- public static final int CODE_NOT_FOUND = 404;
- public static final int CODE_ILLEGAL_ARGUMENT = 406;
- public static final int CODE_NOT_LOGGED_IN = 407;
- public static final int CODE_TIME_OUT = 408;
- public static final int CODE_CONFLICT = 409;
- public static final int CODE_CONDITION_ERROR = 412;
- public static final int CODE_UNSUPPORTED_TYPE = 415;
- public static final int CODE_OUT_OF_RANGE = 416;
- public static final int CODE_NULL_POINTER = 417;
- public static final int CODE_SERVER_ERROR = 500;
-
-
- public static final String KEY_CODE = "code";
- public static final String KEY_MSG = "msg";
- public static final String KEY_ID = "id";
- public static final String KEY_COUNT = "count";
- public static final String KEY_TOTAL = "total";
-
- /**获取状态
- * @return
- */
- public int getCode() {
- try {
- return getIntValue(KEY_CODE);
- } catch (Exception e) {
- //empty
- }
- return 0;
- }
- /**获取信息
- * @return
- */
- public String getMsg() {
- return getString(KEY_MSG);
- }
- /**获取id
- * @return
- */
- public long getId() {
- try {
- return getLongValue(KEY_ID);
- } catch (Exception e) {
- //empty
- }
- return 0;
- }
- /**获取数量
- * @return
- */
- public int getCount() {
- try {
- return getIntValue(KEY_COUNT);
- } catch (Exception e) {
- //empty
- }
- return 0;
- }
- /**获取总数
- * @return
- */
- public int getTotal() {
- try {
- return getIntValue(KEY_TOTAL);
- } catch (Exception e) {
- //empty
- }
- return 0;
- }
-
-
- /**是否成功
- * @return
- */
- public boolean isSucceed() {
- return isSucceed(getCode());
- }
- /**是否成功
- * @param code
- * @return
- */
- public static boolean isSucceed(int code) {
- return code == CODE_SUCCEED;
- }
- /**是否成功
- * @param response
- * @return
- */
- public static boolean isSucceed(JSONResponse response) {
- return response != null && response.isSucceed();
- }
-
- /**校验服务端是否存在table
- * @return
- */
- public boolean isExist() {
- return isExist(getCount());
- }
- /**校验服务端是否存在table
- * @param count
- * @return
- */
- public static boolean isExist(int count) {
- return count > 0;
- }
- /**校验服务端是否存在table
- * @param response
- * @return
- */
- public static boolean isExist(JSONResponse response) {
- return response != null && response.isExist();
- }
-
- /**获取内部的JSONResponse
- * @param key
- * @return
- */
- public JSONResponse getJSONResponse(String key) {
- return getObject(key, JSONResponse.class);
- }
- //状态信息,非GET请求获得的信息>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
-
-
-
-
- /**
- * key = clazz.getSimpleName()
- * @param clazz
- * @return
- */
- public T getObject(Class clazz) {
- return getObject(clazz == null ? "" : clazz.getSimpleName(), clazz);
- }
- /**
- * @param key
- * @param clazz
- * @return
- */
- public T getObject(String key, Class clazz) {
- return getObject(this, key, clazz);
- }
- /**
- * @param object
- * @param key
- * @param clazz
- * @return
- */
- public static T getObject(JSONObject object, String key, Class clazz) {
- return toObject(object == null ? null : object.getJSONObject(key), clazz);
- }
-
- /**
- * @param clazz
- * @return
- */
- public T toObject(Class clazz) {
- return toObject(this, clazz);
- }
- /**
- * @param object
- * @param clazz
- * @return
- */
- public static T toObject(JSONObject object, Class clazz) {
- return JSON.parseObject(JSON.toJSONString(object), clazz);
- }
-
-
-
-
- /**
- * key = KEY_ARRAY
- * @param clazz
- * @return
- */
- public List getList(Class clazz) {
- return getList(KEY_ARRAY, clazz);
- }
- /**
- * arrayObject = this
- * @param key
- * @param clazz
- * @return
- */
- public List getList(String key, Class clazz) {
- return getList(this, key, clazz);
- }
-
- /**
- * key = KEY_ARRAY
- * @param object
- * @param clazz
- * @return
- */
- public static List getList(JSONObject object, Class clazz) {
- return getList(object, KEY_ARRAY, clazz);
- }
- /**
- * @param object
- * @param key
- * @param clazz
- * @return
- */
- public static List getList(JSONObject object, String key, Class clazz) {
- Object obj = object == null ? null : object.get(replaceArray(key));
- if (obj == null) {
- return null;
- }
- return obj instanceof JSONArray ? JSON.parseArray((JSONArray) obj, clazz) : toList((JSONObject) obj, clazz);
- }
- /**
- * @param clazz
- * @return
- */
- public List toList(Class clazz) {
- return toList(this, clazz);
- }
- /**
- * @param arrayObject
- * @param clazz
- * @return
- */
- public static List toList(JSONObject arrayObject, Class clazz) {
- return clazz == null ? null : JSON.parseArray(JSON.toJSONString(
- toArray(arrayObject, clazz.getSimpleName())), clazz);
- }
-
- /**
- * key = KEY_ARRAY
- * @param className
- * @return
- */
- public JSONArray getArray(String className) {
- return getArray(KEY_ARRAY, className);
- }
- /**
- * @param key
- * @param className
- * @return
- */
- public JSONArray getArray(String key, String className) {
- return getArray(this, key, className);
- }
- /**
- * @param object
- * @param key
- * @param className
- * @return
- */
- public static JSONArray getArray(JSONObject object, String className) {
- return getArray(object, KEY_ARRAY, className);
- }
- /**
- * key = KEY_ARRAY
- * @param object
- * @param className
- * @return
- */
- public static JSONArray getArray(JSONObject object, String key, String className) {
- Object obj = object == null ? null : object.get(replaceArray(key));
- if (obj == null) {
- return null;
- }
- return obj instanceof JSONArray ? (JSONArray) obj : toArray((JSONObject) obj, className);
- }
-
- /**
- * @param className
- * @return
- */
- public JSONArray toArray(String className) {
- return toArray(this, className);
- }
- /**{0:{Table:{}}, 1:{Table:{}}...} 转化为 [{Table:{}}, {Table:{}}]
- * array.set(index, isContainer ? value : value.getJSONObject(className));
- * @param arrayObject
- * @param className className.equals(Table) ? {Table:{Content}} => {Content}
- * @return
- */
- public static JSONArray toArray(JSONObject arrayObject, String className) {
- Set set = arrayObject == null ? null : arrayObject.keySet();
- if (set == null || set.isEmpty()) {
- return null;
- }
-
- // [{...},{...},...]
- String parentString = StringUtil.getTrimedString(JSON.toJSONString(arrayObject));
- if (parentString.isEmpty()) {
- return null;
- }
- if (parentString.startsWith("[")) {
- if (parentString.endsWith("]") == false) {
- parentString += "]";
- }
- return JSON.parseArray(parentString);
- }
-
- //{"0":{Table:{...}}, "1":{Table:{...}}...}
-
- className = StringUtil.getTrimedString(className);
- boolean isContainer = true;
-
- JSONArray array = new JSONArray(set.size());
- JSONObject value;
- boolean isFirst = true;
- int index;
- for (String key : set) {//0, 1, 2,...
- value = StringUtil.isNumer(key) == false ? null : arrayObject.getJSONObject(key);// Table:{}
- if (value != null) {
- try {
- index = Integer.valueOf(0 + key);
- if (isFirst && isTableKey(className) && value.containsKey(className)) {// 判断是否需要提取table
- isContainer = false;
- }
- array.set(index, isContainer ? value : value.getJSONObject(className));
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- isFirst = false;
- }
- return array;
- }
-
-
-
- // /**
- // * @return
- // */
- // public JSONObject format() {
- // return format(this);
- // }
- /**将Item[]:[{Table:{}}, {Table:{}}...] 或 Item[]:{0:{Table:{}}, 1:{Table:{}}...}
- * 转化为 itemList:[{Table:{}}, {Table:{}}],如果 Item.equals(Table),则将 {Table:{Content}} 转化为 {Content}
- * @param target
- * @param response
- * @return
- */
- public static JSONObject format(final JSONObject response) {
- //太长查看不方便,不如debug Log.i(TAG, "format response = \n" + JSON.toJSONString(response));
- if (response == null || response.isEmpty()) {
- Log.i(TAG, "format response == null || response.isEmpty() >> return response;");
- return response;
- }
- JSONObject transferredObject = new JSONObject(true);
-
- Set set = response.keySet();
- if (set != null) {
-
- Object value;
- String arrayKey;
- for (String key : set) {
- value = response.get(key);
-
- if (value instanceof JSONArray) {//转化JSONArray内部的APIJSON Array
- transferredObject.put(replaceArray(key), format(key, (JSONArray) value));
- } else if (value instanceof JSONObject) {//APIJSON Array转为常规JSONArray
- if (isArrayKey(key)) {//APIJSON Array转为常规JSONArray
- arrayKey = key.substring(0, key.lastIndexOf(KEY_ARRAY));
- transferredObject.put(getArrayKey(getSimpleName(arrayKey))
- , format(key, toArray((JSONObject) value, arrayKey)));//需要将name:alias传至toArray
- } else {//常规JSONObject,往下一级提取
- transferredObject.put(getSimpleName(key), format((JSONObject) value));
- }
- } else {//其它Object,直接填充
- transferredObject.put(getSimpleName(key), value);
- }
- }
- }
-
- //太长查看不方便,不如debug Log.i(TAG, "format return transferredObject = " + JSON.toJSONString(transferredObject));
- return transferredObject;
- }
-
- /**
- * @param responseArray
- * @return
- */
- public static JSONArray format(String name, final JSONArray responseArray) {
- //太长查看不方便,不如debug Log.i(TAG, "format responseArray = \n" + JSON.toJSONString(responseArray));
- if (responseArray == null || responseArray.isEmpty()) {
- Log.i(TAG, "format responseArray == null || responseArray.isEmpty() >> return response;");
- return responseArray;
- }
- int index = name == null ? -1 : name.lastIndexOf(KEY_ARRAY);
- String className = index < 0 ? "" : name.substring(0, index);
-
- JSONArray transferredArray = new JSONArray();
-
- Object value;
- boolean isContainer = true;
- boolean isFirst = true;
- for (int i = 0; i < responseArray.size(); i++) {
- value = responseArray.get(i);
- if (value instanceof JSONArray) {//转化JSONArray内部的APIJSON Array
- transferredArray.add(format(null, (JSONArray) value));
- } else if (value instanceof JSONObject) {//JSONObject,往下一级提取
- //判断是否需要提取child
- if (isFirst && isTableKey(className) && ((JSONObject) value).containsKey(className)) {
- isContainer = false;
- }
- //直接添加child 或 添加提取出的child
- transferredArray.add(format(isContainer ? (JSONObject)value : ((JSONObject)value).getJSONObject(className) ));
- isFirst = false;
- } else {//其它Object,直接填充
- transferredArray.add(responseArray.get(i));
- }
- }
-
- //太长查看不方便,不如debug Log.i(TAG, "format return transferredArray = " + JSON.toJSONString(transferredArray));
- return transferredArray;
- }
-
- /**替换key+KEY_ARRAY为keyList
- * @param key
- * @return getSimpleName(isArrayKey(key) ? getArrayKey(...) : key) {@link #getSimpleName(String)}
- */
- public static String replaceArray(String key) {
- if (isArrayKey(key)) {
- key = getArrayKey(key.substring(0, key.lastIndexOf(KEY_ARRAY)));
- }
- return getSimpleName(key);
- }
- /**获取列表变量名
- * @param key => StringUtil.getNoBlankString(key)
- * @return empty ? "list" : key + "List" 且首字母小写
- */
- public static String getArrayKey(String key) {
- return StringUtil.addSuffix(key, "list");
- }
-
- /**获取简单名称
- * @param fullName name 或 name:alias
- * @return name > name; name:alias > alias
- */
- public static String getSimpleName(String fullName) {
- //key:alias -> alias; key:alias[] -> alias[]
- int index = fullName == null ? -1 : fullName.indexOf(":");
- if (index >= 0) {
- fullName = fullName.substring(index + 1);
- }
- return fullName;
- }
-
-
-}
diff --git a/APIJSON(Android)/APIJSON(ADT)/APIJSONTest/src/apijson/demo/model/Wallet.java b/APIJSON(Android)/APIJSON(ADT)/APIJSONTest/src/apijson/demo/model/Wallet.java
deleted file mode 100644
index ba2459c47..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/APIJSONTest/src/apijson/demo/model/Wallet.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON)
-
-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 apijson.demo.model;
-
-import static zuo.biao.apijson.RequestRole.ADMIN;
-import static zuo.biao.apijson.RequestRole.OWNER;
-
-import java.math.BigDecimal;
-
-import zuo.biao.apijson.MethodAccess;
-
-/**钱包类,已用UserPrivacy替代
- * @author Lemon
- * @see
- *
POST_GET:
-{
- "Wallet":{
- "disallow":"!",
- "necessary":"id"
- }
-}
- *
- *
POST:post/wallet
-{
- "Wallet":{
- "disallow":"!",
- "necessary":"id"
- },
- "necessary":"payPassword"
-}
- *
- *
PUT:put/wallet
-{
- "Wallet":{
- "disallow":"!",
- "necessary":"id,balance+"
- },
- "necessary":"payPassword"
-}
- *
- *
DELETE:delete/wallet
-{
- "Wallet":{
- "disallow":"!",
- "necessary":"id"
- },
- "necessary":"payPassword"
-}
- *
- */
-@Deprecated
-@MethodAccess(
- GET = {},
- HEAD = {},
- POST_GET = {OWNER, ADMIN},
- POST_HEAD = {OWNER, ADMIN},
- POST = {ADMIN},
- DELETE = {ADMIN}
- )
-public class Wallet extends BaseModel {
- private static final long serialVersionUID = 1L;
-
- public BigDecimal balance;
-
- /**默认构造方法,JSON等解析时必须要有
- */
- public Wallet() {
- super();
- }
- public Wallet(long id) {
- this();
- setId(id);
- }
-
-
- public Wallet setUserId(long userId) {
- setId(userId);
- return this;
- }
-
- public BigDecimal getBalance() {
- return balance;
- }
- public Wallet setBalance(BigDecimal balance) {
- this.balance = balance;
- return this;
- }
-
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/APIJSONLibrary/src/main/java/zuo/biao/apijson/BaseModel.java b/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/APIJSONLibrary/src/main/java/zuo/biao/apijson/BaseModel.java
deleted file mode 100644
index fd6eb9c21..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/APIJSONLibrary/src/main/java/zuo/biao/apijson/BaseModel.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON)
-
-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 zuo.biao.apijson;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.Map;
-
-/**base model for reduce model codes
- * @author Lemon
- * @use extends BaseModel
- */
-@SuppressWarnings("serial")
-public abstract class BaseModel implements Serializable {
-
- private Long id;
- private Long date;
-
- public Long getId() {
- return id;
- }
- public BaseModel setId(Long id) {
- this.id = id;
- return this;
- }
- public Long getDate() {
- return date;
- }
- public BaseModel setDate(Long date) {
- this.date = date;
- return this;
- }
-
- //判断是否为空 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- /**判断collection是否为空
- * @param collection
- * @return
- */
- public static boolean isEmpty(Collection collection) {
- return collection == null || collection.isEmpty();
- }
- /**判断map是否为空
- * @param
- * @param
- * @param map
- * @return
- */
- public static boolean isEmpty(Map map) {
- return map == null || map.isEmpty();
- }
- //判断是否为空 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
- //判断是否包含 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- /**判断collection是否包含object
- * @param collection
- * @param object
- * @return
- */
- public static boolean isContain(Collection collection, T object) {
- return collection != null && collection.contains(object);
- }
- /**判断map是否包含key
- * @param
- * @param
- * @param map
- * @param key
- * @return
- */
- public static boolean isContainKey(Map map, K key) {
- return map != null && map.containsKey(key);
- }
- /**判断map是否包含value
- * @param
- * @param
- * @param map
- * @param value
- * @return
- */
- public static boolean isContainValue(Map map, V value) {
- return map != null && map.containsValue(value);
- }
- //判断是否为包含 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
- //获取集合长度 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- /**获取数量
- * @param
- * @param array
- * @return
- */
- public static int count(T[] array) {
- return array == null ? 0 : array.length;
- }
- /**获取数量
- * @param
- * @param collection List, Vector, Set等都是Collection的子类
- * @return
- */
- public static int count(Collection collection) {
- return collection == null ? 0 : collection.size();
- }
- /**获取数量
- * @param
- * @param
- * @param map
- * @return
- */
- public static int count(Map map) {
- return map == null ? 0 : map.size();
- }
- //获取集合长度 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
- //获取集合长度 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- /**获取
- * @param
- * @param array
- * @return
- */
- public static T get(T[] array, int position) {
- return position < 0 || position >= count(array) ? null : array[position];
- }
- /**获取
- * @param
- * @param collection List, Vector, Set等都是Collection的子类
- * @return
- */
- @SuppressWarnings("unchecked")
- public static T get(Collection collection, int position) {
- return (T) (collection == null ? null : get(collection.toArray(), position));
- }
- /**获取
- * @param
- * @param
- * @param map null ? null
- * @param key null ? null : map.get(key);
- * @return
- */
- public static V get(Map map, K key) {
- return key == null || map == null ? null : map.get(key);
- }
- //获取集合长度 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
-
- //获取非基本类型对应基本类型的非空值 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- /**获取非空值
- * @param value
- * @return
- */
- public static boolean value(Boolean value) {
- return value == null ? false : value;
- }
- /**获取非空值
- * @param value
- * @return
- */
- public static int value(Integer value) {
- return value == null ? 0 : value;
- }
- /**获取非空值
- * @param value
- * @return
- */
- public static long value(Long value) {
- return value == null ? 0 : value;
- }
- /**获取非空值
- * @param value
- * @return
- */
- public static float value(Float value) {
- return value == null ? 0 : value;
- }
- /**获取非空值
- * @param value
- * @return
- */
- public static double value(Double value) {
- return value == null ? 0 : value;
- }
- //获取非基本类型对应基本类型的非空值 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/APIJSONLibrary/src/main/java/zuo/biao/apijson/FunctionList.java b/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/APIJSONLibrary/src/main/java/zuo/biao/apijson/FunctionList.java
deleted file mode 100644
index 6dc2d3407..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/APIJSONLibrary/src/main/java/zuo/biao/apijson/FunctionList.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON)
-
-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 zuo.biao.apijson;
-
-import java.util.Collection;
-import java.util.Map;
-
-/**可远程调用的函数列表
- * @author Lemon
- */
-public interface FunctionList {
-
- //判断是否为空 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- /**判断collection是否为空
- * @param collection
- * @return
- */
- public boolean isEmpty(Collection collection);
- /**判断map是否为空
- * @param
- * @param
- * @param map
- * @return
- */
- public boolean isEmpty(Map map);
- //判断是否为空 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
- //判断是否为包含 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- /**判断collection是否包含object
- * @param collection
- * @param object
- * @return
- */
- public boolean isContain(Collection collection, T object);
- /**判断map是否包含key
- * @param
- * @param
- * @param map
- * @param key
- * @return
- */
- public boolean isContainKey(Map map, K key);
- /**判断map是否包含value
- * @param
- * @param
- * @param map
- * @param value
- * @return
- */
- public boolean isContainValue(Map map, V value);
- //判断是否为包含 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
- //获取集合长度 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- /**获取数量
- * @param
- * @param array
- * @return
- */
- public int count(T[] array);
- /**获取数量
- * @param
- * @param collection List, Vector, Set等都是Collection的子类
- * @return
- */
- public int count(Collection collection);
- /**获取数量
- * @param
- * @param
- * @param map
- * @return
- */
- public int count(Map map);
- //获取集合长度 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
- //获取集合长度 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- /**获取
- * @param
- * @param array
- * @return
- */
- public T get(T[] array, int position);
- /**获取
- * @param
- * @param collection List, Vector, Set等都是Collection的子类
- * @return
- */
- public T get(Collection collection, int position);
- /**获取
- * @param
- * @param
- * @param map null ? null
- * @param key null ? null : map.get(key);
- * @return
- */
- public V get(Map map, K key);
- //获取集合长度 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
-
- //获取非基本类型对应基本类型的非空值 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- /**获取非空值
- * @param value
- * @return
- */
- public boolean value(Boolean value);
- /**获取非空值
- * @param value
- * @return
- */
- public int value(Integer value);
- /**获取非空值
- * @param value
- * @return
- */
- public long value(Long value);
- /**获取非空值
- * @param value
- * @return
- */
- public float value(Float value);
- /**获取非空值
- * @param value
- * @return
- */
- public double value(Double value);
- //获取非基本类型对应基本类型的非空值 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-}
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/APIJSONLibrary/src/main/java/zuo/biao/apijson/JSONObject.java b/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/APIJSONLibrary/src/main/java/zuo/biao/apijson/JSONObject.java
deleted file mode 100644
index e1fdb9060..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/APIJSONLibrary/src/main/java/zuo/biao/apijson/JSONObject.java
+++ /dev/null
@@ -1,434 +0,0 @@
-/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON)
-
-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 zuo.biao.apijson;
-
-import static zuo.biao.apijson.StringUtil.UTF_8;
-import static zuo.biao.apijson.StringUtil.bigAlphaPattern;
-import static zuo.biao.apijson.StringUtil.namePattern;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import java.net.URLEncoder;
-import java.util.Set;
-
-
-/**use this class instead of com.alibaba.fastjson.JSONObject, not encode in default cases
- * @author Lemon
- */
-public class JSONObject extends com.alibaba.fastjson.JSONObject {
- private static final long serialVersionUID = 8907029699680768212L;
-
- /**ordered
- */
- public JSONObject() {
- super(true);
- }
- /**transfer Object to JSONObject
- * encode = false;
- * @param object
- * @see {@link #JSONObject(Object, boolean)}
- */
- public JSONObject(Object object) {
- this(object, false);
- }
- /**transfer Object to JSONObject
- * @param object
- * @param encode
- * @see {@link #JSONObject(String, boolean)}
- */
- public JSONObject(Object object, boolean encode) {
- this(toJSONString(object), encode);
- }
- /**parse JSONObject with JSON String
- * encode = false;
- * @param json
- * @see {@link #JSONObject(String, boolean)}
- */
- public JSONObject(String json) {
- this(json, false);
- }
- /**parse JSONObject with JSON String
- * @param json
- * @param encode
- * @see {@link #JSONObject(com.alibaba.fastjson.JSONObject, boolean)}
- */
- public JSONObject(String json, boolean encode) {
- this(parseObject(json), encode);
- }
- /**transfer com.alibaba.fastjson.JSONObject to JSONObject
- * encode = false;
- * @param object
- * @see {@link #JSONObject(com.alibaba.fastjson.JSONObject, boolean)}
- */
- public JSONObject(com.alibaba.fastjson.JSONObject object) {
- this(object, false);
- }
- /**transfer com.alibaba.fastjson.JSONObject to JSONObject
- * @param object
- * @param encode
- * @see {@link #add(com.alibaba.fastjson.JSONObject, boolean)}
- */
- public JSONObject(com.alibaba.fastjson.JSONObject object, boolean encode) {
- this();
- add(object, encode);
- }
-
-
-
-
- /**put key-value in object into this
- * encode = false;
- * @param object
- * @return {@link #add(com.alibaba.fastjson.JSONObject, boolean)}
- */
- public JSONObject add(com.alibaba.fastjson.JSONObject object) {
- return add(object, false);
- }
- /**put key-value in object into this
- * @param object
- * @param encode
- * @return this
- */
- public JSONObject add(com.alibaba.fastjson.JSONObject object, boolean encode) {
- //TODO putAll(object);
-
- Set set = object == null ? null : object.keySet();
- if (set != null) {
- for (String key : set) {
- put(key, object.get(key), encode);
- }
- }
- return this;
- }
-
-
-
- /**
- * @param key if decode && key instanceof String, key = URLDecoder.decode((String) key, UTF_8)
- * @param decode if decode && value instanceof String, value = URLDecoder.decode((String) value, UTF_8)
- * @return
- */
- public Object get(Object key, boolean decode) {
- if (decode) {
- if (key instanceof String) {
- if (((String) key).endsWith("+") || ((String) key).endsWith("-")) {
- try {//多层encode导致内部Comment[]传到服务端decode后最终变为Comment%5B%5D
- key = URLDecoder.decode((String) key, UTF_8);
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- return null;
- }
- }
- }
- Object value = super.get(key);
- if (value instanceof String) {
- try {
- value = URLDecoder.decode((String) value, UTF_8);
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- }
- return value;
- }
- return super.get(key);
- }
-
- /**
- * encode = false
- * @param value must be annotated by {@link APIJSONRequest}
- * @return {@link #put(String, boolean)}
- */
- public Object put(Object value) {
- return put(value, false);
- }
- /**
- * key = value.getClass().getSimpleName()
- * @param value must be annotated by {@link APIJSONRequest}
- * @param encode
- * @return {@link #put(String, Object, boolean)}
- */
- public Object put(Object value, boolean encode) {
- return put(null, value, encode);
- }
- /**
- * @param key if StringUtil.isNotEmpty(key, true) == false,
- *
key = value == null ? null : value.getClass().getSimpleName();
- *
>> if decode && key instanceof String, key = URLDecoder.decode((String) key, UTF_8)
- * @param value URLEncoder.encode((String) value, UTF_8);
- * @param encode if value instanceof String, value = URLEncoder.encode((String) value, UTF_8);
- * @return
- */
- public Object put(String key, Object value, boolean encode) {
- if (StringUtil.isNotEmpty(key, true) == false) {
- Class> clazz = value == null ? null : value.getClass();
- if (clazz == null || clazz.getAnnotation(APIJSONRequest.class) == null) {
- throw new IllegalArgumentException("put StringUtil.isNotEmpty(key, true) == false" +
- " && clazz == null || clazz.getAnnotation(APIJSONRequest.class) == null" +
- " \n key为空时仅支持 类型被@APIJSONRequest注解 的value !!!" +
- " \n 如果一定要这么用,请对 " + clazz.getName() + " 注解!" +
- " \n 如果是类似 key[]:{} 结构的请求,建议add(...)方法!");
- }
- key = value.getClass().getSimpleName();
- }
- if (encode) {
- if (key.endsWith("+") || key.endsWith("-")) {
- try {//多层encode导致内部Comment[]传到服务端decode后最终变为Comment%5B%5D
- key = URLEncoder.encode(key, UTF_8);
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- }
- if (value instanceof String) {//只在value instanceof String时encode key?{@link #get(Object, boolean)}内做不到
- try {
- value = URLEncoder.encode((String) value, UTF_8);
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- }
- }
- return super.put(key, value);
- }
-
-
-
- //judge <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- public static final String KEY_ARRAY = "[]";
-
- /**判断是否为Array的key
- * @param key
- * @return
- */
- public static boolean isArrayKey(String key) {
- return key != null && key.endsWith(KEY_ARRAY);
- }
- /**判断是否为对应Table的key
- * @param key
- * @return
- */
- public static boolean isTableKey(String key) {
- return isWord(key) && bigAlphaPattern.matcher(key.substring(0, 1)).matches();
- }
- /**判断是否为词,只能包含字母,数字或下划线
- * @param key
- * @return
- */
- public static boolean isWord(String key) {
- return StringUtil.isNotEmpty(key, false) && namePattern.matcher(key).matches();
- }
- //judge >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
- //JSONObject内关键词 key <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
- public static final String KEY_COLUMN = "@column";//@key关键字都放这个类
- public static final String KEY_GROUP = "@group";//@key关键字都放这个类
- public static final String KEY_HAVING = "@having";//@key关键字都放这个类
- public static final String KEY_ORDER = "@order";//@key关键字都放这个类
-
- /**set keys need to be returned
- * @param keys key0, key1, key2 ...
- * @return {@link #setColumn(String)}
- */
- public JSONObject setColumn(String... keys) {
- return setColumn(StringUtil.getString(keys, true));
- }
- /**set keys need to be returned
- * @param keys "key0,key1,key2..."
- * @return
- */
- public JSONObject setColumn(String keys) {
- put(KEY_COLUMN, keys);
- return this;
- }
- public String getColumn() {
- return getString(KEY_COLUMN);
- }
-
- /**set keys for group by
- * @param keys key0, key1, key2 ...
- * @return {@link #setGroup(String)}
- */
- public JSONObject setGroup(String... keys) {
- return setGroup(StringUtil.getString(keys, true));
- }
- /**set keys for group by
- * @param keys "key0,key1,key2..."
- * @return
- */
- public JSONObject setGroup(String keys) {
- put(KEY_GROUP, keys);
- return this;
- }
- public String getGroup() {
- return getString(KEY_GROUP);
- }
-
- /**set keys for having
- * @param keys count(key0) > 1, sum(key1) <= 5, function2(key2) ? value2 ...
- * @return {@link #setHaving(String)}
- */
- public JSONObject setHaving(String... keys) {
- return setHaving(StringUtil.getString(keys, true));
- }
- /**set keys for having
- * @param keys "key0,key1,key2..."
- * @return
- */
- public JSONObject setHaving(String keys) {
- put(KEY_HAVING, keys);
- return this;
- }
- public String getHaving() {
- return getString(KEY_HAVING);
- }
-
- /**set keys for order by
- * @param keys key0, key1+, key2- ...
- * @return {@link #setOrder(String)}
- */
- public JSONObject setOrder(String... keys) {
- return setOrder(StringUtil.getString(keys, true));
- }
- /**set keys for order by
- * @param keys "key0,key1+,key2-..."
- * @return
- */
- public JSONObject setOrder(String keys) {
- put(KEY_ORDER, keys);
- return this;
- }
- public String getOrder() {
- return getString(KEY_ORDER);
- }
-
-
- //JSONObject内关键词 key >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
-
- //Request,默认encode <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
-
- /**
- * encode = true
- * @param value
- * @param parts path = keys[0] + "/" + keys[1] + "/" + keys[2] + ...
- * @return #put(key+"@", StringUtil.getString(keys, "/"), true)
- */
- public Object putPath(String key, String... keys) {
- return put(key+"@", StringUtil.getString(keys, "/"), true);
- }
-
- /**
- * encode = true
- * @param key
- * @param isNull
- * @return {@link #putNull(String, boolean, boolean)}
- */
- public JSONObject putNull(String key, boolean isNull) {
- return putNull(key, isNull, true);
- }
- /**
- * @param key
- * @param isNull
- * @param encode
- * @return put(key+"{}", SQL.isNull(isNull), encode);
- */
- public JSONObject putNull(String key, boolean isNull, boolean encode) {
- put(key+"{}", SQL.isNull(isNull), encode);
- return this;
- }
- /**
- * trim = false
- * @param key
- * @param isEmpty
- * @return {@link #putEmpty(String, boolean, boolean)}
- */
- public JSONObject putEmpty(String key, boolean isEmpty) {
- return putEmpty(key, isEmpty, false);
- }
- /**
- * encode = true
- * @param key
- * @param isEmpty
- * @return {@link #putEmpty(String, boolean, boolean, boolean)}
- */
- public JSONObject putEmpty(String key, boolean isEmpty, boolean trim) {
- return putEmpty(key, isEmpty, trim, true);
- }
- /**
- * @param key
- * @param isEmpty
- * @param encode
- * @return put(key+"{}", SQL.isEmpty(key, isEmpty, trim), encode);
- */
- public JSONObject putEmpty(String key, boolean isEmpty, boolean trim, boolean encode) {
- put(key+"{}", SQL.isEmpty(key, isEmpty, trim), encode);
- return this;
- }
- /**
- * encode = true
- * @param key
- * @param compare <=0, >5 ...
- * @return {@link #putLength(String, String, boolean)}
- */
- public JSONObject putLength(String key, String compare) {
- return putLength(key, compare, true);
- }
- /**
- * @param key
- * @param compare <=0, >5 ...
- * @param encode
- * @return put(key+"{}", SQL.length(key) + compare, encode);
- */
- public JSONObject putLength(String key, String compare, boolean encode) {
- put(key+"{}", SQL.length(key) + compare, encode);
- return this;
- }
-
- /**设置搜索
- * type = SEARCH_TYPE_CONTAIN_FULL
- * @param key
- * @param value
- * @return {@link #putSearch(String, String, int)}
- */
- public JSONObject putSearch(String key, String value) {
- return putSearch(key, value, SQL.SEARCH_TYPE_CONTAIN_FULL);
- }
- /**设置搜索
- * encode = true
- * @param key
- * @param value
- * @param type
- * @return {@link #putSearch(String, String, int, boolean)}
- */
- public JSONObject putSearch(String key, String value, int type) {
- return putSearch(key, value, type, true);
- }
- /**设置搜索
- * @param key
- * @param value
- * @param type
- * @param encode
- * @return put(key+"$", SQL.search(value, type), encode);
- */
- public JSONObject putSearch(String key, String value, int type, boolean encode) {
- put(key+"$", SQL.search(value, type), encode);
- return this;
- }
-
- //Request,默认encode >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/APIJSONLibrary/src/main/java/zuo/biao/apijson/JSONRequest.java b/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/APIJSONLibrary/src/main/java/zuo/biao/apijson/JSONRequest.java
deleted file mode 100644
index 6bd3bce73..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/APIJSONLibrary/src/main/java/zuo/biao/apijson/JSONRequest.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON)
-
-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 zuo.biao.apijson;
-
-/**encapsulator for request JSONObject, encode in default cases
- * @author Lemon
- * @see #toArray
- * @use JSONRequest request = new JSONRequest(...);
- *
request.put(...);//not a must
- *
request.toArray(...);//not a must
- */
-public class JSONRequest extends JSONObject {
-
- private static final long serialVersionUID = -2223023180338466812L;
-
- public JSONRequest() {
- super();
- }
- /**
- * encode = true
- * @param object must be annotated by {@link APIJSONRequest}
- * @see {@link #JSONRequest(String, Object)}
- */
- public JSONRequest(Object object) {
- this(null, object);
- }
- /**
- * encode = true
- * @param name
- * @param object
- * @see {@link #JSONRequest(String, Object, boolean)}
- */
- public JSONRequest(String name, Object object) {
- this(name, object, true);
- }
- /**
- * @param object must be annotated by {@link APIJSONRequest}
- * @param encode
- * @see {@link #JSONRequest(String, Object, boolean)}
- */
- public JSONRequest(Object object, boolean encode) {
- this(null, object, encode);
- }
- /**
- * @param name
- * @param object
- * @param encode
- * @see {@link #put(String, Object, boolean)}
- */
- public JSONRequest(String name, Object object, boolean encode) {
- this();
- put(name, object, encode);
- }
-
-
-
-
-
-
- public static final String KEY_TAG = "tag";//只在最外层,最外层用JSONRequest
-
- public JSONObject setTag(String tag) {
- put(KEY_TAG, tag);
- return this;
- }
- public String getTag() {
- return getString(KEY_TAG);
- }
-
-
- //array object <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
- public static final int QUERY_TABLE = 0;
- public static final int QUERY_TOTAL = 1;
- public static final int QUERY_ALL = 2;
-
- public static final String KEY_QUERY = "query";
- public static final String KEY_COUNT = "count";
- public static final String KEY_PAGE = "page";
-
- /**
- * @param query what need to query, Table,total,ALL?
- * @return
- */
- public JSONRequest setQuery(int query) {
- put(KEY_QUERY, query);
- return this;
- }
- public int getQuery() {
- return getIntValue(KEY_QUERY);
- }
-
- /**
- * @param count
- * @return
- */
- public JSONRequest setCount(int count) {
- put(KEY_COUNT, count);
- return this;
- }
- public int getCount() {
- return getIntValue(KEY_COUNT);
- }
-
- /**
- * @param page
- * @return
- */
- public JSONRequest setPage(int page) {
- put(KEY_PAGE, page);
- return this;
- }
- public int getPage() {
- return getIntValue(KEY_PAGE);
- }
- //array object >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
-
-
- // 导致JSONObject add >> get = null
- // /**
- // * decode = true
- // * @param key
- // * return {@link #get(Object, boolean)}
- // */
- // @Override
- // public Object get(Object key) {
- // return get(key, true);
- // }
-
- /**
- * encode = true
- * @param value must be annotated by {@link APIJSONRequest}
- * @return {@link #put(String, boolean)}
- */
- @Override
- public Object put(Object value) {
- return put(value, true);
- }
- /**
- * encode = true
- * @param key
- * @param value
- * return {@link #put(String, Object, boolean)}
- */
- @Override
- public Object put(String key, Object value) {
- return put(key, value, true);
- }
-
-
- /**create a parent JSONObject named KEY_ARRAY
- * encode = true;
- * @param count
- * @param page
- * @return {@link #toArray(int, int, boolean)}
- */
- public JSONRequest toArray(int count, int page) {
- return toArray(count, page, true);
- }
- /**create a parent JSONObject named KEY_ARRAY
- * encode = true;
- * @param count
- * @param page
- * @return {@link #toArray(int, int, String, boolean)}
- */
- public JSONRequest toArray(int count, int page, boolean encode) {
- return toArray(count, page, null, encode);
- }
- /**create a parent JSONObject named name+KEY_ARRAY
- * encode = true;
- * @param count
- * @param page
- * @param name
- * @return {@link #toArray(int, int, String, boolean)}
- */
- public JSONRequest toArray(int count, int page, String name) {
- return toArray(count, page, name, true);
- }
- /**create a parent JSONObject named name+KEY_ARRAY.
- * @param count
- * @param page
- * @param name
- * @param encode
- * @return {name+KEY_ARRAY : this}. if needs to be put, use {@link #add(com.alibaba.fastjson.JSONObject)} instead
- */
- public JSONRequest toArray(int count, int page, String name, boolean encode) {
- return new JSONRequest(StringUtil.getString(name) + KEY_ARRAY, this.setCount(count).setPage(page), encode);
- }
-
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/APIJSONLibrary/src/main/java/zuo/biao/apijson/JSONResponse.java b/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/APIJSONLibrary/src/main/java/zuo/biao/apijson/JSONResponse.java
deleted file mode 100644
index 40379e2f9..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/APIJSONLibrary/src/main/java/zuo/biao/apijson/JSONResponse.java
+++ /dev/null
@@ -1,480 +0,0 @@
-/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON)
-
-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 zuo.biao.apijson;
-
-import static zuo.biao.apijson.StringUtil.bigAlphaPattern;
-
-import java.util.List;
-import java.util.Set;
-
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-
-/**parser for response JSON String
- * @author Lemon
- * @see #getList
- * @see #toArray
- * @use JSONResponse response = new JSONResponse(...);
- *
JSONArray array = JSONResponse.toArray(response.getJSONObject(KEY_ARRAY));//not a must
- *
User user = JSONResponse.getObject(response, User.class);//not a must
- *
List list = JSONResponse.getList(response.getJSONObject("Comment[]"), Comment.class);//not a must
- */
-@SuppressWarnings("serial")
-public class JSONResponse extends zuo.biao.apijson.JSONObject {
- private static final String TAG = "JSONResponse";
-
- public JSONResponse() {
- super();
- }
- public JSONResponse(String json) {
- this(parseObject(json));
- }
- public JSONResponse(JSONObject object) {
- super(format(object));
- }
-
- //状态信息,非GET请求获得的信息<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
- public static final int STATUS_SUCCEED = 200;
-
-
- public static final String KEY_ID = "id";
- public static final String KEY_STATUS = "status";
- public static final String KEY_COUNT = "count";
- public static final String KEY_TOTAL = "total";
- public static final String KEY_MESSAGE = "message";
-
- /**获取id
- * @return
- */
- public long getId() {
- return getLongValue(KEY_ID);
- }
- /**获取状态
- * @return
- */
- public int getStatus() {
- return getIntValue(KEY_STATUS);
- }
- /**获取数量
- * @return
- */
- public int getCount() {
- return getIntValue(KEY_COUNT);
- }
- /**获取数量
- * @return
- */
- public int getTotal() {
- try {
- return getIntValue(KEY_TOTAL);
- } catch (Exception e) {
- // TODO: handle exception
- }
- return 0;
- }
- /**获取信息
- * @return
- */
- public String getMessage() {
- return getString(KEY_MESSAGE);
- }
-
- /**是否成功
- * @return
- */
- public boolean isSucceed() {
- return isSucceed(getStatus());
- }
- /**是否成功
- * @param status
- * @return
- */
- public static boolean isSucceed(int status) {
- return status == STATUS_SUCCEED;
- }
- /**是否成功
- * @param response
- * @return
- */
- public static boolean isSucceed(JSONResponse response) {
- return response != null && response.isSucceed();
- }
-
- /**校验服务端是否存在table
- * @return
- */
- public boolean isExist() {
- return isExist(getCount());
- }
- /**校验服务端是否存在table
- * @param count
- * @return
- */
- public static boolean isExist(int count) {
- return count > 0;
- }
- /**校验服务端是否存在table
- * @param response
- * @return
- */
- public static boolean isExist(JSONResponse response) {
- return response != null && response.isExist();
- }
-
- /**获取内部的JSONResponse
- * @param key
- * @return
- */
- public JSONResponse getJSONResponse(String key) {
- return getObject(key, JSONResponse.class);
- }
- //状态信息,非GET请求获得的信息>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
-
-
-
-
- /**
- * key = clazz.getSimpleName()
- * @param clazz
- * @return
- */
- public T getObject(Class clazz) {
- return getObject(clazz == null ? "" : clazz.getSimpleName(), clazz);
- }
- /**
- * @param key
- * @param clazz
- * @return
- */
- public T getObject(String key, Class clazz) {
- return getObject(this, key, clazz);
- }
- /**
- * @param object
- * @param key
- * @param clazz
- * @return
- */
- public static T getObject(JSONObject object, String key, Class clazz) {
- return toObject(object == null ? null : object.getJSONObject(key), clazz);
- }
-
- /**
- * @param clazz
- * @return
- */
- public T toObject(Class clazz) {
- return toObject(this, clazz);
- }
- /**
- * @param object
- * @param clazz
- * @return
- */
- public static T toObject(JSONObject object, Class clazz) {
- return JSON.parseObject(JSON.toJSONString(object), clazz);
- }
-
-
-
-
- /**
- * key = KEY_ARRAY
- * @param clazz
- * @return
- */
- public List getList(Class clazz) {
- return getList(KEY_ARRAY, clazz);
- }
- /**
- * arrayObject = this
- * @param key
- * @param clazz
- * @return
- */
- public List getList(String key, Class clazz) {
- return getList(this, key, clazz);
- }
-
- /**
- * key = KEY_ARRAY
- * @param object
- * @param clazz
- * @return
- */
- public static List getList(JSONObject object, Class clazz) {
- return getList(object, KEY_ARRAY, clazz);
- }
- /**
- * @param object
- * @param key
- * @param clazz
- * @return
- */
- public static List getList(JSONObject object, String key, Class clazz) {
- Object obj = object == null ? null : object.get(replaceArray(key));
- if (obj == null) {
- return null;
- }
- return obj instanceof JSONArray ? JSON.parseArray((JSONArray) obj, clazz) : toList((JSONObject) obj, clazz);
- }
- /**
- * @param clazz
- * @return
- */
- public List toList(Class clazz) {
- return toList(this, clazz);
- }
- /**
- * @param arrayObject
- * @param clazz
- * @return
- */
- public static List toList(JSONObject arrayObject, Class clazz) {
- return clazz == null ? null : JSON.parseArray(JSON.toJSONString(
- toArray(arrayObject, clazz.getSimpleName())), clazz);
- }
-
- /**
- * key = KEY_ARRAY
- * @param className
- * @return
- */
- public JSONArray getArray(String className) {
- return getArray(KEY_ARRAY, className);
- }
- /**
- * @param key
- * @param className
- * @return
- */
- public JSONArray getArray(String key, String className) {
- return getArray(this, key, className);
- }
- /**
- * @param object
- * @param key
- * @param className
- * @return
- */
- public static JSONArray getArray(JSONObject object, String className) {
- return getArray(object, KEY_ARRAY, className);
- }
- /**
- * key = KEY_ARRAY
- * @param object
- * @param className
- * @return
- */
- public static JSONArray getArray(JSONObject object, String key, String className) {
- Object obj = object == null ? null : object.get(replaceArray(key));
- if (obj == null) {
- return null;
- }
- return obj instanceof JSONArray ? (JSONArray) obj : toArray((JSONObject) obj, className);
- }
-
- /**
- * @param className
- * @return
- */
- public JSONArray toArray(String className) {
- return toArray(this, className);
- }
- /**{0:{Table:{}}, 1:{Table:{}}...} 转化为 [{Table:{}}, {Table:{}}]
- * array.set(index, isContainer ? value : value.getJSONObject(className));
- * @param arrayObject
- * @param className className.equals(Table) ? {Table:{Content}} => {Content}
- * @return
- */
- public static JSONArray toArray(JSONObject arrayObject, String className) {
- Set set = arrayObject == null ? null : arrayObject.keySet();
- if (set == null || set.isEmpty()) {
- return null;
- }
-
- // [{...},{...},...]
- String parentString = StringUtil.getTrimedString(JSON.toJSONString(arrayObject));
- if (parentString.isEmpty()) {
- return null;
- }
- if (parentString.startsWith("[")) {
- if (parentString.endsWith("]") == false) {
- parentString += "]";
- }
- return JSON.parseArray(parentString);
- }
-
- //{"0":{Table:{...}}, "1":{Table:{...}}...}
-
- className = StringUtil.getTrimedString(className);
- boolean isContainer = true;
-
- JSONArray array = new JSONArray(set.size());
- JSONObject value;
- boolean isFirst = true;
- int index;
- for (String key : set) {//0, 1, 2,...
- value = StringUtil.isNumer(key) == false ? null : arrayObject.getJSONObject(key);// Table:{}
- if (value != null) {
- try {
- index = Integer.valueOf(0 + key);
- if (isFirst && isTableKey(className) && value.containsKey(className)) {// 判断是否需要提取table
- isContainer = false;
- }
- array.set(index, isContainer ? value : value.getJSONObject(className));
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- isFirst = false;
- }
- return array;
- }
-
-
-
- // /**
- // * @return
- // */
- // public JSONObject format() {
- // return format(this);
- // }
- /**将Item[]:[{Table:{}}, {Table:{}}...] 或 Item[]:{0:{Table:{}}, 1:{Table:{}}...}
- * 转化为 itemList:[{Table:{}}, {Table:{}}],如果 Item.equals(Table),则将 {Table:{Content}} 转化为 {Content}
- * @param target
- * @param response
- * @return
- */
- public static JSONObject format(final JSONObject response) {
- //太长查看不方便,不如debug Log.i(TAG, "format response = \n" + JSON.toJSONString(response));
- if (response == null || response.isEmpty()) {
- Log.i(TAG, "format response == null || response.isEmpty() >> return response;");
- return response;
- }
- JSONObject transferredObject = new JSONObject(true);
-
- Set set = response.keySet();
- if (set != null) {
-
- Object value;
- String arrayKey;
- for (String key : set) {
- value = response.get(key);
-
- if (value instanceof JSONArray) {//转化JSONArray内部的APIJSON Array
- transferredObject.put(replaceArray(key), format(key, (JSONArray) value));
- } else if (value instanceof JSONObject) {//APIJSON Array转为常规JSONArray
- if (isArrayKey(key)) {//APIJSON Array转为常规JSONArray
- arrayKey = key.substring(0, key.lastIndexOf(KEY_ARRAY));
- transferredObject.put(getArrayKey(getSimpleName(arrayKey))
- , format(key, toArray((JSONObject) value, arrayKey)));//需要将name:alias传至toArray
- } else {//常规JSONObject,往下一级提取
- transferredObject.put(getSimpleName(key), format((JSONObject) value));
- }
- } else {//其它Object,直接填充
- transferredObject.put(getSimpleName(key), value);
- }
- }
- }
-
- //太长查看不方便,不如debug Log.i(TAG, "format return transferredObject = " + JSON.toJSONString(transferredObject));
- return transferredObject;
- }
-
- /**
- * @param responseArray
- * @return
- */
- public static JSONArray format(String name, final JSONArray responseArray) {
- //太长查看不方便,不如debug Log.i(TAG, "format responseArray = \n" + JSON.toJSONString(responseArray));
- if (responseArray == null || responseArray.isEmpty()) {
- Log.i(TAG, "format responseArray == null || responseArray.isEmpty() >> return response;");
- return responseArray;
- }
- int index = name == null ? -1 : name.lastIndexOf(KEY_ARRAY);
- String className = index < 0 ? "" : name.substring(0, index);
-
- JSONArray transferredArray = new JSONArray();
-
- Object value;
- boolean isContainer = true;
- boolean isFirst = true;
- for (int i = 0; i < responseArray.size(); i++) {
- value = responseArray.get(i);
- if (value instanceof JSONArray) {//转化JSONArray内部的APIJSON Array
- transferredArray.add(format(null, (JSONArray) value));
- } else if (value instanceof JSONObject) {//JSONObject,往下一级提取
- //判断是否需要提取child
- if (isFirst && isTableKey(className) && ((JSONObject) value).containsKey(className)) {
- isContainer = false;
- }
- //直接添加child 或 添加提取出的child
- transferredArray.add(format(isContainer ? (JSONObject)value : ((JSONObject)value).getJSONObject(className) ));
- isFirst = false;
- } else {//其它Object,直接填充
- transferredArray.add(responseArray.get(i));
- }
- }
-
- //太长查看不方便,不如debug Log.i(TAG, "format return transferredArray = " + JSON.toJSONString(transferredArray));
- return transferredArray;
- }
-
- /**替换key+KEY_ARRAY为keyList
- * @param key
- * @return getSimpleName(isArrayKey(key) ? getArrayKey(...) : key) {@link #getSimpleName(String)}
- */
- public static String replaceArray(String key) {
- if (isArrayKey(key)) {
- key = getArrayKey(key.substring(0, key.lastIndexOf(KEY_ARRAY)));
- }
- return getSimpleName(key);
- }
- /**获取列表变量名
- * @param key => StringUtil.getNoBlankString(key)
- * @return empty ? "list" : key + "List" 且首字母小写
- */
- public static String getArrayKey(String key) {
- key = StringUtil.getNoBlankString(key);
- if (key.isEmpty()) {
- return "list";
- }
-
- String first = key.substring(0, 1);
- if (bigAlphaPattern.matcher(first).matches()) {
- key = first.toLowerCase() + key.substring(1, key.length());
- }
- return key + "List";
- }
-
- /**获取简单名称
- * @param fullName name 或 name:alias
- * @return name > name; name:alias > alias
- */
- public static String getSimpleName(String fullName) {
- //key:alias -> alias; key:alias[] -> alias[]
- int index = fullName == null ? -1 : fullName.indexOf(":");
- if (index >= 0) {
- fullName = fullName.substring(index + 1);
- }
- return fullName;
- }
-
-
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/APIJSONLibrary/src/main/java/zuo/biao/apijson/RequestMethod.java b/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/APIJSONLibrary/src/main/java/zuo/biao/apijson/RequestMethod.java
deleted file mode 100644
index 6a25809d1..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/APIJSONLibrary/src/main/java/zuo/biao/apijson/RequestMethod.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON)
-
-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 zuo.biao.apijson;
-
-/**请求方法,对应org.springframework.web.bind.annotation.RequestMethod,多出一个POST_GET方法
- * @author Lemon
- */
-public enum RequestMethod {
-
- /**
- * 常规获取数据方式
- */
- GET,
-
- /**
- * 检查,默认是非空检查,返回数据总数
- */
- HEAD,
-
- /**
- * 通过POST来GET数据,不显示请求内容和返回结果,一般用于对安全要求比较高的请求
- */
- POST_GET,
-
- /**
- * 通过POST来HEAD数据,不显示请求内容和返回结果,一般用于对安全要求比较高的请求
- */
- POST_HEAD,
-
- /**
- * 新增(或者说插入)数据
- */
- POST,
-
- /**
- * 修改数据,只修改传入字段对应的值
- */
- PUT,
-
- /**
- * 删除数据
- */
- DELETE
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/APIJSONLibrary/src/main/java/zuo/biao/apijson/StringUtil.java b/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/APIJSONLibrary/src/main/java/zuo/biao/apijson/StringUtil.java
deleted file mode 100644
index ac779ec2e..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/APIJSONLibrary/src/main/java/zuo/biao/apijson/StringUtil.java
+++ /dev/null
@@ -1,758 +0,0 @@
-/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON)
-
-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 zuo.biao.apijson;
-
-import java.io.File;
-import java.math.BigDecimal;
-import java.text.DecimalFormat;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**通用字符串(String)相关类,为null时返回""
- * @author Lemon
- * @use StringUtil.
- */
-public class StringUtil {
- private static final String TAG = "StringUtil";
-
- public StringUtil() {
- }
-
- public static final String UTF_8 = "utf-8";
-
- public static final String EMPTY = "无";
- public static final String UNKNOWN = "未知";
- public static final String UNLIMITED = "不限";
-
- public static final String I = "我";
- public static final String YOU = "你";
- public static final String HE = "他";
- public static final String SHE = "她";
- public static final String IT = "它";
-
- public static final String MALE = "男";
- public static final String FEMALE = "女";
-
- public static final String TODO = "未完成";
- public static final String DONE = "已完成";
-
- public static final String FAIL = "失败";
- public static final String SUCCESS = "成功";
-
- public static final String SUNDAY = "日";
- public static final String MONDAY = "一";
- public static final String TUESDAY = "二";
- public static final String WEDNESDAY = "三";
- public static final String THURSDAY = "四";
- public static final String FRIDAY = "五";
- public static final String SATURDAY = "六";
-
- public static final String YUAN = "元";
-
-
- private static String currentString = "";
- /**获取刚传入处理后的string
- * @must 上个影响currentString的方法 和 这个方法都应该在同一线程中,否则返回值可能不对
- * @return
- */
- public static String getCurrentString() {
- return currentString == null ? "" : currentString;
- }
-
- //获取string,为null时返回"" <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
- /**获取string,为null则返回""
- * @param object
- * @return
- */
- public static String getString(Object object) {
- return object == null ? "" : getString(String.valueOf(object));
- }
- /**获取string,为null则返回""
- * @param cs
- * @return
- */
- public static String getString(CharSequence cs) {
- return cs == null ? "" : getString(cs.toString());
- }
- /**获取string,为null则返回""
- * @param s
- * @return
- */
- public static String getString(String s) {
- return s == null ? "" : s;
- }
- /**获取string,为null则返回""
- * ignoreEmptyItem = false;
- * split = ","
- * @param array
- * @return {@link #getString(String[], boolean)}
- */
- public static String getString(String[] array) {
- return getString(array, false);
- }
- /**获取string,为null则返回""
- * split = ","
- * @param array
- * @param ignoreEmptyItem
- * @return {@link #getString(String[], String, boolean)}
- */
- public static String getString(String[] array, boolean ignoreEmptyItem) {
- return getString(array, null, ignoreEmptyItem);
- }
- /**获取string,为null则返回""
- * ignoreEmptyItem = false;
- * @param array
- * @param split
- * @return {@link #getString(String[], String, boolean)}
- */
- public static String getString(String[] array, String split) {
- return getString(array, split, false);
- }
- /**获取string,为null则返回""
- * @param array
- * @param split
- * @param ignoreEmptyItem
- * @return
- */
- public static String getString(String[] array, String split, boolean ignoreEmptyItem) {
- String s = "";
- if (array != null) {
- if (split == null) {
- split = ",";
- }
- for (int i = 0; i < array.length; i++) {
- if (ignoreEmptyItem && isEmpty(array[i], true)) {
- continue;
- }
- s += ((i > 0 ? split : "") + array[i]);
- }
- }
- return getString(s);
- }
-
- //获取string,为null时返回"" >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
- //获取去掉前后空格后的string<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
- /**获取去掉前后空格后的string,为null则返回""
- * @param object
- * @return
- */
- public static String getTrimedString(Object object) {
- return getTrimedString(getString(object));
- }
- /**获取去掉前后空格后的string,为null则返回""
- * @param cs
- * @return
- */
- public static String getTrimedString(CharSequence cs) {
- return getTrimedString(getString(cs));
- }
- /**获取去掉前后空格后的string,为null则返回""
- * @param s
- * @return
- */
- public static String getTrimedString(String s) {
- return getString(s).trim();
- }
-
- //获取去掉前后空格后的string>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
- //获取去掉所有空格后的string <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
- /**获取去掉所有空格后的string,为null则返回""
- * @param object
- * @return
- */
- public static String getNoBlankString(Object object) {
- return getNoBlankString(getString(object));
- }
- /**获取去掉所有空格后的string,为null则返回""
- * @param cs
- * @return
- */
- public static String getNoBlankString(CharSequence cs) {
- return getNoBlankString(getString(cs));
- }
- /**获取去掉所有空格后的string,为null则返回""
- * @param s
- * @return
- */
- public static String getNoBlankString(String s) {
- return getString(s).replaceAll("\\s", "");
- }
-
- //获取去掉所有空格后的string >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
- //获取string的长度<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
- /**获取string的长度,为null则返回0
- * @param object
- * @param trim
- * @return
- */
- public static int getLength(Object object, boolean trim) {
- return getLength(getString(object), trim);
- }
- /**获取string的长度,为null则返回0
- * @param cs
- * @param trim
- * @return
- */
- public static int getLength(CharSequence cs, boolean trim) {
- return getLength(getString(cs), trim);
- }
- /**获取string的长度,为null则返回0
- * @param s
- * @param trim
- * @return
- */
- public static int getLength(String s, boolean trim) {
- s = trim ? getTrimedString(s) : s;
- return getString(s).length();
- }
-
- //获取string的长度>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
- //判断字符是否为空 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
- /**判断字符是否为空
- * @param object
- * @param trim
- * @return
- */
- public static boolean isEmpty(Object object, boolean trim) {
- return isEmpty(getString(object), trim);
- }
- /**判断字符是否为空
- * @param cs
- * @param trim
- * @return
- */
- public static boolean isEmpty(CharSequence cs, boolean trim) {
- return isEmpty(getString(cs), trim);
- }
- /**判断字符是否为空
- * @param s
- * @param trim
- * @return
- */
- public static boolean isEmpty(String s, boolean trim) {
- // Log.i(TAG, "getTrimedString s = " + s);
- if (s == null) {
- return true;
- }
- if (trim) {
- s = s.trim();
- }
- if (s.isEmpty()) {
- return true;
- }
-
- currentString = s;
-
- return false;
- }
-
- //判断字符是否为空 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
- //判断字符是否非空 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
- /**判断字符是否非空
- * @param object
- * @param trim
- * @return
- */
- public static boolean isNotEmpty(Object object, boolean trim) {
- return isNotEmpty(getString(object), trim);
- }
- /**判断字符是否非空
- * @param cs
- * @param trim
- * @return
- */
- public static boolean isNotEmpty(CharSequence cs, boolean trim) {
- return isNotEmpty(getString(cs), trim);
- }
- /**判断字符是否非空
- * @param s
- * @param trim
- * @return
- */
- public static boolean isNotEmpty(String s, boolean trim) {
- return ! isEmpty(s, trim);
- }
-
- //判断字符是否非空 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
- //判断字符类型 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
- public static final Pattern alphaPattern;
- public static final Pattern bigAlphaPattern;
- public static final Pattern namePattern;
- public static final Pattern smallAlphaPattern;
- static {
- alphaPattern = Pattern.compile("[a-zA-Z]");
- bigAlphaPattern = Pattern.compile("[A-Z]");
- namePattern = Pattern.compile("^[0-9a-zA-Z_]+$");//已用55个中英字符测试通过
- smallAlphaPattern = Pattern.compile("[a-z]");
- }
-
- //判断手机格式是否正确
- public static boolean isPhone(String phone) {
- if (isNotEmpty(phone, true) == false) {
- return false;
- }
-
- Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0-2,5-9])|(17[0-9]))\\d{8}$");
-
- currentString = phone;
-
- return p.matcher(phone).matches();
- }
- //判断email格式是否正确
- public static boolean isEmail(String email) {
- if (isNotEmpty(email, true) == false) {
- return false;
- }
-
- String str = "^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
- Pattern p = Pattern.compile(str);
-
- currentString = email;
-
- return p.matcher(email).matches();
- }
-
- /**判断是否全是数字
- * @param s
- * @return
- */
- public static boolean isNumer(String s) {
- if (isNotEmpty(s, true) == false) {
- return false;
- }
-
- Pattern pattern = Pattern.compile("[0-9]");
- Matcher matcher;
- for (int i = 0; i < s.length(); i++) {
- matcher = pattern.matcher(s.substring(i, i+1));
- if(! matcher.matches()){
- return false;
- }
- }
-
- currentString = s;
-
- return true;
- }
- /**判断是否全是字母
- * @param s
- * @return
- */
- public static boolean isAlpha(String s) {
- if (s == null) {
- Log.i(TAG, "isNumberOrAlpha inputed == null >> return false;");
- return false;
- }
- Pattern pAlpha = Pattern.compile("[a-zA-Z]");
- Matcher mAlpha;
- for (int i = 0; i < s.length(); i++) {
- mAlpha = pAlpha.matcher(s.substring(i, i+1));
- if(! mAlpha.matches()){
- return false;
- }
- }
-
- currentString = s;
- return true;
- }
- /**判断是否全是数字或字母
- * @param s
- * @return
- */
- public static boolean isNumberOrAlpha(String s) {
- return isNumer(s) || isAlpha(s);
- }
-
- /**判断字符类型是否是身份证号
- * @param idCard
- * @return
- */
- public static boolean isIDCard(String idCard) {
- if (isNumberOrAlpha(idCard) == false) {
- return false;
- }
- idCard = getString(idCard);
- if (idCard.length() == 15) {
- Log.i(TAG, "isIDCard idCard.length() == 15 old IDCard");
- currentString = idCard;
- return true;
- }
- if (idCard.length() == 18) {
- currentString = idCard;
- return true;
- }
-
- return false;
- }
-
- public static final String HTTP = "http";
- public static final String URL_PREFIX = "http://";
- public static final String URL_PREFIXs = "https://";
- public static final String URL_STAFFIX = URL_PREFIX;
- public static final String URL_STAFFIXs = URL_PREFIXs;
- /**判断字符类型是否是网址
- * @param url
- * @return
- */
- public static boolean isUrl(String url) {
- if (isNotEmpty(url, true) == false) {
- return false;
- } else if (! url.startsWith(URL_PREFIX) && ! url.startsWith(URL_PREFIXs)) {
- return false;
- }
-
- currentString = url;
- return true;
- }
-
- public static final String FILE_PATH_PREFIX = "file://";
- /**判断文件路径是否存在
- * @param path
- * @return
- */
- public static boolean isFilePathExist(String path) {
- return StringUtil.isFilePath(path) && new File(path).exists();
- }
-
- public static final String SEPARATOR = "/";
- /**判断是否为路径
- * @param path
- * @return
- */
- public static boolean isPath(String path) {
- return StringUtil.isNotEmpty(path, true) && path.contains(SEPARATOR)
- && path.contains(SEPARATOR + SEPARATOR) == false && path.endsWith(SEPARATOR) == false;
- }
-
- /**判断字符类型是否是路径
- * @param path
- * @return
- */
- public static boolean isFilePath(String path) {
- if (isNotEmpty(path, true) == false) {
- return false;
- }
-
- if (! path.contains(".") || path.endsWith(".")) {
- return false;
- }
-
- currentString = path;
-
- return true;
- }
-
- //判断字符类型 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
- //提取特殊字符<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
- /**去掉string内所有非数字类型字符
- * @param object
- * @return
- */
- public static String getNumber(Object object) {
- return getNumber(getString(object));
- }
- /**去掉string内所有非数字类型字符
- * @param cs
- * @return
- */
- public static String getNumber(CharSequence cs) {
- return getNumber(getString(cs));
- }
- /**去掉string内所有非数字类型字符
- * @param s
- * @return
- */
- public static String getNumber(String s) {
- return getNumber(s, false);
- }
- /**去掉string内所有非数字类型字符
- * @param s
- * @param onlyStart 中间有非数字时只获取前面的数字
- * @return
- */
- public static String getNumber(String s, boolean onlyStart) {
- if (isNotEmpty(s, true) == false) {
- return "";
- }
-
- String numberString = "";
- String single;
- for (int i = 0; i < s.length(); i++) {
- single = s.substring(i, i + 1);
- if (isNumer(single)) {
- numberString += single;
- } else {
- if (onlyStart) {
- return numberString;
- }
- }
- }
-
- return numberString;
- }
-
- //提取特殊字符>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
- //校正(自动补全等)字符串<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
- /**获取网址,自动补全
- * @param url
- * @return
- */
- public static String getCorrectUrl(String url) {
- Log.i(TAG, "getCorrectUrl : \n" + url);
- if (isNotEmpty(url, true) == false) {
- return "";
- }
-
- // if (! url.endsWith("/") && ! url.endsWith(".html")) {
- // url = url + "/";
- // }
-
- if (isUrl(url) == false) {
- return URL_PREFIX + url;
- }
- return url;
- }
-
- /**获取去掉所有 空格 、"-" 、"+86" 后的phone
- * @param phone
- * @return
- */
- public static String getCorrectPhone(String phone) {
- if (isNotEmpty(phone, true) == false) {
- return "";
- }
-
- phone = getNoBlankString(phone);
- phone = phone.replaceAll("-", "");
- if (phone.startsWith("+86")) {
- phone = phone.substring(3);
- }
- return phone;
- }
-
-
- /**获取邮箱,自动补全
- * @param email
- * @return
- */
- public static String getCorrectEmail(String email) {
- if (isNotEmpty(email, true) == false) {
- return "";
- }
-
- email = getNoBlankString(email);
- if (isEmail(email) == false && ! email.endsWith(".com")) {
- email += ".com";
- }
-
- return email;
- }
-
-
- public static final int PRICE_FORMAT_DEFAULT = 0;
- public static final int PRICE_FORMAT_PREFIX = 1;
- public static final int PRICE_FORMAT_SUFFIX = 2;
- public static final int PRICE_FORMAT_PREFIX_WITH_BLANK = 3;
- public static final int PRICE_FORMAT_SUFFIX_WITH_BLANK = 4;
- public static final String[] PRICE_FORMATS = {
- "", "¥", "元", "¥ ", " 元"
- };
-
- /**获取价格,保留两位小数
- * @param price
- * @return
- */
- public static String getPrice(String price) {
- return getPrice(price, PRICE_FORMAT_DEFAULT);
- }
- /**获取价格,保留两位小数
- * @param price
- * @param formatType 添加单位(元)
- * @return
- */
- public static String getPrice(String price, int formatType) {
- if (isNotEmpty(price, true) == false) {
- return getPrice(0, formatType);
- }
-
- //单独写到getCorrectPrice? <<<<<<<<<<<<<<<<<<<<<<
- String correctPrice = "";
- String s;
- for (int i = 0; i < price.length(); i++) {
- s = price.substring(i, i + 1);
- if (".".equals(s) || isNumer(s)) {
- correctPrice += s;
- }
- }
- //单独写到getCorrectPrice? >>>>>>>>>>>>>>>>>>>>>>
-
- Log.i(TAG, "getPrice <<<<<<<<<<<<<<<<<< correctPrice = " + correctPrice);
- if (correctPrice.contains(".")) {
- // if (correctPrice.startsWith(".")) {
- // correctPrice = 0 + correctPrice;
- // }
- if (correctPrice.endsWith(".")) {
- correctPrice = correctPrice.replaceAll(".", "");
- }
- }
-
- Log.i(TAG, "getPrice correctPrice = " + correctPrice + " >>>>>>>>>>>>>>>>");
- return isNotEmpty(correctPrice, true) ? getPrice(new BigDecimal(0 + correctPrice), formatType) : getPrice(0, formatType);
- }
- /**获取价格,保留两位小数
- * @param price
- * @return
- */
- public static String getPrice(BigDecimal price) {
- return getPrice(price, PRICE_FORMAT_DEFAULT);
- }
- /**获取价格,保留两位小数
- * @param price
- * @return
- */
- public static String getPrice(double price) {
- return getPrice(price, PRICE_FORMAT_DEFAULT);
- }
- /**获取价格,保留两位小数
- * @param price
- * @param formatType 添加单位(元)
- * @return
- */
- public static String getPrice(BigDecimal price, int formatType) {
- return getPrice(price == null ? 0 : price.doubleValue(), formatType);
- }
- /**获取价格,保留两位小数
- * @param price
- * @param formatType 添加单位(元)
- * @return
- */
- public static String getPrice(double price, int formatType) {
- String s = new DecimalFormat("#########0.00").format(price);
- switch (formatType) {
- case PRICE_FORMAT_PREFIX:
- return PRICE_FORMATS[PRICE_FORMAT_PREFIX] + s;
- case PRICE_FORMAT_SUFFIX:
- return s + PRICE_FORMATS[PRICE_FORMAT_SUFFIX];
- case PRICE_FORMAT_PREFIX_WITH_BLANK:
- return PRICE_FORMATS[PRICE_FORMAT_PREFIX_WITH_BLANK] + s;
- case PRICE_FORMAT_SUFFIX_WITH_BLANK:
- return s + PRICE_FORMATS[PRICE_FORMAT_SUFFIX_WITH_BLANK];
- default:
- return s;
- }
- }
-
-
- /**分割路径
- * @param path
- * @return
- */
- public static String[] splitPath(String path) {
- if (StringUtil.isNotEmpty(path, true) == false) {
- return null;
- }
- return isPath(path) ? split(path, SEPARATOR) : new String[] {path};
- }
- /**将s分割成String[]
- * @param s
- * @return
- */
- public static String[] split(String s) {
- return split(s, null);
- }
- /**将s用split分割成String[]
- * @param s
- * @param split
- * @return
- */
- public static String[] split(String s, String split) {
- s = getString(s);
- if (s.isEmpty()) {
- return null;
- }
- if (isNotEmpty(split, false) == false) {
- split = ",";
- }
- while (s.startsWith(split)) {
- s = s.substring(split.length());
- }
- while (s.endsWith(split)) {
- s = s.substring(0, s.length() - split.length());
- }
- return s.contains(split) ? s.split(split) : new String[]{s};
- }
-
- /**
- * @param key
- * @param suffix
- * @return key + suffix,第一个字母小写
- */
- public static String addSuffix(String key, String suffix) {
- key = StringUtil.getNoBlankString(key);
- if (key.isEmpty()) {
- return firstCase(suffix);
- }
-
- return firstCase(key) + firstCase(suffix, true);
- }
- /**
- * @param key
- */
- public static String firstCase(String key) {
- return firstCase(key, false);
- }
- /**
- * @param key
- * @param upper
- * @return
- */
- public static String firstCase(String key, boolean upper) {
- key = StringUtil.getString(key);
- if (key.isEmpty()) {
- return "";
- }
-
- String first = key.substring(0, 1);
- key = (upper ? first.toUpperCase() : first.toLowerCase()) + key.substring(1, key.length());
-
- return key;
- }
-
-
- //校正(自动补全等)字符串>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/app/src/main/java/apijson/demo/client/manager/DataManager.java b/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/app/src/main/java/apijson/demo/client/manager/DataManager.java
deleted file mode 100755
index 06559dc1e..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/app/src/main/java/apijson/demo/client/manager/DataManager.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon)
-
-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 apijson.demo.client.manager;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-
-import apijson.demo.client.application.APIJSONApplication;
-import apijson.demo.client.model.User;
-import zuo.biao.library.util.JSON;
-import zuo.biao.library.util.Log;
-import zuo.biao.library.util.StringUtil;
-
-/**数据工具类
- * @author Lemon
- */
-public class DataManager {
- private final String TAG = "DataManager";
-
- private Context context;
- private DataManager(Context context) {
- this.context = context;
- }
-
- private static DataManager instance = new DataManager(APIJSONApplication.getInstance());
- public static DataManager getInstance() {
- return instance;
- }
-
- //用户 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
- private String PATH_USER = "PATH_USER";
-
- public final String KEY_USER = "KEY_USER";
- public final String KEY_USER_ID = "KEY_USER_ID";
- public final String KEY_USER_NAME = "KEY_USER_NAME";
- public final String KEY_USER_PHONE = "KEY_USER_PHONE";
-
- public final String KEY_CURRENT_USER_ID = "KEY_CURRENT_USER_ID";
- public final String KEY_LAST_USER_ID = "KEY_LAST_USER_ID";
-
-
- /**判断是否为当前用户
- * @param userId
- * @return
- */
- public boolean isCurrentUser(long userId) {
- return userId > 0 && userId == getCurrentUserId();
- }
-
- /**获取当前用户id
- * @return
- */
- public long getCurrentUserId() {
- User user = getCurrentUser();
- return user == null ? 0 : user.getId();
- }
-
- /**获取当前用户的手机号
- * @return
- */
- public String getCurrentUserPhone() {
- User user = getCurrentUser();
- return user == null ? "" : user.getPhone();
- }
- /**获取当前用户
- * @return
- */
- public User getCurrentUser() {
- SharedPreferences sdf = context.getSharedPreferences(PATH_USER, Context.MODE_PRIVATE);
- return sdf == null ? null : getUser(sdf.getLong(KEY_CURRENT_USER_ID, 0));
- }
-
-
- /**获取最后一次登录的用户的手机号
- * @return
- */
- public String getLastUserPhone() {
- User user = getLastUser();
- return user == null ? "" : user.getPhone();
- }
-
- /**获取最后一次登录的用户
- * @return
- */
- public User getLastUser() {
- SharedPreferences sdf = context.getSharedPreferences(PATH_USER, Context.MODE_PRIVATE);
- return sdf == null ? null : getUser(sdf.getLong(KEY_LAST_USER_ID, 0));
- }
-
- /**获取用户
- * @param userId
- * @return
- */
- public User getUser(long userId) {
- SharedPreferences sdf = context.getSharedPreferences(PATH_USER, Context.MODE_PRIVATE);
- if (sdf == null) {
- Log.e(TAG, "get sdf == null >> return;");
- return null;
- }
- Log.i(TAG, "getUser userId = " + userId);
- return JSON.parseObject(sdf.getString(StringUtil.getTrimedString(userId), null), User.class);
- }
-
-
- /**保存当前用户,只在登录或注销时调用
- * @param user user == null >> user = new User();
- */
- public void saveCurrentUser(User user) {
- SharedPreferences sdf = context.getSharedPreferences(PATH_USER, Context.MODE_PRIVATE);
- if (sdf == null) {
- Log.e(TAG, "saveUser sdf == null >> return;");
- return;
- }
- if (user == null) {
- Log.w(TAG, "saveUser user == null >> user = new User();");
- user = new User();
- }
- SharedPreferences.Editor editor = sdf.edit();
- editor.remove(KEY_LAST_USER_ID).putLong(KEY_LAST_USER_ID, getCurrentUserId());
- editor.remove(KEY_CURRENT_USER_ID).putLong(KEY_CURRENT_USER_ID, user.getId());
- editor.commit();
-
- saveUser(sdf, user);
- }
-
- /**保存用户
- * @param user
- */
- public void saveUser(User user) {
- saveUser(context.getSharedPreferences(PATH_USER, Context.MODE_PRIVATE), user);
- }
- /**保存用户
- * @param sdf
- * @param user
- */
- public void saveUser(SharedPreferences sdf, User user) {
- if (sdf == null || user == null) {
- Log.e(TAG, "saveUser sdf == null || user == null >> return;");
- return;
- }
- String key = StringUtil.getTrimedString(user.getId());
- Log.i(TAG, "saveUser key = user.getId() = " + user.getId());
- sdf.edit().remove(key).putString(key, JSON.toJSONString(user)).commit();
- }
-
- /**删除用户
- * @param sdf
- * @param userId
- */
- public void removeUser(SharedPreferences sdf, long userId) {
- if (sdf == null) {
- Log.e(TAG, "removeUser sdf == null >> return;");
- return;
- }
- sdf.edit().remove(StringUtil.getTrimedString(userId)).commit();
- }
-
- /**设置当前用户手机号
- * @param phone
- */
- public void setCurrentUserPhone(String phone) {
- User user = getCurrentUser();
- if (user == null) {
- user = new User();
- }
- user.setPhone(phone);
- saveUser(user);
- }
-
- /**设置当前用户姓名
- * @param name
- */
- public void setCurrentUserName(String name) {
- User user = getCurrentUser();
- if (user == null) {
- user = new User();
- }
- user.setName(name);
- saveUser(user);
- }
-
- //用户 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
-
-
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/app/src/main/java/apijson/demo/client/model/Verify.java b/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/app/src/main/java/apijson/demo/client/model/Verify.java
deleted file mode 100644
index d9f8ec21d..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/app/src/main/java/apijson/demo/client/model/Verify.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon)
-
-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 apijson.demo.client.model;
-
-import zuo.biao.library.util.StringUtil;
-
-
-/**验证码类
- * @author Lemon
- */
-public class Verify extends apijson.demo.server.model.Verify {
- private static final long serialVersionUID = 4298571449155754300L;
-
- public Verify() {
- super();
- }
- public Verify(long phone) {
- super(phone);
- }
- public Verify(String code) {
- this();
- setCode(code);
- }
-
- @Override
- public Long getId() {
- return value(super.getId());
- }
-
- /**服务器用id作为phone
- * @return
- */
- public String getPhone() {
- return "" + getId();
- }
- public Verify setPhone(String phone) {
- setId(Long.valueOf(0 + StringUtil.getNumber(phone)));
- return this;
- }
- public Verify setPhone(Long phone) {
- setId(Long.valueOf(0 + StringUtil.getNumber(phone)));
- return this;
- }
-
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/app/src/main/java/apijson/demo/server/model/Comment.java b/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/app/src/main/java/apijson/demo/server/model/Comment.java
deleted file mode 100644
index 83d0ff45a..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/app/src/main/java/apijson/demo/server/model/Comment.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON)
-
-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 apijson.demo.server.model;
-
-import zuo.biao.apijson.APIJSONRequest;
-import zuo.biao.apijson.BaseModel;
-import zuo.biao.apijson.RequestMethod;
-
-/**评论类
- * @author Lemon
- * @see
-*
POST:
-{
- "Comment":{
- "disallow":"id",
- "necessary":"userId,momentId,content"
- }
-}
- *
- */
-@APIJSONRequest(
- method = {RequestMethod.GET, RequestMethod.HEAD, RequestMethod.POST, RequestMethod.DELETE},
- POST = "{\"disallow\": \"id\", \"necessary\": \"userId,momentId,content\"}",
- DELETE = "{\"necessary\": \"id\"}"
- )
-public class Comment extends BaseModel {
- private static final long serialVersionUID = -1011007127735372824L;
-
- private Long toId;
- private Long userId;
- private Long momentId;
- private String content;
- public Comment() {
- super();
- }
- public Comment(long id) {
- this();
- setId(id);
- }
-
-
- public Long getToId() {
- return toId;
- }
- public Comment setToId(Long toId) {
- this.toId = toId;
- return this;
- }
- public Long getUserId() {
- return userId;
- }
- public Comment setUserId(Long userId) {
- this.userId = userId;
- return this;
- }
- public Long getMomentId() {
- return momentId;
- }
- public Comment setMomentId(Long momentId) {
- this.momentId = momentId;
- return this;
- }
- public String getContent() {
- return content;
- }
- public Comment setContent(String content) {
- this.content = content;
- return this;
- }
-
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/app/src/main/java/apijson/demo/server/model/Friend.java b/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/app/src/main/java/apijson/demo/server/model/Friend.java
deleted file mode 100644
index fd0d34d0f..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/app/src/main/java/apijson/demo/server/model/Friend.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON)
-
-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 apijson.demo.server.model;
-
-import zuo.biao.apijson.APIJSONRequest;
-import zuo.biao.apijson.BaseModel;
-import zuo.biao.apijson.RequestMethod;
-
-/**朋友类
- * @author Lemon
- * @see
- *
POST:
-{
- "Friend":{
- "disallow":"state",
- "necessary":"userId,toUserId"
- }
-}
- *
- *
PUT
-{
- "Friend":{
- "disallow":"!",
- "necessary":"id,state"
- }
-}
- *
- */
-@APIJSONRequest(
- method = {RequestMethod.POST_HEAD, RequestMethod.POST, RequestMethod.PUT},
- POST_HEAD = "{}",
- POST = "{\"disallow\": \"state\", \"necessary\": \"userId,toUserId\"}",
- PUT = "{\"disallow\": \"!\", \"necessary\": \"id,state\"}"
- )
-public class Friend extends BaseModel {
- private static final long serialVersionUID = -4478257698563522976L;
-
- public static final int STATE_SEND = 0;
- public static final int STATE_READ = 1;
- public static final int STATE_ACCEPT = 2;
- public static final int STATE_REFUSE = 4;
-
-
- private Long userId;//加好友方
- private Long toUserId;//被加好友方
- private String letter;//加友时稍的话
- private Integer state;//状态
-
- public Friend() {
- super();
- }
-
- public Friend(long id) {
- this();
- setId(id);
- }
-
-
- public Long getUserId() {
- return userId;
- }
-
- public Friend setUserId(Long userId) {
- this.userId = userId;
- return this;
- }
-
- public Long getToUserId() {
- return toUserId;
- }
-
- public Friend setToUserId(Long toUserId) {
- this.toUserId = toUserId;
- return this;
- }
-
- public String getLetter() {
- return letter;
- }
-
- public Friend setLetter(String letter) {
- this.letter = letter;
- return this;
- }
-
- public Integer getState() {
- return state;
- }
-
- public Friend setState(Integer state) {
- this.state = state;
- return this;
- }
-
-
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/app/src/main/java/apijson/demo/server/model/Login.java b/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/app/src/main/java/apijson/demo/server/model/Login.java
deleted file mode 100644
index 528bc1736..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/app/src/main/java/apijson/demo/server/model/Login.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON)
-
-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 apijson.demo.server.model;
-
-import zuo.biao.apijson.APIJSONRequest;
-import zuo.biao.apijson.BaseModel;
-import zuo.biao.apijson.RequestMethod;
-
-/**登录类
- * @author Lemon
- * @see
- *
POST_HEAD:
-{
- "Login":{
- "disallow":"!",
- "necessary":"userId,type"
- }
-}
- *
-*
POST:post_get/login
-{
- "User":{
- "necessary":"phone"
- },
- "Password":{
- "disallow":"!",
- "necessary":"password"
- }
-}
- *
-*
POST(logout):post/logout
-{
- "User":{
- "necessary":"phone"
- }
-}
- *
- */
-@SuppressWarnings("serial")
-@APIJSONRequest(
- method = {RequestMethod.POST_HEAD, RequestMethod.POST},
- POST_HEAD = "{\"disallow\": \"!\", \"necessary\": \"userId,type\"}",
- POST = "{\"User\": {\"necessary\": \"phone\"}, \"Password\": {\"disallow\": \"!\", \"necessary\": \"password\"}}"
- )
-public class Login extends BaseModel {
-
- public static final int TYPE_PASSWORD = 0;
- public static final int TYPE_VERIFY = 1;
-
- private Long userId;
- private Integer type;
-
- public Login() {
- super();
- }
- public Login(long userId) {
- this();
- setUserId(userId);
- }
-
- public Long getUserId() {
- return userId;
- }
- public Login setUserId(Long userId) {
- this.userId = userId;
- return this;
- }
-
- public Integer getType() {
- return type;
- }
- public Login setType(Integer type) {
- this.type = type;
- return this;
- }
-
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/app/src/main/java/apijson/demo/server/model/Moment.java b/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/app/src/main/java/apijson/demo/server/model/Moment.java
deleted file mode 100644
index 1d3ecae58..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/app/src/main/java/apijson/demo/server/model/Moment.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON)
-
-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 apijson.demo.server.model;
-
-import java.util.List;
-
-import zuo.biao.apijson.APIJSONRequest;
-import zuo.biao.apijson.BaseModel;
-import zuo.biao.apijson.RequestMethod;
-
-/**动态类
- * @author Lemon
- * @see
- *
POST:
-{
- "Moment":{
- "disallow":"id",
- "necessary":"userId,pictureList"
- }
-}
- *
- *
PUT:
-{
- "Moment":{
- "disallow":"userId,date",
- "necessary":"id"
- }
-}
- *
- */
-@APIJSONRequest(
- method = {RequestMethod.GET, RequestMethod.HEAD, RequestMethod.POST, RequestMethod.PUT, RequestMethod.DELETE},
- POST = "{\"disallow\": \"id\", \"necessary\": \"userId,pictureList\"}",
- PUT = "{\"disallow\": \"userId,date\", \"necessary\": \"id\"}",
- DELETE = "{\"necessary\": \"id\"}"
- )
-public class Moment extends BaseModel {
- private static final long serialVersionUID = -7437225320551780084L;
-
- private Long userId;
- private String content;
- private List pictureList;
- private List praiseUserIdList;
- private List commentIdList;
-
- public Moment() {
- super();
- }
- public Moment(long id) {
- this();
- setId(id);
- }
-
- public Long getUserId() {
- return userId;
- }
- public Moment setUserId(Long userId) {
- this.userId = userId;
- return this;
- }
- public String getContent() {
- return content;
- }
- public Moment setContent(String content) {
- this.content = content;
- return this;
- }
- public List getPictureList() {
- return pictureList;
- }
- public Moment setPictureList(List pictureList) {
- this.pictureList = pictureList;
- return this;
- }
- public List getPraiseUserIdList() {
- return praiseUserIdList;
- }
- public Moment setPraiseUserIdList(List praiseUserIdList) {
- this.praiseUserIdList = praiseUserIdList;
- return this;
- }
- public List getCommentIdList() {
- return commentIdList;
- }
- public Moment setCommentIdList(List commentIdList) {
- this.commentIdList = commentIdList;
- return this;
- }
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/app/src/main/java/apijson/demo/server/model/Password.java b/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/app/src/main/java/apijson/demo/server/model/Password.java
deleted file mode 100644
index 69d736975..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/app/src/main/java/apijson/demo/server/model/Password.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON)
-
-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 apijson.demo.server.model;
-
-import zuo.biao.apijson.APIJSONRequest;
-import zuo.biao.apijson.BaseModel;
-import zuo.biao.apijson.RequestMethod;
-import zuo.biao.apijson.StringUtil;
-
-/**密码类
- * @author Lemon
- * @see
- *
POST_HEAD:
-{
- "Password":{
- "disallow":"!",
- "necessary":"id,model"
- }
-}
- *
- *
PUT:put/loginPassword, put/payPassword
-{
- "Password":{
- "disallow":"!",
- "necessary":"id,password"
- },
- "necessary":"oldPassword"
-}
- *
- */
-@SuppressWarnings("serial")
-@APIJSONRequest(
- method = {RequestMethod.POST_HEAD, RequestMethod.PUT},
- POST_HEAD = "{\"disallow\": \"!\", \"necessary\": \"id,model\"}",
- PUT = "{\"Password\": {\"disallow\": \"!\", \"necessary\": \"id,password\"}, \"necessary\": \"oldPassword\"}"
- )
-public class Password extends BaseModel {
-
- private String model;//table是MySQL关键字不能用!
- private Integer type;
- private String password;
-
- public Password() {
- super();
- }
- public Password(String model, String phone) {
- this();
- setModel(model);
- setPhone(phone);
- }
- public Password(String model, String phone, String password) {
- this(model, phone);
- setPassword(password);
- }
-
- public Password setPhone(String phone) {
- setId(Long.valueOf(0 + StringUtil.getNumber(phone)));
- return this;
- }
-
- public String getModel() {
- return StringUtil.isNotEmpty(model, true) ? model : "User";
- }
- public Password setModel(String model) {
- this.model = model;
- return this;
- }
- public Integer getType() {
- return type;
- }
- public Password setType(Integer type) {
- this.type = type;
- return this;
- }
- public String getPassword() {
- return password;
- }
- public Password setPassword(String password) {
- this.password = password;
- return this;
- }
-
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/app/src/main/java/apijson/demo/server/model/User.java b/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/app/src/main/java/apijson/demo/server/model/User.java
deleted file mode 100644
index 7405d776d..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/app/src/main/java/apijson/demo/server/model/User.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON)
-
-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 apijson.demo.server.model;
-
-import java.util.List;
-
-import zuo.biao.apijson.APIJSONRequest;
-import zuo.biao.apijson.BaseModel;
-import zuo.biao.apijson.RequestMethod;
-
-/**用户类
- * @author Lemon
- * @see
- *
POST:post/register/user
-{
- "User":{
- "disallow":"id",
- "necessary":"name,phone"
- },
- "necessary":"loginPassword,verify"
-}
- *
- *
PUT:
-{
- "User":{
- "disallow":"phone",
- "necessary":"id"
- }
-}
- *
- *
PUT(User.phone):put/user/phone
-{
- "User":{
- "disallow":"!",
- "necessary":"id,phone"
- },
- "necessary":"loginPassword,verify"
-}
- *
- */
-@APIJSONRequest(
- method = {RequestMethod.GET, RequestMethod.HEAD, RequestMethod.PUT, RequestMethod.DELETE},
- POST = "{\"User\": {\"disallow\": \"id\", \"necessary\": \"name,phone\"}, \"necessary\": \"loginPassword,verify\"}",
- PUT = "{\"disallow\": \"phone\", \"necessary\": \"id\"}"
- )
-public class User extends BaseModel {
- private static final long serialVersionUID = -1635551656020732611L;
-
- public static final int SEX_MAIL = 0;
- public static final int SEX_FEMALE = 1;
- public static final int SEX_UNKNOWN = 2;
-
-
- private Integer sex; //性别
- private String head; //头像url
- private String name; //姓名
- private String phone; //手机
- private String tag; //标签
- private List pictureList; //照片列表
- private List friendIdList; //朋友列表
-
- /**默认构造方法,JSON等解析时必须要有
- */
- public User() {
- super();
- }
- public User(long id) {
- this();
- setId(id);
- }
-
- public Integer getSex() {
- return sex;
- }
- public User setSex(Integer sex) {
- this.sex = sex;
- return this;
- }
- public String getHead() {
- return head;
- }
- public User setHead(String head) {
- this.head = head;
- return this;
- }
- public String getName() {
- return name;
- }
- public User setName(String name) {
- this.name = name;
- return this;
- }
- public String getPhone() {
- return phone;
- }
- public User setPhone(String phone) {
- this.phone = phone;
- return this;
- }
- public List getPictureList() {
- return pictureList;
- }
- public User setPictureList(List pictureList) {
- this.pictureList = pictureList;
- return this;
- }
-
- public String getTag() {
- return tag;
- }
- public User setTag(String tag) {
- this.tag = tag;
- return this;
- }
-
- public List getFriendIdList() {
- return friendIdList;
- }
- public User setFriendIdList(List friendIdList) {
- this.friendIdList = friendIdList;
- return this;
- }
-
-
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/app/src/main/java/apijson/demo/server/model/Verify.java b/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/app/src/main/java/apijson/demo/server/model/Verify.java
deleted file mode 100644
index 8f827a5d4..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/app/src/main/java/apijson/demo/server/model/Verify.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON)
-
-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 apijson.demo.server.model;
-
-import zuo.biao.apijson.APIJSONRequest;
-import zuo.biao.apijson.BaseModel;
-import zuo.biao.apijson.RequestMethod;
-import zuo.biao.apijson.StringUtil;
-
-/**验证码类
- * @author Lemon
- * @see
- *
POST_GET:post_get/authCode
-{
- "Verify":{
- "disallow":"id"
- }
-}
- *
- *
POST:post/authCode
-{
- "Verify":{
- "disallow":"!",
- "necessary":"id"
- }
-}
- *
- */
-@SuppressWarnings("serial")
-@APIJSONRequest(
- method = {RequestMethod.POST_HEAD, RequestMethod.POST_GET, RequestMethod.POST},
- POST_GET = "{\"necessary\": \"id\"}",
- POST = "{\"disallow\": \"!\", \"necessary\": \"id\"}"
- )
-public class Verify extends BaseModel {
-
- private String code;
-
- public Verify() {
- super();
- }
- public Verify(String phone) {
- this();
- setPhone(phone);
- }
- public Verify(Long phone) {
- this();
- setId(phone);
- }
- public Verify(String phone, String code) {
- this(phone);
- setCode(code);
- }
-
-
- public String getCode() {
- return code;
- }
- public Verify setCode(String code) {
- this.code = code;
- return this;
- }
-
- //phone is not column
- // public String getPhone() {
- // return StringUtil.getString(getId());
- // }
- public Verify setPhone(String phone) {
- setId(Long.valueOf(0 + StringUtil.getNumber(phone)));
- return this;
- }
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/app/src/main/java/apijson/demo/server/model/Wallet.java b/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/app/src/main/java/apijson/demo/server/model/Wallet.java
deleted file mode 100644
index 86f6f3b22..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONApp/app/src/main/java/apijson/demo/server/model/Wallet.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON)
-
-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 apijson.demo.server.model;
-
-import java.math.BigDecimal;
-
-import zuo.biao.apijson.APIJSONRequest;
-import zuo.biao.apijson.BaseModel;
-import zuo.biao.apijson.RequestMethod;
-
-/**钱包类
- * @author Lemon
- * @see
- *
POST_GET:
-{
- "Wallet":{
- "disallow":"!",
- "necessary":"userId"
- }
-}
- *
- *
POST:post/wallet
-{
- "Wallet":{
- "disallow":"!",
- "necessary":"userId"
- },
- "necessary":"payPassword"
-}
- *
- *
PUT:put/wallet
-{
- "Wallet":{
- "disallow":"!",
- "necessary":"userId,balance+"
- },
- "necessary":"payPassword,oldPassword"
-}
- *
- *
DELETE:delete/wallet
-{
- "Wallet":{
- "disallow":"!",
- "necessary":"userId"
- },
- "necessary":"payPassword"
-}
- *
- */
-@APIJSONRequest(
- method = {RequestMethod.POST_GET, RequestMethod.POST, RequestMethod.PUT, RequestMethod.DELETE},
- POST_GET = "{\"disallow\": \"!\", \"necessary\": \"userId\"}",
- POST = "{\"Wallet\": {\"disallow\": \"!\", \"necessary\": \"userId\"}, \"necessary\": \"payPassword\"}",
- PUT = "{\"Wallet\": {\"disallow\": \"!\", \"necessary\": \"userId,balance+\"}, \"necessary\": \"payPassword,oldPassword\"}",
- DELETE = "{\"Wallet\": {\"disallow\": \"!\", \"necessary\": \"userId\"}, \"necessary\": \"payPassword\"}"
- )
-public class Wallet extends BaseModel {
- private static final long serialVersionUID = 4298571449155754300L;
-
- public BigDecimal balance;
-
- private Long userId;
-
- /**默认构造方法,JSON等解析时必须要有
- */
- public Wallet() {
- super();
- }
- public Wallet(long id) {
- this();
- setId(id);
- }
-
- public Long getUserId() {
- return userId;
- }
- public Wallet setUserId(Long userId) {
- this.userId = userId;
- return this;
- }
-
- public BigDecimal getBalance() {
- return balance;
- }
- public Wallet setBalance(BigDecimal balance) {
- this.balance = balance;
- return this;
- }
-
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/APIJSON(AndroidStudio).iml b/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/APIJSON(AndroidStudio).iml
deleted file mode 100644
index 8e7b54319..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/APIJSON(AndroidStudio).iml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/APIJSONLibrary/APIJSONLibrary.iml b/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/APIJSONLibrary/APIJSONLibrary.iml
deleted file mode 100644
index 53245c8f7..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/APIJSONLibrary/APIJSONLibrary.iml
+++ /dev/null
@@ -1,107 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- generateDebugSources
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/APIJSONLibrary/src/main/java/zuo/biao/apijson/APIJSONRequest.java b/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/APIJSONLibrary/src/main/java/zuo/biao/apijson/APIJSONRequest.java
deleted file mode 100644
index a00fc0416..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/APIJSONLibrary/src/main/java/zuo/biao/apijson/APIJSONRequest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON)
-
-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 zuo.biao.apijson;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**请求方法对应的JSON结构
- * @author Lemon
- */
-@Target({ElementType.METHOD, ElementType.TYPE})
-@Retention(RetentionPolicy.RUNTIME)
-@Documented
-public @interface APIJSONRequest {
-
- /**
- * @return 允许的请求方法
- */
- RequestMethod[] method() default {};
-
-
- /**@see {@link RequestMethod#POST_GET}
- * @return 该请求方法允许的结构
- */
- String POST_GET() default "";
-
- /**@see {@link RequestMethod#POST_HEAD}
- * @return 该请求方法允许的结构
- */
- String POST_HEAD() default "";
-
- /**@see {@link RequestMethod#POST}
- * @return 该请求方法允许的结构
- */
- String POST() default "";
-
- /**@see {@link RequestMethod#PUT}
- * @return 该请求方法允许的结构
- */
- String PUT() default "";
-
- /**@see {@link RequestMethod#DELETE}
- * @return 该请求方法允许的结构
- */
- String DELETE() default "";
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/APIJSONLibrary/src/main/java/zuo/biao/apijson/FunctionList.java b/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/APIJSONLibrary/src/main/java/zuo/biao/apijson/FunctionList.java
deleted file mode 100644
index 6dc2d3407..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/APIJSONLibrary/src/main/java/zuo/biao/apijson/FunctionList.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON)
-
-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 zuo.biao.apijson;
-
-import java.util.Collection;
-import java.util.Map;
-
-/**可远程调用的函数列表
- * @author Lemon
- */
-public interface FunctionList {
-
- //判断是否为空 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- /**判断collection是否为空
- * @param collection
- * @return
- */
- public boolean isEmpty(Collection collection);
- /**判断map是否为空
- * @param
- * @param
- * @param map
- * @return
- */
- public boolean isEmpty(Map map);
- //判断是否为空 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
- //判断是否为包含 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- /**判断collection是否包含object
- * @param collection
- * @param object
- * @return
- */
- public boolean isContain(Collection collection, T object);
- /**判断map是否包含key
- * @param
- * @param
- * @param map
- * @param key
- * @return
- */
- public boolean isContainKey(Map map, K key);
- /**判断map是否包含value
- * @param
- * @param
- * @param map
- * @param value
- * @return
- */
- public boolean isContainValue(Map map, V value);
- //判断是否为包含 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
- //获取集合长度 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- /**获取数量
- * @param
- * @param array
- * @return
- */
- public int count(T[] array);
- /**获取数量
- * @param
- * @param collection List, Vector, Set等都是Collection的子类
- * @return
- */
- public int count(Collection collection);
- /**获取数量
- * @param
- * @param
- * @param map
- * @return
- */
- public int count(Map map);
- //获取集合长度 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
- //获取集合长度 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- /**获取
- * @param
- * @param array
- * @return
- */
- public T get(T[] array, int position);
- /**获取
- * @param
- * @param collection List, Vector, Set等都是Collection的子类
- * @return
- */
- public T get(Collection collection, int position);
- /**获取
- * @param
- * @param
- * @param map null ? null
- * @param key null ? null : map.get(key);
- * @return
- */
- public V get(Map map, K key);
- //获取集合长度 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
-
- //获取非基本类型对应基本类型的非空值 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- /**获取非空值
- * @param value
- * @return
- */
- public boolean value(Boolean value);
- /**获取非空值
- * @param value
- * @return
- */
- public int value(Integer value);
- /**获取非空值
- * @param value
- * @return
- */
- public long value(Long value);
- /**获取非空值
- * @param value
- * @return
- */
- public float value(Float value);
- /**获取非空值
- * @param value
- * @return
- */
- public double value(Double value);
- //获取非基本类型对应基本类型的非空值 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-}
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/APIJSONLibrary/src/main/java/zuo/biao/apijson/JSON.java b/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/APIJSONLibrary/src/main/java/zuo/biao/apijson/JSON.java
deleted file mode 100644
index e52532d6a..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/APIJSONLibrary/src/main/java/zuo/biao/apijson/JSON.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON)
-
-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 zuo.biao.apijson;
-
-import java.util.List;
-
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.alibaba.fastjson.parser.Feature;
-import com.alibaba.fastjson.serializer.SerializerFeature;
-
-/**阿里FastJSON封装类 防止解析时异常
- * @author Lemon
- */
-public class JSON {
- private static final String TAG = "JSON";
-
- /**判断json格式是否正确
- * @param s
- * @return
- */
- public static boolean isJsonCorrect(String s) {
- //太长 Log.i(TAG, "isJsonCorrect <<<< " + s + " >>>>>>>");
- if (s == null
- // || s.equals("[]")
- // || s.equals("{}")
- || s.equals("")
- || s.equals("[null]")
- || s.equals("{null}")
- || s.equals("null")) {
- return false;
- }
- return true;
- }
-
- /**获取有效的json
- * @param s
- * @return
- */
- public static String getCorrectJson(String s) {
- return getCorrectJson(s, false);
- }
- /**获取有效的json
- * @param s
- * @param isArray
- * @return
- */
- public static String getCorrectJson(String s, boolean isArray) {
- s = StringUtil.getTrimedString(s);
- // if (isArray) {
- // if (s.startsWith("\"")) {
- // s = s.substring(1);
- // }
- // if (s.endsWith("\"")) {
- // s = s.substring(0, s.length() - 1);
- // }
- // }
- return s;//isJsonCorrect(s) ? s : null;
- }
-
- /**json转JSONObject
- * @param json
- * @return
- */
- public static JSONObject parseObject(Object obj) {
- return parseObject(toJSONString(obj));
- }
- /**json转JSONObject
- * @param json
- * @return
- */
- public static JSONObject parseObject(String json) {
- int features = com.alibaba.fastjson.JSON.DEFAULT_PARSER_FEATURE;
- features |= Feature.OrderedField.getMask();
- return parseObject(json, features);
- }
- /**json转JSONObject
- * @param json
- * @param features
- * @return
- */
- public static JSONObject parseObject(String json, int features) {
- try {
- return com.alibaba.fastjson.JSON.parseObject(getCorrectJson(json), JSONObject.class, features);
- } catch (Exception e) {
- Log.i(TAG, "parseObject catch \n" + e.getMessage());
- }
- return null;
- }
-
- /**JSONObject转实体类
- * @param object
- * @param clazz
- * @return
- */
- public static T parseObject(JSONObject object, Class clazz) {
- return parseObject(toJSONString(object), clazz);
- }
- /**json转实体类
- * @param json
- * @param clazz
- * @return
- */
- public static T parseObject(String json, Class clazz) {
- try {
- int features = com.alibaba.fastjson.JSON.DEFAULT_PARSER_FEATURE;
- features |= Feature.OrderedField.getMask();
- return com.alibaba.fastjson.JSON.parseObject(getCorrectJson(json), clazz, features);
- } catch (Exception e) {
- Log.i(TAG, "parseObject catch \n" + e.getMessage());
- }
- return null;
- }
-
- /**json转JSONArray
- * @param json
- * @return
- */
- public static JSONArray parseArray(String json) {
- try {
- return com.alibaba.fastjson.JSON.parseArray(getCorrectJson(json, true));
- } catch (Exception e) {
- Log.i(TAG, "parseArray catch \n" + e.getMessage());
- }
- return null;
- }
- /**JSONArray转实体类列表
- * @param array
- * @param clazz
- * @return
- */
- public static List parseArray(JSONArray array, Class clazz) {
- return parseArray(toJSONString(array), clazz);
- }
- /**json转实体类列表
- * @param json
- * @param clazz
- * @return
- */
- public static List parseArray(String json, Class clazz) {
- try {
- return com.alibaba.fastjson.JSON.parseArray(getCorrectJson(json, true), clazz);
- } catch (Exception e) {
- Log.i(TAG, "parseArray catch \n" + e.getMessage());
- }
- return null;
- }
-
- /**实体类转json
- * @param obj
- * @return
- */
- public static String toJSONString(Object obj) {
- if (obj instanceof String) {
- return (String) obj;
- }
- try {
- return com.alibaba.fastjson.JSON.toJSONString(obj);
- } catch (Exception e) {
- Log.e(TAG, "toJSONString catch \n" + e.getMessage());
- }
- return null;
- }
-
- /**实体类转json
- * @param obj
- * @param features
- * @return
- */
- public static String toJSONString(Object obj, SerializerFeature... features) {
- if (obj instanceof String) {
- return (String) obj;
- }
- try {
- return com.alibaba.fastjson.JSON.toJSONString(obj, features);
- } catch (Exception e) {
- Log.e(TAG, "parseArray catch \n" + e.getMessage());
- }
- return null;
- }
-
- /**格式化,显示更好看
- * @param json
- * @return
- */
- public static String format(String json) {
- return format(parseObject(json));
- }
- /**格式化,显示更好看
- * @param object
- * @return
- */
- public static String format(JSONObject object) {
- return toJSONString(object, SerializerFeature.PrettyFormat);
- }
-
- /**判断是否为JSONObject
- * @param obj instanceof String ? parseObject
- * @return
- */
- public static boolean isJSONObject(Object obj) {
- if (obj instanceof JSONObject) {
- return true;
- }
- if (obj instanceof String) {
- try {
- JSONObject json = parseObject((String) obj);
- return json != null && json.isEmpty() == false;
- } catch (Exception e) {
- Log.e(TAG, "isJSONObject catch \n" + e.getMessage());
- }
- }
-
- return false;
- }
- /**判断是否为JSONArray
- * @param obj instanceof String ? parseArray
- * @return
- */
- public static boolean isJSONArray(Object obj) {
- if (obj instanceof JSONArray) {
- return true;
- }
- if (obj instanceof String) {
- try {
- JSONArray json = parseArray((String) obj);
- return json != null && json.isEmpty() == false;
- } catch (Exception e) {
- Log.e(TAG, "isJSONArray catch \n" + e.getMessage());
- }
- }
-
- return false;
- }
-
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/APIJSONLibrary/src/main/java/zuo/biao/apijson/JSONObject.java b/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/APIJSONLibrary/src/main/java/zuo/biao/apijson/JSONObject.java
deleted file mode 100644
index d030e71f7..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/APIJSONLibrary/src/main/java/zuo/biao/apijson/JSONObject.java
+++ /dev/null
@@ -1,432 +0,0 @@
-/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON)
-
-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 zuo.biao.apijson;
-
-import static zuo.biao.apijson.StringUtil.UTF_8;
-import static zuo.biao.apijson.StringUtil.bigAlphaPattern;
-import static zuo.biao.apijson.StringUtil.namePattern;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import java.net.URLEncoder;
-import java.util.Set;
-
-
-/**use this class instead of com.alibaba.fastjson.JSONObject, not encode in default cases
- * @author Lemon
- */
-public class JSONObject extends com.alibaba.fastjson.JSONObject {
- private static final long serialVersionUID = 8907029699680768212L;
-
- /**ordered
- */
- public JSONObject() {
- super(true);
- }
- /**transfer Object to JSONObject
- * encode = false;
- * @param object
- * @see {@link #JSONObject(Object, boolean)}
- */
- public JSONObject(Object object) {
- this(object, false);
- }
- /**transfer Object to JSONObject
- * @param object
- * @param encode
- * @see {@link #JSONObject(String, boolean)}
- */
- public JSONObject(Object object, boolean encode) {
- this(toJSONString(object), encode);
- }
- /**parse JSONObject with JSON String
- * encode = false;
- * @param json
- * @see {@link #JSONObject(String, boolean)}
- */
- public JSONObject(String json) {
- this(json, false);
- }
- /**parse JSONObject with JSON String
- * @param json
- * @param encode
- * @see {@link #JSONObject(com.alibaba.fastjson.JSONObject, boolean)}
- */
- public JSONObject(String json, boolean encode) {
- this(parseObject(json), encode);
- }
- /**transfer com.alibaba.fastjson.JSONObject to JSONObject
- * encode = false;
- * @param object
- * @see {@link #JSONObject(com.alibaba.fastjson.JSONObject, boolean)}
- */
- public JSONObject(com.alibaba.fastjson.JSONObject object) {
- this(object, false);
- }
- /**transfer com.alibaba.fastjson.JSONObject to JSONObject
- * @param object
- * @param encode
- * @see {@link #add(com.alibaba.fastjson.JSONObject, boolean)}
- */
- public JSONObject(com.alibaba.fastjson.JSONObject object, boolean encode) {
- this();
- add(object, encode);
- }
-
-
-
-
- /**put key-value in object into this
- * encode = false;
- * @param object
- * @return {@link #add(com.alibaba.fastjson.JSONObject, boolean)}
- */
- public JSONObject add(com.alibaba.fastjson.JSONObject object) {
- return add(object, false);
- }
- /**put key-value in object into this
- * @param object
- * @param encode
- * @return this
- */
- public JSONObject add(com.alibaba.fastjson.JSONObject object, boolean encode) {
- Set set = object == null ? null : object.keySet();
- if (set != null) {
- for (String key : set) {
- put(key, object.get(key), encode);
- }
- }
- return this;
- }
-
-
-
- /**
- * @param key if decode && key instanceof String, key = URLDecoder.decode((String) key, UTF_8)
- * @param decode if decode && value instanceof String, value = URLDecoder.decode((String) value, UTF_8)
- * @return
- */
- public Object get(Object key, boolean decode) {
- if (decode) {
- if (key instanceof String) {
- if (((String) key).endsWith("+") || ((String) key).endsWith("-")) {
- try {//多层encode导致内部Comment[]传到服务端decode后最终变为Comment%5B%5D
- key = URLDecoder.decode((String) key, UTF_8);
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- return null;
- }
- }
- }
- Object value = super.get(key);
- if (value instanceof String) {
- try {
- value = URLDecoder.decode((String) value, UTF_8);
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- }
- return value;
- }
- return super.get(key);
- }
-
- /**
- * encode = false
- * @param value must be annotated by {@link APIJSONRequest}
- * @return {@link #put(String, boolean)}
- */
- public Object put(Object value) {
- return put(value, false);
- }
- /**
- * key = value.getClass().getSimpleName()
- * @param value must be annotated by {@link APIJSONRequest}
- * @param encode
- * @return {@link #put(String, Object, boolean)}
- */
- public Object put(Object value, boolean encode) {
- return put(null, value, encode);
- }
- /**
- * @param key if StringUtil.isNotEmpty(key, true) == false,
- *
key = value == null ? null : value.getClass().getSimpleName();
- *
>> if decode && key instanceof String, key = URLDecoder.decode((String) key, UTF_8)
- * @param value URLEncoder.encode((String) value, UTF_8);
- * @param encode if value instanceof String, value = URLEncoder.encode((String) value, UTF_8);
- * @return
- */
- public Object put(String key, Object value, boolean encode) {
- if (StringUtil.isNotEmpty(key, true) == false) {
- Class> clazz = value == null ? null : value.getClass();
- if (clazz == null || clazz.getAnnotation(APIJSONRequest.class) == null) {
- throw new IllegalArgumentException("put StringUtil.isNotEmpty(key, true) == false" +
- " && clazz == null || clazz.getAnnotation(APIJSONRequest.class) == null" +
- " \n key为空时仅支持 类型被@APIJSONRequest注解 的value !!!" +
- " \n 如果一定要这么用,请对 " + clazz.getName() + " 注解!" +
- " \n 如果是类似 key[]:{} 结构的请求,建议add(...)方法!");
- }
- key = value.getClass().getSimpleName();
- }
- if (encode) {
- if (key.endsWith("+") || key.endsWith("-")) {
- try {//多层encode导致内部Comment[]传到服务端decode后最终变为Comment%5B%5D
- key = URLEncoder.encode(key, UTF_8);
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- }
- if (value instanceof String) {//只在value instanceof String时encode key?{@link #get(Object, boolean)}内做不到
- try {
- value = URLEncoder.encode((String) value, UTF_8);
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- }
- }
- return super.put(key, value);
- }
-
-
-
- //judge <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- public static final String KEY_ARRAY = "[]";
-
- /**判断是否为Array的key
- * @param key
- * @return
- */
- public static boolean isArrayKey(String key) {
- return key != null && key.endsWith(KEY_ARRAY);
- }
- /**判断是否为对应Table的key
- * @param key
- * @return
- */
- public static boolean isTableKey(String key) {
- return isWord(key) && bigAlphaPattern.matcher(key.substring(0, 1)).matches();
- }
- /**判断是否为词,只能包含字母,数字或下划线
- * @param key
- * @return
- */
- public static boolean isWord(String key) {
- return StringUtil.isNotEmpty(key, false) && namePattern.matcher(key).matches();
- }
- //judge >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
- //JSONObject内关键词 key <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
- public static final String KEY_COLUMN = "@column";//@key关键字都放这个类
- public static final String KEY_GROUP = "@group";//@key关键字都放这个类
- public static final String KEY_HAVING = "@having";//@key关键字都放这个类
- public static final String KEY_ORDER = "@order";//@key关键字都放这个类
-
- /**set keys need to be returned
- * @param keys key0, key1, key2 ...
- * @return {@link #setColumn(String)}
- */
- public JSONObject setColumn(String... keys) {
- return setColumn(StringUtil.getString(keys, true));
- }
- /**set keys need to be returned
- * @param keys "key0,key1,key2..."
- * @return
- */
- public JSONObject setColumn(String keys) {
- put(KEY_COLUMN, keys);
- return this;
- }
- public String getColumn() {
- return getString(KEY_COLUMN);
- }
-
- /**set keys for group by
- * @param keys key0, key1, key2 ...
- * @return {@link #setGroup(String)}
- */
- public JSONObject setGroup(String... keys) {
- return setGroup(StringUtil.getString(keys, true));
- }
- /**set keys for group by
- * @param keys "key0,key1,key2..."
- * @return
- */
- public JSONObject setGroup(String keys) {
- put(KEY_GROUP, keys);
- return this;
- }
- public String getGroup() {
- return getString(KEY_GROUP);
- }
-
- /**set keys for having
- * @param keys count(key0) > 1, sum(key1) <= 5, function2(key2) ? value2 ...
- * @return {@link #setHaving(String)}
- */
- public JSONObject setHaving(String... keys) {
- return setHaving(StringUtil.getString(keys, true));
- }
- /**set keys for having
- * @param keys "key0,key1,key2..."
- * @return
- */
- public JSONObject setHaving(String keys) {
- put(KEY_HAVING, keys);
- return this;
- }
- public String getHaving() {
- return getString(KEY_HAVING);
- }
-
- /**set keys for order by
- * @param keys key0, key1+, key2- ...
- * @return {@link #setOrder(String)}
- */
- public JSONObject setOrder(String... keys) {
- return setOrder(StringUtil.getString(keys, true));
- }
- /**set keys for order by
- * @param keys "key0,key1+,key2-..."
- * @return
- */
- public JSONObject setOrder(String keys) {
- put(KEY_ORDER, keys);
- return this;
- }
- public String getOrder() {
- return getString(KEY_ORDER);
- }
-
-
- //JSONObject内关键词 key >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
-
- //Request,默认encode <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
-
- /**
- * encode = true
- * @param value
- * @param parts path = keys[0] + "/" + keys[1] + "/" + keys[2] + ...
- * @return #put(key+"@", StringUtil.getString(keys, "/"), true)
- */
- public Object putPath(String key, String... keys) {
- return put(key+"@", StringUtil.getString(keys, "/"), true);
- }
-
- /**
- * encode = true
- * @param key
- * @param isNull
- * @return {@link #putNull(String, boolean, boolean)}
- */
- public JSONObject putNull(String key, boolean isNull) {
- return putNull(key, isNull, true);
- }
- /**
- * @param key
- * @param isNull
- * @param encode
- * @return put(key+"{}", SQL.isNull(isNull), encode);
- */
- public JSONObject putNull(String key, boolean isNull, boolean encode) {
- put(key+"{}", SQL.isNull(isNull), encode);
- return this;
- }
- /**
- * trim = false
- * @param key
- * @param isEmpty
- * @return {@link #putEmpty(String, boolean, boolean)}
- */
- public JSONObject putEmpty(String key, boolean isEmpty) {
- return putEmpty(key, isEmpty, false);
- }
- /**
- * encode = true
- * @param key
- * @param isEmpty
- * @return {@link #putEmpty(String, boolean, boolean, boolean)}
- */
- public JSONObject putEmpty(String key, boolean isEmpty, boolean trim) {
- return putEmpty(key, isEmpty, trim, true);
- }
- /**
- * @param key
- * @param isEmpty
- * @param encode
- * @return put(key+"{}", SQL.isEmpty(key, isEmpty, trim), encode);
- */
- public JSONObject putEmpty(String key, boolean isEmpty, boolean trim, boolean encode) {
- put(key+"{}", SQL.isEmpty(key, isEmpty, trim), encode);
- return this;
- }
- /**
- * encode = true
- * @param key
- * @param compare <=0, >5 ...
- * @return {@link #putLength(String, String, boolean)}
- */
- public JSONObject putLength(String key, String compare) {
- return putLength(key, compare, true);
- }
- /**
- * @param key
- * @param compare <=0, >5 ...
- * @param encode
- * @return put(key+"{}", SQL.length(key) + compare, encode);
- */
- public JSONObject putLength(String key, String compare, boolean encode) {
- put(key+"{}", SQL.length(key) + compare, encode);
- return this;
- }
-
- /**设置搜索
- * type = SEARCH_TYPE_CONTAIN_FULL
- * @param key
- * @param value
- * @return {@link #putSearch(String, String, int)}
- */
- public JSONObject putSearch(String key, String value) {
- return putSearch(key, value, SQL.SEARCH_TYPE_CONTAIN_FULL);
- }
- /**设置搜索
- * encode = true
- * @param key
- * @param value
- * @param type
- * @return {@link #putSearch(String, String, int, boolean)}
- */
- public JSONObject putSearch(String key, String value, int type) {
- return putSearch(key, value, type, true);
- }
- /**设置搜索
- * @param key
- * @param value
- * @param type
- * @param encode
- * @return put(key+"$", SQL.search(value, type), encode);
- */
- public JSONObject putSearch(String key, String value, int type, boolean encode) {
- put(key+"$", SQL.search(value, type), encode);
- return this;
- }
-
- //Request,默认encode >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/APIJSONLibrary/src/main/java/zuo/biao/apijson/JSONRequest.java b/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/APIJSONLibrary/src/main/java/zuo/biao/apijson/JSONRequest.java
deleted file mode 100644
index 6bd3bce73..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/APIJSONLibrary/src/main/java/zuo/biao/apijson/JSONRequest.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON)
-
-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 zuo.biao.apijson;
-
-/**encapsulator for request JSONObject, encode in default cases
- * @author Lemon
- * @see #toArray
- * @use JSONRequest request = new JSONRequest(...);
- *
request.put(...);//not a must
- *
request.toArray(...);//not a must
- */
-public class JSONRequest extends JSONObject {
-
- private static final long serialVersionUID = -2223023180338466812L;
-
- public JSONRequest() {
- super();
- }
- /**
- * encode = true
- * @param object must be annotated by {@link APIJSONRequest}
- * @see {@link #JSONRequest(String, Object)}
- */
- public JSONRequest(Object object) {
- this(null, object);
- }
- /**
- * encode = true
- * @param name
- * @param object
- * @see {@link #JSONRequest(String, Object, boolean)}
- */
- public JSONRequest(String name, Object object) {
- this(name, object, true);
- }
- /**
- * @param object must be annotated by {@link APIJSONRequest}
- * @param encode
- * @see {@link #JSONRequest(String, Object, boolean)}
- */
- public JSONRequest(Object object, boolean encode) {
- this(null, object, encode);
- }
- /**
- * @param name
- * @param object
- * @param encode
- * @see {@link #put(String, Object, boolean)}
- */
- public JSONRequest(String name, Object object, boolean encode) {
- this();
- put(name, object, encode);
- }
-
-
-
-
-
-
- public static final String KEY_TAG = "tag";//只在最外层,最外层用JSONRequest
-
- public JSONObject setTag(String tag) {
- put(KEY_TAG, tag);
- return this;
- }
- public String getTag() {
- return getString(KEY_TAG);
- }
-
-
- //array object <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
- public static final int QUERY_TABLE = 0;
- public static final int QUERY_TOTAL = 1;
- public static final int QUERY_ALL = 2;
-
- public static final String KEY_QUERY = "query";
- public static final String KEY_COUNT = "count";
- public static final String KEY_PAGE = "page";
-
- /**
- * @param query what need to query, Table,total,ALL?
- * @return
- */
- public JSONRequest setQuery(int query) {
- put(KEY_QUERY, query);
- return this;
- }
- public int getQuery() {
- return getIntValue(KEY_QUERY);
- }
-
- /**
- * @param count
- * @return
- */
- public JSONRequest setCount(int count) {
- put(KEY_COUNT, count);
- return this;
- }
- public int getCount() {
- return getIntValue(KEY_COUNT);
- }
-
- /**
- * @param page
- * @return
- */
- public JSONRequest setPage(int page) {
- put(KEY_PAGE, page);
- return this;
- }
- public int getPage() {
- return getIntValue(KEY_PAGE);
- }
- //array object >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
-
-
- // 导致JSONObject add >> get = null
- // /**
- // * decode = true
- // * @param key
- // * return {@link #get(Object, boolean)}
- // */
- // @Override
- // public Object get(Object key) {
- // return get(key, true);
- // }
-
- /**
- * encode = true
- * @param value must be annotated by {@link APIJSONRequest}
- * @return {@link #put(String, boolean)}
- */
- @Override
- public Object put(Object value) {
- return put(value, true);
- }
- /**
- * encode = true
- * @param key
- * @param value
- * return {@link #put(String, Object, boolean)}
- */
- @Override
- public Object put(String key, Object value) {
- return put(key, value, true);
- }
-
-
- /**create a parent JSONObject named KEY_ARRAY
- * encode = true;
- * @param count
- * @param page
- * @return {@link #toArray(int, int, boolean)}
- */
- public JSONRequest toArray(int count, int page) {
- return toArray(count, page, true);
- }
- /**create a parent JSONObject named KEY_ARRAY
- * encode = true;
- * @param count
- * @param page
- * @return {@link #toArray(int, int, String, boolean)}
- */
- public JSONRequest toArray(int count, int page, boolean encode) {
- return toArray(count, page, null, encode);
- }
- /**create a parent JSONObject named name+KEY_ARRAY
- * encode = true;
- * @param count
- * @param page
- * @param name
- * @return {@link #toArray(int, int, String, boolean)}
- */
- public JSONRequest toArray(int count, int page, String name) {
- return toArray(count, page, name, true);
- }
- /**create a parent JSONObject named name+KEY_ARRAY.
- * @param count
- * @param page
- * @param name
- * @param encode
- * @return {name+KEY_ARRAY : this}. if needs to be put, use {@link #add(com.alibaba.fastjson.JSONObject)} instead
- */
- public JSONRequest toArray(int count, int page, String name, boolean encode) {
- return new JSONRequest(StringUtil.getString(name) + KEY_ARRAY, this.setCount(count).setPage(page), encode);
- }
-
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/APIJSONLibrary/src/main/java/zuo/biao/apijson/JSONResponse.java b/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/APIJSONLibrary/src/main/java/zuo/biao/apijson/JSONResponse.java
deleted file mode 100644
index 40379e2f9..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/APIJSONLibrary/src/main/java/zuo/biao/apijson/JSONResponse.java
+++ /dev/null
@@ -1,480 +0,0 @@
-/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON)
-
-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 zuo.biao.apijson;
-
-import static zuo.biao.apijson.StringUtil.bigAlphaPattern;
-
-import java.util.List;
-import java.util.Set;
-
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-
-/**parser for response JSON String
- * @author Lemon
- * @see #getList
- * @see #toArray
- * @use JSONResponse response = new JSONResponse(...);
- *
JSONArray array = JSONResponse.toArray(response.getJSONObject(KEY_ARRAY));//not a must
- *
User user = JSONResponse.getObject(response, User.class);//not a must
- *
List list = JSONResponse.getList(response.getJSONObject("Comment[]"), Comment.class);//not a must
- */
-@SuppressWarnings("serial")
-public class JSONResponse extends zuo.biao.apijson.JSONObject {
- private static final String TAG = "JSONResponse";
-
- public JSONResponse() {
- super();
- }
- public JSONResponse(String json) {
- this(parseObject(json));
- }
- public JSONResponse(JSONObject object) {
- super(format(object));
- }
-
- //状态信息,非GET请求获得的信息<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
- public static final int STATUS_SUCCEED = 200;
-
-
- public static final String KEY_ID = "id";
- public static final String KEY_STATUS = "status";
- public static final String KEY_COUNT = "count";
- public static final String KEY_TOTAL = "total";
- public static final String KEY_MESSAGE = "message";
-
- /**获取id
- * @return
- */
- public long getId() {
- return getLongValue(KEY_ID);
- }
- /**获取状态
- * @return
- */
- public int getStatus() {
- return getIntValue(KEY_STATUS);
- }
- /**获取数量
- * @return
- */
- public int getCount() {
- return getIntValue(KEY_COUNT);
- }
- /**获取数量
- * @return
- */
- public int getTotal() {
- try {
- return getIntValue(KEY_TOTAL);
- } catch (Exception e) {
- // TODO: handle exception
- }
- return 0;
- }
- /**获取信息
- * @return
- */
- public String getMessage() {
- return getString(KEY_MESSAGE);
- }
-
- /**是否成功
- * @return
- */
- public boolean isSucceed() {
- return isSucceed(getStatus());
- }
- /**是否成功
- * @param status
- * @return
- */
- public static boolean isSucceed(int status) {
- return status == STATUS_SUCCEED;
- }
- /**是否成功
- * @param response
- * @return
- */
- public static boolean isSucceed(JSONResponse response) {
- return response != null && response.isSucceed();
- }
-
- /**校验服务端是否存在table
- * @return
- */
- public boolean isExist() {
- return isExist(getCount());
- }
- /**校验服务端是否存在table
- * @param count
- * @return
- */
- public static boolean isExist(int count) {
- return count > 0;
- }
- /**校验服务端是否存在table
- * @param response
- * @return
- */
- public static boolean isExist(JSONResponse response) {
- return response != null && response.isExist();
- }
-
- /**获取内部的JSONResponse
- * @param key
- * @return
- */
- public JSONResponse getJSONResponse(String key) {
- return getObject(key, JSONResponse.class);
- }
- //状态信息,非GET请求获得的信息>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
-
-
-
-
- /**
- * key = clazz.getSimpleName()
- * @param clazz
- * @return
- */
- public T getObject(Class clazz) {
- return getObject(clazz == null ? "" : clazz.getSimpleName(), clazz);
- }
- /**
- * @param key
- * @param clazz
- * @return
- */
- public T getObject(String key, Class clazz) {
- return getObject(this, key, clazz);
- }
- /**
- * @param object
- * @param key
- * @param clazz
- * @return
- */
- public static T getObject(JSONObject object, String key, Class clazz) {
- return toObject(object == null ? null : object.getJSONObject(key), clazz);
- }
-
- /**
- * @param clazz
- * @return
- */
- public T toObject(Class clazz) {
- return toObject(this, clazz);
- }
- /**
- * @param object
- * @param clazz
- * @return
- */
- public static T toObject(JSONObject object, Class clazz) {
- return JSON.parseObject(JSON.toJSONString(object), clazz);
- }
-
-
-
-
- /**
- * key = KEY_ARRAY
- * @param clazz
- * @return
- */
- public List getList(Class clazz) {
- return getList(KEY_ARRAY, clazz);
- }
- /**
- * arrayObject = this
- * @param key
- * @param clazz
- * @return
- */
- public List getList(String key, Class clazz) {
- return getList(this, key, clazz);
- }
-
- /**
- * key = KEY_ARRAY
- * @param object
- * @param clazz
- * @return
- */
- public static List getList(JSONObject object, Class clazz) {
- return getList(object, KEY_ARRAY, clazz);
- }
- /**
- * @param object
- * @param key
- * @param clazz
- * @return
- */
- public static List getList(JSONObject object, String key, Class clazz) {
- Object obj = object == null ? null : object.get(replaceArray(key));
- if (obj == null) {
- return null;
- }
- return obj instanceof JSONArray ? JSON.parseArray((JSONArray) obj, clazz) : toList((JSONObject) obj, clazz);
- }
- /**
- * @param clazz
- * @return
- */
- public List toList(Class clazz) {
- return toList(this, clazz);
- }
- /**
- * @param arrayObject
- * @param clazz
- * @return
- */
- public static List toList(JSONObject arrayObject, Class clazz) {
- return clazz == null ? null : JSON.parseArray(JSON.toJSONString(
- toArray(arrayObject, clazz.getSimpleName())), clazz);
- }
-
- /**
- * key = KEY_ARRAY
- * @param className
- * @return
- */
- public JSONArray getArray(String className) {
- return getArray(KEY_ARRAY, className);
- }
- /**
- * @param key
- * @param className
- * @return
- */
- public JSONArray getArray(String key, String className) {
- return getArray(this, key, className);
- }
- /**
- * @param object
- * @param key
- * @param className
- * @return
- */
- public static JSONArray getArray(JSONObject object, String className) {
- return getArray(object, KEY_ARRAY, className);
- }
- /**
- * key = KEY_ARRAY
- * @param object
- * @param className
- * @return
- */
- public static JSONArray getArray(JSONObject object, String key, String className) {
- Object obj = object == null ? null : object.get(replaceArray(key));
- if (obj == null) {
- return null;
- }
- return obj instanceof JSONArray ? (JSONArray) obj : toArray((JSONObject) obj, className);
- }
-
- /**
- * @param className
- * @return
- */
- public JSONArray toArray(String className) {
- return toArray(this, className);
- }
- /**{0:{Table:{}}, 1:{Table:{}}...} 转化为 [{Table:{}}, {Table:{}}]
- * array.set(index, isContainer ? value : value.getJSONObject(className));
- * @param arrayObject
- * @param className className.equals(Table) ? {Table:{Content}} => {Content}
- * @return
- */
- public static JSONArray toArray(JSONObject arrayObject, String className) {
- Set set = arrayObject == null ? null : arrayObject.keySet();
- if (set == null || set.isEmpty()) {
- return null;
- }
-
- // [{...},{...},...]
- String parentString = StringUtil.getTrimedString(JSON.toJSONString(arrayObject));
- if (parentString.isEmpty()) {
- return null;
- }
- if (parentString.startsWith("[")) {
- if (parentString.endsWith("]") == false) {
- parentString += "]";
- }
- return JSON.parseArray(parentString);
- }
-
- //{"0":{Table:{...}}, "1":{Table:{...}}...}
-
- className = StringUtil.getTrimedString(className);
- boolean isContainer = true;
-
- JSONArray array = new JSONArray(set.size());
- JSONObject value;
- boolean isFirst = true;
- int index;
- for (String key : set) {//0, 1, 2,...
- value = StringUtil.isNumer(key) == false ? null : arrayObject.getJSONObject(key);// Table:{}
- if (value != null) {
- try {
- index = Integer.valueOf(0 + key);
- if (isFirst && isTableKey(className) && value.containsKey(className)) {// 判断是否需要提取table
- isContainer = false;
- }
- array.set(index, isContainer ? value : value.getJSONObject(className));
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- isFirst = false;
- }
- return array;
- }
-
-
-
- // /**
- // * @return
- // */
- // public JSONObject format() {
- // return format(this);
- // }
- /**将Item[]:[{Table:{}}, {Table:{}}...] 或 Item[]:{0:{Table:{}}, 1:{Table:{}}...}
- * 转化为 itemList:[{Table:{}}, {Table:{}}],如果 Item.equals(Table),则将 {Table:{Content}} 转化为 {Content}
- * @param target
- * @param response
- * @return
- */
- public static JSONObject format(final JSONObject response) {
- //太长查看不方便,不如debug Log.i(TAG, "format response = \n" + JSON.toJSONString(response));
- if (response == null || response.isEmpty()) {
- Log.i(TAG, "format response == null || response.isEmpty() >> return response;");
- return response;
- }
- JSONObject transferredObject = new JSONObject(true);
-
- Set set = response.keySet();
- if (set != null) {
-
- Object value;
- String arrayKey;
- for (String key : set) {
- value = response.get(key);
-
- if (value instanceof JSONArray) {//转化JSONArray内部的APIJSON Array
- transferredObject.put(replaceArray(key), format(key, (JSONArray) value));
- } else if (value instanceof JSONObject) {//APIJSON Array转为常规JSONArray
- if (isArrayKey(key)) {//APIJSON Array转为常规JSONArray
- arrayKey = key.substring(0, key.lastIndexOf(KEY_ARRAY));
- transferredObject.put(getArrayKey(getSimpleName(arrayKey))
- , format(key, toArray((JSONObject) value, arrayKey)));//需要将name:alias传至toArray
- } else {//常规JSONObject,往下一级提取
- transferredObject.put(getSimpleName(key), format((JSONObject) value));
- }
- } else {//其它Object,直接填充
- transferredObject.put(getSimpleName(key), value);
- }
- }
- }
-
- //太长查看不方便,不如debug Log.i(TAG, "format return transferredObject = " + JSON.toJSONString(transferredObject));
- return transferredObject;
- }
-
- /**
- * @param responseArray
- * @return
- */
- public static JSONArray format(String name, final JSONArray responseArray) {
- //太长查看不方便,不如debug Log.i(TAG, "format responseArray = \n" + JSON.toJSONString(responseArray));
- if (responseArray == null || responseArray.isEmpty()) {
- Log.i(TAG, "format responseArray == null || responseArray.isEmpty() >> return response;");
- return responseArray;
- }
- int index = name == null ? -1 : name.lastIndexOf(KEY_ARRAY);
- String className = index < 0 ? "" : name.substring(0, index);
-
- JSONArray transferredArray = new JSONArray();
-
- Object value;
- boolean isContainer = true;
- boolean isFirst = true;
- for (int i = 0; i < responseArray.size(); i++) {
- value = responseArray.get(i);
- if (value instanceof JSONArray) {//转化JSONArray内部的APIJSON Array
- transferredArray.add(format(null, (JSONArray) value));
- } else if (value instanceof JSONObject) {//JSONObject,往下一级提取
- //判断是否需要提取child
- if (isFirst && isTableKey(className) && ((JSONObject) value).containsKey(className)) {
- isContainer = false;
- }
- //直接添加child 或 添加提取出的child
- transferredArray.add(format(isContainer ? (JSONObject)value : ((JSONObject)value).getJSONObject(className) ));
- isFirst = false;
- } else {//其它Object,直接填充
- transferredArray.add(responseArray.get(i));
- }
- }
-
- //太长查看不方便,不如debug Log.i(TAG, "format return transferredArray = " + JSON.toJSONString(transferredArray));
- return transferredArray;
- }
-
- /**替换key+KEY_ARRAY为keyList
- * @param key
- * @return getSimpleName(isArrayKey(key) ? getArrayKey(...) : key) {@link #getSimpleName(String)}
- */
- public static String replaceArray(String key) {
- if (isArrayKey(key)) {
- key = getArrayKey(key.substring(0, key.lastIndexOf(KEY_ARRAY)));
- }
- return getSimpleName(key);
- }
- /**获取列表变量名
- * @param key => StringUtil.getNoBlankString(key)
- * @return empty ? "list" : key + "List" 且首字母小写
- */
- public static String getArrayKey(String key) {
- key = StringUtil.getNoBlankString(key);
- if (key.isEmpty()) {
- return "list";
- }
-
- String first = key.substring(0, 1);
- if (bigAlphaPattern.matcher(first).matches()) {
- key = first.toLowerCase() + key.substring(1, key.length());
- }
- return key + "List";
- }
-
- /**获取简单名称
- * @param fullName name 或 name:alias
- * @return name > name; name:alias > alias
- */
- public static String getSimpleName(String fullName) {
- //key:alias -> alias; key:alias[] -> alias[]
- int index = fullName == null ? -1 : fullName.indexOf(":");
- if (index >= 0) {
- fullName = fullName.substring(index + 1);
- }
- return fullName;
- }
-
-
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/APIJSONLibrary/src/main/java/zuo/biao/apijson/RequestMethod.java b/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/APIJSONLibrary/src/main/java/zuo/biao/apijson/RequestMethod.java
deleted file mode 100644
index 6a25809d1..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/APIJSONLibrary/src/main/java/zuo/biao/apijson/RequestMethod.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON)
-
-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 zuo.biao.apijson;
-
-/**请求方法,对应org.springframework.web.bind.annotation.RequestMethod,多出一个POST_GET方法
- * @author Lemon
- */
-public enum RequestMethod {
-
- /**
- * 常规获取数据方式
- */
- GET,
-
- /**
- * 检查,默认是非空检查,返回数据总数
- */
- HEAD,
-
- /**
- * 通过POST来GET数据,不显示请求内容和返回结果,一般用于对安全要求比较高的请求
- */
- POST_GET,
-
- /**
- * 通过POST来HEAD数据,不显示请求内容和返回结果,一般用于对安全要求比较高的请求
- */
- POST_HEAD,
-
- /**
- * 新增(或者说插入)数据
- */
- POST,
-
- /**
- * 修改数据,只修改传入字段对应的值
- */
- PUT,
-
- /**
- * 删除数据
- */
- DELETE
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/APIJSONTest.iml b/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/APIJSONTest.iml
deleted file mode 100644
index 1a46b0589..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/APIJSONTest.iml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/Test.iml b/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/Test.iml
deleted file mode 100644
index 29df7991d..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/Test.iml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/app/app.iml b/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/app/app.iml
deleted file mode 100644
index 892b4e68b..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/app/app.iml
+++ /dev/null
@@ -1,114 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- generateDebugSources
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/app/src/main/java/apijson/demo/model/BaseModel.java b/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/app/src/main/java/apijson/demo/model/BaseModel.java
deleted file mode 100644
index 8f6d961e0..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/APIJSONTest/app/src/main/java/apijson/demo/model/BaseModel.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon)
-
-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 apijson.demo.model;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.Map;
-
-/**base model for reduce model codes
- * @author Lemon
- * @use extends BaseModel
- */
-@SuppressWarnings("serial")
-public abstract class BaseModel implements Serializable {
-
- private Long id;
- private Long date;
-
- public Long getId() {
- return id;
- }
- public BaseModel setId(Long id) {
- this.id = id;
- return this;
- }
- public Long getDate() {
- return date;
- }
- public BaseModel setDate(Long date) {
- this.date = date;
- return this;
- }
-
- //判断是否为空 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- /**判断collection是否为空
- * @param collection
- * @return
- */
- public static boolean isEmpty(Collection collection) {
- return collection == null || collection.isEmpty();
- }
- /**判断map是否为空
- * @param
- * @param
- * @param map
- * @return
- */
- public static boolean isEmpty(Map map) {
- return map == null || map.isEmpty();
- }
- //判断是否为空 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
- //判断是否包含 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- /**判断collection是否包含object
- * @param collection
- * @param object
- * @return
- */
- public static boolean isContain(Collection collection, T object) {
- return collection != null && collection.contains(object);
- }
- /**判断map是否包含key
- * @param
- * @param
- * @param map
- * @param key
- * @return
- */
- public static boolean isContainKey(Map map, K key) {
- return map != null && map.containsKey(key);
- }
- /**判断map是否包含value
- * @param
- * @param
- * @param map
- * @param value
- * @return
- */
- public static boolean isContainValue(Map map, V value) {
- return map != null && map.containsValue(value);
- }
- //判断是否为包含 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
- //获取集合长度 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- /**获取数量
- * @param
- * @param array
- * @return
- */
- public static int count(T[] array) {
- return array == null ? 0 : array.length;
- }
- /**获取数量
- * @param
- * @param collection collection, Vector, Set等都是Collection的子类
- * @return
- */
- public static int count(Collection collection) {
- return collection == null ? 0 : collection.size();
- }
- /**获取数量
- * @param
- * @param
- * @param map
- * @return
- */
- public static int count(Map map) {
- return map == null ? 0 : map.size();
- }
- //获取集合长度 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
- //获取集合长度 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- /**获取
- * @param
- * @param array
- * @return
- */
- public static T get(T[] array, int position) {
- return position < 0 || position >= count(array) ? null : array[position];
- }
- /**获取
- * @param
- * @param collection List, Vector, Set等都是Collection的子类
- * @return
- */
- @SuppressWarnings("unchecked")
- public static T get(Collection collection, int position) {
- return (T) (collection == null ? null : get(collection.toArray(), position));
- }
- /**获取
- * @param