Skip to content

Commit 8e3fd43

Browse files
committed
init some utils
1 parent 9fba997 commit 8e3fd43

File tree

9 files changed

+232
-3
lines changed

9 files changed

+232
-3
lines changed

.project

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>CodeFactory</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.m2e.core.maven2Builder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
21+
<nature>org.eclipse.jdt.core.javanature</nature>
22+
</natures>
23+
</projectDescription>

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
codeGenerator
1+
䍯摥䙡捴潲礊㴽㴽㴽㴽㴽㴽㴊듺싫ퟔ뚯짺돉릤뻟�
22
=============
3-
4-
codeGenerator
3+
�����Զ����ɹ���

pom.xml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>org.luckystars</groupId>
6+
<artifactId>CodeFactory</artifactId>
7+
<version>1.0.0-SNAPSHOT</version>
8+
<packaging>jar</packaging>
9+
<build>
10+
<sourceDirectory>src/main/java</sourceDirectory>
11+
<testSourceDirectory>src/test/java</testSourceDirectory>
12+
<outputDirectory>build/classes</outputDirectory>
13+
<testOutputDirectory>build/test-classes</testOutputDirectory>
14+
<directory>build</directory>
15+
<resources>
16+
<resource>
17+
<directory>resource</directory>
18+
</resource>
19+
<resource>
20+
<directory>overview</directory>
21+
</resource>
22+
</resources>
23+
<testResources>
24+
<testResource>
25+
<directory>resource</directory>
26+
</testResource>
27+
<testResource>
28+
<directory>overview</directory>
29+
</testResource>
30+
</testResources>
31+
<plugins>
32+
<plugin>
33+
<groupId>org.apache.maven.plugins</groupId>
34+
<artifactId>maven-compiler-plugin</artifactId>
35+
<configuration>
36+
<source>1.6</source>
37+
<target>1.6</target>
38+
</configuration>
39+
</plugin>
40+
<plugin>
41+
<groupId>org.apache.maven.plugins</groupId>
42+
<artifactId>maven-resources-plugin</artifactId>
43+
<configuration>
44+
<encoding>UTF-8</encoding>
45+
</configuration>
46+
</plugin>
47+
<plugin>
48+
<artifactId>maven-surefire-plugin</artifactId>
49+
<version>2.7.1</version>
50+
<configuration>
51+
<skipTests>true</skipTests>
52+
</configuration>
53+
</plugin>
54+
</plugins>
55+
</build>
56+
<name>CodeFactory</name>
57+
<url>http://maven.apache.org</url>
58+
59+
<properties>
60+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
61+
</properties>
62+
63+
<dependencies>
64+
<dependency>
65+
<groupId>junit</groupId>
66+
<artifactId>junit</artifactId>
67+
<version>4.8</version>
68+
<scope>test</scope>
69+
</dependency>
70+
<dependency>
71+
<groupId>org.jdesktop</groupId>
72+
<artifactId>swing-layout</artifactId>
73+
<version>1.0.3</version>
74+
</dependency>
75+
<dependency>
76+
<groupId>org.netbeans</groupId>
77+
<artifactId>awtextra</artifactId>
78+
<version>1.0</version>
79+
</dependency>
80+
<dependency>
81+
<groupId>com.google.code.gson</groupId>
82+
<artifactId>gson</artifactId>
83+
<version>2.2.2</version>
84+
</dependency>
85+
<dependency>
86+
<groupId>commons-io</groupId>
87+
<artifactId>commons-io</artifactId>
88+
<version>2.4</version>
89+
</dependency>
90+
</dependencies>
91+
</project>

resource/config.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#一些配置
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package org.luckystars.codefactory;
2+
3+
public class Main {
4+
5+
public static void main(String[] args) {
6+
7+
}
8+
9+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package org.luckystars.codefactory.constants;
2+
3+
/**
4+
* 数据类型
5+
* @author xuechong
6+
*
7+
*/
8+
public enum DataType {
9+
10+
INT("int",0x1),
11+
STRING("str",0x2),
12+
BOOL("bool",0x3);
13+
14+
private final String name;
15+
private final int code;
16+
17+
DataType(String name,int code){
18+
this.name = name;
19+
this.code = code;
20+
}
21+
22+
public String getName() {
23+
return name;
24+
}
25+
public int getCode() {
26+
return code;
27+
}
28+
29+
public static DataType findByName(String name){
30+
for (DataType data : DataType.values()) {
31+
if(data.getName().equals(name)){
32+
return data;
33+
}
34+
}
35+
return null;
36+
}
37+
38+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package org.luckystars.codefactory.model;
2+
3+
public class TableContext {
4+
5+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package org.luckystars.codefactory.util;
2+
3+
import java.io.File;
4+
import java.io.IOException;
5+
import java.lang.reflect.Type;
6+
import java.net.URISyntaxException;
7+
import java.util.Collection;
8+
9+
import org.apache.commons.io.FileUtils;
10+
11+
import com.google.gson.Gson;
12+
13+
public class JsonUtil {
14+
15+
private static final Gson gson = new Gson();
16+
17+
public static Collection<?> getObjList(Type type,String filePath){
18+
return gson.fromJson(loadFile(filePath), type);
19+
}
20+
/**
21+
* get String from json file
22+
* @param filePath
23+
* @return
24+
* @author xuechong
25+
*/
26+
private static String loadFile(String filePath){
27+
try {
28+
return FileUtils.readFileToString(
29+
new File(
30+
Thread.currentThread().getContextClassLoader().
31+
getResource(filePath).toURI()));
32+
} catch (IOException e) {
33+
e.printStackTrace();
34+
return "";
35+
} catch (URISyntaxException e) {
36+
e.printStackTrace();
37+
return "";
38+
}
39+
}
40+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package org.luckystars.codefactory.util;
2+
3+
import java.io.IOException;
4+
import java.util.Properties;
5+
6+
public class ProperiesUtil {
7+
8+
private static final String DEFAULT_LOCATION = "config.properties";
9+
10+
public static String get(String key){
11+
return get(key,DEFAULT_LOCATION);
12+
}
13+
14+
private static String get(String key, String fileName) {
15+
Properties propertie = new Properties();
16+
try {
17+
propertie.load(Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName));
18+
} catch (IOException e) {
19+
e.printStackTrace();
20+
}
21+
return propertie.getProperty(key);
22+
}
23+
}

0 commit comments

Comments
 (0)