diff options
author | 2021-08-03 18:42:39 +0900 | |
---|---|---|
committer | 2021-08-06 19:32:38 +0900 | |
commit | be4f78978faba3d3ceb88df02a7f93a2e09ff1e0 (patch) | |
tree | 1f3f1a96251ac4f655c8a96fc33d5d4ee779cd06 /rba.tool.core/src/rba/tool/core/ui/CommonValueValidator.java | |
parent | 71ca7c6cab863767ef30c8bd05b2bbfda8731cb5 (diff) |
Initial commit
Bug-AGL: SPEC-4033
Signed-off-by: Kenji Hosokawa <khosokawa@jp.adit-jv.com>
Diffstat (limited to 'rba.tool.core/src/rba/tool/core/ui/CommonValueValidator.java')
-rw-r--r-- | rba.tool.core/src/rba/tool/core/ui/CommonValueValidator.java | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/rba.tool.core/src/rba/tool/core/ui/CommonValueValidator.java b/rba.tool.core/src/rba/tool/core/ui/CommonValueValidator.java new file mode 100644 index 0000000..c724760 --- /dev/null +++ b/rba.tool.core/src/rba/tool/core/ui/CommonValueValidator.java @@ -0,0 +1,51 @@ +package rba.tool.core.ui;
+
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import org.apache.commons.lang3.StringUtils;
+
+public class CommonValueValidator {
+
+ public static boolean isExistFilePath(String folderPath, String fileName) {
+ if (StringUtils.isEmpty(folderPath) || StringUtils.isEmpty(fileName))
+ return false;
+ return Files.exists(Paths.get(folderPath, fileName));
+ }
+
+ public static boolean isExistFilePath(String filePath) {
+ if (StringUtils.isEmpty(filePath))
+ return false;
+ return Files.exists(Paths.get(filePath));
+ }
+
+ public static boolean isValidFileName(String target) {
+ if (StringUtils.isEmpty(target)) {
+ return false;
+ }
+ if (target.length() > 250) {
+ return false;
+ }
+ if (target.contains("¥") || target.contains("/") || target.contains(":") || target.contains("*") || target.contains("?") || target.contains("\"") || target.contains("|")
+ || target.contains("<") || target.contains(">")) {
+ return false;
+ }
+
+ return true;
+ }
+
+ public static boolean isValidFolderName(String target) {
+ if (StringUtils.isEmpty(target)) {
+ return false;
+ }
+ if (target.length() > 250) {
+ return false;
+ }
+ if (target.contains("¥") || target.contains("/") || target.contains(":") || target.contains("*") || target.contains("?") || target.contains("\"") || target.contains("|")
+ || target.contains("<") || target.contains(">") || target.contains(".") || target.contains(",")) {
+ return false;
+ }
+
+ return true;
+ }
+}
|