From 69df5995fda10e05936a5759c11c414427bf70f6 Mon Sep 17 00:00:00 2001 From: leebj Date: Mon, 11 Nov 2024 08:52:09 +0900 Subject: [PATCH] =?UTF-8?q?=ED=95=9C=EA=B8=80=20=EA=B4=80=EB=A0=A8=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=20=ED=81=B4=EB=9E=98=EC=8A=A4=20=ED=8C=A8?= =?UTF-8?q?=ED=82=A4=EC=A7=80=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 7 +- .../java/cokr/xit/fims/cmmn/CmmnUtil.java | 104 -------- src/main/java/cokr/xit/fims/cmmn/Hangul.java | 223 ------------------ 3 files changed, 1 insertion(+), 333 deletions(-) delete mode 100644 src/main/java/cokr/xit/fims/cmmn/Hangul.java diff --git a/pom.xml b/pom.xml index 4c78457b..e271b94a 100644 --- a/pom.xml +++ b/pom.xml @@ -148,12 +148,7 @@ 0.0.1-SNAPSHOT - - - com.ibm.icu - icu4j - 75.1 - + diff --git a/src/main/java/cokr/xit/fims/cmmn/CmmnUtil.java b/src/main/java/cokr/xit/fims/cmmn/CmmnUtil.java index 7bfac8c4..e8f43843 100644 --- a/src/main/java/cokr/xit/fims/cmmn/CmmnUtil.java +++ b/src/main/java/cokr/xit/fims/cmmn/CmmnUtil.java @@ -102,110 +102,6 @@ public class CmmnUtil { return Pattern.matches(REGEXP_PATTERN_KOR, str); } - /** - * 전화번호(유선,무선) 형식인지 체크한다. - * @param 문자열 - * @return boolean - */ - public static boolean isTelno(String str) { - - //01X - String REGEXP_PHONE = "^(01)\\d{8,9}$"; - if(Pattern.matches(REGEXP_PHONE, str)) { - return true; - } - - //서울 - String REGEXP_TEL = "^(02)\\d{7,8}$"; - if(Pattern.matches(REGEXP_TEL, str)) { - return true; - } - - //지방 - REGEXP_TEL = "^(0)(3|4|5|6)\\d{8,9}$"; - if(Pattern.matches(REGEXP_TEL, str)) { - return true; - } - - //070 - REGEXP_TEL = "^(070)\\d{7,8}$"; - if(Pattern.matches(REGEXP_TEL, str)) { - return true; - } - - //전국대표번호(0000-0000) - REGEXP_TEL = "^\\d{8}$"; - if(Pattern.matches(REGEXP_TEL, str)) { - return true; - } - - return false; - } - - /** - * 문자수신 가능한 휴대폰번호인지 체크한다. - * @param 문자열 - * @return boolean - */ - public static boolean isReceivePhone(String str) { - String REGEXP_PHONE = "^(01)\\d{8,9}$"; - return Pattern.matches(REGEXP_PHONE, str); - } - - /** - * 문자열에서 차량번호를 추출한다. - * @param 문자열 - * @return String 차량번호 - */ - public static String extractCarNumber(String carNum){ - - try{ - String regex = "[서울|부산|대구|인천|대전|광주|울산|제주|경기|강원|충남|전남|전북|경남|경북|세종]{2}\\d{2}[가|나|다|라|마|거|너|더|러|머|버|서|어|저|고|노|도|로|모|보|소|오|조|구|누|두|루|무|부|수|우|주|바|사|아|자|허|배|호|하\\x20]\\d{4}"; - Pattern p = Pattern.compile(regex); - Matcher m = p.matcher(carNum); - if (m.find()) { - return m.group(); - } - - - regex = "\\d{3}[가|나|다|라|마|거|너|더|러|머|버|서|어|저|고|노|도|로|모|보|소|오|조|구|누|두|루|무|부|수|우|주|바|사|아|자|허|배|호|하\\x20]\\d{4}"; - p = Pattern.compile(regex); - m = p.matcher(carNum); - if (m.find()) { - return m.group(); - } - - regex = "\\d{2}[가|나|다|라|마|거|너|더|러|머|버|서|어|저|고|노|도|로|모|보|소|오|조|구|누|두|루|무|부|수|우|주|바|사|아|자|허|배|호|하\\x20]\\d{4}"; - p = Pattern.compile(regex); - m = p.matcher(carNum); - if (m.find()) { - return m.group(); - } - - return ""; - - }catch(Exception e){ - return ""; - } - } - - /** - * "연-월-일 시:분:초" 형식 여부를 체크한다. - * @param 문자열 - * @return boolean - */ - public static boolean isDateTimePattern(String str){ - String DATETIME_PATTERN = "(19|20)\\d{2}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1]) (2[0-3]|[01][0-9]):[0-5][0-9]:[0-5][0-9]"; - Pattern datetimePattern = Pattern.compile(DATETIME_PATTERN); - - if(datetimePattern.matcher(str).matches()) { - return true; - } else { - return false; - } - } - - /** * 순서를 숫자에서 알파벳문자로 변환한다. * @param index 순서번호, 대소문자여부(대문자일경우 true, 소문자일경우 false), startFromZero 0부터 시작 여부(0부터 시작시 true, 1부터 시작시 false) diff --git a/src/main/java/cokr/xit/fims/cmmn/Hangul.java b/src/main/java/cokr/xit/fims/cmmn/Hangul.java deleted file mode 100644 index 41cebee3..00000000 --- a/src/main/java/cokr/xit/fims/cmmn/Hangul.java +++ /dev/null @@ -1,223 +0,0 @@ -package cokr.xit.fims.cmmn; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; - -import org.apache.commons.io.IOUtils; - -import com.ibm.icu.text.CharsetDetector; -import com.ibm.icu.text.CharsetMatch; - -public class Hangul { - - public Hangul(int hangulIsNByte){ - this.hangulIsNByte = hangulIsNByte; - } - - private int hangulIsNByte; - - public int is() { - return this.hangulIsNByte; - } - - /** - * 문자열의 바이트 수 구하기 - * - * @param str - * @return - */ - public int getByteLength(String str) { - if(str == null) { - return 0; - } - int byteLen = 0; - - for(int i=0;i 127) || (ch < 0)) { - byteLen += this.is(); - } else { - byteLen += 1; - } - } - - return byteLen; - } - - /** - * 문자열을 바이트 단위로 패딩 - * - * @param str - * @param byteLen - * @param ch - * @return - */ - public String lpadByte(String str, int byteLen, String ch) { - String result = str; - - int strLen = this.getByteLength(str); - - for(int i=0; i < byteLen - strLen ; i++) { - result = ch + result; - } - - return result; - } - - /** - * 문자열을 바이트 단위로 패딩 - * - * @param str - * @param byteLen - * @param ch - * @return - */ - public String rpadByte(String str, int byteLen, String ch) { - String result = str; - - int strLen = this.getByteLength(str); - - for(int i=0; i < byteLen - strLen ; i++) { - result += ch; - } - - return result; - } - - /** - * 문자열을 바이트 단위로 substring하기 - * - * @param str - * @param beginBytes - * @param endBytes - * @return - */ - public String substringByBytes(String str, int beginBytes, int endBytes) { - if (str == null || str.length() == 0) { - return ""; - } - - if (beginBytes < 0) { - beginBytes = 0; - } - - if (endBytes < 1) { - return ""; - } - - int len = str.length(); - - int beginIndex = -1; - int endIndex = 0; - - int curBytes = 0; - String ch = null; - for (int i = 0; i < len; i++) { - ch = str.substring(i, i + 1); - curBytes += this.getByteLength(ch); - - - if (beginIndex == -1 && curBytes >= beginBytes) { - beginIndex = i; - } - - if (curBytes > endBytes) { - break; - } else { - endIndex = i + 1; - } - } - - return str.substring(beginIndex, endIndex); - } - - /** - * 문자열을 바이트 단위로 substring하기 - * - * @param str - * @param beginBytes - * @return - */ - public String substringByBytes(String str, int beginBytes) { - if (str == null || str.length() == 0) { - return ""; - } - - if (beginBytes < 0) { - beginBytes = 0; - } - - int len = str.length(); - - int beginIndex = -1; - - int curBytes = 0; - String ch = null; - for (int i = 0; i < len; i++) { - ch = str.substring(i, i + 1); - curBytes += this.getByteLength(ch); - - - if (beginIndex == -1 && curBytes >= beginBytes) { - beginIndex = i; - } - - } - - return str.substring(beginIndex); - } - - /** - * 텍스트파일 인코딩 확인 - * - * @param path 파일경로 - * @return 캐릭터셋 - */ - public String encodingDetect(String path) throws IOException { - File f = new File(path); - - return encodingDetect(f); - } - - /** - * 텍스트파일 인코딩 확인 - * - * @param file 파일 - * @return 캐릭터셋 - */ - public String encodingDetect(File file) throws IOException { - CharsetDetector detector; - CharsetMatch match; - - FileInputStream fis = null; - try { - String result = ""; - - fis = new FileInputStream(file); - - byte[] byteData = new byte[(int) file.length()]; - - fis.read(byteData); - fis.close(); - detector = new CharsetDetector(); - - detector.setText(byteData); - match = detector.detect(); - - System.out.println("encoding is \"" + match.getName() + "\""); - - if(match.getName().equals("UTF-8") || match.getName().equals("EUC-KR")) { - result = match.getName(); - } else { - result = "EUC-KR"; - } - - return result; - } - finally { - IOUtils.closeQuietly(fis); - } - } -}