diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
new file mode 100644
index 000000000..f0d9515f5
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -0,0 +1,83 @@
+name: Bug Report/报告 bug
+description: "Create a report to help us improve, please read FAQ first./帮助我们更好地改进项目,但请先阅读常见问题与提问前必看,不要提已有的重复问题!"
+title: "[Bug] "
+labels: [kind/bug]
+body:
+- type: markdown
+ attributes:
+ value: "如果你已经知道问题所在、怎么解决,请直接 提交 Pull Request 为社区做贡献,非常感谢。\n开发者也是人,也需要工作、休息、恋爱、陪伴家人、走亲会友等,也有心情不好和身体病痛,\n往往没有额外的时间精力顾及一些小问题,请理解和支持,开源要大家参与贡献才会更美好~\n少数个人的热情终有被耗尽的一天,只有大家共同建设和繁荣社区,才能让开源可持续发展! "
+
+- type: input
+ attributes:
+ label: APIJSON Version/APIJSON 版本号
+ placeholder: |
+ e.g./例如 5.4.0 ,如果不是最新版请用最新版,复现问题再来,原则上不更新旧版,而是只维护一个最新版
+
+ validations:
+ required: true
+
+- type: input
+ attributes:
+ label: Database Type & Version/数据库类型及版本号
+ placeholder: |
+ e.g./例如 MySQL 5.7.34
+
+ validations:
+ required: true
+
+- type: textarea
+ attributes:
+ label: Environment/环境信息
+ description: |
+ e.g./例如:
+ - **JDK/基础库**: 1.8.0_17
+ - **OS/系统**: MacOS Monterey 12.6 (21G115) M1
+ value: |
+ - JDK/基础库:
+ - OS/系统:
+ render: markdown
+
+ validations:
+ required: true
+
+- type: input
+ attributes:
+ label: APIAuto Screenshots/APIAuto 请求与结果完整截屏
+ description: "Upload by copy and paste image file or url./复制图片文件或 URL 再粘贴到输入框(用 APIAuto 能静态检查出很多问题,甚至还有修复建议,不用浪费你我的时间)\n https://github.com/TommyLemon/APIAuto "
+ value:
+
+ validations:
+ required: true
+
+- type: textarea
+ attributes:
+ label: Current Behavior/问题描述
+ description: "A concise description of what you're experiencing. Must contains screenshots./\n\n**提 bug 请发请求和响应的【完整截屏】,没图的自行解决!\n开发者有限的时间和精力主要放在【维护项目源码和文档】上!\n【描述不详细】 或 【文档/常见问题 已有答案】 的问题可能会被忽略!!\n【态度 不文明/不友善】的可能会被拉黑,问题也可能不予解答!!!**\n\n请求参数 JSON 中表名、字段名、关键词及对应的值都是大小写敏感、逗号敏感、分号敏感、空格敏感、换行敏感,\n大部分情况都不允许空格和换行,表名以大写字母开头,不要想当然,请严格按照 设计规范 来调用 API \n https://github.com/Tencent/APIJSON/issues/181 "
+ render: markdown
+
+ validations:
+ required: true
+
+- type: textarea
+ attributes:
+ label: Expected Behavior/期望结果
+ description: A concise description of what you expected to happen./具体描述你期望返回什么样的结果或者达到什么样的效果?
+ render: markdown
+
+ validations:
+ required: false
+
+
+- type: textarea
+ attributes:
+ label: Any additional comments?/其它补充说明?
+ description: |
+ e.g. some background/context of how you ran into this bug./例如:一些背景或上下文信息,包括复现步骤、相关日志等
+ render: markdown
+
+ validations:
+ required: false
+
+- type: markdown
+ attributes:
+ value: "Please follow the rules to fulfil all required inputs. You can add screenshots by comment after submit this issue./\n请按要求填写所有必填项,未填完将提交不了!\n如果随意填写敷衍了事,将直接关闭 issue,问题不会得到解答!\n可以提交后再通过回复评论来补充上传截屏图片(复制粘贴文件)。\n如果是网页 bug 等与你无关的原因导致提交不了,可以改为填问卷:\n https://wj.qq.com/s2/10971431/2a09 "
diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml
new file mode 100644
index 000000000..3ba13e0ce
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/config.yml
@@ -0,0 +1 @@
+blank_issues_enabled: false
diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml
new file mode 100644
index 000000000..6f14d47b3
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature_request.yml
@@ -0,0 +1,17 @@
+name: Feature Request/期望新增功能
+description: Request a new feature/期望新增什么样的功能或特性,或者做哪些方面的改进?
+title: "[Feature] "
+labels: [kind/feature]
+body:
+- type: textarea
+ attributes:
+ label: Description
+ description: |
+ Please describe what this feature does./具体描述下是什么样的功能或特性,以及你为什么想要它,用在什么场景,碰到了什么痛点,有什么解决思路,尝试过哪些,效果怎样?
+
+ validations:
+ required: true
+
+- type: markdown
+ attributes:
+ value: 推荐去建议收集箱提问,也方便 统一检索和管理、投票决定优先级、更新处理进度 等: https://github.com/Tencent/APIJSON/issues/37
diff --git a/.github/ISSUE_TEMPLATE/other_issues.yml b/.github/ISSUE_TEMPLATE/other_issues.yml
new file mode 100644
index 000000000..9f9a6d0ea
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/other_issues.yml
@@ -0,0 +1,16 @@
+name: Other Issues/其它反馈
+description: For questions, suggestions, improvements and others./问题(非 bug)、建议(非新增功能) 或 其它
+title: "[xxx] "
+body:
+- type: textarea
+ attributes:
+ label: Description
+ description: |
+ Please describe the issue./请具体描述,包括是什么、为什么、如何做
+
+ validations:
+ required: true
+
+- type: markdown
+ attributes:
+ value: "Bug 反馈请使用正确的模板,用错模板将直接关闭 issue,不予解答:\n https://github.com/Tencent/APIJSON/issues/new?assignees=&labels=kind%2Fbug&template=bug_report.yml&title=%5BBug%5D+ \n有建议请去建议收集箱提问,也方便 统一检索和管理、投票决定优先级、更新处理进度 等:\n https://github.com/Tencent/APIJSON/issues/37 "
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000..a06bbd0a8
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,38 @@
+.DS_Store
+.gradle
+yarn.lock
+*.project
+
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**
+!**/src/test/**
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+
+### VS Code ###
+.vscode/
+APIJSONORM/bin
+*.DS_Store
diff --git a/APIJSON(Android)/APIJSON(ADT)/.classpath b/APIJSON(Android)/APIJSON(ADT)/.classpath
deleted file mode 100644
index 7bc01d9a9..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/.classpath
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/APIJSON(Android)/APIJSON(ADT)/.project b/APIJSON(Android)/APIJSON(ADT)/.project
deleted file mode 100644
index 55204fbec..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/.project
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
- APIJSON(ADT)
-
-
-
-
-
- com.android.ide.eclipse.adt.ResourceManagerBuilder
-
-
-
-
- com.android.ide.eclipse.adt.PreCompilerBuilder
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- com.android.ide.eclipse.adt.ApkBuilder
-
-
-
-
-
- com.android.ide.eclipse.adt.AndroidNature
- org.eclipse.jdt.core.javanature
-
-
diff --git a/APIJSON(Android)/APIJSON(ADT)/.travis.yml b/APIJSON(Android)/APIJSON(ADT)/.travis.yml
deleted file mode 100644
index 4a8b340d5..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/.travis.yml
+++ /dev/null
@@ -1,28 +0,0 @@
-language: android
-sudo: false
-jdk:
- - oraclejdk7
-android:
- components:
- - build-tools-23.0.2
- - android-21
- - extra-android-m2repository
- - extra-android-support
-before_install:
- - export CHROME_BIN=chromium-browser
- - export JAVA_HOME=/usr/lib/jvm/java-7-oraclejdk7-amd64
- - export ANDROID_HOME=/usr/local/android-sdk
- - echo yes | android update sdk --all --no-ui --force
- - export DISPLAY=:99.0
- - sh -e /etc/init.d/apijson start
-before_script:
- - . $HOME/.nvm/nvm.sh
- - nvm install 4
- - nvm use 4
- - npm install
- - echo no | android create avd --force -n test -t android-21 --abi armeabi-v7a
- - emulator -avd test -no-audio -no-window &
- - android-wait-for-emulator
- - adb shell input keyevent 82 &
-script: "make test"
-after_script: "npm install coveralls@2 && cat ./coverage/lcov.info | coveralls"
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(ADT)/AndroidManifest.xml b/APIJSON(Android)/APIJSON(ADT)/AndroidManifest.xml
deleted file mode 100644
index 753f84573..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/AndroidManifest.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(ADT)/gen/zuo/biao/apijson/client/BuildConfig.java b/APIJSON(Android)/APIJSON(ADT)/gen/zuo/biao/apijson/client/BuildConfig.java
deleted file mode 100644
index c345af65a..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/gen/zuo/biao/apijson/client/BuildConfig.java
+++ /dev/null
@@ -1,6 +0,0 @@
-/** Automatically generated file. DO NOT MODIFY */
-package zuo.biao.apijson.client;
-
-public final class BuildConfig {
- public final static boolean DEBUG = true;
-}
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(ADT)/gen/zuo/biao/apijson/client/R.java b/APIJSON(Android)/APIJSON(ADT)/gen/zuo/biao/apijson/client/R.java
deleted file mode 100644
index b1c494ec3..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/gen/zuo/biao/apijson/client/R.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/* AUTO-GENERATED FILE. DO NOT MODIFY.
- *
- * This class was automatically generated by the
- * aapt tool from the resource data it found. It
- * should not be modified by hand.
- */
-
-package zuo.biao.apijson.client;
-
-public final class R {
- public static final class attr {
- }
- public static final class dimen {
- /** Default screen margins, per the Android Design guidelines.
- */
- public static final int activity_horizontal_margin=0x7f040000;
- public static final int activity_vertical_margin=0x7f040001;
- }
- public static final class drawable {
- public static final int ic_launcher=0x7f020000;
- }
- public static final class id {
- public static final int btnQueryQuery=0x7f070003;
- public static final int etQueryUri=0x7f070002;
- public static final int pbQuery=0x7f070001;
- public static final int tvQueryResult=0x7f070000;
- }
- public static final class layout {
- public static final int query_activity=0x7f030000;
- public static final int select_activity=0x7f030001;
- }
- public static final class string {
- public static final int action_settings=0x7f050003;
- public static final int app_name=0x7f050000;
- public static final int app_version=0x7f050001;
- public static final int demo_array=0x7f050007;
- public static final int demo_complex=0x7f050008;
- public static final int demo_rely=0x7f050006;
- public static final int demo_single=0x7f050005;
- public static final int hello_world=0x7f050002;
- public static final int query_error=0x7f050004;
- }
- public static final class style {
- /**
- Base application theme, dependent on API level. This theme is replaced
- by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-
-
- Theme customizations available in newer API levels can go in
- res/values-vXX/styles.xml, while customizations related to
- backward-compatibility can go here.
-
- */
- public static final int AppBaseTheme=0x7f060000;
- /** Application theme.
- All customizations that are NOT specific to a particular API-level can go here.
- */
- public static final int AppTheme=0x7f060001;
- public static final int activity_page=0x7f060003;
- public static final int match_match=0x7f060002;
- public static final int match_wrap=0x7f060004;
- public static final int select_json=0x7f060006;
- public static final int select_name=0x7f060005;
- }
-}
diff --git a/APIJSON(Android)/APIJSON(ADT)/ic_launcher-web.png b/APIJSON(Android)/APIJSON(ADT)/ic_launcher-web.png
deleted file mode 100644
index a18cbb48c..000000000
Binary files a/APIJSON(Android)/APIJSON(ADT)/ic_launcher-web.png and /dev/null differ
diff --git a/APIJSON(Android)/APIJSON(ADT)/libs/fastjson-1.2.21.jar b/APIJSON(Android)/APIJSON(ADT)/libs/fastjson-1.2.21.jar
deleted file mode 100644
index b00791c53..000000000
Binary files a/APIJSON(Android)/APIJSON(ADT)/libs/fastjson-1.2.21.jar and /dev/null differ
diff --git a/APIJSON(Android)/APIJSON(ADT)/libs/okhttp-2.1.0.jar b/APIJSON(Android)/APIJSON(ADT)/libs/okhttp-2.1.0.jar
deleted file mode 100644
index 837defb9d..000000000
Binary files a/APIJSON(Android)/APIJSON(ADT)/libs/okhttp-2.1.0.jar and /dev/null differ
diff --git a/APIJSON(Android)/APIJSON(ADT)/libs/okio-1.0.0.jar b/APIJSON(Android)/APIJSON(ADT)/libs/okio-1.0.0.jar
deleted file mode 100644
index 909cfa98d..000000000
Binary files a/APIJSON(Android)/APIJSON(ADT)/libs/okio-1.0.0.jar and /dev/null differ
diff --git a/APIJSON(Android)/APIJSON(ADT)/proguard-project.txt b/APIJSON(Android)/APIJSON(ADT)/proguard-project.txt
deleted file mode 100644
index f2fe1559a..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/proguard-project.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-# To enable ProGuard in your project, edit project.properties
-# to define the proguard.config property as described in that file.
-#
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in ${sdk.dir}/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the ProGuard
-# include property in project.properties.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
diff --git a/APIJSON(Android)/APIJSON(ADT)/project.properties b/APIJSON(Android)/APIJSON(ADT)/project.properties
deleted file mode 100644
index 6e18427a4..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/project.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system edit
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-#
-# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
-#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
-
-# Project target.
-target=android-21
diff --git a/APIJSON(Android)/APIJSON(ADT)/res/drawable-hdpi/ic_launcher.png b/APIJSON(Android)/APIJSON(ADT)/res/drawable-hdpi/ic_launcher.png
deleted file mode 100644
index cde69bccc..000000000
Binary files a/APIJSON(Android)/APIJSON(ADT)/res/drawable-hdpi/ic_launcher.png and /dev/null differ
diff --git a/APIJSON(Android)/APIJSON(ADT)/res/drawable-mdpi/.DS_Store b/APIJSON(Android)/APIJSON(ADT)/res/drawable-mdpi/.DS_Store
deleted file mode 100644
index 5008ddfcf..000000000
Binary files a/APIJSON(Android)/APIJSON(ADT)/res/drawable-mdpi/.DS_Store and /dev/null differ
diff --git a/APIJSON(Android)/APIJSON(ADT)/res/drawable-mdpi/ic_launcher.png b/APIJSON(Android)/APIJSON(ADT)/res/drawable-mdpi/ic_launcher.png
deleted file mode 100755
index c133a0cbd..000000000
Binary files a/APIJSON(Android)/APIJSON(ADT)/res/drawable-mdpi/ic_launcher.png and /dev/null differ
diff --git a/APIJSON(Android)/APIJSON(ADT)/res/drawable-xhdpi/.DS_Store b/APIJSON(Android)/APIJSON(ADT)/res/drawable-xhdpi/.DS_Store
deleted file mode 100644
index 5008ddfcf..000000000
Binary files a/APIJSON(Android)/APIJSON(ADT)/res/drawable-xhdpi/.DS_Store and /dev/null differ
diff --git a/APIJSON(Android)/APIJSON(ADT)/res/drawable-xhdpi/ic_launcher.png b/APIJSON(Android)/APIJSON(ADT)/res/drawable-xhdpi/ic_launcher.png
deleted file mode 100755
index bfa42f0e7..000000000
Binary files a/APIJSON(Android)/APIJSON(ADT)/res/drawable-xhdpi/ic_launcher.png and /dev/null differ
diff --git a/APIJSON(Android)/APIJSON(ADT)/res/drawable-xxhdpi/.DS_Store b/APIJSON(Android)/APIJSON(ADT)/res/drawable-xxhdpi/.DS_Store
deleted file mode 100644
index 5008ddfcf..000000000
Binary files a/APIJSON(Android)/APIJSON(ADT)/res/drawable-xxhdpi/.DS_Store and /dev/null differ
diff --git a/APIJSON(Android)/APIJSON(ADT)/res/drawable-xxhdpi/ic_launcher.png b/APIJSON(Android)/APIJSON(ADT)/res/drawable-xxhdpi/ic_launcher.png
deleted file mode 100755
index 324e72cdd..000000000
Binary files a/APIJSON(Android)/APIJSON(ADT)/res/drawable-xxhdpi/ic_launcher.png and /dev/null differ
diff --git a/APIJSON(Android)/APIJSON(ADT)/res/drawable/.DS_Store b/APIJSON(Android)/APIJSON(ADT)/res/drawable/.DS_Store
deleted file mode 100644
index 5008ddfcf..000000000
Binary files a/APIJSON(Android)/APIJSON(ADT)/res/drawable/.DS_Store and /dev/null differ
diff --git a/APIJSON(Android)/APIJSON(ADT)/res/drawable/ic_launcher.png b/APIJSON(Android)/APIJSON(ADT)/res/drawable/ic_launcher.png
deleted file mode 100644
index cde69bccc..000000000
Binary files a/APIJSON(Android)/APIJSON(ADT)/res/drawable/ic_launcher.png and /dev/null differ
diff --git a/APIJSON(Android)/APIJSON(ADT)/res/layout/query_activity.xml b/APIJSON(Android)/APIJSON(ADT)/res/layout/query_activity.xml
deleted file mode 100644
index 722977d80..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/res/layout/query_activity.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(ADT)/res/layout/select_activity.xml b/APIJSON(Android)/APIJSON(ADT)/res/layout/select_activity.xml
deleted file mode 100644
index 080037a3f..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/res/layout/select_activity.xml
+++ /dev/null
@@ -1,67 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(ADT)/res/values-zh/strings.xml b/APIJSON(Android)/APIJSON(ADT)/res/values-zh/strings.xml
deleted file mode 100644
index 6c388ebd3..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/res/values-zh/strings.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-APIJSON
-1.0
-Hello world!
-Settings
-单个Object
-Object之间的依赖
-Object数组
-复杂结构
-没有访问权限
-允许使用权限
-查询
-可能出现了一些问题,可以按照以下步骤解决:\n\n1.检查网络连接\n\n2.检查url是否为一个可用的IPV4地址\n\n3.长按[查询]按钮用浏览器发送请求\n\n4.查看目标服务器上的log\n\n5.再试一次
-{\n \"User\":{\n \"id\":38710\n }\n}
-{\n \"User\":{\n \"id\":70793\n },\n \"Work\":{\n \"userId\":\"User/id\"\n }\n}
-{\n \"User[]\":{\n \"count\":10,\n \"User\":{\n \"sex\":0\n }\n }\n}
-{\n \"[]\":{\n \"count\":2,\n \"User\":{\n \"sex\":0\n },\n \"Work\":{\n \"userId\":\"/User/id\"\n },\n \"Comment[]\":{\n \"count\":3,\n \"Comment\":{\n \"workId\":\"[]/Work/id\"\n }\n }\n }\n}
-{\n \"Wallet\":{\n \"userId\":38710\n }\n}
-{\n \"Wallet\":{\n \"userId\":38710\n },\n \"currentUserId\":38710,\n \"payPassword\":\"123456\"\n}
-
-
diff --git a/APIJSON(Android)/APIJSON(ADT)/res/values/dimens.xml b/APIJSON(Android)/APIJSON(ADT)/res/values/dimens.xml
deleted file mode 100644
index 55c1e5908..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/res/values/dimens.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
- 16dp
- 16dp
-
-
diff --git a/APIJSON(Android)/APIJSON(ADT)/res/values/strings.xml b/APIJSON(Android)/APIJSON(ADT)/res/values/strings.xml
deleted file mode 100644
index d68ab0fc9..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/res/values/strings.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-APIJSON
-1.0
-Hello world!
-Settings
-Single
-Rely
-Array
-Complex
-Access Error
-Access Permitted
-Query
-There may be something wrong,you can follow by the steps:\n\n1.Check your net connection\n\n2.Check the url whether it\'s an available ipv4 address\n\n3.Long click the [Query] button to open the request by web browser\n\n4.Check logs outputed on the target server\n\n5.Try again
-{\n \"User\":{\n \"id\":38710\n }\n}
-{\n \"User\":{\n \"id\":70793\n },\n \"Work\":{\n \"userId\":\"User/id\"\n }\n}
-{\n \"User[]\":{\n \"count\":10,\n \"User\":{\n \"sex\":0\n }\n }\n}
-{\n \"[]\":{\n \"count\":2,\n \"User\":{\n \"sex\":0\n },\n \"Work\":{\n \"userId\":\"/User/id\"\n },\n \"Comment[]\":{\n \"count\":3,\n \"Comment\":{\n \"workId\":\"[]/Work/id\"\n }\n }\n }\n}
-{\n \"Wallet\":{\n \"userId\":38710\n }\n}
-{\n \"Wallet\":{\n \"userId\":38710\n },\n \"currentUserId\":38710,\n \"payPassword\":\"123456\"\n}
-
-
diff --git a/APIJSON(Android)/APIJSON(ADT)/res/values/styles.xml b/APIJSON(Android)/APIJSON(ADT)/res/values/styles.xml
deleted file mode 100644
index 69e2137a1..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/res/values/styles.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/JSON.java b/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/JSON.java
deleted file mode 100644
index 3dd6585c8..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/JSON.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*Copyright ©2015 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 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;
-
-/**阿里json封装类 防止解析时异常
- * @author Lemon
- */
-public class JSON {
- private static final String TAG = "JSON";
-
- /**判断json格式是否正确
- * @param s
- * @return
- */
- public static boolean isJsonCorrect(String s) {
- System.out.println(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) {
- s = StringUtil.getNoBlankString(s);
- return isJsonCorrect(s) ? s : "";
- }
-
- /**json转JSONObject
- * @param s
- * @return
- */
- public static JSONObject parseObject(String json) {
- try {
- int features = com.alibaba.fastjson.JSON.DEFAULT_PARSER_FEATURE;
- features |= Feature.SortFeidFastMatch.getMask();
- return com.alibaba.fastjson.JSON.parseObject(getCorrectJson(json), JSONObject.class, features);
- } catch (Exception e) {
- System.out.println(TAG + "parseObject catch \n" + e.getMessage());
- }
- return null;
- }
-
- /**json转实体类
- * @param s
- * @param clazz
- * @return
- */
- public static T parseObject(String json, Class clazz) {
- try {
- int features = com.alibaba.fastjson.JSON.DEFAULT_PARSER_FEATURE;
- features |= Feature.SortFeidFastMatch.getMask();
- return com.alibaba.fastjson.JSON.parseObject(getCorrectJson(json), clazz, features);
- } catch (Exception e) {
- System.out.println(TAG + "parseObject catch \n" + e.getMessage());
- }
- return null;
- }
-
- /**json转JSONArray
- * @param json
- * @return
- */
- public static JSONArray parseArray(String json) {
- return com.alibaba.fastjson.JSON.parseArray(json);
- }
- /**json转实体类列表
- * @param s
- * @param clazz
- * @return
- */
- public static List parseArray(String json, Class clazz) {
- try {
- return com.alibaba.fastjson.JSON.parseArray(getCorrectJson(json), clazz);
- } catch (Exception e) {
- System.out.println(TAG + "parseArray catch \n" + e.getMessage());
- }
- return null;
- }
-
- /**实体类转json
- * @param obj
- * @return
- */
- public static String toJSONString(Object obj) {
- try {
- return com.alibaba.fastjson.JSON.toJSONString(obj, SerializerFeature.SortField);
- } catch (Exception e) {
- System.out.println(TAG + "toJSONString catch \n" + e.getMessage());
- }
- return null;
- }
-
-
-}
diff --git a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/StringUtil.java b/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/StringUtil.java
deleted file mode 100644
index ec429f55a..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/StringUtil.java
+++ /dev/null
@@ -1,642 +0,0 @@
-/*Copyright ©2015 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 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;
-
-import android.util.Log;
-import android.widget.TextView;
-
-/**通用字符串(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 tv
- * @return
- */
- public static String getString(TextView tv) {
- if (tv == null || tv.getText() == null) {
- return "";
- }
- return getString(tv.getText().toString());
- }
- /**获取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时返回"" >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
- //获取去掉前后空格后的string<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
- /**获取去掉前后空格后的string,为null则返回""
- * @param tv
- * @return
- */
- public static String getTrimedString(TextView tv) {
- return getTrimedString(getString(tv));
- }
- /**获取去掉前后空格后的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 tv
- * @return
- */
- public static String getNoBlankString(TextView tv) {
- return getNoBlankString(getString(tv));
- }
- /**获取去掉所有空格后的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 tv
- * @param trim
- * @return
- */
- public static int getLength(TextView tv, boolean trim) {
- return getLength(getString(tv), trim);
- }
- /**获取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 tv
- * @param trim
- * @return
- */
- public static boolean isNotEmpty(TextView tv, boolean trim) {
- return isNotEmpty(getString(tv), trim);
- }
- /**判断字符是否非空
- * @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) {
- // Log.i(TAG, "getTrimedString s = " + s);
- if (s == null) {
- return false;
- }
- if (trim) {
- s = s.trim();
- }
- if (s.length() <= 0) {
- return false;
- }
-
- currentString = s;
-
- return true;
- }
-
- //判断字符是否非空 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
- //判断字符类型 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
- //判断手机格式是否正确
- 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) {
- System.out.println("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 inputed
- * @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.w(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();
- }
- /**判断字符类型是否是路径
- * @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 tv
- * @return
- */
- public static String getNumber(TextView tv) {
- return getNumber(getString(tv));
- }
- /**去掉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) {
- 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;
- }
- }
-
- return numberString;
- }
-
- //提取特殊字符>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
- //校正(自动补全等)字符串<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
- /**获取网址,自动补全
- * @param tv
- * @return
- */
- public static String getCorrectUrl(TextView tv) {
- return getCorrectUrl(getString(tv));
- }
- /**获取网址,自动补全
- * @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 tv
- * @return
- */
- public static String getCorrectPhone(TextView tv) {
- return getCorrectPhone(getString(tv));
- }
- /**获取去掉所有 空格 、"-" 、"+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 tv
- * @return
- */
- public static String getCorrectEmail(TextView tv) {
- return getCorrectEmail(getString(tv));
- }
- /**获取邮箱,自动补全
- * @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;
- }
- }
-
-
- //校正(自动补全等)字符串>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-}
diff --git a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/DemoApplication.java b/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/DemoApplication.java
deleted file mode 100644
index f1fd04be6..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/DemoApplication.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*Copyright ©2015 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 zuo.biao.apijson.client;
-
-import android.app.Application;
-import android.util.Log;
-
-/**Application
- * @author Lemon
- * @see #init
- */
-public class DemoApplication extends Application {
- private static final String TAG = "DemoApplication";
-
-
- private static Application instance;
- public static Application getInstance() {
- return instance;
- }
-
- @Override
- public void onCreate() {
- super.onCreate();
- Log.d(TAG, "项目启动 >>>>>>>>>>>>>>>>>>>> \n\n");
-
- init(this);
- }
-
- /**初始化方法
- * @param application
- * @must 调用init方法且只能调用一次,如果extends BaseApplication会自动调用
- */
- public static void init(Application application) {
- instance = application;
- if (instance == null) {
- Log.e(TAG, "\n\n\n\n\n !!!!!! 调用BaseApplication中的init方法,instance不能为null !!!" +
- "\n <<<<<< init instance == null !!! >>>>>>>> \n\n\n\n");
- }
-
- }
-
- /**获取应用名
- * @return
- */
- public String getAppName() {
- return getResources().getString(R.string.app_name);
- }
- /**获取应用版本名(显示给用户看的)
- * @return
- */
- public String getAppVersion() {
- return getResources().getString(R.string.app_version);
- }
-
-
-}
diff --git a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/HttpManager.java b/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/HttpManager.java
deleted file mode 100644
index e2ce95b1a..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/HttpManager.java
+++ /dev/null
@@ -1,328 +0,0 @@
-/*Copyright ©2015 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 zuo.biao.apijson.client;
-
-import static zuo.biao.apijson.StringUtil.UTF_8;
-
-import java.io.IOException;
-import java.net.CookieHandler;
-import java.net.URI;
-import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import zuo.biao.apijson.StringUtil;
-import android.content.Context;
-import android.os.AsyncTask;
-import android.text.TextUtils;
-import android.util.Log;
-
-import com.squareup.okhttp.FormEncodingBuilder;
-import com.squareup.okhttp.OkHttpClient;
-import com.squareup.okhttp.Request;
-import com.squareup.okhttp.Response;
-
-/**HTTP请求管理类
- * @author Lemon
- * @use HttpManager.getInstance().get(...)或HttpManager.getInstance().post(...) > 在回调方法onHttpRequestSuccess和onHttpRequestError处理HTTP请求结果
- * @must 解决getToken,getResponseCode,getResponseData中的TODO
- */
-public class HttpManager {
- private static final String TAG = "HttpManager";
-
- /**网络请求回调接口
- */
- public interface OnHttpResponseListener {
- /**
- * @param requestCode 请求码,自定义,在发起请求的类中可以用requestCode来区分各个请求
- * @param resultJson 服务器返回的Json串
- * @param e 异常
- */
- void onHttpResponse(int requestCode, String resultJson, Exception e);
- }
-
-
-
- private Context context;
- private static HttpManager instance;// 单例
- private HttpManager(Context context) {
- this.context = context;
-
- }
-
- public synchronized static HttpManager getInstance() {
- if (instance == null) {
- instance = new HttpManager(DemoApplication.getInstance());
- }
- return instance;
- }
-
-
-
- /**
- * 列表首页页码。有些服务器设置为1,即列表页码从1开始
- */
- public static final int PAGE_NUM_0 = 0;
-
- public static final String KEY_TOKEN = "token";
- public static final String KEY_COOKIE = "cookie";
-
-
- /**GET请求
- * @param paramList 请求参数列表,(可以一个键对应多个值)
- * @param url 接口url
- * @param requestCode
- * 请求码,类似onActivityResult中请求码,当同一activity中以实现接口方式发起多个网络请求时,请求结束后都会回调
- * {@link OnHttpResponseListener#onHttpResponse(int, String, Exception)}
- * 在发起请求的类中可以用requestCode来区分各个请求
- * @param listener
- */
- public void get(final String url_, final String request, final OnHttpResponseListener listener) {
- Log.d(TAG, "get url_ = " + url_ + "; request = " + request + " >>>");
- new AsyncTask() {
-
- String result;
- @Override
- protected Exception doInBackground(Void... params) {
- try {
- String url = StringUtil.getNoBlankString(url_)
- + URLEncoder.encode(StringUtil.getNoBlankString(request), UTF_8);
- StringBuffer sb = new StringBuffer();
- sb.append(url);
-
- OkHttpClient client = getHttpClient(url);
- if (client == null) {
- return new Exception(TAG + ".get AsyncTask.doInBackground client == null >> return;");
- }
-
- result = getResponseJson(client, new Request.Builder()
- .addHeader(KEY_TOKEN, getToken(url))
- .url(http://github.com/sb.toString()).build());
- } catch (Exception e) {
- Log.e(TAG, "get AsyncTask.doInBackground try { result = getResponseJson(..." +
- "} catch (Exception e) {\n" + e.getMessage());
- return e;
- }
-
- return null;
- }
-
- @Override
- protected void onPostExecute(Exception exception) {
- super.onPostExecute(exception);
- listener.onHttpResponse(0, result, exception);
- }
-
- }.execute();
-
- }
-
-
- /**POST请求
- * @param paramList 请求参数列表,(可以一个键对应多个值)
- * @param url 接口url
- * @param requestCode
- * 请求码,类似onActivityResult中请求码,当同一activity中以实现接口方式发起多个网络请求时,请求结束后都会回调
- * {@link OnHttpResponseListener#onHttpResponse(int, String, Exception)}
- * 在发起请求的类中可以用requestCode来区分各个请求
- * @param listener
- */
- public void post(final String url_, final String request, final OnHttpResponseListener listener) {
-
- new AsyncTask() {
-
- String result;
- @Override
- protected Exception doInBackground(Void... params) {
-
- FormEncodingBuilder fBuilder = new FormEncodingBuilder();
- try {
- String url = StringUtil.getNoBlankString(url_)
- + URLEncoder.encode(StringUtil.getNoBlankString(request), UTF_8);
-
- OkHttpClient client = getHttpClient(url);
- if (client == null) {
- return new Exception(TAG + ".post AsyncTask.doInBackground client == null >> return;");
- }
- result = getResponseJson(client, new Request.Builder()
- .addHeader(KEY_TOKEN, getToken(url)).url(http://github.com/StringUtil.getNoBlankString(url))
- .post(fBuilder.build()).build());
- } catch (Exception e) {
- Log.e(TAG, "post AsyncTask.doInBackground try { result = getResponseJson(..." +
- "} catch (Exception e) {\n" + e.getMessage());
- return e;
- }
-
- return null;
- }
-
- @Override
- protected void onPostExecute(Exception exception) {
- super.onPostExecute(exception);
- listener.onHttpResponse(0, result, exception);
- }
-
- }.execute();
- }
-
-
- //httpGet/httpPost 内调用方法 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
- /**
- * @param url
- * @return
- */
- private OkHttpClient getHttpClient(String url) {
- Log.i(TAG, "getHttpClient url = " + url);
- if (StringUtil.isNotEmpty(url, true) == false) {
- Log.e(TAG, "getHttpClient StringUtil.isNotEmpty(url, true) == false >> return null;");
- return null;
- }
-
- OkHttpClient client = new OkHttpClient();
- client.setCookieHandler(new HttpHead());
- client.setConnectTimeout(15, TimeUnit.SECONDS);
- client.setWriteTimeout(10, TimeUnit.SECONDS);
- client.setReadTimeout(10, TimeUnit.SECONDS);
-
- return client;
- }
-
- /**
- * @param paramList
- * @must demo_***改为服务器设定值
- * @return
- */
- public String getToken(String tag) {
- return context.getSharedPreferences(KEY_TOKEN, Context.MODE_PRIVATE).getString(KEY_TOKEN + tag, "");
- }
- /**
- * @param tag
- * @param value
- */
- public void saveToken(String tag, String value) {
- context.getSharedPreferences(KEY_TOKEN, Context.MODE_PRIVATE)
- .edit()
- .remove(KEY_TOKEN + tag)
- .putString(KEY_TOKEN + tag, value)
- .commit();
- }
-
-
- /**
- * @return
- */
- public String getCookie() {
- return context.getSharedPreferences(KEY_COOKIE, Context.MODE_PRIVATE).getString(KEY_COOKIE, "");
- }
- /**
- * @param value
- */
- public void saveCookie(String value) {
- context.getSharedPreferences(KEY_COOKIE, Context.MODE_PRIVATE)
- .edit()
- .remove(KEY_COOKIE)
- .putString(KEY_COOKIE, value)
- .commit();
- }
-
-
- /**
- * @param client
- * @param request
- * @return
- * @throws Exception
- */
- private String getResponseJson(OkHttpClient client, Request request) throws Exception {
- if (client == null || request == null) {
- Log.e(TAG, "getResponseJson client == null || request == null >> return null;");
- return null;
- }
- Response response = client.newCall(request).execute();
- return response.isSuccessful() ? response.body().string() : null;
- }
-
- /**从object中获取key对应的值
- * *获取如果T是基本类型容易崩溃,所以需要try-catch
- * @param json
- * @param key
- * @return
- * @throws JSONException
- */
- public T getValue(String json, String key) throws JSONException {
- return getValue(new JSONObject(json), key);
- }
- /**从object中获取key对应的值
- * *获取如果T是基本类型容易崩溃,所以需要try-catch
- * @param object
- * @param key
- * @return
- * @throws JSONException
- */
- @SuppressWarnings("unchecked")
- public T getValue(JSONObject object, String key) throws JSONException {
- return (T) object.get(key);
- }
-
- //httpGet/httpPost 内调用方法 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
-
-
- /**http请求头
- */
- public class HttpHead extends CookieHandler {
- public HttpHead() {
- }
-
- @Override
- public Map> get(URI uri, Map> requestHeaders) throws IOException {
- String cookie = getCookie();
- Map> map = new HashMap>();
- map.putAll(requestHeaders);
- if (!TextUtils.isEmpty(cookie)) {
- List cList = new ArrayList();
- cList.add(cookie);
- map.put("Cookie", cList);
- }
- return map;
- }
-
- @Override
- public void put(URI uri, Map> responseHeaders) throws IOException {
- List list = responseHeaders.get("Set-Cookie");
- if (list != null) {
- for (int i = 0; i < list.size(); i++) {
- String cookie = list.get(i);
- if (cookie.startsWith("JSESSIONID")) {
- saveCookie(list.get(i));
- break;
- }
- }
- }
- }
-
- }
-
-
-
-
-}
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/JSONObject.java b/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/JSONObject.java
deleted file mode 100644
index 642072c14..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/JSONObject.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*Copyright ©2015 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 zuo.biao.apijson.client;
-
-import static zuo.biao.apijson.StringUtil.UTF_8;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import java.net.URLEncoder;
-import java.util.Set;
-
-import zuo.biao.apijson.JSON;
-import zuo.biao.apijson.StringUtil;
-
-/**use this class instead of com.alibaba.fastjson.JSONObject
- * @author Lemon
- */
-public class JSONObject extends com.alibaba.fastjson.JSONObject {
- private static final long serialVersionUID = 8907029699680768212L;
-
- /**ordered
- */
- public JSONObject() {
- super(true);
- }
- public JSONObject(String json) {
- this(JSON.parseObject(json));
- }
- /**transfer com.alibaba.fastjson.JSONObject to JSONObject
- * @param object
- */
- public JSONObject(com.alibaba.fastjson.JSONObject object) {
- this();
- add(object);
- }
-
-
-
- /**
- * @param key
- * @return if value is String, return URLDecoder.decode((String) value, UTF_8);
- */
- public Object getWithDecode(String key) {
- Object value = get(key);
- if (value instanceof String) {
- try {
- return URLDecoder.decode((String) value, UTF_8);
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- }
- return value;
- }
-
-
- /**put(value.getClass().getSimpleName(), value);
- * @param value
- * @return
- */
- public Object putWithEncode(Object value) {
- return putWithEncode(null, value);
- }
- /**
- * @param key
- * @param value if is String, value = URLEncoder.encode((String) value, UTF_8);
- * @return
- */
- public Object putWithEncode(String key, Object value) {
- if (value instanceof String) {
- try {
- value = URLEncoder.encode((String) value, UTF_8);
- //just encode /, not need to encode [] ? URLEncoder.encode(key, UTF_8)
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- }
- return super.put(StringUtil.isNotEmpty(key, true) ? key : value.getClass().getSimpleName(), value);
- }
-
- /**put key-value in object into this
- * @param object
- */
- public void add(com.alibaba.fastjson.JSONObject object) {
- Set set = object == null ? null : object.keySet();
- if (set != null) {
- for (String key : set) {
- put(key, object.get(key));
- }
- }
- }
-
-
- //array object <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- public static final String KEY_COUNT = "count";
- public static final String KEY_PAGE = "page";
-
- public JSONObject setCount(int count) {
- put(KEY_COUNT, count);
- return this;
- }
- public int getCount() {
- return getIntValue(KEY_COUNT);
- }
-
- public JSONObject setPage(int page) {
- put(KEY_PAGE, page);
- return this;
- }
- public int getPage() {
- return getIntValue(KEY_PAGE);
- }
- //array object >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
-
- //judge <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- /**
- * @param json
- * @return
- */
- public static boolean isJSONObject(String json) {
- return JSON.parseObject(json) != null;
- }
- /**
- * @param key
- * @return
- */
- public static boolean isObjectKey(String key) {
- key = StringUtil.getString(key);
- return StringUtil.isNotEmpty(key, false) && isArrayKey(key) == false && StringUtil.isAlpha(key.substring(0, 1));
- }
- /**
- * @param key
- * @return
- */
- public static boolean isArrayKey(String key) {
- return key.endsWith("[]");
- }
- //judge >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-}
diff --git a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/JSONRequest.java b/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/JSONRequest.java
deleted file mode 100644
index 73d40f37a..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/JSONRequest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*Copyright ©2015 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 zuo.biao.apijson.client;
-
-import zuo.biao.apijson.StringUtil;
-
-/**encapsulator for request JSONObject
- * @author Lemon
- * @see #toArray
- * @see RequestUtil
- * @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();
- }
- public JSONRequest(Object object) {
- this(null, object);
- }
- public JSONRequest(String name, Object object) {
- this();
- put(name, object);
- }
-
- /**put(value.getClass().getSimpleName(), value);
- * @param value
- * @return
- */
- public Object put(Object value) {
- return super.putWithEncode(value);
- }
- @Override
- public Object put(String key, Object value) {
- return super.putWithEncode(key, value);
- }
-
-
- /**create a parent JSONObject named []
- * @param count
- * @param page
- * @return {"[]":this}
- */
- public JSONRequest toArray(int count, int page) {
- return toArray(count, page, null);
- }
- /**create a parent JSONObject named name+[]
- * @param count
- * @param page
- * @param name
- * @return {name+"[]" : this}
- */
- public JSONRequest toArray(int count, int page, String name) {
- return new JSONRequest(StringUtil.getString(name) + "[]", this.setCount(count).setPage(page));
- }
-
-}
diff --git a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/JSONResponse.java b/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/JSONResponse.java
deleted file mode 100644
index ff317c0ac..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/JSONResponse.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*Copyright ©2015 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 zuo.biao.apijson.client;
-
-import java.util.List;
-import java.util.Set;
-
-import zuo.biao.apijson.JSON;
-import zuo.biao.apijson.StringUtil;
-import zuo.biao.apijson.client.ui.QueryActivity;
-
-import com.alibaba.fastjson.JSONArray;
-
-/**parser for response JSON String
- * @author Lemon
- * @see #getList
- * @see #getJSONArray
- * @see QueryActivity#onHttpResponse
- * @use JSONResponse response = new JSONResponse(...);
- *
JSONArray array = JSONResponse.getJSONArray(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 JSONObject {
- private static final long serialVersionUID = -6707531287941223427L;
-
- public JSONResponse() {
- super();
- }
- public JSONResponse(String json) {
- super(json);
- }
- public JSONResponse(com.alibaba.fastjson.JSONObject object) {
- super(object);
- }
-
- @Override
- public Object get(Object key) {
- return key instanceof String ? super.getWithDecode((String) key) : super.get(key);
- }
- public Object get(String key) {
- return getWithDecode(key);
- }
-
-
-
- /**
- * @param clazz
- * @return
- */
- public T getObject(Class clazz) {
- return getObject(this, clazz);
- }
- /**
- * @param object
- * @param clazz
- * @return
- */
- public static T getObject(com.alibaba.fastjson.JSONObject object, Class clazz) {
- return JSON.parseObject(JSON.toJSONString(clazz == null ? object : object.getJSONObject(clazz.getSimpleName())), clazz);
- }
- // /**
- // * @param json
- // * @param clazz
- // * @return
- // */
- // public static T getObject(String json, Class clazz) {
- // return getObject(JSON.parseObject(json, clazz), clazz);
- // }
-
-
- /**
- * arrayObject = this
- * @param clazz
- * @return
- */
- public List getList(Class clazz) {
- return getList(this, clazz);
- }
- /**
- * @param arrayObject
- * @param clazz
- * @return
- */
- public static List getList(com.alibaba.fastjson.JSONObject arrayObject, Class clazz) {
- return JSON.parseArray(JSON.toJSONString(getJSONArray(arrayObject
- , clazz == null ? null : clazz.getSimpleName())), clazz);
- }
-
- /**
- * @param arrayKey
- * @param className
- * @return
- */
- public JSONArray getJSONArray(String arrayKey, String className) {
- if (StringUtil.isNotEmpty(arrayKey, true) == false) {
- arrayKey = StringUtil.getString(className) + "[]";
- }
- return isArrayKey(arrayKey) ? getJSONArray(getJSONObject(arrayKey), className) : super.getJSONArray(arrayKey);
- }
-
- /**
- * arrayObject = this
- * @return
- */
- public JSONArray getJSONArray() {
- return getJSONArray(this, null);
- }
- /**
- * arrayObject = this
- * @return
- */
- public JSONArray getJSONArray(String className) {
- return getJSONArray(this, className);
- }
- /**
- * @param
- * @param arrayObject
- * @param clazz
- * @return
- */
- public static JSONArray getJSONArray(com.alibaba.fastjson.JSONObject arrayObject) {
- return getJSONArray(arrayObject, null);
- }
- /**
- * @param
- * @param arrayObject
- * @param clazz
- * @return
- */
- public static JSONArray getJSONArray(com.alibaba.fastjson.JSONObject arrayObject, String className) {
- Set set = arrayObject == null ? null : arrayObject.keySet();
- if (set == null || set.isEmpty()) {
- return null;
- }
-
- String parentString = StringUtil.getTrimedString(com.alibaba.fastjson.JSON.toJSONString(arrayObject));
- if (parentString.isEmpty()) {
- return null;
- }
- if (parentString.startsWith("[")) {
- if (parentString.endsWith("]") == false) {
- parentString += "]";
- }
- return JSON.parseArray(parentString);
- }
-
- //{"0":{...}, "1":{...}...}
-
- className = StringUtil.getTrimedString(className);
-
- JSONArray array = new JSONArray(set.size());
- com.alibaba.fastjson.JSONObject value;
- int index;
- for (String key : set) {//0, 1, 2,...
- value = StringUtil.isNumer(key) == false ? null : arrayObject.getJSONObject(key);
- if (value != null) {
- try {
- index = Integer.valueOf(0 + key);
- array.set(index, className.isEmpty() ? value : value.getJSONObject(className));
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- return array;
- }
-
-
-}
diff --git a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/RequestUtil.java b/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/RequestUtil.java
deleted file mode 100644
index ab8ee4e26..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/RequestUtil.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*Copyright ©2015 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 zuo.biao.apijson.client;
-
-import zuo.biao.apijson.client.model.Comment;
-import zuo.biao.apijson.client.model.User;
-import zuo.biao.apijson.client.model.Wallet;
-import zuo.biao.apijson.client.model.Work;
-
-/**create request JSONObjects
- * @author Lemon
- */
-public class RequestUtil {
-
- public static JSONObject newSingleRequest() {
- return new JSONRequest(new User((long) 38710));
- }
-
- public static JSONObject newRelyRequest() {
- JSONRequest request = new JSONRequest();
- request.put(new User((long) 70793));
- request.put(Work.class.getSimpleName(), new JSONRequest("userId", "User/id"));
- return request;
- }
-
- public static JSONObject newArrayRequest() {
- return new JSONRequest(new User().setSex(0)).toArray(10, 0, User.class.getSimpleName());
- }
-
- public static JSONObject newComplexRequest() {
-
- JSONRequest request = new JSONRequest();
- request.put(new User().setSex(0));
- request.put(Work.class.getSimpleName(), new JSONRequest("userId", "/User/id"));
-
- request.add(new JSONRequest(Comment.class.getSimpleName(), new JSONRequest("workId", "[]/Work/id")).
- toArray(3, 0, Comment.class.getSimpleName()));
-
- return request.toArray(2, 1);
- }
-
- public static JSONObject newAccessErrorRequest() {
- return new JSONRequest(new Wallet((long) 38710));
- }
-
- public static JSONObject newAccessPermittedRequest() {
- JSONRequest request = new JSONRequest();
- request.put(new Wallet().setUserId((long) 38710));
- request.put("currentUserId", 38710);
- request.put("payPassword", "123456");
- return request;
- }
-
-}
diff --git a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/RequestUtil2.java b/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/RequestUtil2.java
deleted file mode 100644
index 492ac1f36..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/RequestUtil2.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*Copyright ©2015 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 zuo.biao.apijson.client;
-
-import static zuo.biao.apijson.StringUtil.UTF_8;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-
-import zuo.biao.apijson.JSON;
-import zuo.biao.apijson.StringUtil;
-import zuo.biao.apijson.client.model.User;
-import zuo.biao.apijson.client.model.Work;
-
-/**RequestUtil is suggested
- * @author Lemon
- */
-public class RequestUtil2 {
-
-
- /**
- * @param object
- * @return
- */
- public static String getString(JSONObject object) {
- try {
- return URLEncoder.encode(JSON.toJSONString(object), UTF_8);
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- return null;
- }
-
- /**
- * name = null, {"[]":object}
- * @param object
- * @return NonNull
- */
- public static JSONObject getArrayRequest(JSONObject object) {
- return getArrayRequest(null, object);
- }
- /**
- * name = null, {"name+"[]"":object}
- * @param object
- * @return NonNull
- */
- public static JSONObject getArrayRequest(String name, JSONObject object) {
- return getObjectRequest((name == null ? "" : name) + "[]", object);
- }
-
- /**
- * @param object
- * @return
- */
- public static JSONObject getObjectRequest(T object) {
- return getObjectRequest(null, object);
- }
- /**
- * @param name
- * @param object
- * @return NonNull
- */
- public static JSONObject getObjectRequest(String name, T object) {
- JSONObject jsonObject = new JSONObject();
- if (object != null) {
- jsonObject.put(StringUtil.isNotEmpty(name, true) ? name : object.getClass().getSimpleName(), object);
- }
- return jsonObject;
- }
-
-
- /**
- * @param parent
- * @param child
- * @return
- */
- public static JSONObject put(JSONObject parent, T child) {
- if (parent == null) {
- parent = new JSONObject();
- }
- if (child != null) {
- parent.put(child.getClass().getSimpleName(), child);
- }
- return parent;
- }
-
-
- /**
- * @return
- */
- public static JSONObject newSingleRequest() {
- return getObjectRequest(new User((long) 38710));
- }
- /**
- * @return
- */
- public static JSONObject newRelyRequest() {
- JSONObject object = new JSONObject();
-
- object.put(User.class.getSimpleName(), new User((long) 38710));
-
- JSONObject workObject = new JSONObject();
- try {
- workObject.put("userId", URLEncoder.encode("User/id", UTF_8));//User.getFieldPath("id"));
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- return null;
- }
- object.put(Work.class.getSimpleName(), workObject);
-
- return object;
- }
- /**
- * @return
- */
- public static JSONObject newArrayRequest() {
- JSONObject object = new JSONObject();
- object.put("count", 10);
- object = put(object, new User().setSex(0));
- return getArrayRequest(object);
- }
- /**
- * @return
- */
- public static JSONObject newComplexRequest() {
- JSONObject userObject = new JSONObject();
- userObject.put("sex", 0);
-
- JSONObject workObject = new JSONObject();
- // workObject.put("userId", "/User/id");
- try {
- workObject.put("userId", URLEncoder.encode("/User/id", UTF_8));
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- JSONObject commentObject = new JSONObject();
- // commentObject.put("workId", "[]/Work/id");
- try {
- commentObject.put("workId", URLEncoder.encode("[]/Work/id", UTF_8));
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- JSONObject commentArrayObject = new JSONObject();
- commentArrayObject.put("page", 0);
- commentArrayObject.put("count", 3);
- commentArrayObject.put("Comment", commentObject);
-
- JSONObject arrayObject = new JSONObject();
- arrayObject.put("page", 1);
- arrayObject.put("count", 10);
- arrayObject.put("User", userObject);
- arrayObject.put("Work", workObject);
- try {
- arrayObject.put(URLEncoder.encode("Comment[]", UTF_8), commentArrayObject);
- } catch (UnsupportedEncodingException e1) {
- e1.printStackTrace();
- }
-
- return getArrayRequest(arrayObject);
- }
-
-}
diff --git a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/model/BaseModel.java b/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/model/BaseModel.java
deleted file mode 100644
index 906071a83..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/model/BaseModel.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*Copyright ©2015 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 zuo.biao.apijson.client.model;
-
-import java.io.Serializable;
-
-/**base model for reduce model codes
- * @author Lemon
- * @use extends BaseModel
- */
-public abstract class BaseModel implements Serializable {
- private static final long serialVersionUID = 7560533944342381808L;
-
- public Long id;
-
- public Long getId() {
- return id;
- }
- public void setId(Long id) {
- this.id = id;
- }
-
-}
diff --git a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/model/Comment.java b/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/model/Comment.java
deleted file mode 100644
index f60ed339a..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/model/Comment.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*Copyright ©2015 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 zuo.biao.apijson.client.model;
-
-/**评论类
- * @author Lemon
- */
-public class Comment extends BaseModel {
- private static final long serialVersionUID = -1011007127735372824L;
-
-
- public Long workId;
- public Long parentId;
- public Long userId;
- public Long targetUserId;
- public String userName;
- public String targetUserName;
- public String content;
- public Comment() {
- super();
- }
- public Comment(Long id, String content) {
- this();
- this.id = id;
- this.content = content;
- }
-
- public Long getWorkId() {
- return workId;
- }
- public void setWorkId(Long workId) {
- this.workId = workId;
- }
- public Long getParentId() {
- return parentId;
- }
- public void setParentId(Long parentId) {
- this.parentId = parentId;
- }
- public Long getUserId() {
- return userId;
- }
- public void setUserId(Long userId) {
- this.userId = userId;
- }
- public Long getTargetUserId() {
- return targetUserId;
- }
- public void setTargetUserId(Long targetUserId) {
- this.targetUserId = targetUserId;
- }
- public String getUserName() {
- return userName;
- }
- public void setUserName(String userName) {
- this.userName = userName;
- }
- public String getTargetUserName() {
- return targetUserName;
- }
- public void setTargetUserName(String targetUserName) {
- this.targetUserName = targetUserName;
- }
- public String getContent() {
- return content;
- }
- public void setContent(String content) {
- this.content = content;
- }
-
-
-}
diff --git a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/model/User.java b/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/model/User.java
deleted file mode 100644
index 29e9abad2..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/model/User.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*Copyright ©2015 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 zuo.biao.apijson.client.model;
-
-/**用户类
- * @author Lemon
- */
-public class User extends BaseModel {
- private static final long serialVersionUID = -1635551656020732611L;
-
- public Integer sex;
- public String head;
- public String name;
- public String phone;
- public String picture;
-
- /**默认构造方法,JSON等解析时必须要有
- */
- public User() {
- super();
- }
- public User(Long id) {
- this();
- this.id = id;
- }
- public User(Long id, String name) {
- this(id);
- this.name = name;
- }
-
- public Integer getSex() {
- return sex;
- }
- public User setSex(Integer sex) {
- this.sex = sex;
- return this;
- }
- public String getHead() {
- return head;
- }
- public void setHead(String head) {
- this.head = head;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public String getPhone() {
- return phone;
- }
- public void setPhone(String phone) {
- this.phone = phone;
- }
- public String getPicture() {
- return picture;
- }
- public void setPicture(String picture) {
- this.picture = picture;
- }
-
- //// @Override
- //// public boolean isCorrect() {//根据自己的需求决定,也可以直接 return true
- //// return id != null && id > 0;// && StringUtil.isNotEmpty(phone, true);
- //// }
- //
- // @Override
- // public JSONObject toJSONObject() {
- // return toJSONObject(this);
- // }
-}
diff --git a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/model/Wallet.java b/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/model/Wallet.java
deleted file mode 100644
index 90f5a2825..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/model/Wallet.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*Copyright ©2015 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 zuo.biao.apijson.client.model;
-
-import java.math.BigDecimal;
-
-/**钱包类
- * @author Lemon
- */
-public class Wallet extends BaseModel {
- private static final long serialVersionUID = 4298571449155754300L;
-
- public BigDecimal balance;
-
- public Long userId;
-
- /**默认构造方法,JSON等解析时必须要有
- */
- public Wallet() {
- super();
- }
- public Wallet(Long id) {
- this();
- this.id = id;
- }
-
- public Wallet setUserId(Long userId) {
- this.userId = userId;
- return this;
- }
- public Long getUserId() {
- return userId;
- }
-
- public BigDecimal getBalance() {
- return balance;
- }
- public void setBalance(BigDecimal balance) {
- this.balance = balance;
- }
-
-}
diff --git a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/model/Work.java b/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/model/Work.java
deleted file mode 100644
index 2023ec1a9..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/model/Work.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*Copyright ©2015 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 zuo.biao.apijson.client.model;
-
-/**作品类
- * @author Lemon
- */
-public class Work extends BaseModel {
- private static final long serialVersionUID = -7437225320551780084L;
-
- public long userId;
- public String title;
- public String content;
- public String picture;
-
- public Work() {
- super();
- }
- public Work(long id, String title) {
- this();
- this.id = id;
- this.title = title;
- }
-
- public long getUserId() {
- return userId;
- }
- public void setUserId(long userId) {
- this.userId = userId;
- }
- public String getTitle() {
- return title;
- }
- public void setTitle(String title) {
- this.title = title;
- }
- public String getContent() {
- return content;
- }
- public void setContent(String content) {
- this.content = content;
- }
- public String getPicture() {
- return picture;
- }
- public void setPicture(String picture) {
- this.picture = picture;
- }
-
-
-// @Override
-// public boolean isCorrect() {
-// return getId() > 0 && getUserId() > 0
-// && (StringUtil.isNotEmpty(getTitle(), true) || StringUtil.isNotEmpty(getContent(), true));
-// }
-
-}
diff --git a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/model/package-info.java b/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/model/package-info.java
deleted file mode 100644
index 4934219e5..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/model/package-info.java
+++ /dev/null
@@ -1,11 +0,0 @@
-/**
- * the names of classes equal the names of tables in Server database one by one, so do the variables and columns
- * (name) : model <=> table
- * (name, type) : variable <=> column
- * @warn don't use any base type like int or char in models, use Integer and String instead
- */
-/**
- * @author Lemon
- *
- */
-package zuo.biao.apijson.client.model;
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/ui/QueryActivity.java b/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/ui/QueryActivity.java
deleted file mode 100644
index a6bc339cc..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/ui/QueryActivity.java
+++ /dev/null
@@ -1,272 +0,0 @@
-/*Copyright ©2015 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 zuo.biao.apijson.client.ui;
-
-import static zuo.biao.apijson.StringUtil.UTF_8;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.util.List;
-
-import zuo.biao.apijson.JSON;
-import zuo.biao.apijson.StringUtil;
-import zuo.biao.apijson.client.HttpManager;
-import zuo.biao.apijson.client.HttpManager.OnHttpResponseListener;
-import zuo.biao.apijson.client.JSONResponse;
-import zuo.biao.apijson.client.R;
-import zuo.biao.apijson.client.RequestUtil;
-import zuo.biao.apijson.client.model.Comment;
-import zuo.biao.apijson.client.model.User;
-import zuo.biao.apijson.client.model.Wallet;
-import zuo.biao.apijson.client.model.Work;
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.View.OnLongClickListener;
-import android.widget.EditText;
-import android.widget.ProgressBar;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import com.alibaba.fastjson.JSONArray;
-
-/**activity for requesting a query in Server
- * @author Lemon
- */
-public class QueryActivity extends Activity implements OnHttpResponseListener {
- private static final String TAG = "QueryActivity";
-
-
- public static final String INTENT_TYPE = "INTENT_TYPE";
- public static final String INTENT_URL = "INTENT_URL";
-
- public static final String RESULT_URL = "RESULT_URL";
-
- /**
- * @param context
- * @param type
- * @param url
- * @return
- */
- public static Intent createIntent(Context context, int type, String url) {
- return new Intent(context, QueryActivity.class)
- .putExtra(QueryActivity.INTENT_TYPE, type)
- .putExtra(QueryActivity.INTENT_URL, url);
- }
-
-
- public static final int TYPE_SINGLE = 0;
- public static final int TYPE_RELY = 1;
- public static final int TYPE_ARRAY = 2;
- public static final int TYPE_COMPLEX = 3;
- public static final int TYPE_ACCESS_ERROR = 4;
- public static final int TYPE_ACCESS_PERMITTED = 5;
-
-
- private int type = TYPE_SINGLE;
- private String url;
-
- private Activity context;
- private boolean isAlive;
-
- private TextView tvQueryResult;
- private ProgressBar pbQuery;
- private EditText etQueryUri;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.query_activity);
- context = this;
- isAlive = true;
-
- Intent intent = getIntent();
- type = intent.getIntExtra(INTENT_TYPE, type);
- url = intent.getStringExtra(INTENT_URL);
-
-
- tvQueryResult = (TextView) findViewById(R.id.tvQueryResult);
- pbQuery = (ProgressBar) findViewById(R.id.pbQuery);
- etQueryUri = (EditText) findViewById(R.id.etQueryUri);
-
- etQueryUri.setText(StringUtil.getString(StringUtil.isNotEmpty(url, true)
- ? url : "http://192.168.1.104:8080/get/"));//TODO my computer ipv4 address,edit it to an available one
-
-
- query();
-
-
- findViewById(R.id.btnQueryQuery).setOnClickListener(new OnClickListener() {
-
- @Override
- public void onClick(View v) {
- query();
- }
- });
- findViewById(R.id.btnQueryQuery).setOnLongClickListener(new OnLongClickListener() {
-
- @Override
- public boolean onLongClick(View v) {
- openWebSite();
- return true;
- }
- });
- }
-
-
-
- //click event,called form layout android:onClick <<<<<<<<<<<<<<<<
- public void query(View v) {
- query();
- }
- //click event,called form layout android:onClick >>>>>>>>>>>>>>>>
-
- private String request;
- public void setRequest() {
- url = StringUtil.getNoBlankString(etQueryUri);
- switch (type) {
- case TYPE_SINGLE:
- request = JSON.toJSONString(RequestUtil.newSingleRequest());
- break;
- case TYPE_RELY:
- request = JSON.toJSONString(RequestUtil.newRelyRequest());
- break;
- case TYPE_ARRAY:
- request = JSON.toJSONString(RequestUtil.newArrayRequest());
- break;
- case TYPE_ACCESS_ERROR:
- request = JSON.toJSONString(RequestUtil.newAccessErrorRequest());
- break;
- case TYPE_ACCESS_PERMITTED:
- request = JSON.toJSONString(RequestUtil.newAccessPermittedRequest());
- break;
- default:
- request = JSON.toJSONString(RequestUtil.newComplexRequest());
- break;
- }
- Log.d(TAG, "setRequest url = " + url + ";\n request = " + request);
- }
-
- /**request a query from server,and the result will be received by onHttpResponse method
- */
- private void query() {
- setRequest();
-
- tvQueryResult.setText("requesting...\n\n url = " + url + "\n\n request = \n" + request
- + "\n\n\n" + getResources().getString(R.string.query_error));
- pbQuery.setVisibility(View.VISIBLE);
-
- HttpManager.getInstance().get(url, request, this);
- }
-
-
-
- @Override
- public void onHttpResponse(int requestCode, final String resultJson, final Exception e) {
- Log.d(TAG, "onHttpResponse resultJson = " + resultJson);
- if (e != null) {
- Log.e(TAG, "onHttpResponse e = " + e.getMessage());
- }
- JSONResponse response = new JSONResponse(resultJson);
- if (type == TYPE_ARRAY) {
- logList(JSONResponse.getList(response.getJSONObject("User[]"), User.class));
- } else if (type == TYPE_COMPLEX) {
- JSONArray array = JSONResponse.getJSONArray(response.getJSONObject("[]"));//, "Comment[]");//
- if (array == null || array.isEmpty()) {
- Log.e(TAG, "onHttpResponse type == TYPE_COMPLEX >> array == null || array.isEmpty() >> return;");
- return;
- }
- response = new JSONResponse(array.getJSONObject(0));
-
- User user = JSONResponse.getObject(response, User.class);
- Log.d(TAG, "onHttpResponse type == TYPE_COMPLEX >> user = " + JSON.toJSONString(user));
- Work work = JSONResponse.getObject(response, Work.class);
- Log.d(TAG, "onHttpResponse type == TYPE_COMPLEX >> work = " + JSON.toJSONString(work));
- logList(JSONResponse.getList(response == null ? null : response.getJSONObject("Comment[]"), Comment.class));
- } else if (type == TYPE_ACCESS_PERMITTED) {
- response = new JSONResponse(resultJson);
- Wallet wallet = JSONResponse.getObject(response, Wallet.class);
- Log.d(TAG, "onHttpResponse type == TYPE_ACCESS_PERMITTED >> wallet = " + JSON.toJSONString(wallet));
- }
-
- runOnUiThread(new Runnable() {
-
- @Override
- public void run() {
- if (isAlive) {
- pbQuery.setVisibility(View.GONE);
- Toast.makeText(context, "received result!", Toast.LENGTH_SHORT).show();
-
- tvQueryResult.setText(e == null || JSON.isJsonCorrect(resultJson)
- ? StringUtil.getTrimedString(resultJson)
- : e.getMessage() + "\n\n\n" + getResources().getString(R.string.query_error));
-
- }
- }
- });
- }
-
-
- private void logList(List list) {
- if (list == null || list.isEmpty()) {
- Log.e(TAG, "logList list == null || list.isEmpty() >> return;");
- return;
- }
- for (T data : list) {
- Log.d(TAG, "\n logList " + (data == null ? "data" : data.getClass().getSimpleName())
- + " = \n" + JSON.toJSONString(data));
- }
- }
-
-
-
- /**open request URL String with a browser
- */
- public void openWebSite() {
- setRequest();
- String webSite = null;
- try {
- webSite = StringUtil.getNoBlankString(url)
- + URLEncoder.encode(StringUtil.getNoBlankString(request), UTF_8);
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- if (StringUtil.isNotEmpty(webSite, true) == false) {
- Log.e(TAG, "openWebSite StringUtil.isNotEmpty(webSite, true) == false >> return;");
- return;
- }
-
- startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(webSite)));
- }
-
-
-
- @Override
- public void finish() {
- setResult(RESULT_OK, new Intent().putExtra(RESULT_URL, url));
- super.finish();
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- isAlive = false;
- }
-
-}
diff --git a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/ui/SelectActivity.java b/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/ui/SelectActivity.java
deleted file mode 100644
index 5ccd82d83..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/ui/SelectActivity.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*Copyright ©2015 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 zuo.biao.apijson.client.ui;
-
-import zuo.biao.apijson.client.R;
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.Toast;
-
-/**activity for selecting a request
- * @author Lemon
- */
-public class SelectActivity extends Activity {
-
- public static final String RESULT_JSON = "RESULT_JSON";
-
- public static Intent createIntent(Context context) {
- return new Intent(context, SelectActivity.class);
- }
-
-
- private Activity context;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.select_activity);
-
- context = this;
- }
-
- //click event,called form layout android:onClick <<<<<<<<<<<<<<<<
- public void selectSingle(View v) {
- select(QueryActivity.TYPE_SINGLE);
- }
-
- public void selectRely(View v) {
- select(QueryActivity.TYPE_RELY);
- }
-
- public void selectArray(View v) {
- select(QueryActivity.TYPE_ARRAY);
- }
-
- public void selectComplex(View v) {
- select(QueryActivity.TYPE_COMPLEX);
- }
-
- public void selectAccessError(View v) {
- select(QueryActivity.TYPE_ACCESS_ERROR);
- }
-
- public void selectAccessPermitted(View v) {
- select(QueryActivity.TYPE_ACCESS_PERMITTED);
- }
- //click event,called form layout android:onClick >>>>>>>>>>>>>>>>
-
- private String url;
- private void select(int type) {
- startActivityForResult(QueryActivity.createIntent(context, type, url), REQUEST_TO_QUERY);
- }
-
- private static final int REQUEST_TO_QUERY = 1;
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- if (resultCode != RESULT_OK) {
- return;
- }
- switch (requestCode) {
- case REQUEST_TO_QUERY:
- if (data == null) {
- Toast.makeText(context, "onActivityResult data == null !!!", Toast.LENGTH_SHORT).show();
- return;
- }
- url = data.getStringExtra(QueryActivity.RESULT_URL);
- break;
- default:
- break;
- }
- }
-
-
-}
diff --git a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/ui/package-info.java b/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/ui/package-info.java
deleted file mode 100644
index 693ef57f1..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/client/ui/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*Copyright ©2015 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.*/
-
-/**
- * views show messages on screen
- */
-/**
- * @author Lemon
- *
- */
-package zuo.biao.apijson.client.ui;
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/package-info.java b/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/package-info.java
deleted file mode 100644
index a425e7828..000000000
--- a/APIJSON(Android)/APIJSON(ADT)/src/zuo/biao/apijson/package-info.java
+++ /dev/null
@@ -1,8 +0,0 @@
-/**
- * the same files for server and client projects
- */
-/**
- * @author Lemon
- *
- */
-package zuo.biao.apijson;
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/.gitignore b/APIJSON(Android)/APIJSON(AndroidStudio)/.gitignore
deleted file mode 100644
index c6cbe562a..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-*.iml
-.gradle
-/local.properties
-/.idea/workspace.xml
-/.idea/libraries
-.DS_Store
-/build
-/captures
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/.idea/.name b/APIJSON(Android)/APIJSON(AndroidStudio)/.idea/.name
deleted file mode 100644
index 16f0e27a8..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/.idea/.name
+++ /dev/null
@@ -1 +0,0 @@
-APIJSON
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/.idea/compiler.xml b/APIJSON(Android)/APIJSON(AndroidStudio)/.idea/compiler.xml
deleted file mode 100644
index 96cc43efa..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/.idea/compiler.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/.idea/copyright/profiles_settings.xml b/APIJSON(Android)/APIJSON(AndroidStudio)/.idea/copyright/profiles_settings.xml
deleted file mode 100644
index e7bedf337..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/.idea/copyright/profiles_settings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/.idea/dictionaries/Tommy.xml b/APIJSON(Android)/APIJSON(AndroidStudio)/.idea/dictionaries/Tommy.xml
deleted file mode 100644
index b4ca1e7c3..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/.idea/dictionaries/Tommy.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/.idea/encodings.xml b/APIJSON(Android)/APIJSON(AndroidStudio)/.idea/encodings.xml
deleted file mode 100644
index 97626ba45..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/.idea/encodings.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/.idea/gradle.xml b/APIJSON(Android)/APIJSON(AndroidStudio)/.idea/gradle.xml
deleted file mode 100644
index 508b3d9b8..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/.idea/gradle.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/.idea/misc.xml b/APIJSON(Android)/APIJSON(AndroidStudio)/.idea/misc.xml
deleted file mode 100644
index f0ee78c38..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/.idea/misc.xml
+++ /dev/null
@@ -1,65 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Spelling
-
-
-
-
- SpellCheckingInspection
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/.idea/modules.xml b/APIJSON(Android)/APIJSON(AndroidStudio)/.idea/modules.xml
deleted file mode 100644
index b40f7a6f1..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/.idea/modules.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/.idea/runConfigurations.xml b/APIJSON(Android)/APIJSON(AndroidStudio)/.idea/runConfigurations.xml
deleted file mode 100644
index 7f68460d8..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/.idea/runConfigurations.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/.gitignore b/APIJSON(Android)/APIJSON(AndroidStudio)/app/.gitignore
deleted file mode 100644
index 796b96d1c..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/app/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/build
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/build.gradle b/APIJSON(Android)/APIJSON(AndroidStudio)/app/build.gradle
deleted file mode 100644
index 5b6830856..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/app/build.gradle
+++ /dev/null
@@ -1,27 +0,0 @@
-apply plugin: 'com.android.application'
-
-android {
- compileSdkVersion 22
- buildToolsVersion '23.0.2'
- defaultConfig {
- applicationId "zuo.biao.apijson.client"
- minSdkVersion 15
- targetSdkVersion 23
- versionCode 1
- versionName "1.0"
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
- productFlavors {
- }
-}
-
-dependencies {
- compile files('libs/fastjson-1.2.21.jar')
- compile files('libs/okhttp-2.1.0.jar')
- compile files('libs/okio-1.0.0.jar')
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/libs/fastjson-1.2.21.jar b/APIJSON(Android)/APIJSON(AndroidStudio)/app/libs/fastjson-1.2.21.jar
deleted file mode 100644
index b00791c53..000000000
Binary files a/APIJSON(Android)/APIJSON(AndroidStudio)/app/libs/fastjson-1.2.21.jar and /dev/null differ
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/libs/okhttp-2.1.0.jar b/APIJSON(Android)/APIJSON(AndroidStudio)/app/libs/okhttp-2.1.0.jar
deleted file mode 100644
index 837defb9d..000000000
Binary files a/APIJSON(Android)/APIJSON(AndroidStudio)/app/libs/okhttp-2.1.0.jar and /dev/null differ
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/libs/okio-1.0.0.jar b/APIJSON(Android)/APIJSON(AndroidStudio)/app/libs/okio-1.0.0.jar
deleted file mode 100644
index 909cfa98d..000000000
Binary files a/APIJSON(Android)/APIJSON(AndroidStudio)/app/libs/okio-1.0.0.jar and /dev/null differ
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/proguard-rules.pro b/APIJSON(Android)/APIJSON(AndroidStudio)/app/proguard-rules.pro
deleted file mode 100644
index 90cb5eb39..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/app/proguard-rules.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in /Users/Tommy/Library/Android/sdk/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/androidTest/java/zuo/biao/apijson/client/ApplicationTest.java b/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/androidTest/java/zuo/biao/apijson/client/ApplicationTest.java
deleted file mode 100644
index e44a51bfd..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/androidTest/java/zuo/biao/apijson/client/ApplicationTest.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package zuo.biao.apijson.client;
-
-import android.app.Application;
-import android.test.ApplicationTestCase;
-
-/**
- * Testing Fundamentals
- */
-public class ApplicationTest extends ApplicationTestCase {
- public ApplicationTest() {
- super(Application.class);
- }
-}
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/AndroidManifest.xml b/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/AndroidManifest.xml
deleted file mode 100644
index 753f84573..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/JSON.java b/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/JSON.java
deleted file mode 100644
index 3dd6585c8..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/JSON.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*Copyright ©2015 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 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;
-
-/**阿里json封装类 防止解析时异常
- * @author Lemon
- */
-public class JSON {
- private static final String TAG = "JSON";
-
- /**判断json格式是否正确
- * @param s
- * @return
- */
- public static boolean isJsonCorrect(String s) {
- System.out.println(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) {
- s = StringUtil.getNoBlankString(s);
- return isJsonCorrect(s) ? s : "";
- }
-
- /**json转JSONObject
- * @param s
- * @return
- */
- public static JSONObject parseObject(String json) {
- try {
- int features = com.alibaba.fastjson.JSON.DEFAULT_PARSER_FEATURE;
- features |= Feature.SortFeidFastMatch.getMask();
- return com.alibaba.fastjson.JSON.parseObject(getCorrectJson(json), JSONObject.class, features);
- } catch (Exception e) {
- System.out.println(TAG + "parseObject catch \n" + e.getMessage());
- }
- return null;
- }
-
- /**json转实体类
- * @param s
- * @param clazz
- * @return
- */
- public static T parseObject(String json, Class clazz) {
- try {
- int features = com.alibaba.fastjson.JSON.DEFAULT_PARSER_FEATURE;
- features |= Feature.SortFeidFastMatch.getMask();
- return com.alibaba.fastjson.JSON.parseObject(getCorrectJson(json), clazz, features);
- } catch (Exception e) {
- System.out.println(TAG + "parseObject catch \n" + e.getMessage());
- }
- return null;
- }
-
- /**json转JSONArray
- * @param json
- * @return
- */
- public static JSONArray parseArray(String json) {
- return com.alibaba.fastjson.JSON.parseArray(json);
- }
- /**json转实体类列表
- * @param s
- * @param clazz
- * @return
- */
- public static List parseArray(String json, Class clazz) {
- try {
- return com.alibaba.fastjson.JSON.parseArray(getCorrectJson(json), clazz);
- } catch (Exception e) {
- System.out.println(TAG + "parseArray catch \n" + e.getMessage());
- }
- return null;
- }
-
- /**实体类转json
- * @param obj
- * @return
- */
- public static String toJSONString(Object obj) {
- try {
- return com.alibaba.fastjson.JSON.toJSONString(obj, SerializerFeature.SortField);
- } catch (Exception e) {
- System.out.println(TAG + "toJSONString catch \n" + e.getMessage());
- }
- return null;
- }
-
-
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/StringUtil.java b/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/StringUtil.java
deleted file mode 100644
index ec429f55a..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/StringUtil.java
+++ /dev/null
@@ -1,642 +0,0 @@
-/*Copyright ©2015 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 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;
-
-import android.util.Log;
-import android.widget.TextView;
-
-/**通用字符串(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 tv
- * @return
- */
- public static String getString(TextView tv) {
- if (tv == null || tv.getText() == null) {
- return "";
- }
- return getString(tv.getText().toString());
- }
- /**获取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时返回"" >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
- //获取去掉前后空格后的string<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
- /**获取去掉前后空格后的string,为null则返回""
- * @param tv
- * @return
- */
- public static String getTrimedString(TextView tv) {
- return getTrimedString(getString(tv));
- }
- /**获取去掉前后空格后的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 tv
- * @return
- */
- public static String getNoBlankString(TextView tv) {
- return getNoBlankString(getString(tv));
- }
- /**获取去掉所有空格后的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 tv
- * @param trim
- * @return
- */
- public static int getLength(TextView tv, boolean trim) {
- return getLength(getString(tv), trim);
- }
- /**获取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 tv
- * @param trim
- * @return
- */
- public static boolean isNotEmpty(TextView tv, boolean trim) {
- return isNotEmpty(getString(tv), trim);
- }
- /**判断字符是否非空
- * @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) {
- // Log.i(TAG, "getTrimedString s = " + s);
- if (s == null) {
- return false;
- }
- if (trim) {
- s = s.trim();
- }
- if (s.length() <= 0) {
- return false;
- }
-
- currentString = s;
-
- return true;
- }
-
- //判断字符是否非空 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
- //判断字符类型 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
- //判断手机格式是否正确
- 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) {
- System.out.println("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 inputed
- * @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.w(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();
- }
- /**判断字符类型是否是路径
- * @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 tv
- * @return
- */
- public static String getNumber(TextView tv) {
- return getNumber(getString(tv));
- }
- /**去掉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) {
- 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;
- }
- }
-
- return numberString;
- }
-
- //提取特殊字符>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
- //校正(自动补全等)字符串<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
- /**获取网址,自动补全
- * @param tv
- * @return
- */
- public static String getCorrectUrl(TextView tv) {
- return getCorrectUrl(getString(tv));
- }
- /**获取网址,自动补全
- * @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 tv
- * @return
- */
- public static String getCorrectPhone(TextView tv) {
- return getCorrectPhone(getString(tv));
- }
- /**获取去掉所有 空格 、"-" 、"+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 tv
- * @return
- */
- public static String getCorrectEmail(TextView tv) {
- return getCorrectEmail(getString(tv));
- }
- /**获取邮箱,自动补全
- * @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;
- }
- }
-
-
- //校正(自动补全等)字符串>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/DemoApplication.java b/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/DemoApplication.java
deleted file mode 100644
index f1fd04be6..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/DemoApplication.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*Copyright ©2015 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 zuo.biao.apijson.client;
-
-import android.app.Application;
-import android.util.Log;
-
-/**Application
- * @author Lemon
- * @see #init
- */
-public class DemoApplication extends Application {
- private static final String TAG = "DemoApplication";
-
-
- private static Application instance;
- public static Application getInstance() {
- return instance;
- }
-
- @Override
- public void onCreate() {
- super.onCreate();
- Log.d(TAG, "项目启动 >>>>>>>>>>>>>>>>>>>> \n\n");
-
- init(this);
- }
-
- /**初始化方法
- * @param application
- * @must 调用init方法且只能调用一次,如果extends BaseApplication会自动调用
- */
- public static void init(Application application) {
- instance = application;
- if (instance == null) {
- Log.e(TAG, "\n\n\n\n\n !!!!!! 调用BaseApplication中的init方法,instance不能为null !!!" +
- "\n <<<<<< init instance == null !!! >>>>>>>> \n\n\n\n");
- }
-
- }
-
- /**获取应用名
- * @return
- */
- public String getAppName() {
- return getResources().getString(R.string.app_name);
- }
- /**获取应用版本名(显示给用户看的)
- * @return
- */
- public String getAppVersion() {
- return getResources().getString(R.string.app_version);
- }
-
-
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/HttpManager.java b/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/HttpManager.java
deleted file mode 100644
index e2ce95b1a..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/HttpManager.java
+++ /dev/null
@@ -1,328 +0,0 @@
-/*Copyright ©2015 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 zuo.biao.apijson.client;
-
-import static zuo.biao.apijson.StringUtil.UTF_8;
-
-import java.io.IOException;
-import java.net.CookieHandler;
-import java.net.URI;
-import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import zuo.biao.apijson.StringUtil;
-import android.content.Context;
-import android.os.AsyncTask;
-import android.text.TextUtils;
-import android.util.Log;
-
-import com.squareup.okhttp.FormEncodingBuilder;
-import com.squareup.okhttp.OkHttpClient;
-import com.squareup.okhttp.Request;
-import com.squareup.okhttp.Response;
-
-/**HTTP请求管理类
- * @author Lemon
- * @use HttpManager.getInstance().get(...)或HttpManager.getInstance().post(...) > 在回调方法onHttpRequestSuccess和onHttpRequestError处理HTTP请求结果
- * @must 解决getToken,getResponseCode,getResponseData中的TODO
- */
-public class HttpManager {
- private static final String TAG = "HttpManager";
-
- /**网络请求回调接口
- */
- public interface OnHttpResponseListener {
- /**
- * @param requestCode 请求码,自定义,在发起请求的类中可以用requestCode来区分各个请求
- * @param resultJson 服务器返回的Json串
- * @param e 异常
- */
- void onHttpResponse(int requestCode, String resultJson, Exception e);
- }
-
-
-
- private Context context;
- private static HttpManager instance;// 单例
- private HttpManager(Context context) {
- this.context = context;
-
- }
-
- public synchronized static HttpManager getInstance() {
- if (instance == null) {
- instance = new HttpManager(DemoApplication.getInstance());
- }
- return instance;
- }
-
-
-
- /**
- * 列表首页页码。有些服务器设置为1,即列表页码从1开始
- */
- public static final int PAGE_NUM_0 = 0;
-
- public static final String KEY_TOKEN = "token";
- public static final String KEY_COOKIE = "cookie";
-
-
- /**GET请求
- * @param paramList 请求参数列表,(可以一个键对应多个值)
- * @param url 接口url
- * @param requestCode
- * 请求码,类似onActivityResult中请求码,当同一activity中以实现接口方式发起多个网络请求时,请求结束后都会回调
- * {@link OnHttpResponseListener#onHttpResponse(int, String, Exception)}
- * 在发起请求的类中可以用requestCode来区分各个请求
- * @param listener
- */
- public void get(final String url_, final String request, final OnHttpResponseListener listener) {
- Log.d(TAG, "get url_ = " + url_ + "; request = " + request + " >>>");
- new AsyncTask() {
-
- String result;
- @Override
- protected Exception doInBackground(Void... params) {
- try {
- String url = StringUtil.getNoBlankString(url_)
- + URLEncoder.encode(StringUtil.getNoBlankString(request), UTF_8);
- StringBuffer sb = new StringBuffer();
- sb.append(url);
-
- OkHttpClient client = getHttpClient(url);
- if (client == null) {
- return new Exception(TAG + ".get AsyncTask.doInBackground client == null >> return;");
- }
-
- result = getResponseJson(client, new Request.Builder()
- .addHeader(KEY_TOKEN, getToken(url))
- .url(http://github.com/sb.toString()).build());
- } catch (Exception e) {
- Log.e(TAG, "get AsyncTask.doInBackground try { result = getResponseJson(..." +
- "} catch (Exception e) {\n" + e.getMessage());
- return e;
- }
-
- return null;
- }
-
- @Override
- protected void onPostExecute(Exception exception) {
- super.onPostExecute(exception);
- listener.onHttpResponse(0, result, exception);
- }
-
- }.execute();
-
- }
-
-
- /**POST请求
- * @param paramList 请求参数列表,(可以一个键对应多个值)
- * @param url 接口url
- * @param requestCode
- * 请求码,类似onActivityResult中请求码,当同一activity中以实现接口方式发起多个网络请求时,请求结束后都会回调
- * {@link OnHttpResponseListener#onHttpResponse(int, String, Exception)}
- * 在发起请求的类中可以用requestCode来区分各个请求
- * @param listener
- */
- public void post(final String url_, final String request, final OnHttpResponseListener listener) {
-
- new AsyncTask() {
-
- String result;
- @Override
- protected Exception doInBackground(Void... params) {
-
- FormEncodingBuilder fBuilder = new FormEncodingBuilder();
- try {
- String url = StringUtil.getNoBlankString(url_)
- + URLEncoder.encode(StringUtil.getNoBlankString(request), UTF_8);
-
- OkHttpClient client = getHttpClient(url);
- if (client == null) {
- return new Exception(TAG + ".post AsyncTask.doInBackground client == null >> return;");
- }
- result = getResponseJson(client, new Request.Builder()
- .addHeader(KEY_TOKEN, getToken(url)).url(http://github.com/StringUtil.getNoBlankString(url))
- .post(fBuilder.build()).build());
- } catch (Exception e) {
- Log.e(TAG, "post AsyncTask.doInBackground try { result = getResponseJson(..." +
- "} catch (Exception e) {\n" + e.getMessage());
- return e;
- }
-
- return null;
- }
-
- @Override
- protected void onPostExecute(Exception exception) {
- super.onPostExecute(exception);
- listener.onHttpResponse(0, result, exception);
- }
-
- }.execute();
- }
-
-
- //httpGet/httpPost 内调用方法 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
- /**
- * @param url
- * @return
- */
- private OkHttpClient getHttpClient(String url) {
- Log.i(TAG, "getHttpClient url = " + url);
- if (StringUtil.isNotEmpty(url, true) == false) {
- Log.e(TAG, "getHttpClient StringUtil.isNotEmpty(url, true) == false >> return null;");
- return null;
- }
-
- OkHttpClient client = new OkHttpClient();
- client.setCookieHandler(new HttpHead());
- client.setConnectTimeout(15, TimeUnit.SECONDS);
- client.setWriteTimeout(10, TimeUnit.SECONDS);
- client.setReadTimeout(10, TimeUnit.SECONDS);
-
- return client;
- }
-
- /**
- * @param paramList
- * @must demo_***改为服务器设定值
- * @return
- */
- public String getToken(String tag) {
- return context.getSharedPreferences(KEY_TOKEN, Context.MODE_PRIVATE).getString(KEY_TOKEN + tag, "");
- }
- /**
- * @param tag
- * @param value
- */
- public void saveToken(String tag, String value) {
- context.getSharedPreferences(KEY_TOKEN, Context.MODE_PRIVATE)
- .edit()
- .remove(KEY_TOKEN + tag)
- .putString(KEY_TOKEN + tag, value)
- .commit();
- }
-
-
- /**
- * @return
- */
- public String getCookie() {
- return context.getSharedPreferences(KEY_COOKIE, Context.MODE_PRIVATE).getString(KEY_COOKIE, "");
- }
- /**
- * @param value
- */
- public void saveCookie(String value) {
- context.getSharedPreferences(KEY_COOKIE, Context.MODE_PRIVATE)
- .edit()
- .remove(KEY_COOKIE)
- .putString(KEY_COOKIE, value)
- .commit();
- }
-
-
- /**
- * @param client
- * @param request
- * @return
- * @throws Exception
- */
- private String getResponseJson(OkHttpClient client, Request request) throws Exception {
- if (client == null || request == null) {
- Log.e(TAG, "getResponseJson client == null || request == null >> return null;");
- return null;
- }
- Response response = client.newCall(request).execute();
- return response.isSuccessful() ? response.body().string() : null;
- }
-
- /**从object中获取key对应的值
- * *获取如果T是基本类型容易崩溃,所以需要try-catch
- * @param json
- * @param key
- * @return
- * @throws JSONException
- */
- public T getValue(String json, String key) throws JSONException {
- return getValue(new JSONObject(json), key);
- }
- /**从object中获取key对应的值
- * *获取如果T是基本类型容易崩溃,所以需要try-catch
- * @param object
- * @param key
- * @return
- * @throws JSONException
- */
- @SuppressWarnings("unchecked")
- public T getValue(JSONObject object, String key) throws JSONException {
- return (T) object.get(key);
- }
-
- //httpGet/httpPost 内调用方法 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
-
-
- /**http请求头
- */
- public class HttpHead extends CookieHandler {
- public HttpHead() {
- }
-
- @Override
- public Map> get(URI uri, Map> requestHeaders) throws IOException {
- String cookie = getCookie();
- Map> map = new HashMap>();
- map.putAll(requestHeaders);
- if (!TextUtils.isEmpty(cookie)) {
- List cList = new ArrayList();
- cList.add(cookie);
- map.put("Cookie", cList);
- }
- return map;
- }
-
- @Override
- public void put(URI uri, Map> responseHeaders) throws IOException {
- List list = responseHeaders.get("Set-Cookie");
- if (list != null) {
- for (int i = 0; i < list.size(); i++) {
- String cookie = list.get(i);
- if (cookie.startsWith("JSESSIONID")) {
- saveCookie(list.get(i));
- break;
- }
- }
- }
- }
-
- }
-
-
-
-
-}
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/JSONObject.java b/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/JSONObject.java
deleted file mode 100644
index 642072c14..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/JSONObject.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*Copyright ©2015 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 zuo.biao.apijson.client;
-
-import static zuo.biao.apijson.StringUtil.UTF_8;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import java.net.URLEncoder;
-import java.util.Set;
-
-import zuo.biao.apijson.JSON;
-import zuo.biao.apijson.StringUtil;
-
-/**use this class instead of com.alibaba.fastjson.JSONObject
- * @author Lemon
- */
-public class JSONObject extends com.alibaba.fastjson.JSONObject {
- private static final long serialVersionUID = 8907029699680768212L;
-
- /**ordered
- */
- public JSONObject() {
- super(true);
- }
- public JSONObject(String json) {
- this(JSON.parseObject(json));
- }
- /**transfer com.alibaba.fastjson.JSONObject to JSONObject
- * @param object
- */
- public JSONObject(com.alibaba.fastjson.JSONObject object) {
- this();
- add(object);
- }
-
-
-
- /**
- * @param key
- * @return if value is String, return URLDecoder.decode((String) value, UTF_8);
- */
- public Object getWithDecode(String key) {
- Object value = get(key);
- if (value instanceof String) {
- try {
- return URLDecoder.decode((String) value, UTF_8);
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- }
- return value;
- }
-
-
- /**put(value.getClass().getSimpleName(), value);
- * @param value
- * @return
- */
- public Object putWithEncode(Object value) {
- return putWithEncode(null, value);
- }
- /**
- * @param key
- * @param value if is String, value = URLEncoder.encode((String) value, UTF_8);
- * @return
- */
- public Object putWithEncode(String key, Object value) {
- if (value instanceof String) {
- try {
- value = URLEncoder.encode((String) value, UTF_8);
- //just encode /, not need to encode [] ? URLEncoder.encode(key, UTF_8)
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- }
- return super.put(StringUtil.isNotEmpty(key, true) ? key : value.getClass().getSimpleName(), value);
- }
-
- /**put key-value in object into this
- * @param object
- */
- public void add(com.alibaba.fastjson.JSONObject object) {
- Set set = object == null ? null : object.keySet();
- if (set != null) {
- for (String key : set) {
- put(key, object.get(key));
- }
- }
- }
-
-
- //array object <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- public static final String KEY_COUNT = "count";
- public static final String KEY_PAGE = "page";
-
- public JSONObject setCount(int count) {
- put(KEY_COUNT, count);
- return this;
- }
- public int getCount() {
- return getIntValue(KEY_COUNT);
- }
-
- public JSONObject setPage(int page) {
- put(KEY_PAGE, page);
- return this;
- }
- public int getPage() {
- return getIntValue(KEY_PAGE);
- }
- //array object >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
-
- //judge <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- /**
- * @param json
- * @return
- */
- public static boolean isJSONObject(String json) {
- return JSON.parseObject(json) != null;
- }
- /**
- * @param key
- * @return
- */
- public static boolean isObjectKey(String key) {
- key = StringUtil.getString(key);
- return StringUtil.isNotEmpty(key, false) && isArrayKey(key) == false && StringUtil.isAlpha(key.substring(0, 1));
- }
- /**
- * @param key
- * @return
- */
- public static boolean isArrayKey(String key) {
- return key.endsWith("[]");
- }
- //judge >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/JSONRequest.java b/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/JSONRequest.java
deleted file mode 100644
index 73d40f37a..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/JSONRequest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*Copyright ©2015 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 zuo.biao.apijson.client;
-
-import zuo.biao.apijson.StringUtil;
-
-/**encapsulator for request JSONObject
- * @author Lemon
- * @see #toArray
- * @see RequestUtil
- * @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();
- }
- public JSONRequest(Object object) {
- this(null, object);
- }
- public JSONRequest(String name, Object object) {
- this();
- put(name, object);
- }
-
- /**put(value.getClass().getSimpleName(), value);
- * @param value
- * @return
- */
- public Object put(Object value) {
- return super.putWithEncode(value);
- }
- @Override
- public Object put(String key, Object value) {
- return super.putWithEncode(key, value);
- }
-
-
- /**create a parent JSONObject named []
- * @param count
- * @param page
- * @return {"[]":this}
- */
- public JSONRequest toArray(int count, int page) {
- return toArray(count, page, null);
- }
- /**create a parent JSONObject named name+[]
- * @param count
- * @param page
- * @param name
- * @return {name+"[]" : this}
- */
- public JSONRequest toArray(int count, int page, String name) {
- return new JSONRequest(StringUtil.getString(name) + "[]", this.setCount(count).setPage(page));
- }
-
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/JSONResponse.java b/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/JSONResponse.java
deleted file mode 100644
index ff317c0ac..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/JSONResponse.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*Copyright ©2015 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 zuo.biao.apijson.client;
-
-import java.util.List;
-import java.util.Set;
-
-import zuo.biao.apijson.JSON;
-import zuo.biao.apijson.StringUtil;
-import zuo.biao.apijson.client.ui.QueryActivity;
-
-import com.alibaba.fastjson.JSONArray;
-
-/**parser for response JSON String
- * @author Lemon
- * @see #getList
- * @see #getJSONArray
- * @see QueryActivity#onHttpResponse
- * @use JSONResponse response = new JSONResponse(...);
- *
JSONArray array = JSONResponse.getJSONArray(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 JSONObject {
- private static final long serialVersionUID = -6707531287941223427L;
-
- public JSONResponse() {
- super();
- }
- public JSONResponse(String json) {
- super(json);
- }
- public JSONResponse(com.alibaba.fastjson.JSONObject object) {
- super(object);
- }
-
- @Override
- public Object get(Object key) {
- return key instanceof String ? super.getWithDecode((String) key) : super.get(key);
- }
- public Object get(String key) {
- return getWithDecode(key);
- }
-
-
-
- /**
- * @param clazz
- * @return
- */
- public T getObject(Class clazz) {
- return getObject(this, clazz);
- }
- /**
- * @param object
- * @param clazz
- * @return
- */
- public static T getObject(com.alibaba.fastjson.JSONObject object, Class clazz) {
- return JSON.parseObject(JSON.toJSONString(clazz == null ? object : object.getJSONObject(clazz.getSimpleName())), clazz);
- }
- // /**
- // * @param json
- // * @param clazz
- // * @return
- // */
- // public static T getObject(String json, Class clazz) {
- // return getObject(JSON.parseObject(json, clazz), clazz);
- // }
-
-
- /**
- * arrayObject = this
- * @param clazz
- * @return
- */
- public List getList(Class clazz) {
- return getList(this, clazz);
- }
- /**
- * @param arrayObject
- * @param clazz
- * @return
- */
- public static List getList(com.alibaba.fastjson.JSONObject arrayObject, Class clazz) {
- return JSON.parseArray(JSON.toJSONString(getJSONArray(arrayObject
- , clazz == null ? null : clazz.getSimpleName())), clazz);
- }
-
- /**
- * @param arrayKey
- * @param className
- * @return
- */
- public JSONArray getJSONArray(String arrayKey, String className) {
- if (StringUtil.isNotEmpty(arrayKey, true) == false) {
- arrayKey = StringUtil.getString(className) + "[]";
- }
- return isArrayKey(arrayKey) ? getJSONArray(getJSONObject(arrayKey), className) : super.getJSONArray(arrayKey);
- }
-
- /**
- * arrayObject = this
- * @return
- */
- public JSONArray getJSONArray() {
- return getJSONArray(this, null);
- }
- /**
- * arrayObject = this
- * @return
- */
- public JSONArray getJSONArray(String className) {
- return getJSONArray(this, className);
- }
- /**
- * @param
- * @param arrayObject
- * @param clazz
- * @return
- */
- public static JSONArray getJSONArray(com.alibaba.fastjson.JSONObject arrayObject) {
- return getJSONArray(arrayObject, null);
- }
- /**
- * @param
- * @param arrayObject
- * @param clazz
- * @return
- */
- public static JSONArray getJSONArray(com.alibaba.fastjson.JSONObject arrayObject, String className) {
- Set set = arrayObject == null ? null : arrayObject.keySet();
- if (set == null || set.isEmpty()) {
- return null;
- }
-
- String parentString = StringUtil.getTrimedString(com.alibaba.fastjson.JSON.toJSONString(arrayObject));
- if (parentString.isEmpty()) {
- return null;
- }
- if (parentString.startsWith("[")) {
- if (parentString.endsWith("]") == false) {
- parentString += "]";
- }
- return JSON.parseArray(parentString);
- }
-
- //{"0":{...}, "1":{...}...}
-
- className = StringUtil.getTrimedString(className);
-
- JSONArray array = new JSONArray(set.size());
- com.alibaba.fastjson.JSONObject value;
- int index;
- for (String key : set) {//0, 1, 2,...
- value = StringUtil.isNumer(key) == false ? null : arrayObject.getJSONObject(key);
- if (value != null) {
- try {
- index = Integer.valueOf(0 + key);
- array.set(index, className.isEmpty() ? value : value.getJSONObject(className));
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- return array;
- }
-
-
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/RequestUtil.java b/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/RequestUtil.java
deleted file mode 100644
index ab8ee4e26..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/RequestUtil.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*Copyright ©2015 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 zuo.biao.apijson.client;
-
-import zuo.biao.apijson.client.model.Comment;
-import zuo.biao.apijson.client.model.User;
-import zuo.biao.apijson.client.model.Wallet;
-import zuo.biao.apijson.client.model.Work;
-
-/**create request JSONObjects
- * @author Lemon
- */
-public class RequestUtil {
-
- public static JSONObject newSingleRequest() {
- return new JSONRequest(new User((long) 38710));
- }
-
- public static JSONObject newRelyRequest() {
- JSONRequest request = new JSONRequest();
- request.put(new User((long) 70793));
- request.put(Work.class.getSimpleName(), new JSONRequest("userId", "User/id"));
- return request;
- }
-
- public static JSONObject newArrayRequest() {
- return new JSONRequest(new User().setSex(0)).toArray(10, 0, User.class.getSimpleName());
- }
-
- public static JSONObject newComplexRequest() {
-
- JSONRequest request = new JSONRequest();
- request.put(new User().setSex(0));
- request.put(Work.class.getSimpleName(), new JSONRequest("userId", "/User/id"));
-
- request.add(new JSONRequest(Comment.class.getSimpleName(), new JSONRequest("workId", "[]/Work/id")).
- toArray(3, 0, Comment.class.getSimpleName()));
-
- return request.toArray(2, 1);
- }
-
- public static JSONObject newAccessErrorRequest() {
- return new JSONRequest(new Wallet((long) 38710));
- }
-
- public static JSONObject newAccessPermittedRequest() {
- JSONRequest request = new JSONRequest();
- request.put(new Wallet().setUserId((long) 38710));
- request.put("currentUserId", 38710);
- request.put("payPassword", "123456");
- return request;
- }
-
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/RequestUtil2.java b/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/RequestUtil2.java
deleted file mode 100644
index 492ac1f36..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/RequestUtil2.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*Copyright ©2015 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 zuo.biao.apijson.client;
-
-import static zuo.biao.apijson.StringUtil.UTF_8;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-
-import zuo.biao.apijson.JSON;
-import zuo.biao.apijson.StringUtil;
-import zuo.biao.apijson.client.model.User;
-import zuo.biao.apijson.client.model.Work;
-
-/**RequestUtil is suggested
- * @author Lemon
- */
-public class RequestUtil2 {
-
-
- /**
- * @param object
- * @return
- */
- public static String getString(JSONObject object) {
- try {
- return URLEncoder.encode(JSON.toJSONString(object), UTF_8);
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- return null;
- }
-
- /**
- * name = null, {"[]":object}
- * @param object
- * @return NonNull
- */
- public static JSONObject getArrayRequest(JSONObject object) {
- return getArrayRequest(null, object);
- }
- /**
- * name = null, {"name+"[]"":object}
- * @param object
- * @return NonNull
- */
- public static JSONObject getArrayRequest(String name, JSONObject object) {
- return getObjectRequest((name == null ? "" : name) + "[]", object);
- }
-
- /**
- * @param object
- * @return
- */
- public static JSONObject getObjectRequest(T object) {
- return getObjectRequest(null, object);
- }
- /**
- * @param name
- * @param object
- * @return NonNull
- */
- public static JSONObject getObjectRequest(String name, T object) {
- JSONObject jsonObject = new JSONObject();
- if (object != null) {
- jsonObject.put(StringUtil.isNotEmpty(name, true) ? name : object.getClass().getSimpleName(), object);
- }
- return jsonObject;
- }
-
-
- /**
- * @param parent
- * @param child
- * @return
- */
- public static JSONObject put(JSONObject parent, T child) {
- if (parent == null) {
- parent = new JSONObject();
- }
- if (child != null) {
- parent.put(child.getClass().getSimpleName(), child);
- }
- return parent;
- }
-
-
- /**
- * @return
- */
- public static JSONObject newSingleRequest() {
- return getObjectRequest(new User((long) 38710));
- }
- /**
- * @return
- */
- public static JSONObject newRelyRequest() {
- JSONObject object = new JSONObject();
-
- object.put(User.class.getSimpleName(), new User((long) 38710));
-
- JSONObject workObject = new JSONObject();
- try {
- workObject.put("userId", URLEncoder.encode("User/id", UTF_8));//User.getFieldPath("id"));
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- return null;
- }
- object.put(Work.class.getSimpleName(), workObject);
-
- return object;
- }
- /**
- * @return
- */
- public static JSONObject newArrayRequest() {
- JSONObject object = new JSONObject();
- object.put("count", 10);
- object = put(object, new User().setSex(0));
- return getArrayRequest(object);
- }
- /**
- * @return
- */
- public static JSONObject newComplexRequest() {
- JSONObject userObject = new JSONObject();
- userObject.put("sex", 0);
-
- JSONObject workObject = new JSONObject();
- // workObject.put("userId", "/User/id");
- try {
- workObject.put("userId", URLEncoder.encode("/User/id", UTF_8));
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- JSONObject commentObject = new JSONObject();
- // commentObject.put("workId", "[]/Work/id");
- try {
- commentObject.put("workId", URLEncoder.encode("[]/Work/id", UTF_8));
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- JSONObject commentArrayObject = new JSONObject();
- commentArrayObject.put("page", 0);
- commentArrayObject.put("count", 3);
- commentArrayObject.put("Comment", commentObject);
-
- JSONObject arrayObject = new JSONObject();
- arrayObject.put("page", 1);
- arrayObject.put("count", 10);
- arrayObject.put("User", userObject);
- arrayObject.put("Work", workObject);
- try {
- arrayObject.put(URLEncoder.encode("Comment[]", UTF_8), commentArrayObject);
- } catch (UnsupportedEncodingException e1) {
- e1.printStackTrace();
- }
-
- return getArrayRequest(arrayObject);
- }
-
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/model/BaseModel.java b/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/model/BaseModel.java
deleted file mode 100644
index 906071a83..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/model/BaseModel.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*Copyright ©2015 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 zuo.biao.apijson.client.model;
-
-import java.io.Serializable;
-
-/**base model for reduce model codes
- * @author Lemon
- * @use extends BaseModel
- */
-public abstract class BaseModel implements Serializable {
- private static final long serialVersionUID = 7560533944342381808L;
-
- public Long id;
-
- public Long getId() {
- return id;
- }
- public void setId(Long id) {
- this.id = id;
- }
-
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/model/Comment.java b/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/model/Comment.java
deleted file mode 100644
index f60ed339a..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/model/Comment.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*Copyright ©2015 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 zuo.biao.apijson.client.model;
-
-/**评论类
- * @author Lemon
- */
-public class Comment extends BaseModel {
- private static final long serialVersionUID = -1011007127735372824L;
-
-
- public Long workId;
- public Long parentId;
- public Long userId;
- public Long targetUserId;
- public String userName;
- public String targetUserName;
- public String content;
- public Comment() {
- super();
- }
- public Comment(Long id, String content) {
- this();
- this.id = id;
- this.content = content;
- }
-
- public Long getWorkId() {
- return workId;
- }
- public void setWorkId(Long workId) {
- this.workId = workId;
- }
- public Long getParentId() {
- return parentId;
- }
- public void setParentId(Long parentId) {
- this.parentId = parentId;
- }
- public Long getUserId() {
- return userId;
- }
- public void setUserId(Long userId) {
- this.userId = userId;
- }
- public Long getTargetUserId() {
- return targetUserId;
- }
- public void setTargetUserId(Long targetUserId) {
- this.targetUserId = targetUserId;
- }
- public String getUserName() {
- return userName;
- }
- public void setUserName(String userName) {
- this.userName = userName;
- }
- public String getTargetUserName() {
- return targetUserName;
- }
- public void setTargetUserName(String targetUserName) {
- this.targetUserName = targetUserName;
- }
- public String getContent() {
- return content;
- }
- public void setContent(String content) {
- this.content = content;
- }
-
-
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/model/User.java b/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/model/User.java
deleted file mode 100644
index 29e9abad2..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/model/User.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*Copyright ©2015 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 zuo.biao.apijson.client.model;
-
-/**用户类
- * @author Lemon
- */
-public class User extends BaseModel {
- private static final long serialVersionUID = -1635551656020732611L;
-
- public Integer sex;
- public String head;
- public String name;
- public String phone;
- public String picture;
-
- /**默认构造方法,JSON等解析时必须要有
- */
- public User() {
- super();
- }
- public User(Long id) {
- this();
- this.id = id;
- }
- public User(Long id, String name) {
- this(id);
- this.name = name;
- }
-
- public Integer getSex() {
- return sex;
- }
- public User setSex(Integer sex) {
- this.sex = sex;
- return this;
- }
- public String getHead() {
- return head;
- }
- public void setHead(String head) {
- this.head = head;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public String getPhone() {
- return phone;
- }
- public void setPhone(String phone) {
- this.phone = phone;
- }
- public String getPicture() {
- return picture;
- }
- public void setPicture(String picture) {
- this.picture = picture;
- }
-
- //// @Override
- //// public boolean isCorrect() {//根据自己的需求决定,也可以直接 return true
- //// return id != null && id > 0;// && StringUtil.isNotEmpty(phone, true);
- //// }
- //
- // @Override
- // public JSONObject toJSONObject() {
- // return toJSONObject(this);
- // }
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/model/Wallet.java b/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/model/Wallet.java
deleted file mode 100644
index 90f5a2825..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/model/Wallet.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*Copyright ©2015 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 zuo.biao.apijson.client.model;
-
-import java.math.BigDecimal;
-
-/**钱包类
- * @author Lemon
- */
-public class Wallet extends BaseModel {
- private static final long serialVersionUID = 4298571449155754300L;
-
- public BigDecimal balance;
-
- public Long userId;
-
- /**默认构造方法,JSON等解析时必须要有
- */
- public Wallet() {
- super();
- }
- public Wallet(Long id) {
- this();
- this.id = id;
- }
-
- public Wallet setUserId(Long userId) {
- this.userId = userId;
- return this;
- }
- public Long getUserId() {
- return userId;
- }
-
- public BigDecimal getBalance() {
- return balance;
- }
- public void setBalance(BigDecimal balance) {
- this.balance = balance;
- }
-
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/model/Work.java b/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/model/Work.java
deleted file mode 100644
index 2023ec1a9..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/model/Work.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*Copyright ©2015 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 zuo.biao.apijson.client.model;
-
-/**作品类
- * @author Lemon
- */
-public class Work extends BaseModel {
- private static final long serialVersionUID = -7437225320551780084L;
-
- public long userId;
- public String title;
- public String content;
- public String picture;
-
- public Work() {
- super();
- }
- public Work(long id, String title) {
- this();
- this.id = id;
- this.title = title;
- }
-
- public long getUserId() {
- return userId;
- }
- public void setUserId(long userId) {
- this.userId = userId;
- }
- public String getTitle() {
- return title;
- }
- public void setTitle(String title) {
- this.title = title;
- }
- public String getContent() {
- return content;
- }
- public void setContent(String content) {
- this.content = content;
- }
- public String getPicture() {
- return picture;
- }
- public void setPicture(String picture) {
- this.picture = picture;
- }
-
-
-// @Override
-// public boolean isCorrect() {
-// return getId() > 0 && getUserId() > 0
-// && (StringUtil.isNotEmpty(getTitle(), true) || StringUtil.isNotEmpty(getContent(), true));
-// }
-
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/model/package-info.java b/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/model/package-info.java
deleted file mode 100644
index 4934219e5..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/model/package-info.java
+++ /dev/null
@@ -1,11 +0,0 @@
-/**
- * the names of classes equal the names of tables in Server database one by one, so do the variables and columns
- * (name) : model <=> table
- * (name, type) : variable <=> column
- * @warn don't use any base type like int or char in models, use Integer and String instead
- */
-/**
- * @author Lemon
- *
- */
-package zuo.biao.apijson.client.model;
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/ui/QueryActivity.java b/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/ui/QueryActivity.java
deleted file mode 100644
index a6bc339cc..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/ui/QueryActivity.java
+++ /dev/null
@@ -1,272 +0,0 @@
-/*Copyright ©2015 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 zuo.biao.apijson.client.ui;
-
-import static zuo.biao.apijson.StringUtil.UTF_8;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.util.List;
-
-import zuo.biao.apijson.JSON;
-import zuo.biao.apijson.StringUtil;
-import zuo.biao.apijson.client.HttpManager;
-import zuo.biao.apijson.client.HttpManager.OnHttpResponseListener;
-import zuo.biao.apijson.client.JSONResponse;
-import zuo.biao.apijson.client.R;
-import zuo.biao.apijson.client.RequestUtil;
-import zuo.biao.apijson.client.model.Comment;
-import zuo.biao.apijson.client.model.User;
-import zuo.biao.apijson.client.model.Wallet;
-import zuo.biao.apijson.client.model.Work;
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.View.OnLongClickListener;
-import android.widget.EditText;
-import android.widget.ProgressBar;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import com.alibaba.fastjson.JSONArray;
-
-/**activity for requesting a query in Server
- * @author Lemon
- */
-public class QueryActivity extends Activity implements OnHttpResponseListener {
- private static final String TAG = "QueryActivity";
-
-
- public static final String INTENT_TYPE = "INTENT_TYPE";
- public static final String INTENT_URL = "INTENT_URL";
-
- public static final String RESULT_URL = "RESULT_URL";
-
- /**
- * @param context
- * @param type
- * @param url
- * @return
- */
- public static Intent createIntent(Context context, int type, String url) {
- return new Intent(context, QueryActivity.class)
- .putExtra(QueryActivity.INTENT_TYPE, type)
- .putExtra(QueryActivity.INTENT_URL, url);
- }
-
-
- public static final int TYPE_SINGLE = 0;
- public static final int TYPE_RELY = 1;
- public static final int TYPE_ARRAY = 2;
- public static final int TYPE_COMPLEX = 3;
- public static final int TYPE_ACCESS_ERROR = 4;
- public static final int TYPE_ACCESS_PERMITTED = 5;
-
-
- private int type = TYPE_SINGLE;
- private String url;
-
- private Activity context;
- private boolean isAlive;
-
- private TextView tvQueryResult;
- private ProgressBar pbQuery;
- private EditText etQueryUri;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.query_activity);
- context = this;
- isAlive = true;
-
- Intent intent = getIntent();
- type = intent.getIntExtra(INTENT_TYPE, type);
- url = intent.getStringExtra(INTENT_URL);
-
-
- tvQueryResult = (TextView) findViewById(R.id.tvQueryResult);
- pbQuery = (ProgressBar) findViewById(R.id.pbQuery);
- etQueryUri = (EditText) findViewById(R.id.etQueryUri);
-
- etQueryUri.setText(StringUtil.getString(StringUtil.isNotEmpty(url, true)
- ? url : "http://192.168.1.104:8080/get/"));//TODO my computer ipv4 address,edit it to an available one
-
-
- query();
-
-
- findViewById(R.id.btnQueryQuery).setOnClickListener(new OnClickListener() {
-
- @Override
- public void onClick(View v) {
- query();
- }
- });
- findViewById(R.id.btnQueryQuery).setOnLongClickListener(new OnLongClickListener() {
-
- @Override
- public boolean onLongClick(View v) {
- openWebSite();
- return true;
- }
- });
- }
-
-
-
- //click event,called form layout android:onClick <<<<<<<<<<<<<<<<
- public void query(View v) {
- query();
- }
- //click event,called form layout android:onClick >>>>>>>>>>>>>>>>
-
- private String request;
- public void setRequest() {
- url = StringUtil.getNoBlankString(etQueryUri);
- switch (type) {
- case TYPE_SINGLE:
- request = JSON.toJSONString(RequestUtil.newSingleRequest());
- break;
- case TYPE_RELY:
- request = JSON.toJSONString(RequestUtil.newRelyRequest());
- break;
- case TYPE_ARRAY:
- request = JSON.toJSONString(RequestUtil.newArrayRequest());
- break;
- case TYPE_ACCESS_ERROR:
- request = JSON.toJSONString(RequestUtil.newAccessErrorRequest());
- break;
- case TYPE_ACCESS_PERMITTED:
- request = JSON.toJSONString(RequestUtil.newAccessPermittedRequest());
- break;
- default:
- request = JSON.toJSONString(RequestUtil.newComplexRequest());
- break;
- }
- Log.d(TAG, "setRequest url = " + url + ";\n request = " + request);
- }
-
- /**request a query from server,and the result will be received by onHttpResponse method
- */
- private void query() {
- setRequest();
-
- tvQueryResult.setText("requesting...\n\n url = " + url + "\n\n request = \n" + request
- + "\n\n\n" + getResources().getString(R.string.query_error));
- pbQuery.setVisibility(View.VISIBLE);
-
- HttpManager.getInstance().get(url, request, this);
- }
-
-
-
- @Override
- public void onHttpResponse(int requestCode, final String resultJson, final Exception e) {
- Log.d(TAG, "onHttpResponse resultJson = " + resultJson);
- if (e != null) {
- Log.e(TAG, "onHttpResponse e = " + e.getMessage());
- }
- JSONResponse response = new JSONResponse(resultJson);
- if (type == TYPE_ARRAY) {
- logList(JSONResponse.getList(response.getJSONObject("User[]"), User.class));
- } else if (type == TYPE_COMPLEX) {
- JSONArray array = JSONResponse.getJSONArray(response.getJSONObject("[]"));//, "Comment[]");//
- if (array == null || array.isEmpty()) {
- Log.e(TAG, "onHttpResponse type == TYPE_COMPLEX >> array == null || array.isEmpty() >> return;");
- return;
- }
- response = new JSONResponse(array.getJSONObject(0));
-
- User user = JSONResponse.getObject(response, User.class);
- Log.d(TAG, "onHttpResponse type == TYPE_COMPLEX >> user = " + JSON.toJSONString(user));
- Work work = JSONResponse.getObject(response, Work.class);
- Log.d(TAG, "onHttpResponse type == TYPE_COMPLEX >> work = " + JSON.toJSONString(work));
- logList(JSONResponse.getList(response == null ? null : response.getJSONObject("Comment[]"), Comment.class));
- } else if (type == TYPE_ACCESS_PERMITTED) {
- response = new JSONResponse(resultJson);
- Wallet wallet = JSONResponse.getObject(response, Wallet.class);
- Log.d(TAG, "onHttpResponse type == TYPE_ACCESS_PERMITTED >> wallet = " + JSON.toJSONString(wallet));
- }
-
- runOnUiThread(new Runnable() {
-
- @Override
- public void run() {
- if (isAlive) {
- pbQuery.setVisibility(View.GONE);
- Toast.makeText(context, "received result!", Toast.LENGTH_SHORT).show();
-
- tvQueryResult.setText(e == null || JSON.isJsonCorrect(resultJson)
- ? StringUtil.getTrimedString(resultJson)
- : e.getMessage() + "\n\n\n" + getResources().getString(R.string.query_error));
-
- }
- }
- });
- }
-
-
- private void logList(List list) {
- if (list == null || list.isEmpty()) {
- Log.e(TAG, "logList list == null || list.isEmpty() >> return;");
- return;
- }
- for (T data : list) {
- Log.d(TAG, "\n logList " + (data == null ? "data" : data.getClass().getSimpleName())
- + " = \n" + JSON.toJSONString(data));
- }
- }
-
-
-
- /**open request URL String with a browser
- */
- public void openWebSite() {
- setRequest();
- String webSite = null;
- try {
- webSite = StringUtil.getNoBlankString(url)
- + URLEncoder.encode(StringUtil.getNoBlankString(request), UTF_8);
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- if (StringUtil.isNotEmpty(webSite, true) == false) {
- Log.e(TAG, "openWebSite StringUtil.isNotEmpty(webSite, true) == false >> return;");
- return;
- }
-
- startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(webSite)));
- }
-
-
-
- @Override
- public void finish() {
- setResult(RESULT_OK, new Intent().putExtra(RESULT_URL, url));
- super.finish();
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- isAlive = false;
- }
-
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/ui/SelectActivity.java b/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/ui/SelectActivity.java
deleted file mode 100644
index 5ccd82d83..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/ui/SelectActivity.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*Copyright ©2015 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 zuo.biao.apijson.client.ui;
-
-import zuo.biao.apijson.client.R;
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.Toast;
-
-/**activity for selecting a request
- * @author Lemon
- */
-public class SelectActivity extends Activity {
-
- public static final String RESULT_JSON = "RESULT_JSON";
-
- public static Intent createIntent(Context context) {
- return new Intent(context, SelectActivity.class);
- }
-
-
- private Activity context;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.select_activity);
-
- context = this;
- }
-
- //click event,called form layout android:onClick <<<<<<<<<<<<<<<<
- public void selectSingle(View v) {
- select(QueryActivity.TYPE_SINGLE);
- }
-
- public void selectRely(View v) {
- select(QueryActivity.TYPE_RELY);
- }
-
- public void selectArray(View v) {
- select(QueryActivity.TYPE_ARRAY);
- }
-
- public void selectComplex(View v) {
- select(QueryActivity.TYPE_COMPLEX);
- }
-
- public void selectAccessError(View v) {
- select(QueryActivity.TYPE_ACCESS_ERROR);
- }
-
- public void selectAccessPermitted(View v) {
- select(QueryActivity.TYPE_ACCESS_PERMITTED);
- }
- //click event,called form layout android:onClick >>>>>>>>>>>>>>>>
-
- private String url;
- private void select(int type) {
- startActivityForResult(QueryActivity.createIntent(context, type, url), REQUEST_TO_QUERY);
- }
-
- private static final int REQUEST_TO_QUERY = 1;
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- if (resultCode != RESULT_OK) {
- return;
- }
- switch (requestCode) {
- case REQUEST_TO_QUERY:
- if (data == null) {
- Toast.makeText(context, "onActivityResult data == null !!!", Toast.LENGTH_SHORT).show();
- return;
- }
- url = data.getStringExtra(QueryActivity.RESULT_URL);
- break;
- default:
- break;
- }
- }
-
-
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/ui/package-info.java b/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/ui/package-info.java
deleted file mode 100644
index 693ef57f1..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/client/ui/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*Copyright ©2015 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.*/
-
-/**
- * views show messages on screen
- */
-/**
- * @author Lemon
- *
- */
-package zuo.biao.apijson.client.ui;
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/package-info.java b/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/package-info.java
deleted file mode 100644
index a425e7828..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/java/zuo/biao/apijson/package-info.java
+++ /dev/null
@@ -1,8 +0,0 @@
-/**
- * the same files for server and client projects
- */
-/**
- * @author Lemon
- *
- */
-package zuo.biao.apijson;
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/res/drawable-hdpi/ic_launcher.png b/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/res/drawable-hdpi/ic_launcher.png
deleted file mode 100644
index cde69bccc..000000000
Binary files a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/res/drawable-hdpi/ic_launcher.png and /dev/null differ
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/res/drawable-mdpi/ic_launcher.png b/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/res/drawable-mdpi/ic_launcher.png
deleted file mode 100755
index c133a0cbd..000000000
Binary files a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/res/drawable-mdpi/ic_launcher.png and /dev/null differ
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/res/drawable-xhdpi/ic_launcher.png b/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/res/drawable-xhdpi/ic_launcher.png
deleted file mode 100755
index bfa42f0e7..000000000
Binary files a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/res/drawable-xhdpi/ic_launcher.png and /dev/null differ
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/res/drawable-xxhdpi/ic_launcher.png b/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/res/drawable-xxhdpi/ic_launcher.png
deleted file mode 100755
index 324e72cdd..000000000
Binary files a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/res/drawable-xxhdpi/ic_launcher.png and /dev/null differ
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/res/drawable/ic_launcher.png b/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/res/drawable/ic_launcher.png
deleted file mode 100644
index cde69bccc..000000000
Binary files a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/res/drawable/ic_launcher.png and /dev/null differ
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/res/layout/query_activity.xml b/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/res/layout/query_activity.xml
deleted file mode 100644
index 722977d80..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/res/layout/query_activity.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/res/layout/select_activity.xml b/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/res/layout/select_activity.xml
deleted file mode 100644
index 080037a3f..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/res/layout/select_activity.xml
+++ /dev/null
@@ -1,67 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/res/values-zh/strings.xml b/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/res/values-zh/strings.xml
deleted file mode 100644
index 6c388ebd3..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/res/values-zh/strings.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-APIJSON
-1.0
-Hello world!
-Settings
-单个Object
-Object之间的依赖
-Object数组
-复杂结构
-没有访问权限
-允许使用权限
-查询
-可能出现了一些问题,可以按照以下步骤解决:\n\n1.检查网络连接\n\n2.检查url是否为一个可用的IPV4地址\n\n3.长按[查询]按钮用浏览器发送请求\n\n4.查看目标服务器上的log\n\n5.再试一次
-{\n \"User\":{\n \"id\":38710\n }\n}
-{\n \"User\":{\n \"id\":70793\n },\n \"Work\":{\n \"userId\":\"User/id\"\n }\n}
-{\n \"User[]\":{\n \"count\":10,\n \"User\":{\n \"sex\":0\n }\n }\n}
-{\n \"[]\":{\n \"count\":2,\n \"User\":{\n \"sex\":0\n },\n \"Work\":{\n \"userId\":\"/User/id\"\n },\n \"Comment[]\":{\n \"count\":3,\n \"Comment\":{\n \"workId\":\"[]/Work/id\"\n }\n }\n }\n}
-{\n \"Wallet\":{\n \"userId\":38710\n }\n}
-{\n \"Wallet\":{\n \"userId\":38710\n },\n \"currentUserId\":38710,\n \"payPassword\":\"123456\"\n}
-
-
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/res/values/dimens.xml b/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/res/values/dimens.xml
deleted file mode 100644
index 55c1e5908..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/res/values/dimens.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
- 16dp
- 16dp
-
-
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/res/values/strings.xml b/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/res/values/strings.xml
deleted file mode 100644
index d68ab0fc9..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-APIJSON
-1.0
-Hello world!
-Settings
-Single
-Rely
-Array
-Complex
-Access Error
-Access Permitted
-Query
-There may be something wrong,you can follow by the steps:\n\n1.Check your net connection\n\n2.Check the url whether it\'s an available ipv4 address\n\n3.Long click the [Query] button to open the request by web browser\n\n4.Check logs outputed on the target server\n\n5.Try again
-{\n \"User\":{\n \"id\":38710\n }\n}
-{\n \"User\":{\n \"id\":70793\n },\n \"Work\":{\n \"userId\":\"User/id\"\n }\n}
-{\n \"User[]\":{\n \"count\":10,\n \"User\":{\n \"sex\":0\n }\n }\n}
-{\n \"[]\":{\n \"count\":2,\n \"User\":{\n \"sex\":0\n },\n \"Work\":{\n \"userId\":\"/User/id\"\n },\n \"Comment[]\":{\n \"count\":3,\n \"Comment\":{\n \"workId\":\"[]/Work/id\"\n }\n }\n }\n}
-{\n \"Wallet\":{\n \"userId\":38710\n }\n}
-{\n \"Wallet\":{\n \"userId\":38710\n },\n \"currentUserId\":38710,\n \"payPassword\":\"123456\"\n}
-
-
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/res/values/styles.xml b/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/res/values/styles.xml
deleted file mode 100644
index 69e2137a1..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/main/res/values/styles.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/test/java/zuo/biao/apijson/client/ExampleUnitTest.java b/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/test/java/zuo/biao/apijson/client/ExampleUnitTest.java
deleted file mode 100644
index e02ebdc79..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/app/src/test/java/zuo/biao/apijson/client/ExampleUnitTest.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package zuo.biao.apijson.client;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * To work on unit tests, switch the Test Artifact in the Build Variants view.
- */
-public class ExampleUnitTest {
- @Test
- public void addition_isCorrect() throws Exception {
- assertEquals(4, 2 + 2);
- }
-}
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/build.gradle b/APIJSON(Android)/APIJSON(AndroidStudio)/build.gradle
deleted file mode 100644
index aff4f415e..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/build.gradle
+++ /dev/null
@@ -1,23 +0,0 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
-
-buildscript {
- repositories {
- jcenter()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:2.1.2'
-
- // NOTE: Do not place your application dependencies here; they belong
- // in the individual module build.gradle files
- }
-}
-
-allprojects {
- repositories {
- jcenter()
- }
-}
-
-task clean(type: Delete) {
- delete rootProject.buildDir
-}
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/gradle.properties b/APIJSON(Android)/APIJSON(AndroidStudio)/gradle.properties
deleted file mode 100644
index 1d3591c8a..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/gradle.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-# Project-wide Gradle settings.
-
-# IDE (e.g. Android Studio) users:
-# Gradle settings configured through the IDE *will override*
-# any settings specified in this file.
-
-# For more details on how to configure your build environment visit
-# http://www.gradle.org/docs/current/userguide/build_environment.html
-
-# Specifies the JVM arguments used for the daemon process.
-# The setting is particularly useful for tweaking memory settings.
-# Default value: -Xmx10248m -XX:MaxPermSize=256m
-# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
-
-# When configured, Gradle will run in incubating parallel mode.
-# This option should only be used with decoupled projects. More details, visit
-# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
-# org.gradle.parallel=true
\ No newline at end of file
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/gradle/wrapper/gradle-wrapper.jar b/APIJSON(Android)/APIJSON(AndroidStudio)/gradle/wrapper/gradle-wrapper.jar
deleted file mode 100644
index 13372aef5..000000000
Binary files a/APIJSON(Android)/APIJSON(AndroidStudio)/gradle/wrapper/gradle-wrapper.jar and /dev/null differ
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/gradle/wrapper/gradle-wrapper.properties b/APIJSON(Android)/APIJSON(AndroidStudio)/gradle/wrapper/gradle-wrapper.properties
deleted file mode 100644
index 122a0dca2..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/gradle/wrapper/gradle-wrapper.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-#Mon Dec 28 10:00:20 PST 2015
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/gradlew b/APIJSON(Android)/APIJSON(AndroidStudio)/gradlew
deleted file mode 100755
index 9d82f7891..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/gradlew
+++ /dev/null
@@ -1,160 +0,0 @@
-#!/usr/bin/env bash
-
-##############################################################################
-##
-## Gradle start up script for UN*X
-##
-##############################################################################
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn ( ) {
- echo "$*"
-}
-
-die ( ) {
- echo
- echo "$*"
- echo
- exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
-esac
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=$((i+1))
- done
- case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
-fi
-
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
- JVM_OPTS=("$@")
-}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
-
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/gradlew.bat b/APIJSON(Android)/APIJSON(AndroidStudio)/gradlew.bat
deleted file mode 100644
index aec99730b..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/gradlew.bat
+++ /dev/null
@@ -1,90 +0,0 @@
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windowz variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-set CMD_LINE_ARGS=%$
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
diff --git a/APIJSON(Android)/APIJSON(AndroidStudio)/settings.gradle b/APIJSON(Android)/APIJSON(AndroidStudio)/settings.gradle
deleted file mode 100644
index e7b4def49..000000000
--- a/APIJSON(Android)/APIJSON(AndroidStudio)/settings.gradle
+++ /dev/null
@@ -1 +0,0 @@
-include ':app'
diff --git a/APIJSON(Server)/APIJSON(Eclipse_JEE)/.gitignore b/APIJSON(Server)/APIJSON(Eclipse_JEE)/.gitignore
deleted file mode 100755
index 2af7cefb0..000000000
--- a/APIJSON(Server)/APIJSON(Eclipse_JEE)/.gitignore
+++ /dev/null
@@ -1,24 +0,0 @@
-target/
-!.mvn/wrapper/maven-wrapper.jar
-
-### STS ###
-.apt_generated
-.classpath
-.factorypath
-.project
-.settings
-.springBeans
-
-### IntelliJ IDEA ###
-.idea
-*.iws
-*.iml
-*.ipr
-
-### NetBeans ###
-nbproject/private/
-build/
-nbbuild/
-dist/
-nbdist/
-.nb-gradle/
\ No newline at end of file
diff --git a/APIJSON(Server)/APIJSON(Eclipse_JEE)/.mvn/wrapper/maven-wrapper.jar b/APIJSON(Server)/APIJSON(Eclipse_JEE)/.mvn/wrapper/maven-wrapper.jar
deleted file mode 100755
index 5fd4d5023..000000000
Binary files a/APIJSON(Server)/APIJSON(Eclipse_JEE)/.mvn/wrapper/maven-wrapper.jar and /dev/null differ
diff --git a/APIJSON(Server)/APIJSON(Eclipse_JEE)/.mvn/wrapper/maven-wrapper.properties b/APIJSON(Server)/APIJSON(Eclipse_JEE)/.mvn/wrapper/maven-wrapper.properties
deleted file mode 100755
index c954cec91..000000000
--- a/APIJSON(Server)/APIJSON(Eclipse_JEE)/.mvn/wrapper/maven-wrapper.properties
+++ /dev/null
@@ -1 +0,0 @@
-distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip
diff --git a/APIJSON(Server)/APIJSON(Eclipse_JEE)/.travis.yml b/APIJSON(Server)/APIJSON(Eclipse_JEE)/.travis.yml
deleted file mode 100755
index d036b68c1..000000000
--- a/APIJSON(Server)/APIJSON(Eclipse_JEE)/.travis.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-language: java
-sudo: false
-jdk:
- - oraclejdk7
\ No newline at end of file
diff --git a/APIJSON(Server)/APIJSON(Eclipse_JEE)/WebContent/META-INF/MANIFEST.MF b/APIJSON(Server)/APIJSON(Eclipse_JEE)/WebContent/META-INF/MANIFEST.MF
deleted file mode 100755
index 5e9495128..000000000
--- a/APIJSON(Server)/APIJSON(Eclipse_JEE)/WebContent/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,3 +0,0 @@
-Manifest-Version: 1.0
-Class-Path:
-
diff --git a/APIJSON(Server)/APIJSON(Eclipse_JEE)/WebContent/WEB-INF/web.xml b/APIJSON(Server)/APIJSON(Eclipse_JEE)/WebContent/WEB-INF/web.xml
deleted file mode 100755
index adb90bb16..000000000
--- a/APIJSON(Server)/APIJSON(Eclipse_JEE)/WebContent/WEB-INF/web.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/APIJSON(Server)/APIJSON(Eclipse_JEE)/apijson.eml b/APIJSON(Server)/APIJSON(Eclipse_JEE)/apijson.eml
deleted file mode 100755
index c9bcaf1c5..000000000
--- a/APIJSON(Server)/APIJSON(Eclipse_JEE)/apijson.eml
+++ /dev/null
@@ -1,75 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/APIJSON(Server)/APIJSON(Eclipse_JEE)/apijson.userlibraries b/APIJSON(Server)/APIJSON(Eclipse_JEE)/apijson.userlibraries
deleted file mode 100755
index 1f093e3b1..000000000
--- a/APIJSON(Server)/APIJSON(Eclipse_JEE)/apijson.userlibraries
+++ /dev/null
@@ -1,148 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/APIJSON(Server)/APIJSON(Eclipse_JEE)/mvnw b/APIJSON(Server)/APIJSON(Eclipse_JEE)/mvnw
deleted file mode 100755
index a1ba1bf55..000000000
--- a/APIJSON(Server)/APIJSON(Eclipse_JEE)/mvnw
+++ /dev/null
@@ -1,233 +0,0 @@
-#!/bin/sh
-# ----------------------------------------------------------------------------
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you 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.
-# ----------------------------------------------------------------------------
-
-# ----------------------------------------------------------------------------
-# Maven2 Start Up Batch script
-#
-# Required ENV vars:
-# ------------------
-# JAVA_HOME - location of a JDK home dir
-#
-# Optional ENV vars
-# -----------------
-# M2_HOME - location of maven2's installed home dir
-# MAVEN_OPTS - parameters passed to the Java VM when running Maven
-# e.g. to debug Maven itself, use
-# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
-# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
-# ----------------------------------------------------------------------------
-
-if [ -z "$MAVEN_SKIP_RC" ] ; then
-
- if [ -f /etc/mavenrc ] ; then
- . /etc/mavenrc
- fi
-
- if [ -f "$HOME/.mavenrc" ] ; then
- . "$HOME/.mavenrc"
- fi
-
-fi
-
-# OS specific support. $var _must_ be set to either true or false.
-cygwin=false;
-darwin=false;
-mingw=false
-case "`uname`" in
- CYGWIN*) cygwin=true ;;
- MINGW*) mingw=true;;
- Darwin*) darwin=true
- #
- # Look for the Apple JDKs first to preserve the existing behaviour, and then look
- # for the new JDKs provided by Oracle.
- #
- if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then
- #
- # Apple JDKs
- #
- export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
- fi
-
- if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then
- #
- # Apple JDKs
- #
- export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
- fi
-
- if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then
- #
- # Oracle JDKs
- #
- export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
- fi
-
- if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then
- #
- # Apple JDKs
- #
- export JAVA_HOME=`/usr/libexec/java_home`
- fi
- ;;
-esac
-
-if [ -z "$JAVA_HOME" ] ; then
- if [ -r /etc/gentoo-release ] ; then
- JAVA_HOME=`java-config --jre-home`
- fi
-fi
-
-if [ -z "$M2_HOME" ] ; then
- ## resolve links - $0 may be a link to maven's home
- PRG="$0"
-
- # need this for relative symlinks
- while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG="`dirname "$PRG"`/$link"
- fi
- done
-
- saveddir=`pwd`
-
- M2_HOME=`dirname "$PRG"`/..
-
- # make it fully qualified
- M2_HOME=`cd "$M2_HOME" && pwd`
-
- cd "$saveddir"
- # echo Using m2 at $M2_HOME
-fi
-
-# For Cygwin, ensure paths are in UNIX format before anything is touched
-if $cygwin ; then
- [ -n "$M2_HOME" ] &&
- M2_HOME=`cygpath --unix "$M2_HOME"`
- [ -n "$JAVA_HOME" ] &&
- JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
- [ -n "$CLASSPATH" ] &&
- CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
-fi
-
-# For Migwn, ensure paths are in UNIX format before anything is touched
-if $mingw ; then
- [ -n "$M2_HOME" ] &&
- M2_HOME="`(cd "$M2_HOME"; pwd)`"
- [ -n "$JAVA_HOME" ] &&
- JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
- # TODO classpath?
-fi
-
-if [ -z "$JAVA_HOME" ]; then
- javaExecutable="`which javac`"
- if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
- # readlink(1) is not available as standard on Solaris 10.
- readLink=`which readlink`
- if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
- if $darwin ; then
- javaHome="`dirname \"$javaExecutable\"`"
- javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
- else
- javaExecutable="`readlink -f \"$javaExecutable\"`"
- fi
- javaHome="`dirname \"$javaExecutable\"`"
- javaHome=`expr "$javaHome" : '\(.*\)/bin'`
- JAVA_HOME="$javaHome"
- export JAVA_HOME
- fi
- fi
-fi
-
-if [ -z "$JAVACMD" ] ; then
- if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- else
- JAVACMD="`which java`"
- fi
-fi
-
-if [ ! -x "$JAVACMD" ] ; then
- echo "Error: JAVA_HOME is not defined correctly." >&2
- echo " We cannot execute $JAVACMD" >&2
- exit 1
-fi
-
-if [ -z "$JAVA_HOME" ] ; then
- echo "Warning: JAVA_HOME environment variable is not set."
-fi
-
-CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin; then
- [ -n "$M2_HOME" ] &&
- M2_HOME=`cygpath --path --windows "$M2_HOME"`
- [ -n "$JAVA_HOME" ] &&
- JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
- [ -n "$CLASSPATH" ] &&
- CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
-fi
-
-# traverses directory structure from process work directory to filesystem root
-# first directory with .mvn subdirectory is considered project base directory
-find_maven_basedir() {
- local basedir=$(pwd)
- local wdir=$(pwd)
- while [ "$wdir" != '/' ] ; do
- if [ -d "$wdir"/.mvn ] ; then
- basedir=$wdir
- break
- fi
- wdir=$(cd "$wdir/.."; pwd)
- done
- echo "${basedir}"
-}
-
-# concatenates all lines of a file
-concat_lines() {
- if [ -f "$1" ]; then
- echo "$(tr -s '\n' ' ' < "$1")"
- fi
-}
-
-export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)}
-MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
-
-# Provide a "standardized" way to retrieve the CLI args that will
-# work with both Windows and non-Windows executions.
-MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
-export MAVEN_CMD_LINE_ARGS
-
-WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
-
-exec "$JAVACMD" \
- $MAVEN_OPTS \
- -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
- "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
- ${WRAPPER_LAUNCHER} "$@"
diff --git a/APIJSON(Server)/APIJSON(Eclipse_JEE)/mvnw.cmd b/APIJSON(Server)/APIJSON(Eclipse_JEE)/mvnw.cmd
deleted file mode 100755
index 2b934e89d..000000000
--- a/APIJSON(Server)/APIJSON(Eclipse_JEE)/mvnw.cmd
+++ /dev/null
@@ -1,145 +0,0 @@
-@REM ----------------------------------------------------------------------------
-@REM Licensed to the Apache Software Foundation (ASF) under one
-@REM or more contributor license agreements. See the NOTICE file
-@REM distributed with this work for additional information
-@REM regarding copyright ownership. The ASF licenses this file
-@REM to you under the Apache License, Version 2.0 (the
-@REM "License"); you may not use this file except in compliance
-@REM with the License. You may obtain a copy of the License at
-@REM
-@REM http://www.apache.org/licenses/LICENSE-2.0
-@REM
-@REM Unless required by applicable law or agreed to in writing,
-@REM software distributed under the License is distributed on an
-@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-@REM KIND, either express or implied. See the License for the
-@REM specific language governing permissions and limitations
-@REM under the License.
-@REM ----------------------------------------------------------------------------
-
-@REM ----------------------------------------------------------------------------
-@REM Maven2 Start Up Batch script
-@REM
-@REM Required ENV vars:
-@REM JAVA_HOME - location of a JDK home dir
-@REM
-@REM Optional ENV vars
-@REM M2_HOME - location of maven2's installed home dir
-@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
-@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
-@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
-@REM e.g. to debug Maven itself, use
-@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
-@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
-@REM ----------------------------------------------------------------------------
-
-@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
-@echo off
-@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
-@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
-
-@REM set %HOME% to equivalent of $HOME
-if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
-
-@REM Execute a user defined script before this one
-if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
-@REM check for pre script, once with legacy .bat ending and once with .cmd ending
-if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
-if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
-:skipRcPre
-
-@setlocal
-
-set ERROR_CODE=0
-
-@REM To isolate internal variables from possible post scripts, we use another setlocal
-@setlocal
-
-@REM ==== START VALIDATION ====
-if not "%JAVA_HOME%" == "" goto OkJHome
-
-echo.
-echo Error: JAVA_HOME not found in your environment. >&2
-echo Please set the JAVA_HOME variable in your environment to match the >&2
-echo location of your Java installation. >&2
-echo.
-goto error
-
-:OkJHome
-if exist "%JAVA_HOME%\bin\java.exe" goto init
-
-echo.
-echo Error: JAVA_HOME is set to an invalid directory. >&2
-echo JAVA_HOME = "%JAVA_HOME%" >&2
-echo Please set the JAVA_HOME variable in your environment to match the >&2
-echo location of your Java installation. >&2
-echo.
-goto error
-
-@REM ==== END VALIDATION ====
-
-:init
-
-set MAVEN_CMD_LINE_ARGS=%*
-
-@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
-@REM Fallback to current working directory if not found.
-
-set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
-IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
-
-set EXEC_DIR=%CD%
-set WDIR=%EXEC_DIR%
-:findBaseDir
-IF EXIST "%WDIR%"\.mvn goto baseDirFound
-cd ..
-IF "%WDIR%"=="%CD%" goto baseDirNotFound
-set WDIR=%CD%
-goto findBaseDir
-
-:baseDirFound
-set MAVEN_PROJECTBASEDIR=%WDIR%
-cd "%EXEC_DIR%"
-goto endDetectBaseDir
-
-:baseDirNotFound
-set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
-cd "%EXEC_DIR%"
-
-:endDetectBaseDir
-
-IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
-
-@setlocal EnableExtensions EnableDelayedExpansion
-for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
-@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
-
-:endReadAdditionalConfig
-
-SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
-
-set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar""
-set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
-
-%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS%
-if ERRORLEVEL 1 goto error
-goto end
-
-:error
-set ERROR_CODE=1
-
-:end
-@endlocal & set ERROR_CODE=%ERROR_CODE%
-
-if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
-@REM check for post script, once with legacy .bat ending and once with .cmd ending
-if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
-if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
-:skipRcPost
-
-@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
-if "%MAVEN_BATCH_PAUSE%" == "on" pause
-
-if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
-
-exit /B %ERROR_CODE%
\ No newline at end of file
diff --git a/APIJSON(Server)/APIJSON(Eclipse_JEE)/pom.xml b/APIJSON(Server)/APIJSON(Eclipse_JEE)/pom.xml
deleted file mode 100755
index 3e26692f0..000000000
--- a/APIJSON(Server)/APIJSON(Eclipse_JEE)/pom.xml
+++ /dev/null
@@ -1,89 +0,0 @@
-
-
- 4.0.0
-
- zuo.biao.apijson.server
- apijson
- 0.0.1-SNAPSHOT
- jar
-
- APIJSON(Idea)
- APIJSON Server project using Spring Boot
-
-
- org.springframework.boot
- spring-boot-starter-parent
- 1.4.1.RELEASE
-
-
-
-
- UTF-8
- UTF-8
- 1.7
-
-
-
-
- mysql
- mysql-connector-java
- 5.1.40
-
-
-
- org.springframework.boot
- spring-boot-starter
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
-
- com.alibaba
- fastjson
- 1.2.21
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
-
-
-
-
-
-
- spring-snapshots
- http://repo.spring.io/snapshot
- true
-
-
- spring-milestones
- http://repo.spring.io/milestone
- true
-
-
-
-
- spring-snapshots
- http://repo.spring.io/snapshot
-
-
- spring-milestones
- http://repo.spring.io/milestone
-
-
-
-
diff --git a/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/JSON.java b/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/JSON.java
deleted file mode 100755
index 7fc6940b3..000000000
--- a/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/JSON.java
+++ /dev/null
@@ -1,118 +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 com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.alibaba.fastjson.parser.Feature;
-import com.alibaba.fastjson.serializer.SerializerFeature;
-
-import java.util.List;
-
-/**阿里json封装类 防止解析时异常
- * @author Lemon
- */
-public class JSON {
- private static final String TAG = "JSON";
-
- /**判断json格式是否正确
- * @param s
- * @return
- */
- public static boolean isJsonCorrect(String s) {
- System.out.println(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) {
- s = StringUtil.getNoBlankString(s);
- return isJsonCorrect(s) ? s : "";
- }
-
- /**json转JSONObject
- * @param json
- * @return
- */
- public static JSONObject parseObject(String json) {
- try {
- int features = com.alibaba.fastjson.JSON.DEFAULT_PARSER_FEATURE;
- features |= Feature.SortFeidFastMatch.getMask();
- return com.alibaba.fastjson.JSON.parseObject(getCorrectJson(json), JSONObject.class, features);
- } catch (Exception e) {
- System.out.println(TAG + "parseObject catch \n" + e.getMessage());
- }
- return null;
- }
-
- /**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.SortFeidFastMatch.getMask();
- return com.alibaba.fastjson.JSON.parseObject(getCorrectJson(json), clazz, features);
- } catch (Exception e) {
- System.out.println(TAG + "parseObject catch \n" + e.getMessage());
- }
- return null;
- }
-
- /**json转JSONArray
- * @param json
- * @return
- */
- public static JSONArray parseArray(String json) {
- return com.alibaba.fastjson.JSON.parseArray(json);
- }
- /**json转实体类列表
- * @param json
- * @param clazz
- * @return
- */
- public static List parseArray(String json, Class clazz) {
- try {
- return com.alibaba.fastjson.JSON.parseArray(getCorrectJson(json), clazz);
- } catch (Exception e) {
- System.out.println(TAG + "parseArray catch \n" + e.getMessage());
- }
- return null;
- }
-
- /**实体类转json
- * @param obj
- * @return
- */
- public static String toJSONString(Object obj) {
- try {
- return com.alibaba.fastjson.JSON.toJSONString(obj, SerializerFeature.SortField);
- } catch (Exception e) {
- System.out.println(TAG + "toJSONString catch \n" + e.getMessage());
- }
- return null;
- }
-
-
-}
diff --git a/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/StringUtil.java b/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/StringUtil.java
deleted file mode 100755
index 9789bee74..000000000
--- a/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/StringUtil.java
+++ /dev/null
@@ -1,601 +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 {
-
- 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时返回"" >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
- //获取去掉前后空格后的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 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) {
- // Log.i(TAG, "getTrimedString s = " + s);
- if (s == null) {
- return false;
- }
- if (trim) {
- s = s.trim();
- }
- if (s.length() <= 0) {
- return false;
- }
-
- currentString = s;
-
- return true;
- }
-
- //判断字符是否非空 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
- //判断字符类型 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
- //判断手机格式是否正确
- 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) {
- System.out.println("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) {
- System.out.println("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 = "/";
- public static boolean isPath(String path) {
- return StringUtil.isNotEmpty(path, true) && path.contains(SEPARATOR)
- && path.contains(SEPARATOR + SEPARATOR) == false && path.endsWith(SEPARATOR) == false;
- }
-
- public static String[] splitPath(String path) {
- path = getString(path);
- if(path.startsWith("/")){
- path = path.substring(1);
- }
- if(path.endsWith("/")){
- path = path.substring(0, path.length() - 1);
- }
- return isPath(path) ? path.split(SEPARATOR) : new String[] {path};
- }
-
-
- /**判断字符类型是否是路径
- * @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) {
- System.out.println("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? >>>>>>>>>>>>>>>>>>>>>>
-
- System.out.println("getPrice <<<<<<<<<<<<<<<<<< correctPrice = " + correctPrice);
- if (correctPrice.contains(".")) {
- // if (correctPrice.startsWith(".")) {
- // correctPrice = 0 + correctPrice;
- // }
- if (correctPrice.endsWith(".")) {
- correctPrice = correctPrice.replaceAll(".", "");
- }
- }
-
- System.out.println("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;
- }
- }
-
-
- //校正(自动补全等)字符串>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-}
diff --git a/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/package-info.java b/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/package-info.java
deleted file mode 100755
index f0e0bfb5a..000000000
--- a/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/package-info.java
+++ /dev/null
@@ -1,22 +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.*/
-
-/**
- * common files package between Server and Client projects
- */
-/**
- * @author Lemon
- *
- */
-package zuo.biao.apijson;
\ No newline at end of file
diff --git a/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/server/APIJSONApplication.java b/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/server/APIJSONApplication.java
deleted file mode 100755
index 009bad2e3..000000000
--- a/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/server/APIJSONApplication.java
+++ /dev/null
@@ -1,29 +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.server;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-
-/**application
- * @author Lemon
- */
-@SpringBootApplication
-public class APIJSONApplication {
-
- public static void main(String[] args) {
- SpringApplication.run(APIJSONApplication.class, args);
- }
-}
diff --git a/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/server/ClientTest.java b/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/server/ClientTest.java
deleted file mode 100755
index 68bce1d88..000000000
--- a/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/server/ClientTest.java
+++ /dev/null
@@ -1,80 +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.server;
-
-/**mock test of client
- * @author Lemon
- */
-public class ClientTest {
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- // new RequestParser().get(\"{User\\":{\\"id\\":1}}\");
- //
- // new RequestParser().get(\"{[User]\\":{ \\"range\\":1, \\"pageNum\\":1, \\"pageSize\\":10, \\"sortOrder\\":\\"id\\", \\"sortDirection\\":\\"increase\\",}}\");
- //
- // new RequestParser().get(\"{\\"[User, Work, [picture]]\\": { \\"=\\": { \\"User\\": id, \\"Work\\": \\"userId\\", \\"picture\\": \\"userId\\"}\\"pageNum\\": 1, \\"pageSize\\": 10, \\"sortOrder\\": \\"id\\", \\"sortDirection\\": \\"increase\\", \\"User\\": { \\"sex\\":SEX_FEMAIL, } \\"picture\\":{ \\"pageNum\\":1, \\"pageSize\\": 3, }}\");
-
-
-// //已经过bejson校验和传输校验
-// new RequestParser().parse("{" +
-//// "\"[]\": {" +
-//// "\"page\": 1, " +
-//// "\"count\": 5," +
-// " \"User\": {" +
-// "\"id\": 38710," +//70793
-//// "\"range\": 1," +
-//// "\"sex\": 0" +
-// "}," +
-// "\"Work\": {" +
-// "\"userId\": \"User/id\"" +
-// "}," +
-// "\"Comment[]\": {" +
-// "\"page\": 0," +
-// "\"count\": 3," +
-// " \"Comment\": {" +
-// "\"workId\": \"Work/id\"" +
-// "}," +
-// "}" +
-//// "}" +
-// "}");
-
- //已经过bejson校验和传输校验
- new RequestParser().parse("{" +
- "\"[]\": {" +
- "\"page\": 1, " +
- "\"count\": 10," +
- " \"User\": {" +
- "\"sex\": 0" +
- "}," +
- "\"Work\": {" +
- "\"userId\": \"/User/id\"" +
- "}," +
- "\"Comment[]\": {" +
- "\"page\": 0," +
- "\"count\": 3," +
- " \"Comment\": {" +
- "\"workId\": \"[]/Work/id\"" +
- "}," +
- "}" +
- "}" +
- "}");
-
-
- }
-
-}
diff --git a/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/server/Controller.java b/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/server/Controller.java
deleted file mode 100755
index 52d8c45c9..000000000
--- a/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/server/Controller.java
+++ /dev/null
@@ -1,50 +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.server;
-
-import com.alibaba.fastjson.JSONObject;
-import org.springframework.web.bind.annotation.*;
-import zuo.biao.apijson.JSON;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-
-import static zuo.biao.apijson.StringUtil.UTF_8;
-
-/**request receiver and controller
- * @author Lemon
- */
-@RestController
-@RequestMapping("")
-public class Controller {
-
- @RequestMapping("get/{request}")
- public String get(@PathVariable String request) {
- System.out.println("request = " + request);
- JSONObject object = new RequestParser().parse(request);
- System.out.println("return " + JSON.toJSONString(object));
- return JSON.toJSONString(object);
- }
-
-// @RequestMapping(value="/request",produces="application/json")
-// public String get2(@RequestBody JSONObject request){
-// return JSON.toJSONString(request);
-// }
-// @RequestMapping(method = RequestMethod.GET)
-// public String create(@RequestBody @Valid JSONObject request) {
-// return JSON.toJSONString(request);
-// }
-
-}
diff --git a/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/server/QueryConfig.java b/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/server/QueryConfig.java
deleted file mode 100755
index ae9ad4274..000000000
--- a/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/server/QueryConfig.java
+++ /dev/null
@@ -1,190 +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.server;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-
-import com.alibaba.fastjson.JSONObject;
-import zuo.biao.apijson.JSON;
-
-/**config model for query
- * @author Lemon
- */
-public class QueryConfig {
-
- private String table;
- private String[] columns;
- private String[][] values;
- private Map where;
- private int limit;
- private int page;
- private int position;
-
- public QueryConfig() {
- }
- public QueryConfig(String table) {
- this();
- setTable(table);
- }
- public QueryConfig(String table, Map where) {
- this(table);
- setWhere(where);
- }
- public QueryConfig(String table, String[] columns, String[][] values) {
- this(table);
- setColumns(columns);
- setValues(values);
- }
- public QueryConfig(int limit, int page) {
- this();
- setLimit(limit);
- setPage(page);
- }
-
-
- public String getTable() {
- return table;
- }
- public QueryConfig setTable(String table) {
- this.table = table;
- return this;
- }
- public String[] getColumns() {
- return columns;
- }
- public QueryConfig setColumns(String[] columns) {
- this.columns = columns;
- return this;
- }
- public String[][] getValues() {
- return values;
- }
- public QueryConfig setValues(String[][] values) {
- this.values = values;
- return this;
- }
- public Map getWhere() {
- return where;
- }
- public QueryConfig setWhere(Map where) {
- this.where = where;
- return this;
- }
- public int getLimit() {
- return limit;
- }
- public QueryConfig setLimit(int limit) {
- this.limit = limit;
- return this;
- }
- public int getPage() {
- return page;
- }
- public QueryConfig setPage(int page) {
- this.page = page;
- return this;
- }
- public int getPosition() {
- return position;
- }
- public QueryConfig setPosition(int position) {
- this.position = position;
- return this;
- }
-
- /**获取限制数量
- * @return
- */
- public String getLimitString() {
- return getLimitString(limit);// + 1);
- }
- /**获取限制数量
- * @param limit
- * @return
- */
- public static String getLimitString(int limit) {
- return limit <= 0 ? "" : " limit " + limit;
- }
-
- /**获取筛选方法
- * @return
- */
- public String getWhereString() {
- return getWhereString(where);
- }
- /**获取筛选方法
- * @param where
- * @return
- */
- public static String getWhereString(Map where) {
- Set set = where == null ? null : where.keySet();
- if (set != null && set.size() > 0) {
- String whereString = " where ";
- Object value;
- for (String key : set) {
- //避免筛选到全部 value = key == null ? null : where.get(key);
- if (key == null) {
- continue;
- }
- whereString += (key + "=" + where.get(key) + " &");
- }
- if (whereString.endsWith("&")) {
- whereString = whereString.substring(0, whereString.length() - 1);
- }
- if (whereString.trim().endsWith("where") == false) {
- return whereString;
- }
- }
- return "";
- }
-
-
- /**获取查询配置
- * @param table
- * @param request
- * @return
- */
- public static synchronized QueryConfig getQueryConfig(String table, JSONObject request) {
- Set set = request == null ? null : request.keySet();
- Map transferredRequest = null;
- if (set != null) {
- transferredRequest = new HashMap();
- for (String key : set) {
- if (JSON.parseObject(request.getString(key)) == null) {//非key-value
- transferredRequest.put(key, request.get(key));
- }
- }
- }
- return new QueryConfig(table).setWhere(transferredRequest);
- }
-
- /**
- * @return
- */
- public String getSQL() {
- return getSQL(this);
- }
- /**
- * @param config
- * @return
- */
- public static String getSQL(QueryConfig config) {
- return config == null ? null : "select * from " + config.getTable() + config.getWhereString() + config.getLimitString();
- }
-
-}
diff --git a/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/server/RequestParser.java b/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/server/RequestParser.java
deleted file mode 100755
index c4214d0d3..000000000
--- a/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/server/RequestParser.java
+++ /dev/null
@@ -1,458 +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.server;
-import static zuo.biao.apijson.StringUtil.UTF_8;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import java.rmi.AccessException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import com.alibaba.fastjson.JSONObject;
-
-import zuo.biao.apijson.JSON;
-import zuo.biao.apijson.StringUtil;
-import zuo.biao.apijson.server.sql.AccessVerifier;
-import zuo.biao.apijson.server.sql.QueryHelper;
-
-/**parser for parsing request to JSONObject
- * @author Lemon
- */
-public class RequestParser {
- private static final String TAG = "RequestParser: ";
-
- public static final String SEPARATOR = StringUtil.SEPARATOR;
-
-
- private JSONObject requestObject;
-
- private boolean parseRelation;
- private Map relationMap;
-
-
- /**
- * @param json
- */
- public JSONObject parse(String json) {
- try {
- json = URLDecoder.decode(json, UTF_8);
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- System.out.println(TAG + "get json = " + json);
-
- relationMap = new HashMap();
- parseRelation = false;
- requestObject = JSON.parseObject(json);
- requestObject = getObject(null, null, null, requestObject);
- parseRelation = true;
- requestObject = getObject(null, null, null, requestObject);
-
- requestObject = AccessVerifier.removeAccessInfo(requestObject);
-
- /**
- * TODO 格式化json,去除标记array内object位置的数字,转为[]形式,比如
- * "Comment[]":{"0":{"Comment":{...}}, ...}
- * 转为
- * "Comment[]":[{...}, ...]
- */
-
- QueryHelper.getInstance().close();
-// QueryHelper2.getInstance().close();
-
- System.out.println(TAG + "\n\n最终返回至客户端的json:\n" + JSON.toJSONString(requestObject));
- return requestObject;
- }
-
-
- /**获取单个对象,该对象处于parentObject内
- * @param parentPath parentObject的路径
- * @param parentConfig
- * @param name parentObject的key
- * @param request parentObject的value
- * @return
- */
- private JSONObject getObject(String parentPath, final QueryConfig parentConfig, String name, final JSONObject request) {
- System.out.println(TAG + "\ngetObject: parentPath = " + parentPath
- + ";\n name = " + name + "; request = " + JSON.toJSONString(request));
- if (request == null) {//key-value条件
- return null;
- }
- String path = getPath(parentPath, name);
-
- QueryConfig config = StringUtil.isNumer(name) ? parentConfig : null;
- if (config == null) {
- config = new QueryConfig(name);
- }
- boolean nameIsNumber = StringUtil.isNumer(name);
- final int position = nameIsNumber ? Integer.valueOf(0 + StringUtil.getNumber(name)) : 0;
-
- boolean containRelation = false;
-
- Set set = request.keySet();
- JSONObject transferredRequest = new JSONObject(true);
- if (set != null) {
- String value;
- JSONObject child;
- JSONObject result;
- boolean isFirst = true;
- for (String key : set) {
- value = transferredRequest.containsKey(key) ? transferredRequest.getString(key) : request.getString(key);
- child = JSON.parseObject(value);
- if (child == null) {//key - value
- transferredRequest.put(key, value);
- if (StringUtil.isPath(value)) {
- System.out.println("getObject StringUtil.isPath(value) >> parseRelation = " + parseRelation);
- if (parseRelation) {
- transferredRequest.put(key, getValueByPath(relationMap.get(getPath(path, key))));
- // relationMap.remove(path + SEPARATOR + key);
- } else {
- containRelation = true;
- relationMap.put(getPath(path, key)//value.contains(parentPath)会因为结构变化而改变
- , getPath((value.startsWith(SEPARATOR) ? parentPath : ""), value));
- }
- }
- } else {
- config.setPosition(isFirst && nameIsNumber ? position : 0);
- if (isArrayKey(key)) {//json array
- result = getArray(path, config, key, child);
- } else {//json object
- isFirst = false;
- result = getObject(path, config, key, child);
- }
- System.out.println(TAG + "getObject key = " + key + "; result = " + result);
- if (result != null && result.isEmpty() == false) {//只添加!=null的值,可能数据库返回数据不够count
- transferredRequest.put(key, result);
- }
- }
- }
- }
-
- if (containRelation == false && isObjectKey(name)) {
- if (parseRelation == false || isInRelationMap(path)) {//避免覆盖原来已经获取的
- // relationMap.remove(path);
- QueryConfig config2 = getQueryConfig(name, transferredRequest);
- if (parentConfig != null) {
- config2.setLimit(parentConfig.getLimit()).setPage(parentConfig.getPage())
- .setPosition(parentConfig.getPosition());//避免position > 0的object获取不到
- }
- JSONObject result = null;
- try {
- result = getSQLObject(config2);
- } catch (AccessException e) {
-// e.printStackTrace();
- result = new JSONObject(true);
- result.put("status", 403);
- result.put("message", e.getMessage());
- }
- // if (result != null) {
- transferredRequest = result;
- if (parseRelation) {
- putValueByPath(path, transferredRequest);//解决获取关联数据时requestObject里不存在需要的关联数据
- }
- // }
- }
- }
-
- return transferredRequest;
- }
-
-
-
- //TODO 如果获取key顺序不能保证就用一个"readOrder":{"user", "work", ...}确定顺序
- /**获取对象数组,该对象数组处于parentObject内
- * @param parentPath parentObject的路径
- * @param parentConfig parentObject对子object的SQL查询配置
- * @param name parentObject的key
- * @param request parentObject的value
- * @return
- */
- private JSONObject getArray(String parentPath, QueryConfig parentConfig, String name, final JSONObject request) {
- System.out.println(TAG + "\n\n\n getArray parentPath = " + parentPath
- + "; name = " + name + "; request = " + JSON.toJSONString(request));
- if (request == null) {//jsonKey-jsonValue条件
- return null;
- }
- String path = getPath(parentPath, name);
-
- int page = 0, count = 0;
- try {
- page = request.getIntValue("page");
- count = request.getIntValue("count");
- } catch (Exception e) {
- // System.out.println(TAG + "getArray try { page = arrayObject.getIntValue(page); ..." +
- // " >> } catch (Exception e) {\n" + e.getMessage());
- }
- if (parseRelation) {
- request.remove("page");
- request.remove("count");
- }
- System.out.println(TAG + "getArray page = " + page + "; count = " + count);
-
- QueryConfig config = new QueryConfig(count, page);
-
- Set set = request.keySet();
- JSONObject transferredRequest = new JSONObject(true);
- if (set != null) {
- JSONObject parent = null;
- String value;
- JSONObject child;
- JSONObject result;
- if (parseRelation == false) {
- //生成count个
- for (int i = 0; i < count; i++) {
- parent = new JSONObject(true);
- for (String key : set) {
- value = request.getString(key);
- child = JSON.parseObject(value);
- if (child == null) {//key - value
- //array里不允许关联,只能在object中关联
- transferredRequest.put(key, value);
- } else {
- config.setPosition(i);
- if (isArrayKey(key)) {//json array
- result = getArray(getPath(path, "" + i), config, key, child);
- } else {//json object
- result = getObject(getPath(path, "" + i), config, key, child);
- }
- System.out.println(TAG + "getArray parseRelation == false >> i = " + i + "result = " + result);
- if (result != null && result.isEmpty() == false) {//只添加!=null的值,可能数据库返回数据不够count
- parent.put(key, result);
-
- //更新关系path中对应改变字段
- Set relationSet = relationMap == null ? null : relationMap.keySet();
- if (relationSet != null) {
- String relationValue;
- String replacePath = getPath(path, "" + i);
- for (String relationKey : relationSet) {
- if (relationKey == null || relationKey.startsWith(replacePath) == false) {
- continue;
- }
- relationValue = relationMap.get(relationKey);
- if (relationValue != null && relationValue.startsWith(path)
- && relationValue.startsWith(replacePath) == false) {
- relationMap.put(relationKey, relationValue.replace(path, replacePath));
- }
- }
- }
- }
- }
- }
- if (parent.isEmpty() == false) {//可能数据库返回数据不够count
- transferredRequest.put("" + i, parent);
- }
- }
- } else {
- for (String key : set) {
- child = JSON.parseObject(request.getString(key));
- if (child == null) {//key - value
- //array里不允许关联,只能在object中关联
- } else {
- config.setPosition(Integer.valueOf(0 + StringUtil.getNumber(key, true)));
- if (isArrayKey(key)) {//json array
- result = getArray(path, config, key, child);
- } else {//json object
- result = getObject(path, config, key, child);
- }
- if (result != null && result.isEmpty() == false) {//只添加!=null的值,可能数据库返回数据不够count
- transferredRequest.put(key, result);
- }
- }
- }
- }
- }
-
- System.out.println(TAG + "getArray return " + JSON.toJSONString(transferredRequest) + "\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n\n");
-
- return transferredRequest;
- }
-
-
- /**获取拼接路径
- * @param path
- * @param name
- * @return
- */
- private String getPath(String path, String name) {
- System.out.println("getPath path = " + path + "; name = " + name + " <<<<<<<<<<<<<");
- path = StringUtil.getString(path);
- name = StringUtil.getString(name);
- if (StringUtil.isNotEmpty(path, false)) {
- if (StringUtil.isNotEmpty(name, false)) {
- path += ((name.startsWith(SEPARATOR) ? "" : SEPARATOR) + name);
- }
- } else {
- path = name;
- }
- System.out.println("getPath return " + path + " >>>>>>>>>>>>>>>>");
- return path;
- }
-
- /**有关联代码的object的关联key在relationMap里
- * @param path
- * @return
- */
- private boolean isInRelationMap(String path) {
- // return relationMap == null ? false : relationMap.containsKey(path);
- Set set = relationMap == null ? null : relationMap.keySet();
- if (set != null) {
- for (String key : set) {
- if (key != null && key.contains(path)) {
- return true;
- }
- }
- }
- return false;
- }
-
-
- /**将已获取完成的object的内容替换requestObject里对应的值
- * @param path object的路径
- * @param value 需要被关联的object
- */
- public synchronized void putValueByPath(String path, Object value) {
- System.out.println("\n putValueByPath path = " + path + "; value = " + value + "\n <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
- String[] keys = StringUtil.splitPath(path);
- if (keys == null) {
- return;
- }
- if (requestObject == null) {
- requestObject = new JSONObject(true);
- }
- // synchronized (requestObject) {
- JSONObject parent = requestObject;
- JSONObject child = null;
- String key;
- for (int i = 0; i < keys.length - 1; i++) {//一步一步到达指定位置parentPath
- key = keys[i];
- child = getJSONObject(parent, key);
- if (child == null) {//不存在该路径就创建
- child = new JSONObject(true);
- parent.put(key, child);
- }
- parent = child;
- }
-
- try {
- System.out.println("putValueByPath parent.put(keys[keys.length - 1], value); >> ");
- parent.put(keys[keys.length - 1], value);
- } catch (Exception e) {
- System.out.println("putValueByPath try { parent.put(keys[keys.length - 1], value); " +
- "} catch (Exception e) {\n" + e.getMessage());
- }
- System.out.println(TAG + "putValueByPath requestObject" + JSON.toJSONString(requestObject) + "\n >>>>>>>>>>>>>>>>>>");
- // }
- }
- /**根据路径获取值
- * @param path
- * @return
- */
- private Object getValueByPath(String path) {
- System.out.println(TAG + "<<<<<<<<<<<<<<< \n getValueByPath path = " + path + "\n <<<<<<<<<<<<<<<<<<");
- String[] keys = StringUtil.splitPath(path);
-
- if (keys != null) {
- JSONObject parent = requestObject;
- JSONObject child = null;
- String key;
- for (int i = 0; i < keys.length - 1; i++) {//一步一步到达指定位置parentPath
- key = keys[i];
- child = getJSONObject(parent, key);
- if (child == null) {//不存在
- return "";
- }
- parent = child;
- }
- try {
- System.out.println("getValueByPath return parent.get(keys[keys.length - 1]); >> ");
- return parent.get(keys[keys.length - 1]);
- } catch (Exception e) {
- System.out.println("getValueByPath try { return parent.get(keys[keys.length - 1]); " +
- "} catch (Exception e) {\n" + e.getMessage());
- }
- }
- System.out.println(TAG + "getValueByPath return requestObject" + JSON.toJSONString(requestObject) + "\n >>>>>>>>>>>>>>>>>>");
- return requestObject;
- }
-
-
- private JSONObject getJSONObject(JSONObject object, String key) {
- try {
- return object.getJSONObject(key);
- } catch (Exception e) {
- System.out.println("getJSONObject try { return object.getJSONObject(key); } catch (Exception e) { \n" + e.getMessage());
- }
- return null;
- }
-
-
- /**获取数据库返回的String
- * @param config
- * @return
- * @throws AccessException
- */
- private synchronized JSONObject getSQLObject(QueryConfig config) throws AccessException {
- System.out.println("getSQLObject config = " + JSON.toJSONString(config));
- AccessVerifier.verify(requestObject, config == null ? null : config.getTable());
- return QueryHelper.getInstance().select(config);//QueryHelper2.getInstance().select(config);//
- }
-
- /**获取查询配置
- * @param table
- * @param request
- * @return
- */
- public QueryConfig getQueryConfig(String table, JSONObject request) {
- return QueryConfig.getQueryConfig(table, request);
- }
- /**获取查询配置
- * @param table
- * @param request
- * @return
- */
- public QueryConfig newQueryConfig(String table, JSONObject request) {
- return QueryConfig.getQueryConfig(table, request);
- }
- /**把parentConfig的array属性继承下来
- * @param config
- * @param parentConfig
- * @return
- */
- private QueryConfig extendQueryConfig(QueryConfig config, QueryConfig parentConfig) {
- if (parentConfig != null) {
- if (config == null) {
- return parentConfig;
- }
- config.setLimit(parentConfig.getLimit()).setPage(parentConfig.getPage()).setPosition(parentConfig.getPosition());
- }
- return config;
- }
-
-
- public boolean isObject(String json) {
- return JSON.parseObject(json) != null;//json.startsWith("{") && json.endsWith("}");
- }
-
- private boolean isObjectKey(String key) {
- key = StringUtil.getString(key);
- return StringUtil.isNotEmpty(key, false) && isArrayKey(key) == false && StringUtil.isAlpha(key.substring(0, 1));
- }
- public boolean isArrayKey(String key) {
- return key.endsWith("[]");//[key]改为了key[],更符合常规逻辑。 key.startsWith("[") && key.endsWith("]");
- }
-
-}
diff --git a/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/server/package-info.java b/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/server/package-info.java
deleted file mode 100755
index aadcdd817..000000000
--- a/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/server/package-info.java
+++ /dev/null
@@ -1,22 +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.*/
-
-/**
- * server files package
- */
-/**
- * @author Lemon
- *
- */
-package zuo.biao.apijson.server;
\ No newline at end of file
diff --git a/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/server/sql/AccessVerifier.java b/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/server/sql/AccessVerifier.java
deleted file mode 100644
index 848301337..000000000
--- a/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/server/sql/AccessVerifier.java
+++ /dev/null
@@ -1,129 +0,0 @@
-package zuo.biao.apijson.server.sql;
-
-import java.rmi.AccessException;
-
-import com.alibaba.fastjson.JSONObject;
-
-import zuo.biao.apijson.StringUtil;
-
-/**权限验证类
- * @author Lemon
- */
-public class AccessVerifier {
- private static final String TAG = "AccessVerifier: ";
-
- private static final int ACCESS_LOGIN = 1;
- private static final int ACCESS_PAY = 2;
-
- public static final String KEY_CURRENT_USER_ID = "currentUserId";
- public static final String KEY_LOGIN_PASSWORD = "loginPassword";
- public static final String KEY_PAY_PASSWORD = "payPassword";
-
- // public static final String[] LOGIN_ACCESS_TABLE_NAMES = {"Work", "Comment"};
- public static final String[] PAY_ACCESS_TABLE_NAMES = {"Wallet"};
-
- /**验证权限是否通过
- * @param request
- * @param tableName
- * @return
- */
- public static boolean verify(JSONObject request, String tableName) throws AccessException {
- try {
- verify(request, getAccessId(tableName));
- } catch (AccessException e) {
- throw new AccessException(TAG + "verify tableName = " + tableName + ", error = " + e.getMessage());
- }
- return true;
- }
-
-
- /**验证权限是否通过
- * @param request
- * @param accessId 可以直接在代码里写ACCESS_LOGIN等,或者建一个Access表,包括id和需要改权限的table的tableName列表
- * @return
- * @throws AccessException
- */
- public static boolean verify(JSONObject request, int accessId) throws AccessException {
- if (accessId < 0 || request == null) {
- return true;
- }
- long currentUserId = request.getLongValue(KEY_CURRENT_USER_ID);
- if (currentUserId <= 0) {
- throw new AccessException(TAG + "verify accessId = " + accessId
- + " >> currentUserId <= 0, currentUserId = " + currentUserId);
- }
- String password;
-
- switch (accessId) {
- case ACCESS_LOGIN:
- password = StringUtil.getString(request.getString(KEY_LOGIN_PASSWORD));
- if (password.equals(StringUtil.getString(getLoginPassword(currentUserId))) == false) {
- throw new AccessException(TAG + "verify accessId = " + accessId
- + " >> currentUserId or loginPassword error"
- + " currentUserId = " + currentUserId + ", loginPassword = " + password);
- }
- case ACCESS_PAY:
- password = StringUtil.getString(request.getString(KEY_PAY_PASSWORD));
- if (password.equals(StringUtil.getString(getPayPassword(currentUserId))) == false) {
- throw new AccessException(TAG + "verify accessId = " + accessId
- + " >> currentUserId or payPassword error"
- + " currentUserId = " + currentUserId + ", payPassword = " + password);
- }
- default:
- return true;
- }
- }
-
- /**获取权限id
- * @param tableName
- * @return
- */
- public static int getAccessId(String tableName) {
- if (StringUtil.isNotEmpty(tableName, true) == false) {
- return -1;
- }
- // for (int i = 0; i < LOGIN_ACCESS_TABLE_NAMES.length; i++) {
- // if (tableName.equals(LOGIN_ACCESS_TABLE_NAMES[i])) {
- // return ACCESS_LOGIN;
- // }
- // }
- for (int i = 0; i < PAY_ACCESS_TABLE_NAMES.length; i++) {
- if (tableName.equals(PAY_ACCESS_TABLE_NAMES[i])) {
- return ACCESS_PAY;
- }
- }
- return -1;
- }
-
- /**获取登录密码
- * @param userId
- * @return
- */
- public static String getLoginPassword(long userId) {
- // TODO 查询并返回对应userId的登录密码
- return "123456";//仅测试用
- }
-
- /**获取支付密码
- * @param userId
- * @return
- */
- public static String getPayPassword(long userId) {
- // TODO 查询并返回对应userId的支付密码
- return "123456";//仅测试用
- }
-
- /**删除请求里的权限信息
- * @param requestObject
- * @return
- */
- public static JSONObject removeAccessInfo(JSONObject requestObject) {
- if (requestObject != null) {
- requestObject.remove(KEY_CURRENT_USER_ID);
- requestObject.remove(KEY_LOGIN_PASSWORD);
- requestObject.remove(KEY_PAY_PASSWORD);
- }
- return requestObject;
- }
-
-}
diff --git a/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/server/sql/QueryHelper.java b/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/server/sql/QueryHelper.java
deleted file mode 100755
index 198b61789..000000000
--- a/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/server/sql/QueryHelper.java
+++ /dev/null
@@ -1,154 +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.server.sql;
-
-import java.sql.*;
-import java.util.ArrayList;
-import java.util.List;
-
-import com.alibaba.fastjson.JSONObject;
-import zuo.biao.apijson.StringUtil;
-import zuo.biao.apijson.server.QueryConfig;
-
-/**helper for query MySQL database
- * @author Lemon
- */
-public class QueryHelper {
- private static final String TAG = "QueryHelper: ";
-
- private static final String YOUR_MYSQL_URL = "jdbc:mysql://localhost:3306/";//TODO edit to an available one
- private static final String YOUR_MYSQL_SCHEMA = "sys";//TODO edit to an available one
- private static final String YOUR_MYSQL_ACCOUNT = "root";//TODO edit to an available one
- private static final String YOUR_MYSQL_PASSWORD = "apijson";//TODO edit to an available one
-
- private QueryHelper() {
-
- }
-
- private static QueryHelper instance;
- public static synchronized QueryHelper getInstance() {
- if (instance == null) {
- instance = new QueryHelper();
- }
- return instance;
- }
-
- public Connection getConnection() throws Exception {
- //调用Class.forName()方法加载驱动程序
- Class.forName("com.mysql.jdbc.Driver");
- System.out.println(TAG + "成功加载MySQL驱动!");
- return DriverManager.getConnection(YOUR_MYSQL_URL + YOUR_MYSQL_SCHEMA, YOUR_MYSQL_ACCOUNT, YOUR_MYSQL_PASSWORD);
- }
-
-
- private static Connection connection;
- private static Statement statement;
- private static DatabaseMetaData metaData;
- public void close() {
- try {
- if (statement != null && statement.isClosed() == false) {
- statement.close();
- }
- if (connection != null && connection.isClosed() == false) {
- connection.close();
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }
- metaData = null;
- statement = null;
- }
-
- public JSONObject select(QueryConfig config) {
- if (config == null || StringUtil.isNotEmpty(config.getTable(), true) == false) {
- System.out.println(TAG + "select config==null||StringUtil.isNotEmpty(config.getTable(), true)==false>>return null;");
- return null;
- }
- final String sql = config.getSQL();
-
- try{
-
-
- System.out.println(TAG + "成功连接到数据库!");
-
- if (connection == null || connection.isClosed()) {
- System.out.println(TAG + "select connection " + (connection == null ? " = null" : ("isClosed = " + connection.isClosed()))) ;
- connection = getConnection();
- statement = connection.createStatement(); //创建Statement对象
- metaData = connection.getMetaData();
- }
-
- List list = getColumnList(config.getTable());
- if (list == null || list.isEmpty()) {
- return null;
- }
-
- System.out.println(TAG + "select sql = " + sql);
-
- ResultSet rs = statement.executeQuery(sql);//创建数据对象
-
- JSONObject object = null;//new JSONObject();//null;
- int position = -1;
- while (rs.next()){
- position ++;
- if (position != config.getPosition()) {
- continue;
- }
- object = new JSONObject(true);
- try {
- for (int i = 0; i < list.size(); i++) {
- object.put(list.get(i), rs.getObject(rs.findColumn(list.get(i))));
- }
- } catch (Exception e) {
- System.out.println(TAG + "select while (rs.next()){ ... >> try { object.put(list.get(i), ..." +
- " >> } catch (Exception e) {\n" + e.getMessage());
- e.printStackTrace();
- }
- break;
- }
-
- rs.close();
-
- return object;
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- return null;
- }
-
-
- /**获取全部字段名列表
- * @param table
- * @return
- */
- public List getColumnList(String table) {
- List list = new ArrayList();
- ResultSet rs;
- try {
- rs = metaData.getColumns(YOUR_MYSQL_SCHEMA, null, table, "%");
- while (rs.next()) {
- System.out.println(TAG + rs.getString(4));
- list.add(rs.getString(4));
- }
- rs.close();
- } catch (Exception e) {
- System.out.println(TAG + "getColumnList try { DatabaseMetaData meta = conn.getMetaData(); ... >> " +
- "} catch (Exception e) {\n" + e.getMessage());
- e.printStackTrace();
- }
- return list;
- }
-}
\ No newline at end of file
diff --git a/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/server/sql/QueryHelper2.java b/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/server/sql/QueryHelper2.java
deleted file mode 100755
index 18dad76d0..000000000
--- a/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/server/sql/QueryHelper2.java
+++ /dev/null
@@ -1,186 +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.server.sql;
-
-import java.sql.*;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import com.alibaba.fastjson.JSONObject;
-import zuo.biao.apijson.StringUtil;
-import zuo.biao.apijson.server.QueryConfig;
-
-/**helper for query MySQL database with cache
- * @author Lemon
- */
-public class QueryHelper2 {
- private static final String TAG = "QueryHelper2: ";
-
- private static final String YOUR_MYSQL_URL = "jdbc:mysql://localhost:3306/";//TODO edit to an available one
- private static final String YOUR_MYSQL_SCHEMA = "sys";//TODO edit to an available one
- private static final String YOUR_MYSQL_ACCOUNT = "root";//TODO edit to an available one
- private static final String YOUR_MYSQL_PASSWORD = "apijson";//TODO edit to an available one
-
- private Map> cacheMap;
- private QueryHelper2() {
-
- }
-
- private static QueryHelper2 instance;
- public static synchronized QueryHelper2 getInstance() {
- if (instance == null) {
- instance = new QueryHelper2();
- }
- return instance;
- }
-
- public Connection getConnection() throws Exception {
- //调用Class.forName()方法加载驱动程序
- Class.forName("com.mysql.jdbc.Driver");
- System.out.println(TAG + "成功加载MySQL驱动!");
- return DriverManager.getConnection(YOUR_MYSQL_URL + YOUR_MYSQL_SCHEMA, YOUR_MYSQL_ACCOUNT, YOUR_MYSQL_PASSWORD);
- }
-
- private void saveCache(String key, List list) {
- if (key == null) {
- System.out.println("saveList key == null >> return;");
- return;
- }
- cacheMap.put(key, list);
- }
- private void removeCache(String key) {
- if (key == null) {
- System.out.println("removeList key == null >> return;");
- return;
- }
- cacheMap.remove(key);
- }
-
- private JSONObject getFromCache(String key, int position) {
- List list = cacheMap.get(key);
- return list == null || position < 0 || position >= list.size() ? null : list.get(position);
- }
-
- private static Connection connection;
- private static Statement statement;
- private static DatabaseMetaData metaData;
- public void close() {
- try {
- statement.close();
- connection.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- metaData = null;
- statement = null;
- cacheMap = null;
- }
-
- public JSONObject select(QueryConfig config) {
- if (config == null || StringUtil.isNotEmpty(config.getTable(), true) == false) {
- System.out.println(TAG + "select config==null||StringUtil.isNotEmpty(config.getTable(), true)==false>>return null;");
- return null;
- }
- final String sql = config.getSQL();
- final int position = config.getPosition();
-
- if (cacheMap == null) {
- cacheMap = new HashMap>();
- }
- JSONObject object = getFromCache(sql, position);
- if (object != null) {
- return object;
- }
-
- try{
- if (connection == null || connection.isClosed()) {
- System.out.println(TAG + "select connection " + (connection == null ? " = null" : ("isClosed = " + connection.isClosed()))) ;
- connection = getConnection();
- statement = connection.createStatement(); //创建Statement对象
- metaData = connection.getMetaData();
- }
- List list = getColumnList(config.getTable(), metaData);
- if (list == null || list.isEmpty()) {
- return null;
- }
-
-
- System.out.println(TAG + "select sql = " + sql);
-
- ResultSet rs = statement.executeQuery(sql);//创建数据对象
-
- List resultList = new ArrayList();
- while (rs.next()){
- object = new JSONObject(true);
- try {
- for (int i = 0; i < list.size(); i++) {
- object.put(list.get(i), rs.getObject(rs.findColumn(list.get(i))));
- }
- } catch (Exception e) {
- System.out.println(TAG + "select while (rs.next()){ ... >> try { object.put(list.get(i), ..." +
- " >> } catch (Exception e) {\n" + e.getMessage());
- e.printStackTrace();
- object = null;
- }
- resultList.add(object);
- }
- rs.close();
-
- //从缓存存取,避免 too many connections崩溃
- if (position < config.getLimit() - 1) {
- System.out.println("select position < config.getLimit() - 1 >> saveCache(sql, resultList);");
- saveCache(sql, resultList);
- } else {
- System.out.println("select position >= config.getLimit() - 1 >> removeCache(sql); return object;");
- removeCache(sql);
- return object;
- }
-
- System.out.println("select return position < 0 || position >= resultList.size() ? null : resultList.get(position); ");
- return position < 0 || position >= resultList.size() ? null : resultList.get(position);
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- return null;
- }
-
-
-
- /**获取全部字段名列表
- * @param table
- * @param meta
- * @return
- */
- public List getColumnList(String table, DatabaseMetaData meta) {
- List list = new ArrayList();
- ResultSet rs;
- try {
- rs = meta.getColumns(YOUR_MYSQL_SCHEMA, null, table, "%");
- while (rs.next()) {
- System.out.println(TAG + rs.getString(4));
- list.add(rs.getString(4));
- }
- rs.close();
- } catch (Exception e) {
- System.out.println(TAG + "getColumnList try { DatabaseMetaData meta = conn.getMetaData(); ... >> " +
- "} catch (Exception e) {\n" + e.getMessage());
- e.printStackTrace();
- }
- return list;
- }
-}
\ No newline at end of file
diff --git a/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/server/sql/package-info.java b/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/server/sql/package-info.java
deleted file mode 100755
index 1194f44e3..000000000
--- a/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/server/sql/package-info.java
+++ /dev/null
@@ -1,22 +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.*/
-
-/**
- * query files package
- */
-/**
- * @author Lemon
- *
- */
-package zuo.biao.apijson.server.sql;
\ No newline at end of file
diff --git a/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/test/java/zuo/biao/apijson/server/ApplicationTests.java b/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/test/java/zuo/biao/apijson/server/ApplicationTests.java
deleted file mode 100755
index 54df56813..000000000
--- a/APIJSON(Server)/APIJSON(Eclipse_JEE)/src/test/java/zuo/biao/apijson/server/ApplicationTests.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package zuo.biao.apijson.server;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-@RunWith(SpringRunner.class)
-@SpringBootTest
-public class ApplicationTests {
-
- @Test
- public void contextLoads() {
- }
-
-}
diff --git a/APIJSON(Server)/APIJSON(Idea)/.gitignore b/APIJSON(Server)/APIJSON(Idea)/.gitignore
deleted file mode 100755
index 2af7cefb0..000000000
--- a/APIJSON(Server)/APIJSON(Idea)/.gitignore
+++ /dev/null
@@ -1,24 +0,0 @@
-target/
-!.mvn/wrapper/maven-wrapper.jar
-
-### STS ###
-.apt_generated
-.classpath
-.factorypath
-.project
-.settings
-.springBeans
-
-### IntelliJ IDEA ###
-.idea
-*.iws
-*.iml
-*.ipr
-
-### NetBeans ###
-nbproject/private/
-build/
-nbbuild/
-dist/
-nbdist/
-.nb-gradle/
\ No newline at end of file
diff --git a/APIJSON(Server)/APIJSON(Idea)/.mvn/wrapper/maven-wrapper.jar b/APIJSON(Server)/APIJSON(Idea)/.mvn/wrapper/maven-wrapper.jar
deleted file mode 100755
index 5fd4d5023..000000000
Binary files a/APIJSON(Server)/APIJSON(Idea)/.mvn/wrapper/maven-wrapper.jar and /dev/null differ
diff --git a/APIJSON(Server)/APIJSON(Idea)/.mvn/wrapper/maven-wrapper.properties b/APIJSON(Server)/APIJSON(Idea)/.mvn/wrapper/maven-wrapper.properties
deleted file mode 100755
index c954cec91..000000000
--- a/APIJSON(Server)/APIJSON(Idea)/.mvn/wrapper/maven-wrapper.properties
+++ /dev/null
@@ -1 +0,0 @@
-distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip
diff --git a/APIJSON(Server)/APIJSON(Idea)/.travis.yml b/APIJSON(Server)/APIJSON(Idea)/.travis.yml
deleted file mode 100644
index d036b68c1..000000000
--- a/APIJSON(Server)/APIJSON(Idea)/.travis.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-language: java
-sudo: false
-jdk:
- - oraclejdk7
\ No newline at end of file
diff --git a/APIJSON(Server)/APIJSON(Idea)/mvnw b/APIJSON(Server)/APIJSON(Idea)/mvnw
deleted file mode 100755
index a1ba1bf55..000000000
--- a/APIJSON(Server)/APIJSON(Idea)/mvnw
+++ /dev/null
@@ -1,233 +0,0 @@
-#!/bin/sh
-# ----------------------------------------------------------------------------
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you 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.
-# ----------------------------------------------------------------------------
-
-# ----------------------------------------------------------------------------
-# Maven2 Start Up Batch script
-#
-# Required ENV vars:
-# ------------------
-# JAVA_HOME - location of a JDK home dir
-#
-# Optional ENV vars
-# -----------------
-# M2_HOME - location of maven2's installed home dir
-# MAVEN_OPTS - parameters passed to the Java VM when running Maven
-# e.g. to debug Maven itself, use
-# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
-# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
-# ----------------------------------------------------------------------------
-
-if [ -z "$MAVEN_SKIP_RC" ] ; then
-
- if [ -f /etc/mavenrc ] ; then
- . /etc/mavenrc
- fi
-
- if [ -f "$HOME/.mavenrc" ] ; then
- . "$HOME/.mavenrc"
- fi
-
-fi
-
-# OS specific support. $var _must_ be set to either true or false.
-cygwin=false;
-darwin=false;
-mingw=false
-case "`uname`" in
- CYGWIN*) cygwin=true ;;
- MINGW*) mingw=true;;
- Darwin*) darwin=true
- #
- # Look for the Apple JDKs first to preserve the existing behaviour, and then look
- # for the new JDKs provided by Oracle.
- #
- if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then
- #
- # Apple JDKs
- #
- export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
- fi
-
- if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then
- #
- # Apple JDKs
- #
- export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
- fi
-
- if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then
- #
- # Oracle JDKs
- #
- export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
- fi
-
- if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then
- #
- # Apple JDKs
- #
- export JAVA_HOME=`/usr/libexec/java_home`
- fi
- ;;
-esac
-
-if [ -z "$JAVA_HOME" ] ; then
- if [ -r /etc/gentoo-release ] ; then
- JAVA_HOME=`java-config --jre-home`
- fi
-fi
-
-if [ -z "$M2_HOME" ] ; then
- ## resolve links - $0 may be a link to maven's home
- PRG="$0"
-
- # need this for relative symlinks
- while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG="`dirname "$PRG"`/$link"
- fi
- done
-
- saveddir=`pwd`
-
- M2_HOME=`dirname "$PRG"`/..
-
- # make it fully qualified
- M2_HOME=`cd "$M2_HOME" && pwd`
-
- cd "$saveddir"
- # echo Using m2 at $M2_HOME
-fi
-
-# For Cygwin, ensure paths are in UNIX format before anything is touched
-if $cygwin ; then
- [ -n "$M2_HOME" ] &&
- M2_HOME=`cygpath --unix "$M2_HOME"`
- [ -n "$JAVA_HOME" ] &&
- JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
- [ -n "$CLASSPATH" ] &&
- CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
-fi
-
-# For Migwn, ensure paths are in UNIX format before anything is touched
-if $mingw ; then
- [ -n "$M2_HOME" ] &&
- M2_HOME="`(cd "$M2_HOME"; pwd)`"
- [ -n "$JAVA_HOME" ] &&
- JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
- # TODO classpath?
-fi
-
-if [ -z "$JAVA_HOME" ]; then
- javaExecutable="`which javac`"
- if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
- # readlink(1) is not available as standard on Solaris 10.
- readLink=`which readlink`
- if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
- if $darwin ; then
- javaHome="`dirname \"$javaExecutable\"`"
- javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
- else
- javaExecutable="`readlink -f \"$javaExecutable\"`"
- fi
- javaHome="`dirname \"$javaExecutable\"`"
- javaHome=`expr "$javaHome" : '\(.*\)/bin'`
- JAVA_HOME="$javaHome"
- export JAVA_HOME
- fi
- fi
-fi
-
-if [ -z "$JAVACMD" ] ; then
- if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- else
- JAVACMD="`which java`"
- fi
-fi
-
-if [ ! -x "$JAVACMD" ] ; then
- echo "Error: JAVA_HOME is not defined correctly." >&2
- echo " We cannot execute $JAVACMD" >&2
- exit 1
-fi
-
-if [ -z "$JAVA_HOME" ] ; then
- echo "Warning: JAVA_HOME environment variable is not set."
-fi
-
-CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin; then
- [ -n "$M2_HOME" ] &&
- M2_HOME=`cygpath --path --windows "$M2_HOME"`
- [ -n "$JAVA_HOME" ] &&
- JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
- [ -n "$CLASSPATH" ] &&
- CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
-fi
-
-# traverses directory structure from process work directory to filesystem root
-# first directory with .mvn subdirectory is considered project base directory
-find_maven_basedir() {
- local basedir=$(pwd)
- local wdir=$(pwd)
- while [ "$wdir" != '/' ] ; do
- if [ -d "$wdir"/.mvn ] ; then
- basedir=$wdir
- break
- fi
- wdir=$(cd "$wdir/.."; pwd)
- done
- echo "${basedir}"
-}
-
-# concatenates all lines of a file
-concat_lines() {
- if [ -f "$1" ]; then
- echo "$(tr -s '\n' ' ' < "$1")"
- fi
-}
-
-export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)}
-MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
-
-# Provide a "standardized" way to retrieve the CLI args that will
-# work with both Windows and non-Windows executions.
-MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
-export MAVEN_CMD_LINE_ARGS
-
-WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
-
-exec "$JAVACMD" \
- $MAVEN_OPTS \
- -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
- "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
- ${WRAPPER_LAUNCHER} "$@"
diff --git a/APIJSON(Server)/APIJSON(Idea)/mvnw.cmd b/APIJSON(Server)/APIJSON(Idea)/mvnw.cmd
deleted file mode 100755
index 2b934e89d..000000000
--- a/APIJSON(Server)/APIJSON(Idea)/mvnw.cmd
+++ /dev/null
@@ -1,145 +0,0 @@
-@REM ----------------------------------------------------------------------------
-@REM Licensed to the Apache Software Foundation (ASF) under one
-@REM or more contributor license agreements. See the NOTICE file
-@REM distributed with this work for additional information
-@REM regarding copyright ownership. The ASF licenses this file
-@REM to you under the Apache License, Version 2.0 (the
-@REM "License"); you may not use this file except in compliance
-@REM with the License. You may obtain a copy of the License at
-@REM
-@REM http://www.apache.org/licenses/LICENSE-2.0
-@REM
-@REM Unless required by applicable law or agreed to in writing,
-@REM software distributed under the License is distributed on an
-@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-@REM KIND, either express or implied. See the License for the
-@REM specific language governing permissions and limitations
-@REM under the License.
-@REM ----------------------------------------------------------------------------
-
-@REM ----------------------------------------------------------------------------
-@REM Maven2 Start Up Batch script
-@REM
-@REM Required ENV vars:
-@REM JAVA_HOME - location of a JDK home dir
-@REM
-@REM Optional ENV vars
-@REM M2_HOME - location of maven2's installed home dir
-@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
-@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
-@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
-@REM e.g. to debug Maven itself, use
-@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
-@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
-@REM ----------------------------------------------------------------------------
-
-@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
-@echo off
-@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
-@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
-
-@REM set %HOME% to equivalent of $HOME
-if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
-
-@REM Execute a user defined script before this one
-if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
-@REM check for pre script, once with legacy .bat ending and once with .cmd ending
-if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
-if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
-:skipRcPre
-
-@setlocal
-
-set ERROR_CODE=0
-
-@REM To isolate internal variables from possible post scripts, we use another setlocal
-@setlocal
-
-@REM ==== START VALIDATION ====
-if not "%JAVA_HOME%" == "" goto OkJHome
-
-echo.
-echo Error: JAVA_HOME not found in your environment. >&2
-echo Please set the JAVA_HOME variable in your environment to match the >&2
-echo location of your Java installation. >&2
-echo.
-goto error
-
-:OkJHome
-if exist "%JAVA_HOME%\bin\java.exe" goto init
-
-echo.
-echo Error: JAVA_HOME is set to an invalid directory. >&2
-echo JAVA_HOME = "%JAVA_HOME%" >&2
-echo Please set the JAVA_HOME variable in your environment to match the >&2
-echo location of your Java installation. >&2
-echo.
-goto error
-
-@REM ==== END VALIDATION ====
-
-:init
-
-set MAVEN_CMD_LINE_ARGS=%*
-
-@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
-@REM Fallback to current working directory if not found.
-
-set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
-IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
-
-set EXEC_DIR=%CD%
-set WDIR=%EXEC_DIR%
-:findBaseDir
-IF EXIST "%WDIR%"\.mvn goto baseDirFound
-cd ..
-IF "%WDIR%"=="%CD%" goto baseDirNotFound
-set WDIR=%CD%
-goto findBaseDir
-
-:baseDirFound
-set MAVEN_PROJECTBASEDIR=%WDIR%
-cd "%EXEC_DIR%"
-goto endDetectBaseDir
-
-:baseDirNotFound
-set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
-cd "%EXEC_DIR%"
-
-:endDetectBaseDir
-
-IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
-
-@setlocal EnableExtensions EnableDelayedExpansion
-for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
-@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
-
-:endReadAdditionalConfig
-
-SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
-
-set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar""
-set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
-
-%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS%
-if ERRORLEVEL 1 goto error
-goto end
-
-:error
-set ERROR_CODE=1
-
-:end
-@endlocal & set ERROR_CODE=%ERROR_CODE%
-
-if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
-@REM check for post script, once with legacy .bat ending and once with .cmd ending
-if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
-if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
-:skipRcPost
-
-@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
-if "%MAVEN_BATCH_PAUSE%" == "on" pause
-
-if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
-
-exit /B %ERROR_CODE%
\ No newline at end of file
diff --git a/APIJSON(Server)/APIJSON(Idea)/pom.xml b/APIJSON(Server)/APIJSON(Idea)/pom.xml
deleted file mode 100755
index 3e26692f0..000000000
--- a/APIJSON(Server)/APIJSON(Idea)/pom.xml
+++ /dev/null
@@ -1,89 +0,0 @@
-
-
- 4.0.0
-
- zuo.biao.apijson.server
- apijson
- 0.0.1-SNAPSHOT
- jar
-
- APIJSON(Idea)
- APIJSON Server project using Spring Boot
-
-
- org.springframework.boot
- spring-boot-starter-parent
- 1.4.1.RELEASE
-
-
-
-
- UTF-8
- UTF-8
- 1.7
-
-
-
-
- mysql
- mysql-connector-java
- 5.1.40
-
-
-
- org.springframework.boot
- spring-boot-starter
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
-
- com.alibaba
- fastjson
- 1.2.21
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
-
-
-
-
-
-
- spring-snapshots
- http://repo.spring.io/snapshot
- true
-
-
- spring-milestones
- http://repo.spring.io/milestone
- true
-
-
-
-
- spring-snapshots
- http://repo.spring.io/snapshot
-
-
- spring-milestones
- http://repo.spring.io/milestone
-
-
-
-
diff --git a/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/JSON.java b/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/JSON.java
deleted file mode 100755
index 7fc6940b3..000000000
--- a/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/JSON.java
+++ /dev/null
@@ -1,118 +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 com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.alibaba.fastjson.parser.Feature;
-import com.alibaba.fastjson.serializer.SerializerFeature;
-
-import java.util.List;
-
-/**阿里json封装类 防止解析时异常
- * @author Lemon
- */
-public class JSON {
- private static final String TAG = "JSON";
-
- /**判断json格式是否正确
- * @param s
- * @return
- */
- public static boolean isJsonCorrect(String s) {
- System.out.println(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) {
- s = StringUtil.getNoBlankString(s);
- return isJsonCorrect(s) ? s : "";
- }
-
- /**json转JSONObject
- * @param json
- * @return
- */
- public static JSONObject parseObject(String json) {
- try {
- int features = com.alibaba.fastjson.JSON.DEFAULT_PARSER_FEATURE;
- features |= Feature.SortFeidFastMatch.getMask();
- return com.alibaba.fastjson.JSON.parseObject(getCorrectJson(json), JSONObject.class, features);
- } catch (Exception e) {
- System.out.println(TAG + "parseObject catch \n" + e.getMessage());
- }
- return null;
- }
-
- /**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.SortFeidFastMatch.getMask();
- return com.alibaba.fastjson.JSON.parseObject(getCorrectJson(json), clazz, features);
- } catch (Exception e) {
- System.out.println(TAG + "parseObject catch \n" + e.getMessage());
- }
- return null;
- }
-
- /**json转JSONArray
- * @param json
- * @return
- */
- public static JSONArray parseArray(String json) {
- return com.alibaba.fastjson.JSON.parseArray(json);
- }
- /**json转实体类列表
- * @param json
- * @param clazz
- * @return
- */
- public static List parseArray(String json, Class clazz) {
- try {
- return com.alibaba.fastjson.JSON.parseArray(getCorrectJson(json), clazz);
- } catch (Exception e) {
- System.out.println(TAG + "parseArray catch \n" + e.getMessage());
- }
- return null;
- }
-
- /**实体类转json
- * @param obj
- * @return
- */
- public static String toJSONString(Object obj) {
- try {
- return com.alibaba.fastjson.JSON.toJSONString(obj, SerializerFeature.SortField);
- } catch (Exception e) {
- System.out.println(TAG + "toJSONString catch \n" + e.getMessage());
- }
- return null;
- }
-
-
-}
diff --git a/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/StringUtil.java b/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/StringUtil.java
deleted file mode 100755
index 9789bee74..000000000
--- a/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/StringUtil.java
+++ /dev/null
@@ -1,601 +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 {
-
- 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时返回"" >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
- //获取去掉前后空格后的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 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) {
- // Log.i(TAG, "getTrimedString s = " + s);
- if (s == null) {
- return false;
- }
- if (trim) {
- s = s.trim();
- }
- if (s.length() <= 0) {
- return false;
- }
-
- currentString = s;
-
- return true;
- }
-
- //判断字符是否非空 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
- //判断字符类型 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
- //判断手机格式是否正确
- 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) {
- System.out.println("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) {
- System.out.println("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 = "/";
- public static boolean isPath(String path) {
- return StringUtil.isNotEmpty(path, true) && path.contains(SEPARATOR)
- && path.contains(SEPARATOR + SEPARATOR) == false && path.endsWith(SEPARATOR) == false;
- }
-
- public static String[] splitPath(String path) {
- path = getString(path);
- if(path.startsWith("/")){
- path = path.substring(1);
- }
- if(path.endsWith("/")){
- path = path.substring(0, path.length() - 1);
- }
- return isPath(path) ? path.split(SEPARATOR) : new String[] {path};
- }
-
-
- /**判断字符类型是否是路径
- * @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) {
- System.out.println("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? >>>>>>>>>>>>>>>>>>>>>>
-
- System.out.println("getPrice <<<<<<<<<<<<<<<<<< correctPrice = " + correctPrice);
- if (correctPrice.contains(".")) {
- // if (correctPrice.startsWith(".")) {
- // correctPrice = 0 + correctPrice;
- // }
- if (correctPrice.endsWith(".")) {
- correctPrice = correctPrice.replaceAll(".", "");
- }
- }
-
- System.out.println("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;
- }
- }
-
-
- //校正(自动补全等)字符串>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-}
diff --git a/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/package-info.java b/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/package-info.java
deleted file mode 100755
index f0e0bfb5a..000000000
--- a/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/package-info.java
+++ /dev/null
@@ -1,22 +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.*/
-
-/**
- * common files package between Server and Client projects
- */
-/**
- * @author Lemon
- *
- */
-package zuo.biao.apijson;
\ No newline at end of file
diff --git a/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/server/APIJSONApplication.java b/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/server/APIJSONApplication.java
deleted file mode 100755
index 009bad2e3..000000000
--- a/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/server/APIJSONApplication.java
+++ /dev/null
@@ -1,29 +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.server;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-
-/**application
- * @author Lemon
- */
-@SpringBootApplication
-public class APIJSONApplication {
-
- public static void main(String[] args) {
- SpringApplication.run(APIJSONApplication.class, args);
- }
-}
diff --git a/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/server/ClientTest.java b/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/server/ClientTest.java
deleted file mode 100755
index 68bce1d88..000000000
--- a/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/server/ClientTest.java
+++ /dev/null
@@ -1,80 +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.server;
-
-/**mock test of client
- * @author Lemon
- */
-public class ClientTest {
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- // new RequestParser().get(\"{User\\":{\\"id\\":1}}\");
- //
- // new RequestParser().get(\"{[User]\\":{ \\"range\\":1, \\"pageNum\\":1, \\"pageSize\\":10, \\"sortOrder\\":\\"id\\", \\"sortDirection\\":\\"increase\\",}}\");
- //
- // new RequestParser().get(\"{\\"[User, Work, [picture]]\\": { \\"=\\": { \\"User\\": id, \\"Work\\": \\"userId\\", \\"picture\\": \\"userId\\"}\\"pageNum\\": 1, \\"pageSize\\": 10, \\"sortOrder\\": \\"id\\", \\"sortDirection\\": \\"increase\\", \\"User\\": { \\"sex\\":SEX_FEMAIL, } \\"picture\\":{ \\"pageNum\\":1, \\"pageSize\\": 3, }}\");
-
-
-// //已经过bejson校验和传输校验
-// new RequestParser().parse("{" +
-//// "\"[]\": {" +
-//// "\"page\": 1, " +
-//// "\"count\": 5," +
-// " \"User\": {" +
-// "\"id\": 38710," +//70793
-//// "\"range\": 1," +
-//// "\"sex\": 0" +
-// "}," +
-// "\"Work\": {" +
-// "\"userId\": \"User/id\"" +
-// "}," +
-// "\"Comment[]\": {" +
-// "\"page\": 0," +
-// "\"count\": 3," +
-// " \"Comment\": {" +
-// "\"workId\": \"Work/id\"" +
-// "}," +
-// "}" +
-//// "}" +
-// "}");
-
- //已经过bejson校验和传输校验
- new RequestParser().parse("{" +
- "\"[]\": {" +
- "\"page\": 1, " +
- "\"count\": 10," +
- " \"User\": {" +
- "\"sex\": 0" +
- "}," +
- "\"Work\": {" +
- "\"userId\": \"/User/id\"" +
- "}," +
- "\"Comment[]\": {" +
- "\"page\": 0," +
- "\"count\": 3," +
- " \"Comment\": {" +
- "\"workId\": \"[]/Work/id\"" +
- "}," +
- "}" +
- "}" +
- "}");
-
-
- }
-
-}
diff --git a/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/server/Controller.java b/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/server/Controller.java
deleted file mode 100755
index 52d8c45c9..000000000
--- a/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/server/Controller.java
+++ /dev/null
@@ -1,50 +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.server;
-
-import com.alibaba.fastjson.JSONObject;
-import org.springframework.web.bind.annotation.*;
-import zuo.biao.apijson.JSON;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-
-import static zuo.biao.apijson.StringUtil.UTF_8;
-
-/**request receiver and controller
- * @author Lemon
- */
-@RestController
-@RequestMapping("")
-public class Controller {
-
- @RequestMapping("get/{request}")
- public String get(@PathVariable String request) {
- System.out.println("request = " + request);
- JSONObject object = new RequestParser().parse(request);
- System.out.println("return " + JSON.toJSONString(object));
- return JSON.toJSONString(object);
- }
-
-// @RequestMapping(value="/request",produces="application/json")
-// public String get2(@RequestBody JSONObject request){
-// return JSON.toJSONString(request);
-// }
-// @RequestMapping(method = RequestMethod.GET)
-// public String create(@RequestBody @Valid JSONObject request) {
-// return JSON.toJSONString(request);
-// }
-
-}
diff --git a/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/server/QueryConfig.java b/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/server/QueryConfig.java
deleted file mode 100755
index ae9ad4274..000000000
--- a/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/server/QueryConfig.java
+++ /dev/null
@@ -1,190 +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.server;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-
-import com.alibaba.fastjson.JSONObject;
-import zuo.biao.apijson.JSON;
-
-/**config model for query
- * @author Lemon
- */
-public class QueryConfig {
-
- private String table;
- private String[] columns;
- private String[][] values;
- private Map where;
- private int limit;
- private int page;
- private int position;
-
- public QueryConfig() {
- }
- public QueryConfig(String table) {
- this();
- setTable(table);
- }
- public QueryConfig(String table, Map where) {
- this(table);
- setWhere(where);
- }
- public QueryConfig(String table, String[] columns, String[][] values) {
- this(table);
- setColumns(columns);
- setValues(values);
- }
- public QueryConfig(int limit, int page) {
- this();
- setLimit(limit);
- setPage(page);
- }
-
-
- public String getTable() {
- return table;
- }
- public QueryConfig setTable(String table) {
- this.table = table;
- return this;
- }
- public String[] getColumns() {
- return columns;
- }
- public QueryConfig setColumns(String[] columns) {
- this.columns = columns;
- return this;
- }
- public String[][] getValues() {
- return values;
- }
- public QueryConfig setValues(String[][] values) {
- this.values = values;
- return this;
- }
- public Map getWhere() {
- return where;
- }
- public QueryConfig setWhere(Map where) {
- this.where = where;
- return this;
- }
- public int getLimit() {
- return limit;
- }
- public QueryConfig setLimit(int limit) {
- this.limit = limit;
- return this;
- }
- public int getPage() {
- return page;
- }
- public QueryConfig setPage(int page) {
- this.page = page;
- return this;
- }
- public int getPosition() {
- return position;
- }
- public QueryConfig setPosition(int position) {
- this.position = position;
- return this;
- }
-
- /**获取限制数量
- * @return
- */
- public String getLimitString() {
- return getLimitString(limit);// + 1);
- }
- /**获取限制数量
- * @param limit
- * @return
- */
- public static String getLimitString(int limit) {
- return limit <= 0 ? "" : " limit " + limit;
- }
-
- /**获取筛选方法
- * @return
- */
- public String getWhereString() {
- return getWhereString(where);
- }
- /**获取筛选方法
- * @param where
- * @return
- */
- public static String getWhereString(Map where) {
- Set set = where == null ? null : where.keySet();
- if (set != null && set.size() > 0) {
- String whereString = " where ";
- Object value;
- for (String key : set) {
- //避免筛选到全部 value = key == null ? null : where.get(key);
- if (key == null) {
- continue;
- }
- whereString += (key + "=" + where.get(key) + " &");
- }
- if (whereString.endsWith("&")) {
- whereString = whereString.substring(0, whereString.length() - 1);
- }
- if (whereString.trim().endsWith("where") == false) {
- return whereString;
- }
- }
- return "";
- }
-
-
- /**获取查询配置
- * @param table
- * @param request
- * @return
- */
- public static synchronized QueryConfig getQueryConfig(String table, JSONObject request) {
- Set set = request == null ? null : request.keySet();
- Map transferredRequest = null;
- if (set != null) {
- transferredRequest = new HashMap();
- for (String key : set) {
- if (JSON.parseObject(request.getString(key)) == null) {//非key-value
- transferredRequest.put(key, request.get(key));
- }
- }
- }
- return new QueryConfig(table).setWhere(transferredRequest);
- }
-
- /**
- * @return
- */
- public String getSQL() {
- return getSQL(this);
- }
- /**
- * @param config
- * @return
- */
- public static String getSQL(QueryConfig config) {
- return config == null ? null : "select * from " + config.getTable() + config.getWhereString() + config.getLimitString();
- }
-
-}
diff --git a/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/server/RequestParser.java b/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/server/RequestParser.java
deleted file mode 100755
index c4214d0d3..000000000
--- a/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/server/RequestParser.java
+++ /dev/null
@@ -1,458 +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.server;
-import static zuo.biao.apijson.StringUtil.UTF_8;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import java.rmi.AccessException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import com.alibaba.fastjson.JSONObject;
-
-import zuo.biao.apijson.JSON;
-import zuo.biao.apijson.StringUtil;
-import zuo.biao.apijson.server.sql.AccessVerifier;
-import zuo.biao.apijson.server.sql.QueryHelper;
-
-/**parser for parsing request to JSONObject
- * @author Lemon
- */
-public class RequestParser {
- private static final String TAG = "RequestParser: ";
-
- public static final String SEPARATOR = StringUtil.SEPARATOR;
-
-
- private JSONObject requestObject;
-
- private boolean parseRelation;
- private Map relationMap;
-
-
- /**
- * @param json
- */
- public JSONObject parse(String json) {
- try {
- json = URLDecoder.decode(json, UTF_8);
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- System.out.println(TAG + "get json = " + json);
-
- relationMap = new HashMap();
- parseRelation = false;
- requestObject = JSON.parseObject(json);
- requestObject = getObject(null, null, null, requestObject);
- parseRelation = true;
- requestObject = getObject(null, null, null, requestObject);
-
- requestObject = AccessVerifier.removeAccessInfo(requestObject);
-
- /**
- * TODO 格式化json,去除标记array内object位置的数字,转为[]形式,比如
- * "Comment[]":{"0":{"Comment":{...}}, ...}
- * 转为
- * "Comment[]":[{...}, ...]
- */
-
- QueryHelper.getInstance().close();
-// QueryHelper2.getInstance().close();
-
- System.out.println(TAG + "\n\n最终返回至客户端的json:\n" + JSON.toJSONString(requestObject));
- return requestObject;
- }
-
-
- /**获取单个对象,该对象处于parentObject内
- * @param parentPath parentObject的路径
- * @param parentConfig
- * @param name parentObject的key
- * @param request parentObject的value
- * @return
- */
- private JSONObject getObject(String parentPath, final QueryConfig parentConfig, String name, final JSONObject request) {
- System.out.println(TAG + "\ngetObject: parentPath = " + parentPath
- + ";\n name = " + name + "; request = " + JSON.toJSONString(request));
- if (request == null) {//key-value条件
- return null;
- }
- String path = getPath(parentPath, name);
-
- QueryConfig config = StringUtil.isNumer(name) ? parentConfig : null;
- if (config == null) {
- config = new QueryConfig(name);
- }
- boolean nameIsNumber = StringUtil.isNumer(name);
- final int position = nameIsNumber ? Integer.valueOf(0 + StringUtil.getNumber(name)) : 0;
-
- boolean containRelation = false;
-
- Set set = request.keySet();
- JSONObject transferredRequest = new JSONObject(true);
- if (set != null) {
- String value;
- JSONObject child;
- JSONObject result;
- boolean isFirst = true;
- for (String key : set) {
- value = transferredRequest.containsKey(key) ? transferredRequest.getString(key) : request.getString(key);
- child = JSON.parseObject(value);
- if (child == null) {//key - value
- transferredRequest.put(key, value);
- if (StringUtil.isPath(value)) {
- System.out.println("getObject StringUtil.isPath(value) >> parseRelation = " + parseRelation);
- if (parseRelation) {
- transferredRequest.put(key, getValueByPath(relationMap.get(getPath(path, key))));
- // relationMap.remove(path + SEPARATOR + key);
- } else {
- containRelation = true;
- relationMap.put(getPath(path, key)//value.contains(parentPath)会因为结构变化而改变
- , getPath((value.startsWith(SEPARATOR) ? parentPath : ""), value));
- }
- }
- } else {
- config.setPosition(isFirst && nameIsNumber ? position : 0);
- if (isArrayKey(key)) {//json array
- result = getArray(path, config, key, child);
- } else {//json object
- isFirst = false;
- result = getObject(path, config, key, child);
- }
- System.out.println(TAG + "getObject key = " + key + "; result = " + result);
- if (result != null && result.isEmpty() == false) {//只添加!=null的值,可能数据库返回数据不够count
- transferredRequest.put(key, result);
- }
- }
- }
- }
-
- if (containRelation == false && isObjectKey(name)) {
- if (parseRelation == false || isInRelationMap(path)) {//避免覆盖原来已经获取的
- // relationMap.remove(path);
- QueryConfig config2 = getQueryConfig(name, transferredRequest);
- if (parentConfig != null) {
- config2.setLimit(parentConfig.getLimit()).setPage(parentConfig.getPage())
- .setPosition(parentConfig.getPosition());//避免position > 0的object获取不到
- }
- JSONObject result = null;
- try {
- result = getSQLObject(config2);
- } catch (AccessException e) {
-// e.printStackTrace();
- result = new JSONObject(true);
- result.put("status", 403);
- result.put("message", e.getMessage());
- }
- // if (result != null) {
- transferredRequest = result;
- if (parseRelation) {
- putValueByPath(path, transferredRequest);//解决获取关联数据时requestObject里不存在需要的关联数据
- }
- // }
- }
- }
-
- return transferredRequest;
- }
-
-
-
- //TODO 如果获取key顺序不能保证就用一个"readOrder":{"user", "work", ...}确定顺序
- /**获取对象数组,该对象数组处于parentObject内
- * @param parentPath parentObject的路径
- * @param parentConfig parentObject对子object的SQL查询配置
- * @param name parentObject的key
- * @param request parentObject的value
- * @return
- */
- private JSONObject getArray(String parentPath, QueryConfig parentConfig, String name, final JSONObject request) {
- System.out.println(TAG + "\n\n\n getArray parentPath = " + parentPath
- + "; name = " + name + "; request = " + JSON.toJSONString(request));
- if (request == null) {//jsonKey-jsonValue条件
- return null;
- }
- String path = getPath(parentPath, name);
-
- int page = 0, count = 0;
- try {
- page = request.getIntValue("page");
- count = request.getIntValue("count");
- } catch (Exception e) {
- // System.out.println(TAG + "getArray try { page = arrayObject.getIntValue(page); ..." +
- // " >> } catch (Exception e) {\n" + e.getMessage());
- }
- if (parseRelation) {
- request.remove("page");
- request.remove("count");
- }
- System.out.println(TAG + "getArray page = " + page + "; count = " + count);
-
- QueryConfig config = new QueryConfig(count, page);
-
- Set set = request.keySet();
- JSONObject transferredRequest = new JSONObject(true);
- if (set != null) {
- JSONObject parent = null;
- String value;
- JSONObject child;
- JSONObject result;
- if (parseRelation == false) {
- //生成count个
- for (int i = 0; i < count; i++) {
- parent = new JSONObject(true);
- for (String key : set) {
- value = request.getString(key);
- child = JSON.parseObject(value);
- if (child == null) {//key - value
- //array里不允许关联,只能在object中关联
- transferredRequest.put(key, value);
- } else {
- config.setPosition(i);
- if (isArrayKey(key)) {//json array
- result = getArray(getPath(path, "" + i), config, key, child);
- } else {//json object
- result = getObject(getPath(path, "" + i), config, key, child);
- }
- System.out.println(TAG + "getArray parseRelation == false >> i = " + i + "result = " + result);
- if (result != null && result.isEmpty() == false) {//只添加!=null的值,可能数据库返回数据不够count
- parent.put(key, result);
-
- //更新关系path中对应改变字段
- Set relationSet = relationMap == null ? null : relationMap.keySet();
- if (relationSet != null) {
- String relationValue;
- String replacePath = getPath(path, "" + i);
- for (String relationKey : relationSet) {
- if (relationKey == null || relationKey.startsWith(replacePath) == false) {
- continue;
- }
- relationValue = relationMap.get(relationKey);
- if (relationValue != null && relationValue.startsWith(path)
- && relationValue.startsWith(replacePath) == false) {
- relationMap.put(relationKey, relationValue.replace(path, replacePath));
- }
- }
- }
- }
- }
- }
- if (parent.isEmpty() == false) {//可能数据库返回数据不够count
- transferredRequest.put("" + i, parent);
- }
- }
- } else {
- for (String key : set) {
- child = JSON.parseObject(request.getString(key));
- if (child == null) {//key - value
- //array里不允许关联,只能在object中关联
- } else {
- config.setPosition(Integer.valueOf(0 + StringUtil.getNumber(key, true)));
- if (isArrayKey(key)) {//json array
- result = getArray(path, config, key, child);
- } else {//json object
- result = getObject(path, config, key, child);
- }
- if (result != null && result.isEmpty() == false) {//只添加!=null的值,可能数据库返回数据不够count
- transferredRequest.put(key, result);
- }
- }
- }
- }
- }
-
- System.out.println(TAG + "getArray return " + JSON.toJSONString(transferredRequest) + "\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n\n");
-
- return transferredRequest;
- }
-
-
- /**获取拼接路径
- * @param path
- * @param name
- * @return
- */
- private String getPath(String path, String name) {
- System.out.println("getPath path = " + path + "; name = " + name + " <<<<<<<<<<<<<");
- path = StringUtil.getString(path);
- name = StringUtil.getString(name);
- if (StringUtil.isNotEmpty(path, false)) {
- if (StringUtil.isNotEmpty(name, false)) {
- path += ((name.startsWith(SEPARATOR) ? "" : SEPARATOR) + name);
- }
- } else {
- path = name;
- }
- System.out.println("getPath return " + path + " >>>>>>>>>>>>>>>>");
- return path;
- }
-
- /**有关联代码的object的关联key在relationMap里
- * @param path
- * @return
- */
- private boolean isInRelationMap(String path) {
- // return relationMap == null ? false : relationMap.containsKey(path);
- Set set = relationMap == null ? null : relationMap.keySet();
- if (set != null) {
- for (String key : set) {
- if (key != null && key.contains(path)) {
- return true;
- }
- }
- }
- return false;
- }
-
-
- /**将已获取完成的object的内容替换requestObject里对应的值
- * @param path object的路径
- * @param value 需要被关联的object
- */
- public synchronized void putValueByPath(String path, Object value) {
- System.out.println("\n putValueByPath path = " + path + "; value = " + value + "\n <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
- String[] keys = StringUtil.splitPath(path);
- if (keys == null) {
- return;
- }
- if (requestObject == null) {
- requestObject = new JSONObject(true);
- }
- // synchronized (requestObject) {
- JSONObject parent = requestObject;
- JSONObject child = null;
- String key;
- for (int i = 0; i < keys.length - 1; i++) {//一步一步到达指定位置parentPath
- key = keys[i];
- child = getJSONObject(parent, key);
- if (child == null) {//不存在该路径就创建
- child = new JSONObject(true);
- parent.put(key, child);
- }
- parent = child;
- }
-
- try {
- System.out.println("putValueByPath parent.put(keys[keys.length - 1], value); >> ");
- parent.put(keys[keys.length - 1], value);
- } catch (Exception e) {
- System.out.println("putValueByPath try { parent.put(keys[keys.length - 1], value); " +
- "} catch (Exception e) {\n" + e.getMessage());
- }
- System.out.println(TAG + "putValueByPath requestObject" + JSON.toJSONString(requestObject) + "\n >>>>>>>>>>>>>>>>>>");
- // }
- }
- /**根据路径获取值
- * @param path
- * @return
- */
- private Object getValueByPath(String path) {
- System.out.println(TAG + "<<<<<<<<<<<<<<< \n getValueByPath path = " + path + "\n <<<<<<<<<<<<<<<<<<");
- String[] keys = StringUtil.splitPath(path);
-
- if (keys != null) {
- JSONObject parent = requestObject;
- JSONObject child = null;
- String key;
- for (int i = 0; i < keys.length - 1; i++) {//一步一步到达指定位置parentPath
- key = keys[i];
- child = getJSONObject(parent, key);
- if (child == null) {//不存在
- return "";
- }
- parent = child;
- }
- try {
- System.out.println("getValueByPath return parent.get(keys[keys.length - 1]); >> ");
- return parent.get(keys[keys.length - 1]);
- } catch (Exception e) {
- System.out.println("getValueByPath try { return parent.get(keys[keys.length - 1]); " +
- "} catch (Exception e) {\n" + e.getMessage());
- }
- }
- System.out.println(TAG + "getValueByPath return requestObject" + JSON.toJSONString(requestObject) + "\n >>>>>>>>>>>>>>>>>>");
- return requestObject;
- }
-
-
- private JSONObject getJSONObject(JSONObject object, String key) {
- try {
- return object.getJSONObject(key);
- } catch (Exception e) {
- System.out.println("getJSONObject try { return object.getJSONObject(key); } catch (Exception e) { \n" + e.getMessage());
- }
- return null;
- }
-
-
- /**获取数据库返回的String
- * @param config
- * @return
- * @throws AccessException
- */
- private synchronized JSONObject getSQLObject(QueryConfig config) throws AccessException {
- System.out.println("getSQLObject config = " + JSON.toJSONString(config));
- AccessVerifier.verify(requestObject, config == null ? null : config.getTable());
- return QueryHelper.getInstance().select(config);//QueryHelper2.getInstance().select(config);//
- }
-
- /**获取查询配置
- * @param table
- * @param request
- * @return
- */
- public QueryConfig getQueryConfig(String table, JSONObject request) {
- return QueryConfig.getQueryConfig(table, request);
- }
- /**获取查询配置
- * @param table
- * @param request
- * @return
- */
- public QueryConfig newQueryConfig(String table, JSONObject request) {
- return QueryConfig.getQueryConfig(table, request);
- }
- /**把parentConfig的array属性继承下来
- * @param config
- * @param parentConfig
- * @return
- */
- private QueryConfig extendQueryConfig(QueryConfig config, QueryConfig parentConfig) {
- if (parentConfig != null) {
- if (config == null) {
- return parentConfig;
- }
- config.setLimit(parentConfig.getLimit()).setPage(parentConfig.getPage()).setPosition(parentConfig.getPosition());
- }
- return config;
- }
-
-
- public boolean isObject(String json) {
- return JSON.parseObject(json) != null;//json.startsWith("{") && json.endsWith("}");
- }
-
- private boolean isObjectKey(String key) {
- key = StringUtil.getString(key);
- return StringUtil.isNotEmpty(key, false) && isArrayKey(key) == false && StringUtil.isAlpha(key.substring(0, 1));
- }
- public boolean isArrayKey(String key) {
- return key.endsWith("[]");//[key]改为了key[],更符合常规逻辑。 key.startsWith("[") && key.endsWith("]");
- }
-
-}
diff --git a/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/server/package-info.java b/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/server/package-info.java
deleted file mode 100755
index aadcdd817..000000000
--- a/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/server/package-info.java
+++ /dev/null
@@ -1,22 +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.*/
-
-/**
- * server files package
- */
-/**
- * @author Lemon
- *
- */
-package zuo.biao.apijson.server;
\ No newline at end of file
diff --git a/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/server/sql/AccessVerifier.java b/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/server/sql/AccessVerifier.java
deleted file mode 100644
index 848301337..000000000
--- a/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/server/sql/AccessVerifier.java
+++ /dev/null
@@ -1,129 +0,0 @@
-package zuo.biao.apijson.server.sql;
-
-import java.rmi.AccessException;
-
-import com.alibaba.fastjson.JSONObject;
-
-import zuo.biao.apijson.StringUtil;
-
-/**权限验证类
- * @author Lemon
- */
-public class AccessVerifier {
- private static final String TAG = "AccessVerifier: ";
-
- private static final int ACCESS_LOGIN = 1;
- private static final int ACCESS_PAY = 2;
-
- public static final String KEY_CURRENT_USER_ID = "currentUserId";
- public static final String KEY_LOGIN_PASSWORD = "loginPassword";
- public static final String KEY_PAY_PASSWORD = "payPassword";
-
- // public static final String[] LOGIN_ACCESS_TABLE_NAMES = {"Work", "Comment"};
- public static final String[] PAY_ACCESS_TABLE_NAMES = {"Wallet"};
-
- /**验证权限是否通过
- * @param request
- * @param tableName
- * @return
- */
- public static boolean verify(JSONObject request, String tableName) throws AccessException {
- try {
- verify(request, getAccessId(tableName));
- } catch (AccessException e) {
- throw new AccessException(TAG + "verify tableName = " + tableName + ", error = " + e.getMessage());
- }
- return true;
- }
-
-
- /**验证权限是否通过
- * @param request
- * @param accessId 可以直接在代码里写ACCESS_LOGIN等,或者建一个Access表,包括id和需要改权限的table的tableName列表
- * @return
- * @throws AccessException
- */
- public static boolean verify(JSONObject request, int accessId) throws AccessException {
- if (accessId < 0 || request == null) {
- return true;
- }
- long currentUserId = request.getLongValue(KEY_CURRENT_USER_ID);
- if (currentUserId <= 0) {
- throw new AccessException(TAG + "verify accessId = " + accessId
- + " >> currentUserId <= 0, currentUserId = " + currentUserId);
- }
- String password;
-
- switch (accessId) {
- case ACCESS_LOGIN:
- password = StringUtil.getString(request.getString(KEY_LOGIN_PASSWORD));
- if (password.equals(StringUtil.getString(getLoginPassword(currentUserId))) == false) {
- throw new AccessException(TAG + "verify accessId = " + accessId
- + " >> currentUserId or loginPassword error"
- + " currentUserId = " + currentUserId + ", loginPassword = " + password);
- }
- case ACCESS_PAY:
- password = StringUtil.getString(request.getString(KEY_PAY_PASSWORD));
- if (password.equals(StringUtil.getString(getPayPassword(currentUserId))) == false) {
- throw new AccessException(TAG + "verify accessId = " + accessId
- + " >> currentUserId or payPassword error"
- + " currentUserId = " + currentUserId + ", payPassword = " + password);
- }
- default:
- return true;
- }
- }
-
- /**获取权限id
- * @param tableName
- * @return
- */
- public static int getAccessId(String tableName) {
- if (StringUtil.isNotEmpty(tableName, true) == false) {
- return -1;
- }
- // for (int i = 0; i < LOGIN_ACCESS_TABLE_NAMES.length; i++) {
- // if (tableName.equals(LOGIN_ACCESS_TABLE_NAMES[i])) {
- // return ACCESS_LOGIN;
- // }
- // }
- for (int i = 0; i < PAY_ACCESS_TABLE_NAMES.length; i++) {
- if (tableName.equals(PAY_ACCESS_TABLE_NAMES[i])) {
- return ACCESS_PAY;
- }
- }
- return -1;
- }
-
- /**获取登录密码
- * @param userId
- * @return
- */
- public static String getLoginPassword(long userId) {
- // TODO 查询并返回对应userId的登录密码
- return "123456";//仅测试用
- }
-
- /**获取支付密码
- * @param userId
- * @return
- */
- public static String getPayPassword(long userId) {
- // TODO 查询并返回对应userId的支付密码
- return "123456";//仅测试用
- }
-
- /**删除请求里的权限信息
- * @param requestObject
- * @return
- */
- public static JSONObject removeAccessInfo(JSONObject requestObject) {
- if (requestObject != null) {
- requestObject.remove(KEY_CURRENT_USER_ID);
- requestObject.remove(KEY_LOGIN_PASSWORD);
- requestObject.remove(KEY_PAY_PASSWORD);
- }
- return requestObject;
- }
-
-}
diff --git a/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/server/sql/QueryHelper.java b/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/server/sql/QueryHelper.java
deleted file mode 100755
index 198b61789..000000000
--- a/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/server/sql/QueryHelper.java
+++ /dev/null
@@ -1,154 +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.server.sql;
-
-import java.sql.*;
-import java.util.ArrayList;
-import java.util.List;
-
-import com.alibaba.fastjson.JSONObject;
-import zuo.biao.apijson.StringUtil;
-import zuo.biao.apijson.server.QueryConfig;
-
-/**helper for query MySQL database
- * @author Lemon
- */
-public class QueryHelper {
- private static final String TAG = "QueryHelper: ";
-
- private static final String YOUR_MYSQL_URL = "jdbc:mysql://localhost:3306/";//TODO edit to an available one
- private static final String YOUR_MYSQL_SCHEMA = "sys";//TODO edit to an available one
- private static final String YOUR_MYSQL_ACCOUNT = "root";//TODO edit to an available one
- private static final String YOUR_MYSQL_PASSWORD = "apijson";//TODO edit to an available one
-
- private QueryHelper() {
-
- }
-
- private static QueryHelper instance;
- public static synchronized QueryHelper getInstance() {
- if (instance == null) {
- instance = new QueryHelper();
- }
- return instance;
- }
-
- public Connection getConnection() throws Exception {
- //调用Class.forName()方法加载驱动程序
- Class.forName("com.mysql.jdbc.Driver");
- System.out.println(TAG + "成功加载MySQL驱动!");
- return DriverManager.getConnection(YOUR_MYSQL_URL + YOUR_MYSQL_SCHEMA, YOUR_MYSQL_ACCOUNT, YOUR_MYSQL_PASSWORD);
- }
-
-
- private static Connection connection;
- private static Statement statement;
- private static DatabaseMetaData metaData;
- public void close() {
- try {
- if (statement != null && statement.isClosed() == false) {
- statement.close();
- }
- if (connection != null && connection.isClosed() == false) {
- connection.close();
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }
- metaData = null;
- statement = null;
- }
-
- public JSONObject select(QueryConfig config) {
- if (config == null || StringUtil.isNotEmpty(config.getTable(), true) == false) {
- System.out.println(TAG + "select config==null||StringUtil.isNotEmpty(config.getTable(), true)==false>>return null;");
- return null;
- }
- final String sql = config.getSQL();
-
- try{
-
-
- System.out.println(TAG + "成功连接到数据库!");
-
- if (connection == null || connection.isClosed()) {
- System.out.println(TAG + "select connection " + (connection == null ? " = null" : ("isClosed = " + connection.isClosed()))) ;
- connection = getConnection();
- statement = connection.createStatement(); //创建Statement对象
- metaData = connection.getMetaData();
- }
-
- List list = getColumnList(config.getTable());
- if (list == null || list.isEmpty()) {
- return null;
- }
-
- System.out.println(TAG + "select sql = " + sql);
-
- ResultSet rs = statement.executeQuery(sql);//创建数据对象
-
- JSONObject object = null;//new JSONObject();//null;
- int position = -1;
- while (rs.next()){
- position ++;
- if (position != config.getPosition()) {
- continue;
- }
- object = new JSONObject(true);
- try {
- for (int i = 0; i < list.size(); i++) {
- object.put(list.get(i), rs.getObject(rs.findColumn(list.get(i))));
- }
- } catch (Exception e) {
- System.out.println(TAG + "select while (rs.next()){ ... >> try { object.put(list.get(i), ..." +
- " >> } catch (Exception e) {\n" + e.getMessage());
- e.printStackTrace();
- }
- break;
- }
-
- rs.close();
-
- return object;
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- return null;
- }
-
-
- /**获取全部字段名列表
- * @param table
- * @return
- */
- public List getColumnList(String table) {
- List list = new ArrayList();
- ResultSet rs;
- try {
- rs = metaData.getColumns(YOUR_MYSQL_SCHEMA, null, table, "%");
- while (rs.next()) {
- System.out.println(TAG + rs.getString(4));
- list.add(rs.getString(4));
- }
- rs.close();
- } catch (Exception e) {
- System.out.println(TAG + "getColumnList try { DatabaseMetaData meta = conn.getMetaData(); ... >> " +
- "} catch (Exception e) {\n" + e.getMessage());
- e.printStackTrace();
- }
- return list;
- }
-}
\ No newline at end of file
diff --git a/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/server/sql/QueryHelper2.java b/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/server/sql/QueryHelper2.java
deleted file mode 100755
index 18dad76d0..000000000
--- a/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/server/sql/QueryHelper2.java
+++ /dev/null
@@ -1,186 +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.server.sql;
-
-import java.sql.*;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import com.alibaba.fastjson.JSONObject;
-import zuo.biao.apijson.StringUtil;
-import zuo.biao.apijson.server.QueryConfig;
-
-/**helper for query MySQL database with cache
- * @author Lemon
- */
-public class QueryHelper2 {
- private static final String TAG = "QueryHelper2: ";
-
- private static final String YOUR_MYSQL_URL = "jdbc:mysql://localhost:3306/";//TODO edit to an available one
- private static final String YOUR_MYSQL_SCHEMA = "sys";//TODO edit to an available one
- private static final String YOUR_MYSQL_ACCOUNT = "root";//TODO edit to an available one
- private static final String YOUR_MYSQL_PASSWORD = "apijson";//TODO edit to an available one
-
- private Map> cacheMap;
- private QueryHelper2() {
-
- }
-
- private static QueryHelper2 instance;
- public static synchronized QueryHelper2 getInstance() {
- if (instance == null) {
- instance = new QueryHelper2();
- }
- return instance;
- }
-
- public Connection getConnection() throws Exception {
- //调用Class.forName()方法加载驱动程序
- Class.forName("com.mysql.jdbc.Driver");
- System.out.println(TAG + "成功加载MySQL驱动!");
- return DriverManager.getConnection(YOUR_MYSQL_URL + YOUR_MYSQL_SCHEMA, YOUR_MYSQL_ACCOUNT, YOUR_MYSQL_PASSWORD);
- }
-
- private void saveCache(String key, List list) {
- if (key == null) {
- System.out.println("saveList key == null >> return;");
- return;
- }
- cacheMap.put(key, list);
- }
- private void removeCache(String key) {
- if (key == null) {
- System.out.println("removeList key == null >> return;");
- return;
- }
- cacheMap.remove(key);
- }
-
- private JSONObject getFromCache(String key, int position) {
- List list = cacheMap.get(key);
- return list == null || position < 0 || position >= list.size() ? null : list.get(position);
- }
-
- private static Connection connection;
- private static Statement statement;
- private static DatabaseMetaData metaData;
- public void close() {
- try {
- statement.close();
- connection.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- metaData = null;
- statement = null;
- cacheMap = null;
- }
-
- public JSONObject select(QueryConfig config) {
- if (config == null || StringUtil.isNotEmpty(config.getTable(), true) == false) {
- System.out.println(TAG + "select config==null||StringUtil.isNotEmpty(config.getTable(), true)==false>>return null;");
- return null;
- }
- final String sql = config.getSQL();
- final int position = config.getPosition();
-
- if (cacheMap == null) {
- cacheMap = new HashMap>();
- }
- JSONObject object = getFromCache(sql, position);
- if (object != null) {
- return object;
- }
-
- try{
- if (connection == null || connection.isClosed()) {
- System.out.println(TAG + "select connection " + (connection == null ? " = null" : ("isClosed = " + connection.isClosed()))) ;
- connection = getConnection();
- statement = connection.createStatement(); //创建Statement对象
- metaData = connection.getMetaData();
- }
- List list = getColumnList(config.getTable(), metaData);
- if (list == null || list.isEmpty()) {
- return null;
- }
-
-
- System.out.println(TAG + "select sql = " + sql);
-
- ResultSet rs = statement.executeQuery(sql);//创建数据对象
-
- List resultList = new ArrayList();
- while (rs.next()){
- object = new JSONObject(true);
- try {
- for (int i = 0; i < list.size(); i++) {
- object.put(list.get(i), rs.getObject(rs.findColumn(list.get(i))));
- }
- } catch (Exception e) {
- System.out.println(TAG + "select while (rs.next()){ ... >> try { object.put(list.get(i), ..." +
- " >> } catch (Exception e) {\n" + e.getMessage());
- e.printStackTrace();
- object = null;
- }
- resultList.add(object);
- }
- rs.close();
-
- //从缓存存取,避免 too many connections崩溃
- if (position < config.getLimit() - 1) {
- System.out.println("select position < config.getLimit() - 1 >> saveCache(sql, resultList);");
- saveCache(sql, resultList);
- } else {
- System.out.println("select position >= config.getLimit() - 1 >> removeCache(sql); return object;");
- removeCache(sql);
- return object;
- }
-
- System.out.println("select return position < 0 || position >= resultList.size() ? null : resultList.get(position); ");
- return position < 0 || position >= resultList.size() ? null : resultList.get(position);
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- return null;
- }
-
-
-
- /**获取全部字段名列表
- * @param table
- * @param meta
- * @return
- */
- public List getColumnList(String table, DatabaseMetaData meta) {
- List list = new ArrayList();
- ResultSet rs;
- try {
- rs = meta.getColumns(YOUR_MYSQL_SCHEMA, null, table, "%");
- while (rs.next()) {
- System.out.println(TAG + rs.getString(4));
- list.add(rs.getString(4));
- }
- rs.close();
- } catch (Exception e) {
- System.out.println(TAG + "getColumnList try { DatabaseMetaData meta = conn.getMetaData(); ... >> " +
- "} catch (Exception e) {\n" + e.getMessage());
- e.printStackTrace();
- }
- return list;
- }
-}
\ No newline at end of file
diff --git a/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/server/sql/package-info.java b/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/server/sql/package-info.java
deleted file mode 100755
index 1194f44e3..000000000
--- a/APIJSON(Server)/APIJSON(Idea)/src/main/java/zuo/biao/apijson/server/sql/package-info.java
+++ /dev/null
@@ -1,22 +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.*/
-
-/**
- * query files package
- */
-/**
- * @author Lemon
- *
- */
-package zuo.biao.apijson.server.sql;
\ No newline at end of file
diff --git a/APIJSON(Server)/APIJSON(Idea)/src/main/resources/application.properties b/APIJSON(Server)/APIJSON(Idea)/src/main/resources/application.properties
deleted file mode 100755
index e69de29bb..000000000
diff --git a/APIJSON(Server)/APIJSON(Idea)/src/test/java/zuo/biao/apijson/server/ApplicationTests.java b/APIJSON(Server)/APIJSON(Idea)/src/test/java/zuo/biao/apijson/server/ApplicationTests.java
deleted file mode 100755
index 54df56813..000000000
--- a/APIJSON(Server)/APIJSON(Idea)/src/test/java/zuo/biao/apijson/server/ApplicationTests.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package zuo.biao.apijson.server;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-@RunWith(SpringRunner.class)
-@SpringBootTest
-public class ApplicationTests {
-
- @Test
- public void contextLoads() {
- }
-
-}
diff --git a/APIJSONORM/.gitignore b/APIJSONORM/.gitignore
new file mode 100644
index 000000000..b83d22266
--- /dev/null
+++ b/APIJSONORM/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/APIJSONORM/README.md b/APIJSONORM/README.md
new file mode 100644
index 000000000..0cb431e27
--- /dev/null
+++ b/APIJSONORM/README.md
@@ -0,0 +1,65 @@
+# APIJSONORM [](https://jitpack.io/#Tencent/APIJSON) [
](https://deepwiki.com/Tencent/APIJSON)
+腾讯 [APIJSON](https://github.com/Tencent/APIJSON) ORM 库,可通过 Maven, Gradle 等远程依赖。
+Tencent [APIJSON](https://github.com/Tencent/APIJSON) ORM library for remote dependencies with Maven, Gradle, etc.
+
+### Maven
+#### 1. 在 pom.xml 中添加 JitPack 仓库
+#### 1. Add the JitPack repository to pom.xml
+```xml
+
+
+ jitpack.io
+ https://jitpack.io
+
+
+```
+
+
+#### 2. 在 pom.xml 中添加 APIJSON 依赖
+#### 2. Add the APIJSON dependency to pom.xml
+```xml
+
+ com.github.Tencent
+ APIJSON
+ LATEST
+
+```
+
+
+
+
+### Gradle
+#### 1. 在项目根目录 build.gradle 中最后添加 JitPack 仓库
+#### 1. Add the JitPack repository in your root build.gradle at the end of repositories
+```gradle
+ allprojects {
+ repositories {
+ ...
+ maven { url 'https://jitpack.io/' }
+ }
+ }
+```
+
+
+#### 2. 在项目某个 module 目录(例如 `app`) build.gradle 中添加 apijson-orm 依赖
+#### 2. Add the APIJSON dependency in one of your modules(such as `app`)
+```gradle
+ dependencies {
+ implementation 'com.github.Tencent:APIJSON:latest'
+ }
+```
+
+
+
+
+### FASTJSON 2
+#### Code
+https://github.com/Tencent/APIJSON/tree/fastjson2
+
+#### Maven
+https://mvnrepository.com/artifact/com.github.linushp/zikai-apijson/1.0
+
+
+
+### Unit Test
+http://apijson.cn/unit
diff --git a/APIJSONORM/pom.xml b/APIJSONORM/pom.xml
new file mode 100644
index 000000000..bd340fa5f
--- /dev/null
+++ b/APIJSONORM/pom.xml
@@ -0,0 +1,55 @@
+
+
+ 4.0.0
+
+ com.github.Tencent
+ APIJSON
+ 8.0.2
+ jar
+
+ APIJSONORM
+ APIJSON ORM Library
+
+
+ UTF-8
+ UTF-8
+ 1.8
+ UTF-8
+ 1.8
+ 1.8
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.12.1
+
+ 1.8
+ 1.8
+
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+ 3.2.1
+
+
+ package
+
+ jar-no-fork
+
+
+
+
+
+
+
+
+
diff --git a/APIJSONORM/src/main/java/apijson/JSON.java b/APIJSONORM/src/main/java/apijson/JSON.java
new file mode 100755
index 000000000..0a14e0420
--- /dev/null
+++ b/APIJSONORM/src/main/java/apijson/JSON.java
@@ -0,0 +1,691 @@
+/*Copyright (C) 2020 Tencent. All rights reserved.
+
+This source code is licensed under the Apache License Version 2.0.*/
+
+package apijson;
+
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**JSON工具类 防止解析时异常
+ * @author Lemon
+ */
+public class JSON {
+
+ static final String TAG = "JSON";
+
+ public static JSONParser extends Map, ? extends List