Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a7efd76c6 | ||
|
|
96a58bcda5 | ||
|
|
34ddd6f26e | ||
|
|
38dc53b484 | ||
|
|
547c036cdb | ||
|
|
a69651447c |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
.idea
|
.idea
|
||||||
|
*.iml
|
||||||
@@ -85,13 +85,13 @@ The framework is not the framework for beautifying UI, but to simplify the step
|
|||||||
- [ ] Data valication
|
- [ ] Data valication
|
||||||
- [ ] Optimize performance
|
- [ ] Optimize performance
|
||||||
|
|
||||||
## ~~Maven Repository~~
|
## Maven Repository
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.gitee.Biubiuyuyu</groupId>
|
<groupId>com.gitee.Biubiuyuyu</groupId>
|
||||||
<artifactId>javafx-plus</artifactId>
|
<artifactId>javafx-plus</artifactId>
|
||||||
<version>1.0.0-RELEASE</version>
|
<version>1.2.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -85,7 +85,7 @@
|
|||||||
- [ ] 键盘事件绑定
|
- [ ] 键盘事件绑定
|
||||||
- [ ] 优化性能
|
- [ ] 优化性能
|
||||||
|
|
||||||
## ~~Maven仓库地址~~
|
## Maven仓库地址
|
||||||
|
|
||||||
maven仓库中的JavaFX-Plus版本是较旧版本,建议使用最新发行版。
|
maven仓库中的JavaFX-Plus版本是较旧版本,建议使用最新发行版。
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ maven仓库中的JavaFX-Plus版本是较旧版本,建议使用最新发行版
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.gitee.Biubiuyuyu</groupId>
|
<groupId>com.gitee.Biubiuyuyu</groupId>
|
||||||
<artifactId>javafx-plus</artifactId>
|
<artifactId>javafx-plus</artifactId>
|
||||||
<version>1.0.0-RELEASE</version>
|
<version>1.2.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
## Git地址
|
## Git地址
|
||||||
|
|||||||
73
pom.xml
73
pom.xml
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
<groupId>com.gitee.Biubiuyuyu</groupId>
|
<groupId>com.gitee.Biubiuyuyu</groupId>
|
||||||
<artifactId>javafx-plus</artifactId>
|
<artifactId>javafx-plus</artifactId>
|
||||||
<version>1.2.0-RELEASE</version>
|
<version>1.2.1-SNAPSHOT</version>
|
||||||
<!-- packaging为pom时,不会加载resources 故注释-->
|
<!-- packaging为pom时,不会加载resources 故注释-->
|
||||||
<!-- <packaging>pom</packaging>-->
|
<!-- <packaging>pom</packaging>-->
|
||||||
|
|
||||||
@@ -19,30 +19,27 @@
|
|||||||
|
|
||||||
<description>this is javafx framework that simplified coding</description>
|
<description>this is javafx framework that simplified coding</description>
|
||||||
|
|
||||||
<distributionManagement>
|
<properties>
|
||||||
<repository>
|
<cglib.version>3.1</cglib.version>
|
||||||
<id>javafx-plus</id>
|
<junit.version>4.13.1</junit.version>
|
||||||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
<slf4j-log4j12.version>1.7.21</slf4j-log4j12.version>
|
||||||
</repository>
|
<tomcat.version>9.0.48</tomcat.version>
|
||||||
<snapshotRepository>
|
<commons-lang3.version>3.12.0</commons-lang3.version>
|
||||||
<id>javafx-plus</id>
|
<commons-io.version>2.11.0</commons-io.version>
|
||||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
</properties>
|
||||||
</snapshotRepository>
|
|
||||||
</distributionManagement>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- 第三方动态代理库 -->
|
<!-- 第三方动态代理库 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cglib</groupId>
|
<groupId>cglib</groupId>
|
||||||
<artifactId>cglib</artifactId>
|
<artifactId>cglib</artifactId>
|
||||||
<version>3.1</version>
|
<version>${cglib.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Junit单元测试 -->
|
<!-- Junit单元测试 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.11</version>
|
<version>${junit.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@@ -50,15 +47,39 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-log4j12</artifactId>
|
<artifactId>slf4j-log4j12</artifactId>
|
||||||
<version>1.7.21</version>
|
<version>${slf4j-log4j12.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.tomcat.embed</groupId>
|
<groupId>org.apache.tomcat.embed</groupId>
|
||||||
<artifactId>tomcat-embed-core</artifactId>
|
<artifactId>tomcat-embed-core</artifactId>
|
||||||
<version>9.0.29</version>
|
<version>${tomcat.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
<version>${commons-lang3.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
<version>${commons-io.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<distributionManagement>
|
||||||
|
<repository>
|
||||||
|
<id>javafx-plus</id>
|
||||||
|
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||||
|
</repository>
|
||||||
|
<snapshotRepository>
|
||||||
|
<id>javafx-plus</id>
|
||||||
|
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
|
||||||
|
</snapshotRepository>
|
||||||
|
</distributionManagement>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<!--配置Maven 对resource文件 过滤 -->
|
<!--配置Maven 对resource文件 过滤 -->
|
||||||
<resources>
|
<resources>
|
||||||
@@ -104,19 +125,11 @@
|
|||||||
</descriptorRefs>
|
</descriptorRefs>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
<!-- Source 开源 -->
|
||||||
</build>
|
|
||||||
|
|
||||||
<profiles>
|
|
||||||
<profile>
|
|
||||||
<id>release</id>
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<!-- Source -->
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
<version>2.2.1</version>
|
<version>3.0.1</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
@@ -126,6 +139,14 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>release</id>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
<!-- Javadoc -->
|
<!-- Javadoc -->
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import cn.edu.scau.biubiusuisui.utils.ClassUtil;
|
|||||||
import cn.edu.scau.biubiusuisui.utils.FileUtil;
|
import cn.edu.scau.biubiusuisui.utils.FileUtil;
|
||||||
import cn.edu.scau.biubiusuisui.utils.LogUtil;
|
import cn.edu.scau.biubiusuisui.utils.LogUtil;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -25,7 +26,6 @@ import java.util.Set;
|
|||||||
*/
|
*/
|
||||||
public class FXPlusApplication {
|
public class FXPlusApplication {
|
||||||
private static final IFXPlusLogger logger = FXPlusLoggerFactory.getLogger(FXPlusApplication.class);
|
private static final IFXPlusLogger logger = FXPlusLoggerFactory.getLogger(FXPlusApplication.class);
|
||||||
// Application
|
|
||||||
|
|
||||||
private static FXWindowParser windowAnnotationParser = new FXWindowParser();
|
private static FXWindowParser windowAnnotationParser = new FXWindowParser();
|
||||||
|
|
||||||
@@ -37,7 +37,11 @@ public class FXPlusApplication {
|
|||||||
|
|
||||||
public static void start(Class clazz, BeanBuilder beanBuilder) {
|
public static void start(Class clazz, BeanBuilder beanBuilder) {
|
||||||
logger.info("starting JavaFX-Plus Application");
|
logger.info("starting JavaFX-Plus Application");
|
||||||
|
try {
|
||||||
logger.info("\n" + FileUtil.readFileFromResources("banner.txt"));
|
logger.info("\n" + FileUtil.readFileFromResources("banner.txt"));
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
logger.error("\n read classpath:banner.txt error, you can ignore it");
|
||||||
|
}
|
||||||
// 初始化日志路径
|
// 初始化日志路径
|
||||||
LogUtil.initLog4jBase();
|
LogUtil.initLog4jBase();
|
||||||
|
|
||||||
@@ -56,15 +60,15 @@ public class FXPlusApplication {
|
|||||||
for (String dir : sets) {
|
for (String dir : sets) {
|
||||||
logger.info("scanning directory: " + dir);
|
logger.info("scanning directory: " + dir);
|
||||||
ClassUtil classUtil = new ClassUtil();
|
ClassUtil classUtil = new ClassUtil();
|
||||||
List<String> temps = classUtil.scanAllClassName(dir);
|
List<String> temps = null;
|
||||||
for (String className : temps) {
|
|
||||||
try {
|
try {
|
||||||
|
temps = classUtil.scanAllClassName(dir);
|
||||||
|
for (String className : temps) {
|
||||||
logger.info("loading class: " + className);
|
logger.info("loading class: " + className);
|
||||||
loadFXPlusClass(className, beanBuilder);
|
loadFXPlusClass(className, beanBuilder);
|
||||||
} catch (ClassNotFoundException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
} catch (UnsupportedEncodingException | ClassNotFoundException exception) {
|
||||||
|
logger.error("{}", exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import cn.edu.scau.biubiusuisui.function.DragWindowHandlerImpl;
|
|||||||
import cn.edu.scau.biubiusuisui.log.FXPlusLoggerFactory;
|
import cn.edu.scau.biubiusuisui.log.FXPlusLoggerFactory;
|
||||||
import cn.edu.scau.biubiusuisui.log.IFXPlusLogger;
|
import cn.edu.scau.biubiusuisui.log.IFXPlusLogger;
|
||||||
import cn.edu.scau.biubiusuisui.utils.FileUtil;
|
import cn.edu.scau.biubiusuisui.utils.FileUtil;
|
||||||
|
import cn.edu.scau.biubiusuisui.utils.IFxPlusConstants;
|
||||||
import cn.edu.scau.biubiusuisui.utils.ResourceBundleUtil;
|
import cn.edu.scau.biubiusuisui.utils.ResourceBundleUtil;
|
||||||
import cn.edu.scau.biubiusuisui.utils.StringUtil;
|
import cn.edu.scau.biubiusuisui.utils.StringUtil;
|
||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
@@ -18,6 +19,7 @@ import javafx.stage.Stage;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -249,8 +251,8 @@ public class FXBaseController extends Pane {
|
|||||||
} else {
|
} else {
|
||||||
logger.warn("the icon file has not existed");
|
logger.warn("the icon file has not existed");
|
||||||
}
|
}
|
||||||
} catch (ProtocolNotSupport protocolNotSupport) {
|
} catch (ProtocolNotSupport | UnsupportedEncodingException exception) {
|
||||||
logger.error(protocolNotSupport.getMessage(), protocolNotSupport);
|
logger.error(exception.getMessage(), exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -281,7 +283,7 @@ public class FXBaseController extends Pane {
|
|||||||
if ("".equals(name) || name == null) { // 原本无“name == null”判断条件,会出错
|
if ("".equals(name) || name == null) { // 原本无“name == null”判断条件,会出错
|
||||||
return StringUtil.getBaseClassName(getClass().getSimpleName());
|
return StringUtil.getBaseClassName(getClass().getSimpleName());
|
||||||
} else {
|
} else {
|
||||||
return StringUtil.getBaseClassName(getClass().getSimpleName()) + "#" + name;
|
return StringUtil.getBaseClassName(getClass().getSimpleName()) + IFxPlusConstants.CONTROLLER_NAME_SEPARATOR + name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,9 +12,13 @@ import java.lang.reflect.Method;
|
|||||||
* @since JavaFX2.0 JDK1.8
|
* @since JavaFX2.0 JDK1.8
|
||||||
*/
|
*/
|
||||||
public class FXMethodEntity {
|
public class FXMethodEntity {
|
||||||
|
/**
|
||||||
|
* 所属Controller
|
||||||
|
*/
|
||||||
private FXBaseController fxBaseController;
|
private FXBaseController fxBaseController;
|
||||||
|
/**
|
||||||
|
* 实际方法
|
||||||
|
*/
|
||||||
private Method method;
|
private Method method;
|
||||||
|
|
||||||
public FXMethodEntity(FXBaseController fxBaseController, Method method) {
|
public FXMethodEntity(FXBaseController fxBaseController, Method method) {
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ public class FXPlusContext {
|
|||||||
controllers = new LinkedList<>();
|
controllers = new LinkedList<>();
|
||||||
}
|
}
|
||||||
controllers.add(fxBaseController);
|
controllers.add(fxBaseController);
|
||||||
|
// @since 1.2.1 fix: 没有将controller真正注册到context的异常
|
||||||
|
controllerContext.put(fxBaseController.getName(), controllers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,19 @@ import java.util.Map;
|
|||||||
* @since JavaFX2.0 JDK1.8
|
* @since JavaFX2.0 JDK1.8
|
||||||
*/
|
*/
|
||||||
public class FXRedirectParam {
|
public class FXRedirectParam {
|
||||||
|
/**
|
||||||
|
* 跳转的目标Controller
|
||||||
|
*/
|
||||||
private String toController;
|
private String toController;
|
||||||
|
/**
|
||||||
|
* query方式的参数, like: helloController?name=JavaFx-Plus&msg=helloWorld
|
||||||
|
* the map will store: { name -> JavaFx-Plus, msg -> helloWorld}
|
||||||
|
*/
|
||||||
private Map<String, Object> query = new HashMap<>();
|
private Map<String, Object> query = new HashMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* param方式的参数,会以map方式传递给目标Controller
|
||||||
|
*/
|
||||||
private Map<String, Object> params = new HashMap<>();
|
private Map<String, Object> params = new HashMap<>();
|
||||||
|
|
||||||
public FXRedirectParam(String toController) {
|
public FXRedirectParam(String toController) {
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package cn.edu.scau.biubiusuisui.log;
|
package cn.edu.scau.biubiusuisui.log;
|
||||||
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author suisui
|
* @author suisui
|
||||||
* @version 1.2
|
* @version 1.2
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package cn.edu.scau.biubiusuisui.utils;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@@ -22,7 +23,14 @@ public class ClassUtil {
|
|||||||
classLoader = getClass().getClassLoader();
|
classLoader = getClass().getClassLoader();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> getAllFXControllerClassName(String base, List<String> nameList) {
|
/**
|
||||||
|
* 获取所有FxController的类名
|
||||||
|
*
|
||||||
|
* @param base 基础目录路径
|
||||||
|
* @param nameList 类名列表
|
||||||
|
* @return 所有FXController的类名列表
|
||||||
|
*/
|
||||||
|
private List<String> getAllFXControllerClassName(String base, List<String> nameList) throws UnsupportedEncodingException {
|
||||||
String splashPath = StringUtil.dotToSplash(base);
|
String splashPath = StringUtil.dotToSplash(base);
|
||||||
URL url = classLoader.getResource(splashPath);
|
URL url = classLoader.getResource(splashPath);
|
||||||
String filePath = StringUtil.getRootPath(url);
|
String filePath = StringUtil.getRootPath(url);
|
||||||
@@ -42,7 +50,7 @@ public class ClassUtil {
|
|||||||
return nameList;
|
return nameList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> scanAllClassName(String base) {
|
public List<String> scanAllClassName(String base) throws UnsupportedEncodingException {
|
||||||
return getAllFXControllerClassName(base, new LinkedList<>());
|
return getAllFXControllerClassName(base, new LinkedList<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +70,9 @@ public class ClassUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static List<String> readFromDirectory(String path) {
|
private static List<String> readFromDirectory(String path) {
|
||||||
if (path == null) return null;
|
if (path == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return readFromFileDirectory(path);
|
return readFromFileDirectory(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,11 @@ package cn.edu.scau.biubiusuisui.utils;
|
|||||||
import cn.edu.scau.biubiusuisui.exception.ProtocolNotSupport;
|
import cn.edu.scau.biubiusuisui.exception.ProtocolNotSupport;
|
||||||
import cn.edu.scau.biubiusuisui.log.FXPlusLoggerFactory;
|
import cn.edu.scau.biubiusuisui.log.FXPlusLoggerFactory;
|
||||||
import cn.edu.scau.biubiusuisui.log.IFXPlusLogger;
|
import cn.edu.scau.biubiusuisui.log.IFXPlusLogger;
|
||||||
|
import org.apache.tomcat.util.http.fileupload.IOUtils;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.net.URLDecoder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jack
|
* @author jack
|
||||||
@@ -33,12 +35,28 @@ public class FileUtil {
|
|||||||
* @param filePath
|
* @param filePath
|
||||||
* @return
|
* @return
|
||||||
* @description 读取resources文件夹下的file,相对于resources的文件路径,如 resources/config.conf 则只需 config.conf
|
* @description 读取resources文件夹下的file,相对于resources的文件路径,如 resources/config.conf 则只需 config.conf
|
||||||
|
* @since 1.2.0 update: 使用getResourcesAsStream读取,屏蔽jar包读取障碍
|
||||||
*/
|
*/
|
||||||
public static String readFileFromResources(String filePath) {
|
public static String readFileFromResources(String filePath) throws UnsupportedEncodingException {
|
||||||
URL url = FileUtil.class.getClassLoader().getResource(filePath);
|
InputStream is = FileUtil.class.getClassLoader().getResourceAsStream(filePath);
|
||||||
if (url != null) {
|
if (is == null) {
|
||||||
String path = StringUtil.getRootPath(url);
|
return "";
|
||||||
return readFile(path);
|
}
|
||||||
|
StringBuffer content = new StringBuffer();
|
||||||
|
try (
|
||||||
|
InputStreamReader inputStreamReader = new InputStreamReader(is);
|
||||||
|
BufferedReader br = new BufferedReader(inputStreamReader);
|
||||||
|
) {
|
||||||
|
String temp;
|
||||||
|
while ((temp = br.readLine()) != null) {
|
||||||
|
// 一次读入一行数据
|
||||||
|
content.append(temp + "\r\n");
|
||||||
|
}
|
||||||
|
return content.toString();
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error("reading file error", e);
|
||||||
|
} finally {
|
||||||
|
IOUtils.closeQuietly(is);
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@@ -59,8 +77,7 @@ public class FileUtil {
|
|||||||
content.append(temp + "\r\n");
|
content.append(temp + "\r\n");
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error(e.getMessage());
|
logger.error("reading file error", e);
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
return content.toString();
|
return content.toString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package cn.edu.scau.biubiusuisui.utils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author suisui
|
||||||
|
* @version 1.2.0
|
||||||
|
* <p> Description: JavaFx-Plus常量 </p>
|
||||||
|
* @time 2021/9/5 10:36 下午
|
||||||
|
*/
|
||||||
|
public interface IFxPlusConstants {
|
||||||
|
/**
|
||||||
|
* 项目默认编码 UTF-8
|
||||||
|
*/
|
||||||
|
String DEFAULT_CHARSET = "UTF-8";
|
||||||
|
/**
|
||||||
|
* FXController名称分隔符
|
||||||
|
*/
|
||||||
|
String CONTROLLER_NAME_SEPARATOR = "#";
|
||||||
|
}
|
||||||
@@ -2,8 +2,11 @@ package cn.edu.scau.biubiusuisui.utils;
|
|||||||
|
|
||||||
import cn.edu.scau.biubiusuisui.log.FXPlusLoggerFactory;
|
import cn.edu.scau.biubiusuisui.log.FXPlusLoggerFactory;
|
||||||
import cn.edu.scau.biubiusuisui.log.IFXPlusLogger;
|
import cn.edu.scau.biubiusuisui.log.IFXPlusLogger;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.net.URLDecoder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jack
|
* @author jack
|
||||||
@@ -11,20 +14,20 @@ import java.net.URL;
|
|||||||
* @version 1.0
|
* @version 1.0
|
||||||
* @date 2019/6/25 3:46
|
* @date 2019/6/25 3:46
|
||||||
* @since JavaFX2.0 JDK1.8
|
* @since JavaFX2.0 JDK1.8
|
||||||
|
* @since 1.3.0 add:继承StringUtils
|
||||||
*/
|
*/
|
||||||
public class StringUtil {
|
public class StringUtil extends StringUtils {
|
||||||
private static IFXPlusLogger logger = FXPlusLoggerFactory.getLogger(StringUtil.class);
|
private static IFXPlusLogger logger = FXPlusLoggerFactory.getLogger(StringUtil.class);
|
||||||
|
|
||||||
private StringUtil() {
|
private StringUtil() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "file:/home/whf/cn/fh" -> "/home/whf/cn/fh"
|
* "file:/home/whf/cn/fh" -> "/home/whf/cn/fh"
|
||||||
* "jar:file:/home/whf/foo.jar!cn/fh" -> "/home/whf/foo.jar"
|
* "jar:file:/home/whf/foo.jar!cn/fh" -> "/home/whf/foo.jar"
|
||||||
*/
|
*/
|
||||||
public static String getRootPath(URL url) {
|
public static String getRootPath(URL url) throws UnsupportedEncodingException {
|
||||||
String fileUrl = url.getFile();
|
String fileUrl = URLDecoder.decode(url.getFile(),IFxPlusConstants.DEFAULT_CHARSET);
|
||||||
int pos = fileUrl.indexOf('!');
|
int pos = fileUrl.indexOf('!');
|
||||||
|
|
||||||
if (-1 == pos) {
|
if (-1 == pos) {
|
||||||
@@ -51,7 +54,6 @@ public class StringUtil {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String splashToDot(String name) {
|
public static String splashToDot(String name) {
|
||||||
|
|
||||||
return name.replaceAll("/", "\\.");
|
return name.replaceAll("/", "\\.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +65,6 @@ public class StringUtil {
|
|||||||
if (-1 != pos) {
|
if (-1 != pos) {
|
||||||
return name.substring(0, pos);
|
return name.substring(0, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +77,6 @@ public class StringUtil {
|
|||||||
public static String trimURI(String uri) {
|
public static String trimURI(String uri) {
|
||||||
String trimmed = uri.substring(1);
|
String trimmed = uri.substring(1);
|
||||||
int splashIndex = trimmed.indexOf('/');
|
int splashIndex = trimmed.indexOf('/');
|
||||||
|
|
||||||
return trimmed.substring(splashIndex);
|
return trimmed.substring(splashIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,8 +103,7 @@ public class StringUtil {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String toInstanceName(String name) {
|
public static String toInstanceName(String name) {
|
||||||
String result = name.substring(0, 1).toLowerCase().concat(name.substring(1));
|
return name.substring(0, 1).toLowerCase().concat(name.substring(1));
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -114,8 +113,7 @@ public class StringUtil {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String toClassName(String name) {
|
public static String toClassName(String name) {
|
||||||
String result = name.substring(0, 1).toUpperCase().concat(name.substring(1));
|
return name.substring(0, 1).toUpperCase().concat(name.substring(1));
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user