Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Commit 22f33ed

Browse files
committed
init web.utils
0 parents  commit 22f33ed

25 files changed

Lines changed: 2149 additions & 0 deletions

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
target/
2+
overlays/
3+
*.idea
4+
*.iml
5+
*.settings
6+
*.classpath
7+
*.project
8+
**/use.bat
9+
src/test/
10+
src/main/generated-sources/
11+
/bin/
12+
*.factorypath

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Feihu Liu
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
## 常用web开发中的各类工具.
3+
4+
```$xml
5+
<dependency>
6+
<groupId>com.fhtiger.utils</groupId>
7+
<artifactId>web.utils</artifactId>
8+
<version>0.0.1-RELEASE</version>
9+
</dependency>
10+
```
11+
12+
# com.fhtiger.utils.webutils
13+
## EmailAssistant
14+
## HtmlConvert
15+
## KeysFind
16+
## MsgAssistant
17+
## TaskManager

pom.xml

Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<modelVersion>4.0.0</modelVersion>
3+
<groupId>com.fhtiger.utils</groupId>
4+
<artifactId>web.utils</artifactId>
5+
<version>0.0.1-SNAPSHOT</version>
6+
<name>web.utils</name>
7+
<description>Useful Utilities For Web Project</description>
8+
<licenses>
9+
<license>
10+
<name>MIT License</name>
11+
<url>http://www.opensource.org/licenses/mit-license.php</url>
12+
<distribution>repo</distribution>
13+
</license>
14+
</licenses>
15+
<scm>
16+
<tag>deploy/release</tag>
17+
<connection>https://github.com/ghostFlyTiger/web.utils.git</connection>
18+
<developerConnection>https://github.com/ghostFlyTiger/</developerConnection>
19+
<url>https://github.com/ghostFlyTiger/web.utils.git</url>
20+
</scm>
21+
<developers>
22+
<developer>
23+
<id>FlyTiger</id>
24+
<name>Feihu Liu</name>
25+
<email>guishizuiezhishi@163.com</email>
26+
<url>https://github.fhtiger.com</url>
27+
<organization>FlyTiger-zh_CN</organization>
28+
<roles>
29+
<role>manager</role>
30+
<role>developer</role>
31+
</roles>
32+
<timezone>+8</timezone>
33+
</developer>
34+
</developers>
35+
<properties>
36+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
37+
<jdk.version>1.8</jdk.version>
38+
<quartz-scheduler-job.version>2.3.0</quartz-scheduler-job.version>
39+
<common-eamil.version>1.5</common-eamil.version>
40+
<common-lang.version>2.5</common-lang.version>
41+
<common-collections.version>3.2.2</common-collections.version>
42+
<common-io.version>2.2</common-io.version>
43+
<log4j.version>2.7</log4j.version>
44+
<freemarker.version>2.3.28</freemarker.version>
45+
<simple.helper.version>0.0.1-RELEASE</simple.helper.version>
46+
</properties>
47+
<dependencies>
48+
<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
49+
<dependency>
50+
<groupId>javax.servlet</groupId>
51+
<artifactId>javax.servlet-api</artifactId>
52+
<version>3.1.0</version>
53+
<scope>provided</scope>
54+
</dependency>
55+
<dependency>
56+
<groupId>javax.validation</groupId>
57+
<artifactId>validation-api</artifactId>
58+
<version>1.1.0.Final</version>
59+
</dependency>
60+
<!-- https://mvnrepository.com/artifact/org.freemarker/freemarker -->
61+
<dependency>
62+
<groupId>org.freemarker</groupId>
63+
<artifactId>freemarker</artifactId>
64+
<version>${freemarker.version</version>
65+
</dependency>
66+
<!-- https://mvnrepository.com/artifact/org.quartz-scheduler/quartz -->
67+
<dependency>
68+
<groupId>org.quartz-scheduler</groupId>
69+
<artifactId>quartz</artifactId>
70+
<version>${quartz-scheduler-job.version}</version>
71+
</dependency>
72+
<dependency>
73+
<groupId>org.quartz-scheduler</groupId>
74+
<artifactId>quartz-jobs</artifactId>
75+
<version>${quartz-scheduler-job.version}</version>
76+
</dependency>
77+
<!-- EmailUtil 邮件发送支持包 -->
78+
<dependency>
79+
<groupId>org.apache.commons</groupId>
80+
<artifactId>commons-email</artifactId>
81+
<version>${common-eamil.version}</version>
82+
</dependency>
83+
<!-- commons-lang 工具包-->
84+
<dependency>
85+
<groupId>commons-lang</groupId>
86+
<artifactId>commons-lang</artifactId>
87+
<version>${common-lang.version}</version>
88+
</dependency>
89+
<!--commons-collections 工具包 -->
90+
<dependency>
91+
<groupId>commons-collections</groupId>
92+
<artifactId>commons-collections</artifactId>
93+
<version>${common-collections.version}</version>
94+
</dependency>
95+
<dependency>
96+
<groupId>commons-io</groupId>
97+
<artifactId>commons-io</artifactId>
98+
<version>${common-io.version}</version>
99+
</dependency>
100+
<!-- https://mvnrepository.com/artifact/eu.bitwalker/UserAgentUtils -->
101+
<!--客户端甄别-->
102+
<dependency>
103+
<groupId>eu.bitwalker</groupId>
104+
<artifactId>UserAgentUtils</artifactId>
105+
<version>1.21</version>
106+
</dependency>
107+
108+
<dependency>
109+
<groupId>com.fhtiger.utils</groupId>
110+
<artifactId>simple-helper-utils</artifactId>
111+
<version>${simple.helper.version}</version>
112+
<exclusions>
113+
<exclusion>
114+
<groupId>org.slf4j</groupId>
115+
<artifactId>slf4j-api</artifactId>
116+
</exclusion>
117+
</exclusions>
118+
</dependency>
119+
120+
<!-- Log4j -->
121+
<dependency>
122+
<groupId>org.apache.logging.log4j</groupId>
123+
<artifactId>log4j-api</artifactId>
124+
<version>${log4j.version}</version>
125+
</dependency>
126+
<dependency>
127+
<groupId>org.apache.logging.log4j</groupId>
128+
<artifactId>log4j-core</artifactId>
129+
<version>${log4j.version}</version>
130+
</dependency>
131+
132+
<dependency>
133+
<groupId>junit</groupId>
134+
<artifactId>junit</artifactId>
135+
<version>4.11</version>
136+
<scope>provided</scope>
137+
</dependency>
138+
<!-- 要多添加下面这个包,因为从4.11版本开始将下面的包分离出去了 -->
139+
<dependency>
140+
<groupId>org.hamcrest</groupId>
141+
<artifactId>hamcrest-core</artifactId>
142+
<version>1.3</version>
143+
<scope>provided</scope>
144+
</dependency>
145+
146+
</dependencies>
147+
<profiles>
148+
<profile>
149+
<id>deploy_release</id>
150+
<activation>
151+
<activeByDefault>true</activeByDefault>
152+
</activation>
153+
<distributionManagement>
154+
<repository>
155+
<id>FlyTiger</id>
156+
<name>fhtiger Release Repository</name>
157+
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
158+
</repository>
159+
<snapshotRepository>
160+
<id>FlyTiger</id>
161+
<name>fhtiger Snapshot Repository</name>
162+
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
163+
</snapshotRepository>
164+
</distributionManagement>
165+
<build>
166+
<plugins>
167+
<!-- GPG -->
168+
<plugin>
169+
<groupId>org.apache.maven.plugins</groupId>
170+
<artifactId>maven-gpg-plugin</artifactId>
171+
<version>1.6</version>
172+
<executions>
173+
<execution>
174+
<phase>verify</phase>
175+
<goals>
176+
<goal>sign</goal>
177+
</goals>
178+
</execution>
179+
</executions>
180+
</plugin>
181+
<!--编译包-->
182+
<plugin>
183+
<groupId>org.apache.maven.plugins</groupId>
184+
<artifactId>maven-compiler-plugin</artifactId>
185+
<configuration>
186+
<encoding>${project.build.sourceEncoding}</encoding>
187+
<source>${jdk.version}</source>
188+
<target>${jdk.version}</target>
189+
<compilerVersion>${jdk.version}</compilerVersion>
190+
<showWarnings>true</showWarnings>
191+
</configuration>
192+
</plugin>
193+
<!--javadoc包-->
194+
<plugin>
195+
<groupId>org.apache.maven.plugins</groupId>
196+
<artifactId>maven-javadoc-plugin</artifactId>
197+
<version>2.8.1</version>
198+
<configuration>
199+
<encoding>${project.build.sourceEncoding}</encoding>
200+
<charset>${project.build.sourceEncoding}</charset>
201+
<docencoding>${project.build.sourceEncoding}</docencoding>
202+
</configuration>
203+
<executions>
204+
<execution>
205+
<id>attach-javadocs</id>
206+
<goals>
207+
<goal>jar</goal>
208+
</goals>
209+
</execution>
210+
</executions>
211+
</plugin>
212+
<!--源码包-->
213+
<plugin>
214+
<groupId>org.apache.maven.plugins</groupId>
215+
<artifactId>maven-source-plugin</artifactId>
216+
<executions>
217+
<execution>
218+
<id>attach-sources</id>
219+
<goals>
220+
<goal>jar-no-fork</goal>
221+
</goals>
222+
</execution>
223+
</executions>
224+
</plugin>
225+
</plugins>
226+
</build>
227+
</profile>
228+
</profiles>
229+
230+
</project>
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package com.fhtiger.utils.web;
2+
3+
import eu.bitwalker.useragentutils.DeviceType;
4+
import eu.bitwalker.useragentutils.UserAgent;
5+
6+
/**
7+
* 客户端甄别
8+
*
9+
* @author LFH
10+
* @since 2019年01月09日 10:41
11+
*/
12+
public final class ClientExamineUtil {
13+
14+
/**
15+
* 获取用户代理对象
16+
* @return
17+
*/
18+
public static UserAgent getUserAgent(String userAgent){
19+
return UserAgent.parseUserAgentString(userAgent);
20+
}
21+
22+
/**
23+
* 获取设备类型
24+
* @return
25+
*/
26+
public static DeviceType getDeviceType(String userAgent){
27+
return getUserAgent(userAgent).getOperatingSystem().getDeviceType();
28+
}
29+
30+
/**
31+
* 是否是PC
32+
* @return
33+
*/
34+
public static boolean isPc(String userAgent){
35+
return DeviceType.COMPUTER.equals(getDeviceType(userAgent));
36+
}
37+
38+
/**
39+
* 是否是手机
40+
* @return
41+
*/
42+
public static boolean isMobile(String userAgent){
43+
return DeviceType.MOBILE.equals(getDeviceType(userAgent));
44+
}
45+
46+
/**
47+
* 是否是平板
48+
* @return
49+
*/
50+
public static boolean isTablet(String userAgent){
51+
return DeviceType.TABLET.equals(getDeviceType(userAgent));
52+
}
53+
54+
/**
55+
* 是否是手机和平板
56+
* @return
57+
*/
58+
public static boolean isMobileOrTablet(String userAgent){
59+
DeviceType deviceType = getDeviceType(userAgent);
60+
return DeviceType.MOBILE.equals(deviceType) || DeviceType.TABLET.equals(deviceType);
61+
}
62+
}

0 commit comments

Comments
 (0)