├── .project
├── 1-hi-utils
├── .classpath
├── .project
├── license.txt
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ ├── META-INF
│ │ └── MANIFEST.MF
│ │ └── com
│ │ └── helpinput
│ │ ├── core
│ │ ├── Consts.java
│ │ ├── FileUtils.java
│ │ ├── LoggerBase.java
│ │ ├── MD5.java
│ │ ├── MapConvertor.java
│ │ ├── MapFormat.java
│ │ ├── PathUtil.java
│ │ ├── Utils.java
│ │ └── WebPathUtils.java
│ │ └── maps
│ │ ├── CaseInsensitiveHashMap.java
│ │ ├── ConcurrentCaseInsensitiveHashMap.java
│ │ ├── ConcurrentHashSet.java
│ │ ├── ConcurrentMap.java
│ │ ├── MapBackedSet.java
│ │ ├── OnceMap.java
│ │ ├── RequestValues.java
│ │ ├── ResponsValues.java
│ │ └── Values.java
│ └── test
│ └── java
│ ├── commons
│ ├── PatternTest.java
│ ├── ReplaceTest.java
│ └── UtilsTest.java
│ ├── logback-test.xml
│ └── maven
│ └── delelastupdate
│ └── DelLastUpdated.java
├── 2-hi-spring-dynamic
├── .classpath
├── .project
├── license.txt
├── override
│ └── org
│ │ ├── hibernate
│ │ ├── annotations
│ │ │ └── common
│ │ │ │ └── util
│ │ │ │ └── ReflectHelper.java
│ │ └── internal
│ │ │ └── util
│ │ │ └── ReflectHelper.java
│ │ └── springframework
│ │ └── core
│ │ └── GenericTypeResolver.java
├── pom.xml
└── src
│ └── main
│ └── java
│ ├── com
│ └── helpinput
│ │ ├── annotation
│ │ ├── Dynamic.java
│ │ ├── Mapping.java
│ │ ├── MappingExclude.java
│ │ ├── Parent.java
│ │ ├── Properties.java
│ │ ├── Property.java
│ │ ├── Prototype.java
│ │ └── TargetType.java
│ │ ├── holder
│ │ ├── ContextHolder.java
│ │ └── SafeHolder.java
│ │ ├── propertyeditors
│ │ ├── GLClassEditor.java
│ │ └── PropertyEditorRegister.java
│ │ ├── settings
│ │ └── Options.java
│ │ └── spring
│ │ ├── BeanDefinitionWrap.java
│ │ ├── BeanInfo.java
│ │ ├── BeanRegister.java
│ │ ├── Commons.java
│ │ ├── Consts.java
│ │ ├── FileReader.java
│ │ ├── Interceptor.java
│ │ ├── ParserUtils.java
│ │ ├── ScanedType.java
│ │ ├── SourceFileMonitor.java
│ │ ├── SourceScaner.java
│ │ ├── proxy
│ │ └── OptimizeTransactionProxyFactoryBean.java
│ │ ├── refresher
│ │ ├── CommonRefresher.java
│ │ ├── ContextRefresher.java
│ │ ├── SessiontRefresher.java
│ │ ├── mvc
│ │ │ └── MvcContextRefresher.java
│ │ └── web
│ │ │ └── WebContextRefresher.java
│ │ ├── registinerceptor
│ │ ├── AbstractBeanRegistInterceptor.java
│ │ ├── BeanRegistInterceptor.java
│ │ ├── ProxybeanRegistInterceptor.java
│ │ └── mvc
│ │ │ └── UrlInterceptorBeanRegistInterceptor.java
│ │ ├── servlet
│ │ └── mvc
│ │ │ └── EnhanceDispachServlet.java
│ │ └── support
│ │ ├── ClassLoaderHolder.java
│ │ └── SourceFileMonitorListener.java
│ └── groovy
│ └── lang
│ └── HiGroovyClassLoader.java
├── 3-hi-spring-Dynamic-mvc-demo
├── .classpath
├── .mymetadata
├── .project
├── WebRoot
│ ├── META-INF
│ │ └── MANIFEST.MF
│ ├── WEB-INF
│ │ ├── classes
│ │ │ ├── config
│ │ │ │ └── spring
│ │ │ │ │ ├── spring-beans.xml
│ │ │ │ │ ├── spring-common.xml
│ │ │ │ │ └── spring-mvc.xml
│ │ │ ├── log4j.properties
│ │ │ └── logback-test.xml
│ │ ├── logback.xml
│ │ ├── script
│ │ │ └── com
│ │ │ │ └── script
│ │ │ │ ├── context
│ │ │ │ └── refreshers
│ │ │ │ │ ├── CommonRefresher.java
│ │ │ │ │ ├── MvcContextRefresher.java
│ │ │ │ │ └── SessiontRefresher.java
│ │ │ │ ├── dao
│ │ │ │ ├── TeacherDao.java
│ │ │ │ └── TeacherDaoImpl.java
│ │ │ │ ├── entity
│ │ │ │ └── Teacher.groovy
│ │ │ │ ├── interceptor
│ │ │ │ └── TeacherIntercepptor.java
│ │ │ │ ├── manager
│ │ │ │ ├── TeacherManager.java
│ │ │ │ └── TeacherManagerImpl.java
│ │ │ │ ├── propertyEditors
│ │ │ │ └── DatePropertyEditor.java
│ │ │ │ ├── settings
│ │ │ │ └── IntervalSetting.java
│ │ │ │ └── web
│ │ │ │ └── TeacherController.java
│ │ └── web.xml
│ ├── addTeacher.jsp
│ ├── addUser.jsp
│ ├── editTeacher.jsp
│ ├── editUser.jsp
│ ├── error.jsp
│ ├── index.jsp
│ ├── js
│ │ └── jquery-1.7.1.js
│ ├── login.jsp
│ ├── success.jsp
│ └── teacherList.jsp
├── license.txt
├── pom.xml
├── spring-dynamic-mvc-demo.sql
└── src
│ ├── com
│ └── tgb
│ │ ├── dao
│ │ ├── UserDao.java
│ │ └── UserDaoImpl.java
│ │ ├── entity
│ │ └── User.java
│ │ ├── interceptor
│ │ └── UserIntercepptor.java
│ │ ├── manager
│ │ ├── UserManager.java
│ │ └── UserManagerImpl.java
│ │ └── web
│ │ └── UserController.java
│ ├── config
│ └── spring
│ │ ├── spring-beans.xml
│ │ ├── spring-common.xml
│ │ └── spring-mvc.xml
│ ├── log4j.properties
│ └── logback-test.xml
├── 3-hi-spring-dynamic-mvc-demo-script
├── .classpath
├── .project
├── license.txt
├── pom.xml
└── readme.txt
├── README.md
├── license.txt
└── pom.xml
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | 1-hi-parent
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/1-hi-utils/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/1-hi-utils/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | 1-hi-utils
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.wst.common.project.facet.core.builder
10 |
11 |
12 |
13 |
14 | org.eclipse.jdt.core.javabuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.wst.validation.validationbuilder
20 |
21 |
22 |
23 |
24 | com.genuitec.eclipse.ast.deploy.core.DeploymentBuilder
25 |
26 |
27 |
28 |
29 | com.genuitec.eclipse.j2eedt.core.DeploymentDescriptorValidator
30 |
31 |
32 |
33 |
34 | org.eclipse.m2e.core.maven2Builder
35 |
36 |
37 |
38 |
39 |
40 | org.eclipse.jem.workbench.JavaEMFNature
41 | com.genuitec.eclipse.ast.deploy.core.deploymentnature
42 | org.eclipse.jdt.core.javanature
43 | org.eclipse.m2e.core.maven2Nature
44 | org.eclipse.wst.common.project.facet.core.nature
45 | org.eclipse.wst.common.modulecore.ModuleCoreNature
46 |
47 |
48 |
--------------------------------------------------------------------------------
/1-hi-utils/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 |
6 | com.helpinput.hi
7 | helpinput-parent
8 | 1.2.4
9 |
10 | helpinput-utils
11 |
12 |
13 |
14 |
15 | commons-lang
16 | commons-lang
17 | 2.6
18 |
19 |
20 |
21 | org.json
22 | json
23 | 20090211
24 |
25 |
26 |
27 | com.alibaba
28 | fastjson
29 | 1.1.27
30 |
31 |
32 |
33 | net.sourceforge.cpdetector
34 | cpdetector
35 | 1.0.7
36 |
37 |
38 |
39 | commons-beanutils
40 | commons-beanutils
41 | 1.8.3
42 |
43 |
44 |
45 | org.slf4j
46 | slf4j-api
47 | 1.7.5
48 | provided
49 |
50 |
51 | commons-io
52 | commons-io
53 | 2.4
54 |
55 |
56 |
57 | junit
58 | junit
59 | 4.11
60 | test
61 |
62 |
63 |
64 |
65 |
66 |
67 | org.apache.maven.plugins
68 | maven-compiler-plugin
69 | 2.5
70 |
71 | 1.8
72 | 1.8
73 |
74 |
75 |
92 |
93 |
94 |
95 |
--------------------------------------------------------------------------------
/1-hi-utils/src/main/java/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Class-Path:
3 |
4 |
--------------------------------------------------------------------------------
/1-hi-utils/src/main/java/com/helpinput/core/Consts.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | /**
18 | *@Author: niaoge(Zhengsheng Xia)
19 | *@Email 78493244@qq.com
20 | *@Date: 2015-6-10
21 | */
22 | package com.helpinput.core;
23 |
24 | public class Consts{
25 | public static final String ONCE = "once";
26 |
27 | public static final String WEB_INF = "WEB-INF";
28 |
29 | public static final String META_INF = "META-INF";
30 |
31 | public static final String WEB_INF_CLASSES = "WEB-INF/classes";
32 |
33 | public static final String RESOURCES = "resources";
34 |
35 | public static final String CONTEXT_PARAM_SECURITY_KEY = "SECURITY_KEY";
36 |
37 | public static final String DEDUALT_SECURITY_KEY = "1234567890123456";
38 |
39 | public static final String EL_MAP_VALUES = ".values.";
40 |
41 | public static final String EL_FIELDNAME_SUFFIX = "}";
42 |
43 | public static final String BRACE_L = "{";
44 |
45 | public static final String BRACE_R = "{";
46 |
47 | public static final String EL_PREFIX = "#{";
48 |
49 | public static final String EL_SUFFIX = "}";
50 |
51 | public static final String ISO_8859_1 = "ISO-8859-1";
52 |
53 | public static final String UTF_8 = "UTF-8";
54 |
55 | public static final String MONGODB_ID = "_id";
56 |
57 | public static final String JDBC_NAME_L = "`";
58 |
59 | public static final String JDBC_NAME_R ="`";
60 |
61 | public static final String SPACE = " ";
62 |
63 | public static final String ALL_FIELD = "*";
64 |
65 | public static final String JDBC_SPLIT = ",";
66 |
67 | public static final String JDBC_QUERY = "?";
68 |
69 | public static final String JDBC_SELECT = "SELECT";
70 |
71 | public static final String JDBC_INSERT = "INSERT INTO";
72 |
73 | public static final String JDBC_UPDATE = "UPDATE";
74 |
75 | public static final String JDBC_DELETE = "DELETE";
76 |
77 | public static final String JDBC_WHERE = "WHERE";
78 |
79 | public static final String JDBC_LIMIT = "LIMIT";
80 |
81 | public static final String JDBC_SKIP = "SKIP";
82 |
83 | public static final String JDBC_OFFSET = "OFFSET";
84 |
85 | public static final String JDBC_ORDER_BY = "ORDER BY";
86 |
87 | public static final String JDBC_VALUES = "VALUES";
88 |
89 | public static final String JDBC_SET = "SET";
90 |
91 | public static final String JDBC_FROM = "FROM";
92 |
93 | public static final String JDBC_EQU = "=";
94 |
95 | public static final String JDBC_AND = "AND";
96 |
97 | public static final String JDBC_AS = "AS";
98 |
99 | public static final String JDBC_OR = "OR";
100 |
101 | public static final String JDBC_BR_L = "(";
102 |
103 | public static final String JDBC_BR_R = ")";
104 |
105 | public static final String JDBC_COUNT = "COUNT(*)";
106 |
107 | public static final String JDBC_COUNT_SIMPLE = "COUNT";
108 |
109 | public static final String JDBC_GROUPBY = "GROUP BY";
110 |
111 | public static final String JDBC_LEFT_JOIN = "LEFT JOIN";
112 |
113 | public static final String JDBC_ON = "ON";
114 |
115 | public static final String FIELDS = "fields";
116 |
117 | public static final String VALUES_SELECTED = "_valuesSelected_";
118 |
119 | public static final String VALIDATORBUNDLE = "_validatorBundle";
120 |
121 | public static final String TABLENAME = "tableName";
122 |
123 | public static final String TABLENAME_ = "tableName_";
124 |
125 | public static final String BEANNAME_ = "beanName_";
126 |
127 | public static final String APP_SCOPE = "appScope";
128 |
129 | public static final String COLON = ":";
130 |
131 | public static final String DOT = ".";
132 |
133 | public static final String SLASH = "/";
134 |
135 | public static final String DOUBLE_QUOTATION="\"";
136 |
137 | public static final String UPDATE_NOT_UNIQUE = "_updateNotUnique_";
138 |
139 | public static final String SUB = "sub";
140 |
141 | public static final String ROLE_ROLE = "role";
142 |
143 | public static final String ROLE_ROLE_FIELD = "roles";
144 |
145 | public static final String ROLE_FAIL_URL = "failUrl";
146 |
147 | public static final String ROLE_URL = "role_url";
148 |
149 | public static final String ROLE_URL_FIELD = "url";
150 |
151 | public static final String ROLE_NAME = "roleName";
152 |
153 | public static final String NODE_ROOT = "┣";
154 |
155 | public static final String NODE_LINDE = "━";
156 |
157 | public static final String ROLE_ACCESS = "access";
158 |
159 | public static final String FACES_REDIRECT = "?faces-redirect=true";
160 |
161 | public static final String VIEW = "view";
162 |
163 | public static final String XHTML_EXT_NAME = ".xhtml";
164 |
165 | public static final String SUB_LINE ="_";
166 |
167 | }
168 |
--------------------------------------------------------------------------------
/1-hi-utils/src/main/java/com/helpinput/core/FileUtils.java:
--------------------------------------------------------------------------------
1 | /* Copyright 2013-2015 the original author or authors.
2 | *
3 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4 | * the License. You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10 | * specific language governing permissions and limitations under the License. */
11 |
12 | /** @Author: niaoge(Zhengsheng Xia)
13 | * @Email 78493244@qq.com
14 | * @Date: 2015-6-10 */
15 | package com.helpinput.core;
16 |
17 | import info.monitorenter.cpdetector.io.ASCIIDetector;
18 | import info.monitorenter.cpdetector.io.CodepageDetectorProxy;
19 | import info.monitorenter.cpdetector.io.JChardetFacade;
20 | import info.monitorenter.cpdetector.io.ParsingDetector;
21 | import info.monitorenter.cpdetector.io.UnicodeDetector;
22 |
23 | import java.io.BufferedReader;
24 | import java.io.Closeable;
25 | import java.io.File;
26 | import java.io.FileInputStream;
27 | import java.io.FileNotFoundException;
28 | import java.io.IOException;
29 | import java.io.InputStreamReader;
30 | import java.io.UnsupportedEncodingException;
31 |
32 | public class FileUtils {
33 |
34 | /** 利用第三方开源包cpdetector获取文件编码格式
35 | *
36 | * @param path
37 | * 要判断文件编码格式的源文件的路径
38 | * @author huanglei
39 | * @version 2012-7-12 14:05 */
40 | public static String getFileEncode(File f) {
41 | /*
42 | * detector是探测器,它把探测任务交给具体的探测实现类的实例完成。
43 | * cpDetector内置了一些常用的探测实现类,这些探测实现类的实例可以通过add方法 加进来,如ParsingDetector、
44 | * JChardetFacade、ASCIIDetector、UnicodeDetector。
45 | * detector按照“谁最先返回非空的探测结果,就以该结果为准”的原则返回探测到的
46 | * 字符集编码。使用需要用到三个第三方JAR包:antlr.jar、chardet.jar和cpdetector.jar
47 | * cpDetector是基于统计学原理的,不保证完全正确。
48 | */
49 | CodepageDetectorProxy detector = CodepageDetectorProxy.getInstance();
50 | /*
51 | * ParsingDetector可用于检查HTML、XML等文件或字符流的编码,构造方法中的参数用于
52 | * 指示是否显示探测过程的详细信息,为false不显示。
53 | */
54 | detector.add(new ParsingDetector(false));
55 | /*
56 | * JChardetFacade封装了由Mozilla组织提供的JChardet,它可以完成大多数文件的编码
57 | * 测定。所以,一般有了这个探测器就可满足大多数项目的要求,如果你还不放心,可以
58 | * 再多加几个探测器,比如下面的ASCIIDetector、UnicodeDetector等。
59 | */
60 | detector.add(JChardetFacade.getInstance());// 用到antlr.jar、chardet.jar
61 | // ASCIIDetector用于ASCII编码测定
62 | detector.add(ASCIIDetector.getInstance());
63 | // UnicodeDetector用于Unicode家族编码的测定
64 | detector.add(UnicodeDetector.getInstance());
65 | java.nio.charset.Charset charset = null;
66 | try {
67 | charset = detector.detectCodepage(f.toURI().toURL());
68 | }
69 | catch (Exception ex) {
70 | ex.printStackTrace();
71 | }
72 | if (charset != null)
73 | return charset.name();
74 | else
75 | return null;
76 | }
77 |
78 | public static String getFileEncode(String path) {
79 | return getFileEncode(new File(path));
80 | }
81 |
82 | public static BufferedReader getFileBufferedReader(String path) throws UnsupportedEncodingException,
83 | FileNotFoundException {
84 | String charsetName = getFileEncode(path);
85 | BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(path), charsetName));
86 | return reader;
87 | }
88 |
89 | public static void closeWithWarning(Closeable c) {
90 | if (c != null) {
91 | try {
92 | c.close();
93 | }
94 | catch (IOException e) {
95 | //LOG.warning("Caught exception during close(): " + e);
96 | }
97 | }
98 | }
99 |
100 | public static String getReaderText(BufferedReader reader) throws IOException {
101 | StringBuilder answer = new StringBuilder();
102 | // reading the content of the file within a char buffer
103 | // allow to keep the correct line endings
104 | char[] charBuffer = new char[8192];
105 | int nbCharRead /* = 0 */;
106 | try {
107 | reader.read(charBuffer);
108 |
109 | while ((nbCharRead = reader.read(charBuffer)) != -1) {
110 | // appends buffer
111 | answer.append(charBuffer, 0, nbCharRead);
112 | }
113 | }
114 | finally {
115 | closeWithWarning(reader);
116 | reader = null;
117 | }
118 | return answer.toString();
119 | }
120 |
121 | public static String getfileText(String path) throws IOException {
122 | BufferedReader reader = getFileBufferedReader(path);
123 | return getReaderText(reader);
124 | }
125 |
126 | public static String getFileExtension(File file) {
127 | String fileName = file.getName();
128 | int lastIdx = fileName.lastIndexOf(".");
129 | if (lastIdx != -1 && lastIdx != 0) {
130 | return fileName.substring(lastIdx + 1);
131 | }
132 | else {
133 | return "";
134 | }
135 | }
136 |
137 | }
138 |
--------------------------------------------------------------------------------
/1-hi-utils/src/main/java/com/helpinput/core/LoggerBase.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | /**
18 | *@Author: niaoge(Zhengsheng Xia)
19 | *@Email 78493244@qq.com
20 | *@Date: 2015-6-10
21 | */
22 | package com.helpinput.core;
23 |
24 |
25 | import org.slf4j.Logger;
26 | import org.slf4j.LoggerFactory;
27 |
28 |
29 | public class LoggerBase {
30 | public static final Logger logger =LoggerFactory.getLogger(LoggerBase.class);
31 | }
32 |
--------------------------------------------------------------------------------
/1-hi-utils/src/main/java/com/helpinput/core/MD5.java:
--------------------------------------------------------------------------------
1 | package com.helpinput.core;
2 |
3 | import java.security.*;
4 |
5 | public class MD5 {
6 | public final static String encode(String s) {
7 | if(s==null){
8 | return null;
9 | }
10 | char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
11 | 'a', 'b', 'c', 'd', 'e', 'f' };
12 | try {
13 | byte[] strTemp = s.getBytes();
14 | MessageDigest mdTemp = MessageDigest.getInstance("MD5");
15 | mdTemp.update(strTemp);
16 | byte[] md = mdTemp.digest();
17 | int j = md.length;
18 | char str[] = new char[j * 2];
19 | int k = 0;
20 | for (int i = 0; i < j; i++) {
21 | byte byte0 = md[i];
22 | str[k++] = hexDigits[byte0 >>> 4 & 0xf];
23 | str[k++] = hexDigits[byte0 & 0xf];
24 | }
25 | return new String(str);
26 | } catch (Exception e) {
27 | return null;
28 | }
29 | }
30 |
31 | public static void main(String[] args) {
32 | System.out.println(encode("jhkj"));
33 | }
34 | }
--------------------------------------------------------------------------------
/1-hi-utils/src/main/java/com/helpinput/core/MapConvertor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | /**
18 | *@Author: niaoge(Zhengsheng Xia)
19 | *@Email 78493244@qq.com
20 | *@Date: 2015-6-10
21 | */
22 | package com.helpinput.core;
23 |
24 | import java.lang.reflect.Method;
25 | import java.text.ParseException;
26 | import java.util.HashMap;
27 | import java.util.Iterator;
28 | import java.util.Map;
29 |
30 | import org.json.JSONException;
31 | import org.json.JSONObject;
32 |
33 | /**
34 | * 转换器 1:将JavaBean 转换成Map、JSONObject 2:将JSONObject 转换成Map
35 | *
36 | */
37 | public class MapConvertor {
38 | /**
39 | * 将javaBean转换成Map
40 | *
41 | * @param javaBean
42 | * javaBean
43 | * @return Map对象
44 | */
45 | public static Map toMap(Object javaBean) {
46 | Map result = new HashMap();
47 | Method[] methods = javaBean.getClass().getDeclaredMethods();
48 |
49 | for (Method method : methods) {
50 | try {
51 | if (method.getName().startsWith("get")) {
52 | String field = method.getName();
53 | field = field.substring(field.indexOf("get") + 3);
54 | field = field.toLowerCase().charAt(0) + field.substring(1);
55 |
56 | Object value = method.invoke(javaBean, (Object[]) null);
57 | result.put(field, null == value ? "" : value.toString());
58 | }
59 | }
60 | catch (Exception e) {
61 | }
62 | }
63 |
64 | return result;
65 | }
66 |
67 | /**
68 | * 将json对象转换成Map
69 | *
70 | * @param jsonObject
71 | * json对象
72 | * @return Map对象
73 | * @throws JSONException
74 | */
75 | public static Map toMap(JSONObject jsonObject) throws JSONException {
76 | Map result = new HashMap();
77 | @SuppressWarnings("unchecked")
78 | Iterator iterator = jsonObject.keys();
79 | String key = null;
80 | String value = null;
81 | while (iterator.hasNext()) {
82 | key = iterator.next();
83 | value = jsonObject.getString(key);
84 | result.put(key, value);
85 | }
86 | return result;
87 | }
88 |
89 | /**
90 | * 将javaBean转换成JSONObject
91 | *
92 | * @param bean
93 | * javaBean
94 | * @return json对象
95 | */
96 | public static JSONObject toJSON(Object bean) {
97 | return new JSONObject(toMap(bean));
98 | }
99 |
100 | public static String methodNameGetFieldName(String methodName) {
101 | StringBuffer sb = new StringBuffer();
102 | sb.append(Character.toLowerCase(methodName.charAt(3)));
103 | sb.append(methodName.substring(4));
104 | return sb.toString();
105 | }
106 |
107 | /**
108 | * 将map转换成Javabean
109 | *
110 | * @param javabean
111 | * javaBean
112 | * @param values
113 | * map数据
114 | */
115 | public static Object toJavaBean(Object javabean, Map, ?> data) {
116 | Method[] methods = javabean.getClass().getDeclaredMethods();
117 | for (Method method : methods) {
118 | try {
119 | if (method.getName().startsWith("set")) {
120 | Class>[] parmaTypes = method.getParameterTypes();
121 | if (parmaTypes.length == 1) {
122 | String fieldName = methodNameGetFieldName(method.getName());
123 | Object value = Utils.convert(data.get(fieldName), parmaTypes[0]);
124 | method.invoke(javabean, value);
125 | // String field = method.getName();
126 | // field = field.substring(field.indexOf("set") + 3);
127 | // field = field.toLowerCase().charAt(0) + field.substring(1);
128 | // method.invoke(javabean, new Object[] { data.get(field) });
129 | }
130 | }
131 | }
132 | catch (Exception e) {
133 | }
134 | }
135 | return javabean;
136 | }
137 |
138 | public static Object toJavaBeanNotClean(Object javabean, Map, ?> data) {
139 | Method[] methods = javabean.getClass().getDeclaredMethods();
140 | for (Method method : methods) {
141 | try {
142 | if (method.getName().startsWith("set")) {
143 | String fieldName = methodNameGetFieldName(method.getName());
144 | Object object = data.get(fieldName);
145 | if (object != null)
146 | method.invoke(javabean, object);
147 | // String field = method.getName();
148 | // field = field.substring(field.indexOf("set") + 3);
149 | // field = field.toLowerCase().charAt(0) + field.substring(1);
150 | // method.invoke(javabean, new Object[] { data.get(field) });
151 | }
152 | }
153 | catch (Exception e) {
154 | }
155 | }
156 | return javabean;
157 | }
158 |
159 | public static boolean checkHasFieldName(Object javabean, String fieldName) {
160 | Method[] methods = javabean.getClass().getDeclaredMethods();
161 | for (Method method : methods) {
162 | try {
163 | if (method.getName().startsWith("set")) {
164 | String scanedFieldName = methodNameGetFieldName(method.getName());
165 | if (scanedFieldName.equals(fieldName))
166 | return true;
167 | }
168 | }
169 | catch (Exception e) {
170 | }
171 | }
172 | return false;
173 | }
174 |
175 | /**
176 | * 将javaBean转换成JSONObject
177 | *
178 | * @param bean
179 | * javaBean
180 | * @return json对象
181 | * @throws ParseException
182 | * json解析异常
183 | * @throws JSONException
184 | */
185 | public static void toJavaBean(Object javabean, String data) throws ParseException, JSONException {
186 | JSONObject jsonObject = new JSONObject(data);
187 | Map datas = toMap(jsonObject);
188 | toJavaBean(javabean, datas);
189 | }
190 | }
191 |
--------------------------------------------------------------------------------
/1-hi-utils/src/main/java/com/helpinput/core/PathUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | /**
18 | *@Author: niaoge(Zhengsheng Xia)
19 | *@Email 78493244@qq.com
20 | *@Date: 2015-6-10
21 | */
22 | package com.helpinput.core;
23 |
24 | import java.util.ArrayList ;
25 | import java.util.List;
26 |
27 | import org.apache.commons.lang.StringUtils;
28 |
29 | import static com.helpinput.core.LoggerBase.logger;
30 |
31 |
32 | /**
33 | * 类 名: PathUtils 描 述: 对于路径问题处理的工具类 作 者: Vv 创 建: 2012-11-29 版 本:
34 | * 历 史: (版本) 作者 时间 注释
35 | */
36 | public class PathUtil {
37 | public static final String PATH_OLD_SPLIT = "\\\\";
38 | public static final String PATH_OTHER_SPLIT = "//";
39 | public static final String PATH_SPLIT = "/";
40 | public static final String UPPER_PATH = "..";
41 | public static final String PATH_HTML = "http://";
42 |
43 | /**
44 | *
45 | * 描 述:追加目录 作 者:Vv 历 史: (版本) 作者 时间 注释
46 | *
47 | * @param parentPath
48 | * 上级目录 如:D:/AA
49 | * @param subPath
50 | * 子目录 如:BB
51 | * @return 以目录名结尾 如: D:/AA/BB
52 | */
53 | public static String appendPath(String parentPath, String subPath) {
54 |
55 | if (StringUtils.isNotBlank(parentPath) && !parentPath.endsWith(PATH_SPLIT)) {
56 | parentPath += PATH_SPLIT;
57 | }
58 | if (StringUtils.isNotBlank(subPath)) {
59 | parentPath = parentPath + subPath;
60 | }
61 |
62 | return processPath(parentPath);
63 | }
64 |
65 | /**
66 | *
67 | * 描 述:根据当前路径获取目标路径的相对路径(传入参数为绝对路径) 算法: 1.将路径分割为文件名的数组
68 | * 2.循环当前目录(currentPath)的文件名数组,分别与目标路径(targetPath)的文件数组里的同一位置(索引值i相同)比较
69 | * 2a.如果同一索引值对应的文件夹名相同,则表示存在相对路径,循环继续(continue),直到一索引值对应的文件夹名不相同时,跳出循环
70 | * 2b.如果两个路径的起始部分不一致,则表示不存在相对路径,返回目标路径 3.根据2中循环结束时的索引值,获取相对路径文件名的集合并组成String
71 | * 作 者:Vv 历 史: (版本) 作者 时间 注释
72 | *
73 | * @param currentPath
74 | * @param targetPath
75 | * @return 存在相对路径,则返回相对路径;否则,返回目标路径
76 | * @throws ProcessPathException
77 | */
78 | public static String getRelativePath(String currentPath, String targetPath) {
79 | if (StringUtils.isBlank(currentPath) || StringUtils.isBlank(targetPath)) {
80 | logger.error("The currentPath or targetPath parameter is required and can't be null or blank.");
81 | return currentPath;
82 | }
83 | currentPath = processPath(currentPath);
84 | targetPath = processPath(targetPath);
85 |
86 | String[] cpNames = currentPath.split(PATH_SPLIT);
87 | String[] tpNames = targetPath.split(PATH_SPLIT);
88 |
89 | List rpNames = new ArrayList();
90 |
91 | /**
92 | * 2.循环当前目录(currentPath)的文件名数组,分别与目标路径(targetPath)的文件数组里的同一位置(索引值i相同)比较
93 | * 2a.如果同一索引值对应的文件夹名相同,则表示存在相对路径,循环继续(continue),直到一索引值对应的文件夹名不相同时,跳出循环
94 | * 2b.如果两个路径的起始部分不一致,则表示不存在相对路径,返回目标路径
95 | */
96 | int i = 0;
97 | for (i = 0; i < cpNames.length; i++) {
98 | if (i > tpNames.length - 1)
99 | break;
100 |
101 | if (cpNames[i].equals(tpNames[i])) {
102 | continue;
103 | }
104 | else if (i == 0) {// 如果currentPath与targetPath的起始目录不相同,则说明不存在相对路径
105 | break;
106 | }
107 | else {
108 | rpNames.add(UPPER_PATH);
109 | break;
110 | }
111 | }
112 |
113 | /**
114 | * 3.根据2中循环结束时的索引值 "i",获取相对路径文件名的集合并组成String
115 | */
116 | for (int j = i; j < tpNames.length; j++) {
117 | rpNames.add(tpNames[j]);
118 | }
119 |
120 | String relativePath = "";
121 | for (String rp : rpNames) {
122 | relativePath = relativePath + rp + PATH_SPLIT;
123 | }
124 |
125 | return processPath(relativePath);
126 | }
127 |
128 | /**
129 | * 描 述:处理路径问题 如:传入 ///localhost//uuzz/admin/main.action; 返回
130 | * /localhost/uuzz/admin/main.action 作 者:Vv 历 史: (版本) 作者 时间 注释
131 | *
132 | * @param path
133 | * @return
134 | */
135 | public static String processPath(String path) {
136 | path = path.replaceAll(PATH_OLD_SPLIT, PATH_SPLIT);
137 | if (path.endsWith(PATH_SPLIT)) {
138 | path = path.substring(0, path.length() - 1);
139 | }
140 |
141 | boolean isHttp = false;
142 | if (path.startsWith(PATH_HTML)) {
143 | isHttp = true;
144 | path = path.substring(PATH_HTML.length());
145 | }
146 |
147 | // 循环处理,将"//"替换为"/"
148 | while (path.contains(PATH_OTHER_SPLIT)) {
149 | path = path.replaceAll(PATH_OTHER_SPLIT, PATH_SPLIT);
150 | }
151 |
152 | if (isHttp) {
153 | path = PATH_HTML + path;
154 | }
155 |
156 | return path;
157 | }
158 | }
159 |
--------------------------------------------------------------------------------
/1-hi-utils/src/main/java/com/helpinput/core/WebPathUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | /**
18 | *@Author: niaoge(Zhengsheng Xia)
19 | *@Email 78493244@qq.com
20 | *@Date: 2015-6-10
21 | */
22 | package com.helpinput.core;
23 |
24 | import static com.helpinput.core.Consts.*;
25 |
26 |
27 | public class WebPathUtils {
28 | public static final String classpath;
29 | public static final String webInfPath;
30 | public static final String webRoot;
31 | static {
32 | classpath = Thread.currentThread().getContextClassLoader().getResource("").getPath();
33 | String dest = classpath;
34 | if (dest.indexOf(WEB_INF) > 0) {
35 | dest = dest.substring(0, dest.indexOf(WEB_INF) + 8);
36 | }
37 | webInfPath = dest;
38 |
39 | dest = classpath;
40 | if (dest.indexOf(WEB_INF) > 0) {
41 | dest = dest.substring(0, dest.indexOf(WEB_INF_CLASSES));
42 | }
43 | webRoot = dest;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/1-hi-utils/src/main/java/com/helpinput/maps/CaseInsensitiveHashMap.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | /**
18 | *@Author: niaoge(Zhengsheng Xia)
19 | *@Email 78493244@qq.com
20 | *@Date: 2015-6-10
21 | */
22 |
23 |
24 | package com.helpinput.maps;
25 |
26 | import java.util.HashMap;
27 | import java.util.LinkedHashMap;
28 | import java.util.Locale;
29 | import java.util.Map;
30 |
31 |
32 | public class CaseInsensitiveHashMap extends LinkedHashMap {
33 |
34 | private static final long serialVersionUID = 1L;
35 |
36 |
37 | private final Map caseInsensitiveKeys;
38 |
39 | private final Locale locale;
40 |
41 |
42 |
43 | public CaseInsensitiveHashMap() {
44 | this(null);
45 | }
46 |
47 |
48 | public CaseInsensitiveHashMap(Locale locale) {
49 | super();
50 | this.caseInsensitiveKeys = new HashMap();
51 | this.locale = (locale != null ? locale : Locale.getDefault());
52 | }
53 |
54 |
55 | public CaseInsensitiveHashMap(int initialCapacity) {
56 | this(initialCapacity, null);
57 | }
58 |
59 | public CaseInsensitiveHashMap(int initialCapacity, Locale locale) {
60 | super(initialCapacity);
61 | this.caseInsensitiveKeys = new HashMap(initialCapacity);
62 | this.locale = (locale != null ? locale : Locale.getDefault());
63 | }
64 |
65 |
66 |
67 | @Override
68 | public V put(String key, V value) {
69 | String oldKey = this.caseInsensitiveKeys.put(convertKey(key), key);
70 | if (oldKey != null && !oldKey.equals(key)) {
71 | super.remove(oldKey);
72 | }
73 | return super.put(key, value);
74 | }
75 |
76 |
77 | @Override
78 | public void putAll(Map extends String, ? extends V> map) {
79 | if (map.isEmpty()) {
80 | return;
81 | }
82 | for (Map.Entry extends String, ? extends V> entry : map.entrySet()) {
83 | put(entry.getKey(), entry.getValue());
84 | }
85 | }
86 |
87 |
88 | @Override
89 | public boolean containsKey(Object key) {
90 | return (key instanceof String && this.caseInsensitiveKeys.containsKey(convertKey((String) key)));
91 | }
92 |
93 |
94 | @Override
95 | public V get(Object key) {
96 | if (key instanceof String) {
97 | return super.get(this.caseInsensitiveKeys.get(convertKey((String) key)));
98 | }
99 | else {
100 | return null;
101 | }
102 | }
103 |
104 |
105 | @Override
106 | public V remove(Object key) {
107 | if (key instanceof String ) {
108 | return super.remove(this.caseInsensitiveKeys.remove(convertKey((String) key)));
109 | }
110 | else {
111 | return null;
112 | }
113 | }
114 |
115 |
116 | @Override
117 | public void clear() {
118 | this.caseInsensitiveKeys.clear();
119 | super.clear();
120 | }
121 |
122 |
123 |
124 | protected String convertKey(String key) {
125 | return key.toLowerCase(this.locale);
126 | }
127 |
128 | }
--------------------------------------------------------------------------------
/1-hi-utils/src/main/java/com/helpinput/maps/ConcurrentCaseInsensitiveHashMap.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | /**
18 | *@Author: niaoge(Zhengsheng Xia)
19 | *@Email 78493244@qq.com
20 | *@Date: 2015-6-10
21 | */
22 |
23 | package com.helpinput.maps;
24 |
25 | import java.util.Map;
26 |
27 | import org.slf4j.Logger;
28 |
29 | import com.helpinput.core.LoggerBase;
30 |
31 |
32 |
33 | public class ConcurrentCaseInsensitiveHashMap extends ConcurrentMap {
34 | private static final long serialVersionUID = 1L;
35 | public static Logger logger=LoggerBase.logger;
36 |
37 | private final ConcurrentMap caseInsensitiveKeys;
38 |
39 |
40 |
41 | /**
42 | * Create a new LinkedCaseInsensitiveMap for the default Locale.
43 | * @see java.lang.String#toLowerCase()
44 | */
45 | public ConcurrentCaseInsensitiveHashMap() {
46 | super();
47 | this.caseInsensitiveKeys = new ConcurrentMap();
48 | }
49 |
50 |
51 | /**
52 | * Create a new LinkedCaseInsensitiveMap that wraps a {@link LinkedHashMap}
53 | * with the given initial capacity and stores lower-case keys according
54 | * to the default Locale.
55 | * @param initialCapacity the initial capacity
56 | * @see java.lang.String#toLowerCase()
57 | */
58 | public ConcurrentCaseInsensitiveHashMap(int initialCapacity) {
59 | super(initialCapacity);
60 | this.caseInsensitiveKeys = new ConcurrentMap();
61 | }
62 |
63 |
64 |
65 | @Override
66 | public V put(String key, V value) {
67 | String oldKey = this.caseInsensitiveKeys.put(convertKey(key), key);
68 | if (oldKey != null && !oldKey.equals(key)) {
69 | super.remove(oldKey);
70 | }
71 | return super.put(key, value);
72 | }
73 |
74 | @Override
75 | public void putAll(Map extends String, ? extends V> map) {
76 | if (map.isEmpty()) {
77 | return;
78 | }
79 | for (Map.Entry extends String, ? extends V> entry : map.entrySet()) {
80 | put(entry.getKey(), entry.getValue());
81 | }
82 | }
83 |
84 | @Override
85 | public boolean containsKey(Object key) {
86 | return (key instanceof String && this.caseInsensitiveKeys.containsKey(convertKey((String) key)));
87 | }
88 |
89 | @Override
90 | public V get(Object key) {
91 | if (key instanceof String) {
92 | return super.get(this.caseInsensitiveKeys.get(convertKey((String)key)));
93 | }
94 | else {
95 | return null;
96 | }
97 | }
98 |
99 | @Override
100 | public V remove(Object key) {
101 | if (key instanceof String ) {
102 | return super.remove(this.caseInsensitiveKeys.remove(convertKey((String) key)));
103 | }
104 | else {
105 | return null;
106 | }
107 | }
108 |
109 | @Override
110 | public void clear() {
111 | this.caseInsensitiveKeys.clear();
112 | super.clear();
113 | }
114 |
115 |
116 | /**
117 | * Convert the given key to a case-insensitive key.
118 | *
The default implementation converts the key
119 | * to lower-case according to this Map's Locale.
120 | * @param key the user-specified key
121 | * @return the key to use for storing
122 | * @see java.lang.String#toLowerCase(java.util.Locale)
123 | */
124 | protected String convertKey(String key) {
125 | return key.toLowerCase();
126 | }
127 |
128 | }
--------------------------------------------------------------------------------
/1-hi-utils/src/main/java/com/helpinput/maps/ConcurrentHashSet.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | /**
18 | *@Author: niaoge(Zhengsheng Xia)
19 | *@Email 78493244@qq.com
20 | *@Date: 2015-6-10
21 | */
22 |
23 | package com.helpinput.maps;
24 |
25 |
26 | import java.util.Collection;
27 | import java.util.concurrent.ConcurrentHashMap;
28 | import java.util.concurrent.ConcurrentMap;
29 |
30 | public class ConcurrentHashSet extends MapBackedSet {
31 |
32 | private static final long serialVersionUID = 8518578988740277828L;
33 |
34 | public ConcurrentHashSet() {
35 | super(new ConcurrentHashMap());
36 | }
37 |
38 | public ConcurrentHashSet(Collection c) {
39 | super(new ConcurrentHashMap(), c);
40 | }
41 |
42 | @Override
43 | public boolean add(E o) {
44 | Boolean answer = ((ConcurrentMap) map).putIfAbsent(o, Boolean.TRUE);
45 | return answer == null;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/1-hi-utils/src/main/java/com/helpinput/maps/ConcurrentMap.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | /**
18 | *@Author: niaoge(Zhengsheng Xia)
19 | *@Email 78493244@qq.com
20 | *@Date: 2015-6-10
21 | */
22 |
23 | package com.helpinput.maps;
24 |
25 | import java.util.concurrent.ConcurrentHashMap;
26 |
27 | public class ConcurrentMap extends ConcurrentHashMap{
28 | private static final long serialVersionUID = 1L;
29 |
30 | public ConcurrentMap() {
31 | super();
32 | }
33 |
34 | public ConcurrentMap(int initialCapacity) {
35 | super(initialCapacity);
36 | }
37 |
38 |
39 | @Override
40 | public V get(Object key) {
41 | if (key==null)
42 | return null;
43 | return super.get(key);
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/1-hi-utils/src/main/java/com/helpinput/maps/MapBackedSet.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | /**
18 | *@Author: niaoge(Zhengsheng Xia)
19 | *@Email 78493244@qq.com
20 | *@Date: 2015-6-10
21 | */
22 | package com.helpinput.maps;
23 |
24 | import java.io.Serializable;
25 | import java.util.AbstractSet;
26 | import java.util.Collection;
27 | import java.util.Iterator;
28 | import java.util.Map;
29 |
30 | public class MapBackedSet extends AbstractSet implements Serializable {
31 |
32 | private static final long serialVersionUID = -8347878570391674042L;
33 |
34 | protected final Map map;
35 |
36 | public MapBackedSet(Map map) {
37 | this.map = map;
38 | }
39 |
40 | public MapBackedSet(Map map, Collection c) {
41 | this.map = map;
42 | addAll(c);
43 | }
44 |
45 | @Override
46 | public int size() {
47 | return map.size();
48 | }
49 |
50 | @Override
51 | public boolean contains(Object o) {
52 | return map.containsKey(o);
53 | }
54 |
55 | @Override
56 | public Iterator iterator() {
57 | return map.keySet().iterator();
58 | }
59 |
60 | @Override
61 | public boolean add(E o) {
62 | return map.put(o, Boolean.TRUE) == null;
63 | }
64 |
65 | @Override
66 | public boolean remove(Object o) {
67 | return map.remove(o) != null;
68 | }
69 |
70 | @Override
71 | public void clear() {
72 | map.clear();
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/1-hi-utils/src/main/java/com/helpinput/maps/OnceMap.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | /**
18 | *@Author: niaoge(Zhengsheng Xia)
19 | *@Email 78493244@qq.com
20 | *@Date: 2015-6-10
21 | */
22 | package com.helpinput.maps;
23 |
24 | import java.util.Map;
25 |
26 |
27 |
28 | public class OnceMap extends RequestValues {
29 | private static final long serialVersionUID = 1L;
30 | //private static Logger logger = LoggerBase.logger;
31 |
32 | private String ownKey;
33 | private Map parent;
34 |
35 | public OnceMap(String ownKey, Map parent) {
36 | this.ownKey = ownKey;
37 | this.parent = parent;
38 | parent.put(ownKey, this);
39 |
40 | }
41 |
42 | /* (non-Javadoc)
43 | * @see com.helpinput.map.CaseInsensitiveHashMap#get(java.lang.Object)
44 | */
45 | public Object get(Object key) {
46 | Object result = remove(key);
47 | if (this.size() == 0) {
48 | this.parent.remove(ownKey);
49 | }
50 | return result;
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/1-hi-utils/src/main/java/com/helpinput/maps/RequestValues.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | /**
18 | *@Author: niaoge(Zhengsheng Xia)
19 | *@Email 78493244@qq.com
20 | *@Date: 2015-6-10
21 | */
22 | package com.helpinput.maps;
23 |
24 | import com.helpinput.core.Utils;
25 |
26 | /** Map,内装从数据库转换的数据,key:fieldName,object:values 有顺序,不区分大小写
27 | *
28 | * @param */
29 | public class RequestValues extends CaseInsensitiveHashMap