Skip to content

Commit 2f8c5a2

Browse files
committed
key里新增搜索$,函数(),引用@,包含{},关键字@并替换原来的引用和包含方式;新增远程调用反射函数
1 parent 2768d7b commit 2f8c5a2

8 files changed

Lines changed: 618 additions & 38 deletions

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*Copyright ©2015 TommyLemon(https://github.com/TommyLemon)
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.*/
14+
15+
package zuo.biao.apijson;
16+
17+
/**自定义Entry
18+
* *java.util.Map.Entry是interface,new Entry(...)不好用,其它的Entry也不好用
19+
* @author Lemon
20+
* @param <K> key
21+
* @param <V> value
22+
* @use new Entry<K, V>(...)
23+
* @warn K,V都需要基本类型时不建议使用,判空麻烦,不如新建一个Model
24+
*/
25+
public class Entry<K, V> {
26+
27+
public K key;
28+
public V value;
29+
30+
public Entry() {
31+
//default
32+
}
33+
public Entry(K key) {
34+
this(key, null);
35+
}
36+
public Entry(K key, V value) {
37+
this.key = key;
38+
this.value = value;
39+
}
40+
41+
42+
public K getKey() {
43+
return key;
44+
}
45+
public void setKey(K key) {
46+
this.key = key;
47+
}
48+
public V getValue() {
49+
return value;
50+
}
51+
public void setValue(V value) {
52+
this.value = value;
53+
}
54+
55+
}
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
/*Copyright ©2015 TommyLemon(https://github.com/TommyLemon)
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.*/
14+
15+
package zuo.biao.apijson;
16+
17+
import java.util.Collection;
18+
import java.util.HashMap;
19+
import java.util.Map;
20+
21+
/**type:value
22+
* @author Lemon
23+
*/
24+
public class TypeValueKeyEntry extends Entry<String, String> {
25+
26+
private static Map<String, Class<?>> classMap;
27+
static {
28+
classMap = new HashMap<>();
29+
classMap.put(boolean.class.getSimpleName(), boolean.class);
30+
classMap.put(int.class.getSimpleName(), int.class);
31+
classMap.put(long.class.getSimpleName(), long.class);
32+
classMap.put(float.class.getSimpleName(), float.class);
33+
classMap.put(double.class.getSimpleName(), double.class);
34+
classMap.put(Boolean.class.getSimpleName(), Boolean.class);
35+
classMap.put(Integer.class.getSimpleName(), Integer.class);
36+
classMap.put(Long.class.getSimpleName(), Long.class);
37+
classMap.put(Float.class.getSimpleName(), Float.class);
38+
classMap.put(Double.class.getSimpleName(), Double.class);
39+
40+
classMap.put(Object.class.getSimpleName(), Object.class);
41+
classMap.put(String.class.getSimpleName(), String.class);
42+
// classMap.put(JSONArray.class.getSimpleName(), JSONArray.class);//JSONArray implements Map
43+
classMap.put(Collection.class.getSimpleName(), Collection.class);//不允许指定<T>
44+
classMap.put(Map.class.getSimpleName(), Map.class);//不允许指定<T>
45+
}
46+
47+
48+
public TypeValueKeyEntry() {
49+
super();
50+
}
51+
52+
53+
/**
54+
* @param <K>
55+
* @param typeValue
56+
* @return
57+
*/
58+
public static <K, V> boolean isCorrect(Entry<K, V> typeValue) {
59+
return typeValue != null && StringUtil.isNotEmpty(typeValue.getValue(), true);
60+
}
61+
62+
/**
63+
* @param typeValue
64+
* @return
65+
*/
66+
public String toEntryString() {
67+
return toEntryString(getKey(), getValue());
68+
}
69+
/**
70+
* @param typeValue
71+
* @return
72+
*/
73+
public static String toEntryString(String typeKey, String valueKey) {
74+
return (typeKey == null ? "" : typeKey + ":") + valueKey;
75+
}
76+
/**
77+
* @param type
78+
* @param value
79+
* @return
80+
*/
81+
public static String toEntryString(Class<?> type, Object value) {
82+
return toEntryString(type == null ? null : type.getSimpleName(), StringUtil.getString(value));
83+
}
84+
/**
85+
* @param typeValue
86+
* @return
87+
*/
88+
public static Entry<String, String> parseKeyEntry(String typeValue) {
89+
typeValue = StringUtil.getString(typeValue);//让客户端去掉所有空格 getNoBlankString(typeValue);
90+
if (typeValue.isEmpty()) {
91+
return null;
92+
}
93+
int index = typeValue.contains(":") ? typeValue.indexOf(":") : -1;
94+
95+
Entry<String, String> entry = new Entry<String, String>();
96+
entry.setKey(index < 0 ? Object.class.getSimpleName() : typeValue.substring(0, index));
97+
entry.setValue(typeValue.substring(index + 1, typeValue.length()));
98+
99+
return entry;
100+
}
101+
/**
102+
* @param valueMap
103+
* @param typeValue
104+
* @return
105+
*/
106+
public static Entry<Class<?>, Object> parseEntry(Map<String, Object> valueMap, String typeValue) {
107+
typeValue = StringUtil.getString(typeValue);//让客户端去掉所有空格 getNoBlankString(typeValue);
108+
if (typeValue.isEmpty()) {
109+
return null;
110+
}
111+
int index = typeValue.contains(":") ? typeValue.indexOf(":") : -1;
112+
113+
Entry<Class<?>, Object> entry = new Entry<>();
114+
entry.setKey(classMap.get(index < 0 ? Object.class.getSimpleName() : typeValue.substring(0, index)));
115+
entry.setValue(valueMap == null ? null : valueMap.get(typeValue.substring(index + 1, typeValue.length())));
116+
117+
return entry;
118+
}
119+
}

‎APIJSON(Server)/APIJSON(Eclipse_JEE)/src/main/java/zuo/biao/apijson/server/APIJSONApplication.java‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
import org.springframework.boot.SpringApplication;
1818
import org.springframework.boot.autoconfigure.SpringBootApplication;
1919

20-
import zuo.biao.apijson.server.sql.AccessVerifier;
21-
2220
/**application
2321
* @author Lemon
2422
*/
@@ -27,7 +25,7 @@ public class APIJSONApplication {
2725

2826
public static void main(String[] args) {
2927
SpringApplication.run(APIJSONApplication.class, args);
30-
31-
AccessVerifier.init();
28+
29+
Function.test();
3230
}
3331
}

0 commit comments

Comments
 (0)