|
|
|
|
@ -4,47 +4,72 @@ import cokr.xit.applib.Hangul;
|
|
|
|
|
|
|
|
|
|
public class MessageUtil {
|
|
|
|
|
|
|
|
|
|
public static String replaceLineChangeForNuri2Oracle(String str) {
|
|
|
|
|
public MessageUtil(String type){
|
|
|
|
|
|
|
|
|
|
if(type.equals("A")) {
|
|
|
|
|
this.nuri2_oracle = "\r\n";
|
|
|
|
|
this.nuri2_oracle_byte = 2;
|
|
|
|
|
this.nuri2_maria = "\\\\r\\\\n";
|
|
|
|
|
this.nuri2_maria_byte = 4;
|
|
|
|
|
} else if(type.equals("B")) {
|
|
|
|
|
this.nuri2_oracle = "\n";
|
|
|
|
|
this.nuri2_oracle_byte = 1;
|
|
|
|
|
this.nuri2_maria = "\\\\n";
|
|
|
|
|
this.nuri2_maria_byte = 2;
|
|
|
|
|
} else if(type.equals("C")) {
|
|
|
|
|
this.nuri2_oracle = "\n";
|
|
|
|
|
this.nuri2_oracle_byte = 1;
|
|
|
|
|
this.nuri2_maria = "\n";
|
|
|
|
|
this.nuri2_maria_byte = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String nuri2_oracle = "";
|
|
|
|
|
private int nuri2_oracle_byte = 0;
|
|
|
|
|
private String nuri2_maria = "";
|
|
|
|
|
private int nuri2_maria_byte = 0;
|
|
|
|
|
|
|
|
|
|
public String replaceLineChangeForNuri2Oracle(String str) {
|
|
|
|
|
String result = "";
|
|
|
|
|
result = str.replaceAll("\r","");
|
|
|
|
|
result = result.replaceAll("\n","\r\n");
|
|
|
|
|
result = result.replaceAll("\n", nuri2_oracle);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String replaceLineChangeForNuri2Maria(String str) {
|
|
|
|
|
public String replaceLineChangeForNuri2Maria(String str) {
|
|
|
|
|
String result = "";
|
|
|
|
|
result = str.replaceAll("\r","");
|
|
|
|
|
result = result.replaceAll("\n", "\\\\r\\\\n");
|
|
|
|
|
result = result.replaceAll("\n", nuri2_maria);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static int countLineChangeForNuri2Oracle(String str) {
|
|
|
|
|
public int countLineChangeForNuri2Oracle(String str) {
|
|
|
|
|
if(str == null || str.equals("")) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return str.split("\r\n",-1).length - 1;
|
|
|
|
|
return str.split(nuri2_oracle,-1).length - 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static int countLineChangeForNuri2Maria(String str) {
|
|
|
|
|
public int countLineChangeForNuri2Maria(String str) {
|
|
|
|
|
if(str == null || str.equals("")) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return str.split("\\\\r\\\\n",-1).length - 1;
|
|
|
|
|
return str.split(nuri2_maria,-1).length - 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static int countBytes(String str, int hangulBytes, String db) {
|
|
|
|
|
public int countBytes(String str, int hangulBytes, String db) {
|
|
|
|
|
|
|
|
|
|
Hangul hangul = new Hangul(hangulBytes);
|
|
|
|
|
|
|
|
|
|
int contentsByteCnt = hangul.getByteLength(str);
|
|
|
|
|
if(db.equals("mariadb") || db.equals("mysql")) {
|
|
|
|
|
int lineChangeCnt = countLineChangeForNuri2Maria(str);
|
|
|
|
|
contentsByteCnt = contentsByteCnt - (lineChangeCnt*3);
|
|
|
|
|
contentsByteCnt = contentsByteCnt - (lineChangeCnt*(nuri2_maria_byte - 1));
|
|
|
|
|
} else {
|
|
|
|
|
int lineChangeCnt = countLineChangeForNuri2Oracle(str);
|
|
|
|
|
contentsByteCnt = contentsByteCnt - lineChangeCnt;
|
|
|
|
|
contentsByteCnt = contentsByteCnt - (lineChangeCnt*(nuri2_oracle_byte - 1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return contentsByteCnt;
|
|
|
|
|
|