diff --git a/pom.xml b/pom.xml
index 4ad1e43..b8e01a1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -15,6 +15,17 @@
UTF-8
+
+ org.apache.groovy
+ groovy
+ 4.0.21
+
+
+ com.ibm.icu
+ icu4j
+ 59.1
+
+
com.h2database
h2
diff --git a/src/main/java/space/caoshd/text_tools/Main.java b/src/main/java/space/caoshd/text_tools/Main.java
index ecc6ee1..05f43af 100644
--- a/src/main/java/space/caoshd/text_tools/Main.java
+++ b/src/main/java/space/caoshd/text_tools/Main.java
@@ -6,7 +6,11 @@ import space.caoshd.text_tools.service.LoadFileToDBService;
public class Main {
public static void main(String[] args) {
- String inputPath = "E:\\workspace\\text-tools\\src\\main\\resources\\data_more.csv";
+ // h2Sort();
+ }
+
+ static void h2Sort() {
+ String inputPath = "d:\\workspace\\text-tools\\data_more.csv";
LoadFileToDBService loadFileToDBService = new LoadFileToDBService();
DBAccessService dbAccessService = new DBAccessService();
loadFileToDBService.setDbAccessService(dbAccessService);
diff --git a/src/main/java/space/caoshd/text_tools/config/GlobalConfig.groovy b/src/main/java/space/caoshd/text_tools/config/GlobalConfig.groovy
new file mode 100644
index 0000000..54bb7c8
--- /dev/null
+++ b/src/main/java/space/caoshd/text_tools/config/GlobalConfig.groovy
@@ -0,0 +1,47 @@
+package space.caoshd.text_tools.config
+
+import space.caoshd.text_tools.util.FileUtils
+
+class GlobalConfig {
+
+ static String createWorkDir() {
+ String baseDir = getBaseDir()
+ String tempDir = "work"
+ return FileUtils.mkdir(baseDir, tempDir)
+ }
+
+ static String createSearchDir() {
+ String baseDir = createWorkDir()
+ String tempDir = "search"
+ return FileUtils.mkdir(baseDir, tempDir)
+ }
+
+ static String createMergeDir() {
+ String baseDir = createWorkDir()
+ String tempDir = "merge"
+ return FileUtils.mkdir(baseDir, tempDir)
+ }
+
+ static String createSliceDir() {
+ String baseDir = createWorkDir()
+ String tempDir = "slice"
+ return FileUtils.mkdir(baseDir, tempDir)
+ }
+
+ static String createSortDir() {
+ String baseDir = createWorkDir()
+ String tempDir = "sort"
+ return FileUtils.mkdir(baseDir, tempDir)
+ }
+
+ static String createDataDir() {
+ String baseDir = createWorkDir()
+ String tempDir = "data"
+ return FileUtils.mkdir(baseDir, tempDir)
+ }
+
+ static String getBaseDir() {
+ return System.getProperty("user.dir")
+ }
+
+}
diff --git a/src/main/java/space/caoshd/text_tools/config/ProjectConfig.java b/src/main/java/space/caoshd/text_tools/config/ProjectConfig.java
deleted file mode 100644
index fffb8ff..0000000
--- a/src/main/java/space/caoshd/text_tools/config/ProjectConfig.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package space.caoshd.text_tools.config;
-
-import space.caoshd.text_tools.util.FileUtils;
-
-public class ProjectConfig {
-
- public static String getAndCreateWorkDir() {
- String baseDir = getBaseDir();
- String tempDir = "work";
- return FileUtils.mkdir(baseDir, tempDir);
- }
-
- public static String getAndCreateMergeDir() {
- String baseDir = getAndCreateWorkDir();
- String tempDir = "merge";
- return FileUtils.mkdir(baseDir, tempDir);
- }
-
- public static String getAndCreateSliceDir() {
- String baseDir = getAndCreateWorkDir();
- String tempDir = "slice";
- return FileUtils.mkdir(baseDir, tempDir);
- }
-
- public static String getAndCreateSortDir() {
- String baseDir = getAndCreateWorkDir();
- String tempDir = "sort";
- return FileUtils.mkdir(baseDir, tempDir);
- }
-
- public static String getAndCreateDataDir() {
- String baseDir = getAndCreateWorkDir();
- String tempDir = "data";
- return FileUtils.mkdir(baseDir, tempDir);
- }
-
- public static String getBaseDir() {
- return System.getenv("user.dir");
- }
-
-}
diff --git a/src/main/java/space/caoshd/text_tools/model/FileItem.groovy b/src/main/java/space/caoshd/text_tools/model/FileItem.groovy
new file mode 100644
index 0000000..2ae3c22
--- /dev/null
+++ b/src/main/java/space/caoshd/text_tools/model/FileItem.groovy
@@ -0,0 +1,12 @@
+package space.caoshd.text_tools.model
+
+class FileItem {
+ String relativePath
+ String absolutePath
+ String relativeDir
+ String absoluteDir
+ String name
+ String baseName
+ Map context = [:]
+ List lineItems = []
+}
diff --git a/src/main/java/space/caoshd/text_tools/model/LineItem.groovy b/src/main/java/space/caoshd/text_tools/model/LineItem.groovy
new file mode 100644
index 0000000..f296058
--- /dev/null
+++ b/src/main/java/space/caoshd/text_tools/model/LineItem.groovy
@@ -0,0 +1,7 @@
+package space.caoshd.text_tools.model
+
+class LineItem {
+ String lineNum
+ String lineContent
+ String matchKeyword
+}
diff --git a/src/main/java/space/caoshd/text_tools/model/SearchOptions.groovy b/src/main/java/space/caoshd/text_tools/model/SearchOptions.groovy
new file mode 100644
index 0000000..7620acf
--- /dev/null
+++ b/src/main/java/space/caoshd/text_tools/model/SearchOptions.groovy
@@ -0,0 +1,14 @@
+package space.caoshd.text_tools.model
+
+import java.util.function.Predicate
+
+class SearchOptions {
+ String basePath
+ String scanPath
+ String outputFile
+ String scanWorkDir
+ Predicate predicate
+ List includeFilenameSuffixes = []
+ List excludeFilenameSuffixes = []
+ Boolean scanContent = Boolean.TRUE
+}
diff --git a/src/main/java/space/caoshd/text_tools/service/DBAccessService.java b/src/main/java/space/caoshd/text_tools/service/DBAccessService.java
index 2481a8b..57a305b 100644
--- a/src/main/java/space/caoshd/text_tools/service/DBAccessService.java
+++ b/src/main/java/space/caoshd/text_tools/service/DBAccessService.java
@@ -1,6 +1,6 @@
package space.caoshd.text_tools.service;
-import space.caoshd.text_tools.config.ProjectConfig;
+import space.caoshd.text_tools.config.GlobalConfig;
import java.sql.Connection;
import java.sql.DriverManager;
@@ -9,6 +9,7 @@ import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
+import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
@@ -74,7 +75,7 @@ public class DBAccessService {
if (memory) {
url = "jdbc:h2:mem:" + filename;
} else {
- String dataDir = ProjectConfig.getAndCreateDataDir();
+ String dataDir = GlobalConfig.createDataDir();
url = "jdbc:h2:file:" + dataDir + "/" + filename;
}
return url;
@@ -155,6 +156,7 @@ public class DBAccessService {
public List