Index: core-module/pom.xml =================================================================== diff -u -re968b2d30c839fd6fb37469ec1cba71732788ec3 -r5a4b956db8ab27e0079e3224f75e6b1f420bd785 --- core-module/pom.xml (.../pom.xml) (revision e968b2d30c839fd6fb37469ec1cba71732788ec3) +++ core-module/pom.xml (.../pom.xml) (revision 5a4b956db8ab27e0079e3224f75e6b1f420bd785) @@ -7,7 +7,7 @@ 313devgrp jstree-project - 19.09.04 + 19.10.01 ../pom.xml @@ -31,7 +31,7 @@ 313devgrp lib-module - 19.09.04 + 19.10.01 pom Index: core-module/src/main/java/egovframework/com/cmm/util/argument/ArgumentUtil.java =================================================================== diff -u --- core-module/src/main/java/egovframework/com/cmm/util/argument/ArgumentUtil.java (revision 0) +++ core-module/src/main/java/egovframework/com/cmm/util/argument/ArgumentUtil.java (revision 5a4b956db8ab27e0079e3224f75e6b1f420bd785) @@ -0,0 +1,55 @@ +package egovframework.com.cmm.util.argument; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +public class ArgumentUtil { + public static Map parse(String[] args){ + String key=null,value=null; + Map argMap = new HashMap(); + for(int i=0;i parameterSet,Map argMap){ + for (String parameter : parameterSet) { + if(!argMap.containsKey(parameter)){ + return false; + } + } + return true; + } + public static boolean parameterCheck(String[] parameters,Map argMap){ + for (String parameter : parameters) { + if(!argMap.containsKey(parameter)){ + return false; + } + } + return true; + } + public static boolean parameterCheck(List parameterList,Map argMap){ + for (String parameter : parameterList) { + if(!argMap.containsKey(parameter)){ + return false; + } + } + return true; + } +} Index: core-module/src/main/java/egovframework/com/cmm/util/collection/MapUtil.java =================================================================== diff -u --- core-module/src/main/java/egovframework/com/cmm/util/collection/MapUtil.java (revision 0) +++ core-module/src/main/java/egovframework/com/cmm/util/collection/MapUtil.java (revision 5a4b956db8ab27e0079e3224f75e6b1f420bd785) @@ -0,0 +1,96 @@ +package egovframework.com.cmm.util.collection; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import kr.co.shineware.util.common.model.Pair; + +public class MapUtil { + + public static int ASCENDING_ORDER = 1; + public static int DESCENDING_ORDER = -1; + + /** + * 맵의 키값을 리스트로 반환 + * @param map + * @return List - 키 리스트 + */ + public static List getKeyList(Map map){ + Iterator it = map.keySet().iterator(); + List result = new ArrayList(); + while(it.hasNext()){ + result.add(it.next()); + } + if(result.size() == 0){ + return null; + } + it = null; + return result; + } + + /** + * 맵을 value로 소팅하여 다시 맵으로 리턴 + * @param map + * @param order Input MapUtil.ASCENDING_ORDER or MapUtil.DESCENDIN_ORDER + * @return Map + */ + public static > Map + sortByValue( Map map ,final int order) + { + List> list = + new LinkedList>( map.entrySet() ); + Collections.sort( list, new Comparator>() + { + public int compare( Map.Entry o1, Map.Entry o2 ) + { + if(order == ASCENDING_ORDER){ + return (o1.getValue()).compareTo( o2.getValue() ); + } + else if(order == DESCENDING_ORDER){ + return (o2.getValue()).compareTo( o1.getValue() ); + } + return (o2.getValue()).compareTo( o1.getValue() ); + } + } ); + + Map result = new LinkedHashMap(); + for (Map.Entry entry : list) + { + result.put( entry.getKey(), entry.getValue() ); + } + list = null; + return result; + } + + /** + * 맵을 Key, Value Pair 형태의 리스트로 반환 + * @param map + * @return List + */ + public static List> getListPair(Map map){ + Iterator it = map.keySet().iterator(); + List> result = new ArrayList>(); + while(it.hasNext()){ + K key = it.next(); + V value = map.get(key); + result.add(new Pair(key,value)); + } + it = null; + return result; + } + + public static void appendKey(Map map,K key){ + Integer tf = map.get(key); + if(tf == null){ + tf = 0; + } + tf++; + map.put(key, tf); + } +} Index: core-module/src/main/java/egovframework/com/cmm/util/file/FileUtil.java =================================================================== diff -u --- core-module/src/main/java/egovframework/com/cmm/util/file/FileUtil.java (revision 0) +++ core-module/src/main/java/egovframework/com/cmm/util/file/FileUtil.java (revision 5a4b956db8ab27e0079e3224f75e6b1f420bd785) @@ -0,0 +1,400 @@ +package egovframework.com.cmm.util.file; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStreamReader; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +/** + * File과 관련된 Util 모음 + * @author jsshin + * + */ +public class FileUtil { + + /** + * 입력된 파일의 내용을 라인별 List 형태로 반환 + * @param filename 읽어들일 파일 이름 + * @param encoding 읽어들일 파일의 인코딩 + * @return 파일의 한라인씩 순차적으로 저장된 리스트 + */ + public static List load2List(String filename,String encoding){ + BufferedReader br; + List resultList = new ArrayList(); + try { + br = new BufferedReader(new InputStreamReader(new FileInputStream(filename), encoding)); + String line; + while ((line = br.readLine()) != null) { +// if(line.trim().length() == 0)continue; + resultList.add(line); + } + br.close(); + br = null; + } catch (Exception e) { + e.printStackTrace(); + } + return resultList; + } + + /** + * 입력된 파일의 내용을 라인별 List 형태로 반환 + * @param filename 읽어들일 파일 이름 + * @param encoding 읽어들일 파일의 인코딩 + * @return 파일의 한라인씩 순차적으로 저장된 리스트 + */ + public static List load2List(String filename,Charset encoding){ + BufferedReader br; + List resultList = new ArrayList(); + try { + br = new BufferedReader(new InputStreamReader(new FileInputStream(filename), encoding)); + String line; + while ((line = br.readLine()) != null) { +// if(line.trim().length() == 0)continue; + resultList.add(line); + } + br.close(); + br = null; + } catch (Exception e) { + e.printStackTrace(); + } + return resultList; + } + + /** + * 입력된 파일의 내용을 라인별 List 형태로 반환 + * @param filename 읽어들일 파일 이름 (기본 인코딩 형식은 UTF-8) + * @return 파일의 한라인씩 순차적으로 저장된 리스트 + */ + public static List load2List(String filename){ + return load2List(filename,"UTF-8"); + } + + /** + * 입력된 filename에 list의 내용을 String 형태로 write + * @param + * @param list + * @param filename + */ + public static void writeList(List list,String filename){ + try { + BufferedWriter bw = new BufferedWriter(new FileWriter(filename)); + int count=0; + for (T line : list) { + bw.write(line.toString()); + if(count != list.size()-1){ + bw.newLine();; + } + count++; + } + bw.close(); + bw = null; + } catch (IOException e) { + e.printStackTrace(); + } + } + + /** + * 입력된 파일의 내용을 라인별 Set 형태로 반환 + * @param filename 읽어들일 파일 이름 + * @param encoding 읽어들일 파일의 인코딩 + * @return 파일의 한라인씩 순차적으로 저장된 리스트 + */ + public static Set load2Set(String filename,String encoding){ + + BufferedReader br; + Set resultSet = new HashSet(); + try { + br = new BufferedReader(new InputStreamReader(new FileInputStream(filename), encoding)); + String line; + while ((line = br.readLine()) != null) { + if(line.trim().length() == 0)continue; + resultSet.add(line); + } + br.close(); + br =null; + line = null; + } catch (Exception e) { + e.printStackTrace(); + } + + return resultSet; + } + + /** + * 입력된 파일의 내용을 라인별 Set 형태로 반환 + * @param filename 읽어들일 파일 이름 (기본 인코딩 형식은 UTF-8) + * @return 파일의 한라인씩 순차적으로 저장된 리스트 + */ + public static Set load2Set(String filename){ + return load2Set(filename,"UTF-8"); + } + + /** + * 입력된 filename에 Set의 내용을 String 형태로 write. + * @param set + * @param filename + */ + public static void writeSet(Set set,String filename){ + try { + BufferedWriter bw = new BufferedWriter(new FileWriter(filename)); + int count = 0; + for (T line : set) { + bw.write(line.toString()); + if(count != set.size() -1){ + bw.newLine(); + } + count++; + } + bw.close(); + bw = null; + } catch (IOException e) { + e.printStackTrace(); + } + } + + /** + * 입력된 파일의 내용을 Map형태로 반환. key, value 구분자는 \t. + * @param filename + * @return + */ + public static Map load2Map(String filename){ + Map resultMap = new HashMap(); + try { + BufferedReader br = new BufferedReader(new FileReader(filename)); + String line; + while ((line = br.readLine()) != null) { + if(line.trim().length() == 0)continue; + String[] tmp = line.split("\t"); + if(tmp.length != 2){ + System.err.println("FileUtil.load2Map error!"); + System.err.println("This line can not split by '\t' : "+line); + } + resultMap.put(tmp[0], tmp[1]); + tmp = null; + } + br.close(); + br = null; + line = null; + } catch (Exception e) { + e.printStackTrace(); + } + return resultMap; + } + + /** + * map의 내용을 filename에 write + * key와 value의 구분자는 \t. + * @param map + * @param filename + */ + public static void writeMap(Map map,String filename){ + try { + BufferedWriter bw = new BufferedWriter(new FileWriter(filename)); + + Set> mapEntrySet = map.entrySet(); + int count = 0; + for (Entry entry : mapEntrySet) { + bw.write(entry.getKey().toString()); + bw.write("\t"); + bw.write(entry.getValue().toString()); + if(count != mapEntrySet.size()-1){ + bw.newLine(); + } + count++; + } + bw.close(); + mapEntrySet = null; + bw = null; + } catch (IOException e) { + e.printStackTrace(); + } + } + + + /** + * 입력된 rootPath의 하위에 있는 모든 파일을 List 형태로 반환(path 포함) + * @param rootPath + * @return + */ + public static List getFileNames(String rootPath){ + List filenames = new ArrayList(); + File f = new File(rootPath); + File[] files = f.listFiles(); + for (File file : files) { + if(file.isDirectory()){ + filenames.addAll(getFileNames(file.getAbsolutePath())); + } + else{ + filenames.add(file.getAbsolutePath()); + } + } + files = null; + f = null; + return filenames; + } + + /** + * 입력된 rootPath의 하위에 있는 모든 파일을 List 형태로 반환(path 포함) + * @param rootPath + * @return + */ + public static List getFileNames(String rootPath,String suffix){ + List filenames = new ArrayList(); + File f = new File(rootPath); + File[] files = f.listFiles(); + for (File file : files) { + if(file.isDirectory()){ + filenames.addAll(getFileNames(file.getAbsolutePath(),suffix)); + } + else{ + if(file.getName().endsWith(suffix)){ + filenames.add(file.getAbsolutePath()); + } + } + } + files = null; + f = null; + return filenames; + } + + /** + * 입력된 파일 이름을 삭제 + * @param filename + * @return success + */ + public static boolean removeFile(String filename){ + File f = new File(filename); + if(f.exists()){ + if(f.delete()){ + return true; + }else{ + return false; + } + } + return false; + } + + /** + * 입력된 이름의 파일을 생성 + * @param filename + * @return + */ + public static boolean makeFile(String filename){ + File f = new File(filename); + try { + return f.createNewFile(); + } catch (IOException e) { + e.printStackTrace(); + } + return false; + } + + /** + * 입력된 이름의 파일을 생성 + * @param filename + * @param makePath filename에 해당하는 path가 없을 시 path 생성 여부 + * @return + */ + public static boolean makeFile(String filename, boolean makePath){ + String path = FileUtil.getPath(filename); + + //makePath를 설정하면 path 먼저 생성 + if(makePath){ + boolean successMakePath = FileUtil.makePath(path); + + //path 생성 실패면 false 리턴 + if(!successMakePath)return false; + } + path = null; + //makeFile + return FileUtil.makeFile(filename); + } + + /** + * 입력된 path 생성. 하위 path 포함하여 생성함. + * @param filename + * @return + */ + public static boolean makePath(String path){ + File f = new File(path); + boolean successMakePath = f.mkdirs(); + if(successMakePath){ + return true; + } + f = null; + return false; + } + + /** + * 입력된 filename 중 path를 반환 + * 실질적인 의미의 path가 아닌 입력된 filename에서 나타나는 path의 가장 마지막 + * token을 제외한 상위 path를 리턴 + * 예) path/to/where/ -> return path/to/ + * @param filename + * @return + */ + public static String getPath(String filename){ + String pathSeparator; + String appendSeparator; + StringBuffer path = new StringBuffer(); + if(filename.contains("/")){ + pathSeparator = "/"; + appendSeparator = "/"; + }else{ + pathSeparator = "\\\\"; + appendSeparator = "\\"; + } + + String[] tmp = filename.split(pathSeparator); + + for(int i=0;i lines = new ArrayList(); + while((line = br.readLine()) != null){ + if(count == splitCount){ + FileUtil.writeList(lines, filename+suffix+suffixNumber); + count = 0; + lines = null; + lines = new ArrayList(); + suffixNumber++; + continue; + } + lines.add(line); + count++; + } + br.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } +} Index: core-module/src/main/java/egovframework/com/cmm/util/model/Jaso.java =================================================================== diff -u --- core-module/src/main/java/egovframework/com/cmm/util/model/Jaso.java (revision 0) +++ core-module/src/main/java/egovframework/com/cmm/util/model/Jaso.java (revision 5a4b956db8ab27e0079e3224f75e6b1f420bd785) @@ -0,0 +1,72 @@ +package egovframework.com.cmm.util.model; + +public class Jaso { + public enum TYPE{ + CHOSUNG, JUNGSUNG, JONGSUNG, ETC + } + private char jaso; + private int index; + private TYPE type; + public Jaso(){ + ; + } + public Jaso(char jaso,TYPE type,int index){ + this.jaso = jaso; + this.type = type; + this.index = index; + } + public char getJaso() { + return jaso; + } + public void setJaso(char jaso) { + this.jaso = jaso; + } + public TYPE getType() { + return type; + } + public void setType(TYPE type) { + this.type = type; + } + public int getIndex() { + return index; + } + public void setIndex(int index) { + this.index = index; + } + @Override + public String toString() { + return "Jaso [jaso=" + jaso + ", index=" + index + ", type=" + type + + "]"; + } + public String toKey(){ + StringBuffer sb = new StringBuffer(); + sb.append(index*10); + sb.append(type.ordinal()); + return sb.toString(); + } + @Override + public int hashCode() { + int result = 1; + result = result + index*10; + result = result + ((type == null) ? 0 : type.ordinal()); + return result; + } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Jaso other = (Jaso) obj; + if (index != other.index) + return false; + if (jaso != other.jaso) + return false; + if (type != other.type) + return false; + return true; + } + +} Index: core-module/src/main/java/egovframework/com/cmm/util/model/Pair.java =================================================================== diff -u --- core-module/src/main/java/egovframework/com/cmm/util/model/Pair.java (revision 0) +++ core-module/src/main/java/egovframework/com/cmm/util/model/Pair.java (revision 5a4b956db8ab27e0079e3224f75e6b1f420bd785) @@ -0,0 +1,81 @@ +package egovframework.com.cmm.util.model; + +import java.io.Serializable; + +/** + * + * + * @param Object type of first value; + * @param Object type of second value; + */ +public class Pair implements Serializable{ + + /** + * + */ + private static final long serialVersionUID = 1L; + private F first; + private S second; + + public Pair(){ + ; + } + + public Pair(F first,S second){ + this.first = first; + this.second = second; + } + + public F getFirst() { + return first; + } + public void setFirst(F first) { + this.first = first; + } + public S getSecond() { + return second; + } + public void setSecond(S second) { + this.second = second; + } + + @Override + public String toString() { + return "Pair [first=" + first + ", second=" + second + "]"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((first == null) ? 0 : first.hashCode()); + result = prime * result + ((second == null) ? 0 : second.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + @SuppressWarnings("rawtypes") + Pair other = (Pair) obj; + if (first == null) { + if (other.first != null) + return false; + } else if (!first.equals(other.first)) + return false; + if (second == null) { + if (other.second != null) + return false; + } else if (!second.equals(other.second)) + return false; + return true; + } + + + +} Index: core-module/src/main/java/egovframework/com/cmm/util/model/Syllable.java =================================================================== diff -u --- core-module/src/main/java/egovframework/com/cmm/util/model/Syllable.java (revision 0) +++ core-module/src/main/java/egovframework/com/cmm/util/model/Syllable.java (revision 5a4b956db8ab27e0079e3224f75e6b1f420bd785) @@ -0,0 +1,63 @@ +package egovframework.com.cmm.util.model; + +public class Syllable { + private char chosung,jungsung,jongsung; + private int chosungIndex,jungsungIndex,jongsungIndex; + public Syllable(char cho,int choIndex,char jung, int jungIndex,char jong, int jongIndex){ + + setChosung(cho); + setJungsung(jung); + setJongsung(jong); + + setChosungIndex(choIndex); + setJungsungIndex(jungIndex); + setJongsungIndex(jongIndex); + } + + public char getJongsung() { + return jongsung; + } + public void setJongsung(char jongsung) { + this.jongsung = jongsung; + } + public char getJungsung() { + return jungsung; + } + public void setJungsung(char jungsung) { + this.jungsung = jungsung; + } + public char getChosung() { + return chosung; + } + public void setChosung(char chosung) { + this.chosung = chosung; + } + public int getChosungIndex() { + return chosungIndex; + } + public void setChosungIndex(int chosungIndex) { + this.chosungIndex = chosungIndex; + } + public int getJungsungIndex() { + return jungsungIndex; + } + public void setJungsungIndex(int jungsungIndex) { + this.jungsungIndex = jungsungIndex; + } + public int getJongsungIndex() { + return jongsungIndex; + } + public void setJongsungIndex(int jongsungIndex) { + this.jongsungIndex = jongsungIndex; + } + + @Override + public String toString() { + return "Jaso [chosung=" + chosung + ", jungsung=" + jungsung + + ", jongsung=" + jongsung + ", chosungIndex=" + chosungIndex + + ", jungsungIndex=" + jungsungIndex + ", jongsungIndex=" + + jongsungIndex + "]"; + } + + +} Index: core-module/src/main/java/egovframework/com/cmm/util/string/StringUtil.java =================================================================== diff -u --- core-module/src/main/java/egovframework/com/cmm/util/string/StringUtil.java (revision 0) +++ core-module/src/main/java/egovframework/com/cmm/util/string/StringUtil.java (revision 5a4b956db8ab27e0079e3224f75e6b1f420bd785) @@ -0,0 +1,457 @@ +package egovframework.com.cmm.util.string; + +import java.lang.Character.UnicodeBlock; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import kr.co.shineware.util.common.model.Jaso; +import kr.co.shineware.util.common.model.Syllable; + +/** + * String과 관련된 Util 모음 + * @author jsshin + * + */ +public class StringUtil { + public static char[] ChoSung = { 0x3131, 0x3132, 0x3134, 0x3137, 0x3138, + 0x3139, 0x3141, 0x3142, 0x3143, 0x3145, 0x3146, 0x3147, 0x3148, + 0x3149, 0x314a, 0x314b, 0x314c, 0x314d, 0x314e }; + public static char[] JungSung = { 0x314f, 0x3150, 0x3151, 0x3152, 0x3153, + 0x3154, 0x3155, 0x3156, 0x3157, 0x3158, 0x3159, 0x315a, 0x315b, + 0x315c, 0x315d, 0x315e, 0x315f, 0x3160, 0x3161, 0x3162, 0x3163 }; + public static char[] JongSung = { 0x0000, 0x3131, 0x3132, 0x3133, 0x3134, + 0x3135, 0x3136, 0x3137, 0x3139, 0x313a, 0x313b, 0x313c, 0x313d, + 0x313e, 0x313f, 0x3140, 0x3141, 0x3142, 0x3144, 0x3145, 0x3146, + 0x3147, 0x3148, 0x314a, 0x314b, 0x314c, 0x314d, 0x314e }; + + /** + * 입력된 source를 spliter 기준으로 분할 + * @param source + * @param spliter + * @return + */ + public static List split(String source, String spliter){ + List splitedList = new ArrayList(); + StringBuffer sb = new StringBuffer(source); + int prevIndex = -1; + int index = 0; + + while(true){ + index = sb.indexOf(spliter, prevIndex+1); + if(index == -1){ + splitedList.add(sb.substring(prevIndex+1)); + break; + } + splitedList.add(sb.substring(prevIndex+1,index)); + prevIndex = index + spliter.length()-1; + } + sb = null; + + return splitedList; + } + + /** + * 입력된 문장을 ngram List 형태로 반환 + * 띄어쓰기를 포함하여 ngram을 생성함 + * @param str 입력 문장 + * @param n ngram에서 n의 개수 + * @param begin 시작 기호 설정 (Can be null) + * @param end 끝나는 기호 설정 (Can be null) + * @return + */ + public static List ngram(String str,int n,String begin,String end){ + + List ngramList = new ArrayList(); + for(int i=0;i str.length()){ + break; + } + StringBuilder sb = new StringBuilder(); + for(int j=i;j ㄱ,ㅏ,x + * + * 입력 문장 중 음절 정보가 부정확한 경우 자소 타입을 ETC로 반환 + * ex : ㅋ,ㅏ,a,b 등 + * @param str + * @return + */ + public static List korean2JasoList(String str) { + int length = str.length(); + List jasoList = new ArrayList(); + + for(int i=0;i jasoList){ + return restoreJasoList2Korean(0, jasoList.size()-1, jasoList); + } + + public static String restoreJasoList2Korean(int begin, int end, List jasoList) { + + int cho=-1,jung=-1,jong=-1; + + StringBuffer koreanStr = new StringBuffer(); + for(int i=begin;i<=end;i++){ + + Jaso jaso = jasoList.get(i); + if(jaso.getType() == Jaso.TYPE.CHOSUNG){ + cho = jaso.getIndex(); + } + else if(jaso.getType() == Jaso.TYPE.JUNGSUNG){ + jung = jaso.getIndex(); + } + else if(jaso.getType() == Jaso.TYPE.JONGSUNG){ + jong = jaso.getIndex(); + } + else{ + jong = Arrays.binarySearch(StringUtil.JongSung, jaso.getJaso()); + } + + if(i+1 > end || jasoList.get(i+1).getType() == Jaso.TYPE.CHOSUNG || jasoList.get(i+1).getType() == Jaso.TYPE.ETC || jasoList.get(i+1).getType() == Jaso.TYPE.ETC){ + //종성이 있는 경우 + if(jong != -1){ + //초성이 있는 경우 + if(cho != -1){ + koreanStr.append((char)(0xAC00+cho*588+jung*28+jong)); + } + //초성이 없는 경우 + else{ + koreanStr.append(jaso.getJaso()); + } + }else if(jung != -1){ + koreanStr.append((char)(0xAC00+cho*588+jung*28)); + }else{ + koreanStr.append(jaso.getJaso()); + } + cho = jung = jong = -1; + } + jaso = null; + } + + return koreanStr.toString(); + } + + /** + * 입력된 ch가 한글인지 아닌지 판단 + * @param ch + * @return + */ + public static boolean isKorean(char ch){ + UnicodeBlock unicodeBlock = UnicodeBlock.of(ch); + if(UnicodeBlock.HANGUL_SYLLABLES == unicodeBlock || + UnicodeBlock.HANGUL_COMPATIBILITY_JAMO == unicodeBlock || + UnicodeBlock.HANGUL_JAMO == unicodeBlock) + return true; + else return false; + } + + public static String getKorean(String in){ + StringBuffer sb = new StringBuffer(); + char[] charArray = in.toCharArray(); + for (char ch : charArray) { + UnicodeBlock unicodeBlock = UnicodeBlock.of(ch); + if(UnicodeBlock.HANGUL_SYLLABLES == unicodeBlock || + UnicodeBlock.HANGUL_COMPATIBILITY_JAMO == unicodeBlock || + UnicodeBlock.HANGUL_JAMO == unicodeBlock){ + sb.append(ch); + } + } + return sb.toString(); + } + + /** + * 입력된 ch가 영어인지 판단 + * @param ch + * @return + */ + public static boolean isEnglish(char ch){ + UnicodeBlock unicodeBlock = UnicodeBlock.of(ch); + if(unicodeBlock == UnicodeBlock.BASIC_LATIN){ + if (((ch >= 'A') && (ch <= 'Z')) || ((ch >= 'a') && (ch <= 'z'))) { + return true; + } + } + return false; + } + + /** + * 입력된 ch가 일본어(카타카나, 카타카나 포네틱 확장, 히라가나)인지 판단 + * @param ch + * @return + */ + public static boolean isJapanese(char ch){ + UnicodeBlock unicodeBlock = UnicodeBlock.of(ch); + if(UnicodeBlock.KATAKANA.equals(unicodeBlock) + || UnicodeBlock.KATAKANA_PHONETIC_EXTENSIONS.equals(unicodeBlock) + || UnicodeBlock.HIRAGANA.equals(unicodeBlock)){ + return true; + } + return false; + } + + /** + * 입력된 ch가 영어 외의 외국어인지 판단(히라가나, 카타카나, 한자) + * @param ch + * @return + */ + public static boolean isForeign(char ch){ + UnicodeBlock unicodeBlock = UnicodeBlock.of(ch); + if(unicodeBlock == UnicodeBlock.HIRAGANA || + unicodeBlock == UnicodeBlock.KATAKANA || + unicodeBlock == UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS){ + return true; + } + return false; + } + + /** + * 입력된 ch가 한자인지 판단 + * @param ch + * @return + */ + public static boolean isChinese(char ch){ + UnicodeBlock unicodeBlock = UnicodeBlock.of(ch); + if(UnicodeBlock.CJK_COMPATIBILITY.equals(unicodeBlock) + || UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS.equals(unicodeBlock) + || UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A.equals(unicodeBlock) + || UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B.equals(unicodeBlock) + || UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS.equals(unicodeBlock)){ + return true; + } + return false; + } + + /** + * 입력된 ch의 유니코드 블록 범위를 반환 + * @param ch + * @return + */ + public static UnicodeBlock getUnicodeBlock(char ch){ + return UnicodeBlock.of(ch); + } + + /** + * 입력된 ch가 숫자인지 아닌지 판단 + * @param ch + * @return + */ + public static boolean isNumeric(char ch){ + if(Character.isDigit(ch)){ + return true; + } + return false; + } + + + public static String korean2JasoString(String word){ + return korean2JasoString(word, false); + } + + /** + * 입력된 word를 자소 스트링 형태로 반환 + * ex : "감기!" -> "ㄱㅏㅁㄱㅣx!" + * @param word 변환할 스트링 + * @param fixJongsung 종성 고정 여부 선택. 종성이 없는 경우에는 x로 문자열 대치. + * @return + */ + public static String korean2JasoString(String word,boolean fixJongsung){ + String key = ""; + for(int j=0;j= 0xAC00 && ch <=0xD7A3){ + tmp = ch - 0xAC00; + cho = tmp / (21*28); + tmp = tmp % (21*28); + jung = tmp / 28; + jong = tmp % 28; + + if(jong != 0){ + return new Syllable(ChoSung[cho], cho,JungSung[jung], jung,JongSung[jong],jong); + }else{ + return new Syllable(ChoSung[cho], cho,JungSung[jung],jung, 'x',jong); + } + } + return null; + } + + /** + * 입력된 jaso word를 스트링 형태로 반환 + * @param jasoWord + * @return + */ + public static String restoreJasoword2Korean(String jasoWord){ + + StringBuilder sb = new StringBuilder(); + int length = jasoWord.length(); + + char cho, jung, jong; + cho = jung = jong = ' '; + + for(int i=0; i= 0x3131 && jasoWord.charAt(i) <= 0x314e) { + + //초성이 비어있으면 초성으로 셋팅 + if(cho == ' ') { + cho = jasoWord.charAt(i); + } else { + //초성이 이미 있고 중성이 없으면 이미 있는 초성을 음절로 출력하고 현재 자음를 초성으로 셋팅 + if(jung == ' ') { + sb.append(cho); + cho = jasoWord.charAt(i); + } else { + //마지막 자소가 아니고 + //초성이 있고 중성도 있지만 종성이 없으면 다음 자소를 확인해 + //자음이면 종성으로 모음이면 현재까지의 초성 중성을 음절로 출력하고 현재 자음을 초성으로 셋팅 + if(i+1 < length) { + if(jasoWord.charAt(i+1) >= 0x3131 && jasoWord.charAt(i+1) <= 0x314e) { + jong = jasoWord.charAt(i); + sb.append(combineJaso2Emjeol(cho, jung, jong)); + cho = jung = jong = ' '; + } else { + sb.append(combineJaso2Emjeol(cho, jung, jong)); + cho = jasoWord.charAt(i); + jung = jong = ' '; + } + } else { + //마지막 자소이면 현재 자음을 종성으로 넣어 음절로 만듬 + jong = jasoWord.charAt(i); + sb.append(combineJaso2Emjeol(cho, jung, jong)); + cho = jung = jong = ' '; + } + + } + } + } + //자소가 모음인 경우 + else { + //초성이 비어있으면 자소만 바로 출력 + if(cho == ' ') { + sb.append(jasoWord.charAt(i)); + } + //초성이 있으면 + else { + jung = jasoWord.charAt(i); + } + } + } + + if(cho != ' ' || jung != ' ' || jong != ' ') { + sb.append(combineJaso2Emjeol(cho, jung, jong)); + } + + return sb.toString(); + } + + private static char combineJaso2Emjeol(char cho, char jung, char jong) { + + + char emjeol = 0; + + if(cho != ' ') { + if(jung != ' ') { + int choIndex = Arrays.binarySearch(ChoSung, cho); + int jungIndex = jung - 0x314f; + + emjeol = (char) (0xAC00 + (choIndex * 588) + (jungIndex * 28)); + + if(jong != ' ') { + int jongIndex = Arrays.binarySearch(JongSung, jong); + emjeol += jongIndex; + } + } else { + emjeol = cho; + } + } else { + if(jong != ' ') { + emjeol = jung; + } else { + emjeol = jong; + } + } + + return emjeol; + + } +} Index: lib-module/pom.xml =================================================================== diff -u -r715926b63c116b12da66ba83911a9dbe43e25971 -r5a4b956db8ab27e0079e3224f75e6b1f420bd785 --- lib-module/pom.xml (.../pom.xml) (revision 715926b63c116b12da66ba83911a9dbe43e25971) +++ lib-module/pom.xml (.../pom.xml) (revision 5a4b956db8ab27e0079e3224f75e6b1f420bd785) @@ -5,7 +5,7 @@ 313devgrp jstree-project - 19.09.04 + 19.10.01 ../pom.xml @@ -23,11 +23,6 @@ - - 313devgrp - jdownloader - 2.0.0 - Index: pom.xml =================================================================== diff -u -rf864d75b4d9d33b5040eaa47c58ab420a7496697 -r5a4b956db8ab27e0079e3224f75e6b1f420bd785 --- pom.xml (.../pom.xml) (revision f864d75b4d9d33b5040eaa47c58ab420a7496697) +++ pom.xml (.../pom.xml) (revision 5a4b956db8ab27e0079e3224f75e6b1f420bd785) @@ -10,7 +10,7 @@ 4.0.0 313devgrp jstree-project - 19.09.04 + 19.10.01 pom jstree-project