Queue Body 정의, 바이트 유틸, String 유틸, 메시지 처리 관련 유틸 추가, 큐성능 테스트 진행중

This commit is contained in:
dsjang 2024-05-20 01:30:01 +09:00
parent f06eb1a20f
commit 1454c2658a
8 changed files with 776 additions and 6 deletions

View File

@ -0,0 +1,46 @@
package com.munjaon.server.queue.config;
public final class BodyCommonConfig {
/* 회원 아이디 (Length : 20 / Position : 0) */
public static final int USERID_BYTE_LENGTH = 20;
public static final int USERID_BYTE_POSITION = 0;
/* 요금제 정보 (Length : 1 / Position : 20) (선불 : P(Prepayment) / 후불 : D(Detered Payment)) */
public static final int FEETYPE_BYTE_LENGTH = 1;
public static final int FEETYPE_BYTE_POSITION = USERID_BYTE_POSITION + USERID_BYTE_LENGTH;
/* 단가정보 (Length : 10 / Position : 21) */
public static final int UNITCOST_BYTE_LENGTH = 10;
public static final int UNITCOST_BYTE_POSITION = FEETYPE_BYTE_POSITION + FEETYPE_BYTE_LENGTH;
/* 메시지 그룹 아이디 (문자온 메시지 테이블에서 그룹핑할 메시지ID) (Length : 20 / Position : 31) */
public static final int MSGGROUPID_BYTE_LENGTH = 20;
public static final int MSGGROUPID_BYTE_POSITION = UNITCOST_BYTE_POSITION + UNITCOST_BYTE_LENGTH;
/* 고객사 메시지 ID 길이 (Length : 20 / Position : 51) */
public static final int MSGID_BYTE_LENGTH = 20;
public static final int MSGID_BYTE_POSITION = MSGGROUPID_BYTE_POSITION + MSGGROUPID_BYTE_LENGTH;
/* 서비스타입(4:SMS / 6:LMS, MMS / 8:카카오 알림톡 / 9:카카오 친구톡) (Length : 1 / Position : 71) */
public static final int SERVICETYPE_BYTE_LENGTH = 1;
public static final int SERVICETYPE_BYTE_POSITION = MSGID_BYTE_POSITION + MSGID_BYTE_LENGTH;
/* 결과코드 (Length : 5 / Position : 72) */
public static final int SENDSTATUS_BYTE_LENGTH = 5;
public static final int SENDSTATUS_BYTE_POSITION = SERVICETYPE_BYTE_POSITION + SERVICETYPE_BYTE_LENGTH;
/* 회신번호 (Length : 12 / Position : 77) */
public static final int SENDER_BYTE_LENGTH = 12;
public static final int SENDER_BYTE_POSITION = SENDSTATUS_BYTE_POSITION + SENDSTATUS_BYTE_LENGTH;
/* 수신번호 (Length : 12 / Position : 89) */
public static final int RECEIVER_BYTE_LENGTH = 12;
public static final int RECEIVER_BYTE_POSITION = SENDER_BYTE_POSITION + SENDER_BYTE_LENGTH;
/* 예약시간 (Length : 15 / Position : 101) */
public static final int RESERVEDT_BYTE_LENGTH = 15;
public static final int RESERVEDT_BYTE_POSITION = RECEIVER_BYTE_POSITION + RECEIVER_BYTE_LENGTH;
/* 요청시간 (Length : 15 / Position : 116) */
public static final int REQUESTDT_BYTE_LENGTH = 15;
public static final int REQUESTDT_BYTE_POSITION = RESERVEDT_BYTE_POSITION + RESERVEDT_BYTE_LENGTH;
/* 원격접속지 주소 (Length : 25 / Position : 131) */
public static final int REMOTEIP_BYTE_LENGTH = 25;
public static final int REMOTEIP_BYTE_POSITION = REQUESTDT_BYTE_POSITION + REQUESTDT_BYTE_LENGTH;
/* 에이전트 코드 (Length : 5 / Position : 156) */
public static final int AGENT_CODE_BYTE_LENGTH = 5;
public static final int AGENT_CODE_BYTE_POSITION = REMOTEIP_BYTE_POSITION + REMOTEIP_BYTE_LENGTH;
/* Body 전체 길이 */
public static final int COMMON_SUM_BYTE_LENGTH = USERID_BYTE_LENGTH + FEETYPE_BYTE_LENGTH + UNITCOST_BYTE_LENGTH + MSGGROUPID_BYTE_LENGTH + MSGID_BYTE_LENGTH + SERVICETYPE_BYTE_LENGTH + SENDSTATUS_BYTE_LENGTH + SENDER_BYTE_LENGTH + RECEIVER_BYTE_LENGTH + RESERVEDT_BYTE_LENGTH + REQUESTDT_BYTE_LENGTH + REMOTEIP_BYTE_LENGTH + AGENT_CODE_BYTE_LENGTH;
}

View File

@ -0,0 +1,25 @@
package com.munjaon.server.queue.config;
public final class MediaBodyConfig {
/* 제목 (Length : 60 / Position : 161) */
public static final int SUBJECT_BYTE_LENGTH = 60;
public static final int SUBJECT_BYTE_POSITION = BodyCommonConfig.AGENT_CODE_BYTE_POSITION + BodyCommonConfig.AGENT_CODE_BYTE_LENGTH;
/* LMS/MMS Message (Length : 2000 / Position : 221) */
public static final int MEDIA_MSG_BYTE_LENGTH = 2000;
public static final int MEDIA_MSG_BYTE_POSITION = SUBJECT_BYTE_POSITION + SUBJECT_BYTE_LENGTH;
/* 파일카운트 (Length : 1 / Position : 2221) */
public static final int FILECNT_BYTE_LENGTH = 1;
public static final int FILECNT_BYTE_POSITION = MEDIA_MSG_BYTE_POSITION + MEDIA_MSG_BYTE_LENGTH;
/* 파일명 #1 (Length : 128 / Position : 2222) */
public static final int FILENAME_ONE_BYTE_LENGTH = 128;
public static final int FILENAME_ONE_BYTE_POSITION = FILECNT_BYTE_POSITION + FILECNT_BYTE_LENGTH;
/* 파일명 #2 (Length : 128 / Position : 2350) */
public static final int FILENAME_TWO_BYTE_LENGTH = 128;
public static final int FILENAME_TWO_BYTE_POSITION = FILENAME_ONE_BYTE_POSITION + FILENAME_ONE_BYTE_LENGTH;
/* 파일명 #3 (Length : 128 / Position : 2478) */
public static final int FILENAME_THREE_BYTE_LENGTH = 128;
public static final int FILENAME_THREE_BYTE_POSITION = FILENAME_TWO_BYTE_POSITION + FILENAME_TWO_BYTE_LENGTH;
/* Media Body 길이 */
public static final int MEDIA_SUM_BYTE_LENGTH = BodyCommonConfig.COMMON_SUM_BYTE_LENGTH + SUBJECT_BYTE_LENGTH + MEDIA_MSG_BYTE_LENGTH + FILECNT_BYTE_LENGTH + FILENAME_ONE_BYTE_LENGTH + FILENAME_TWO_BYTE_LENGTH + FILENAME_THREE_BYTE_LENGTH;
}

View File

@ -1,14 +1,15 @@
package com.munjaon.server.queue.config;
public final class QueueHeaderConfig {
/** Queue File Header Length - [Create Date:10 Byte, Push Count:10 Byte] */
public static final int QUEUE_HEADER_LENGTH = 20;
/* 큐생성일 읽을 위치값 */
/* 변수 정의 : 전체 길이 : 개별 변수 Length : 개별 변수 Position */
/* 큐생성일 읽을 위치값 : 0 */
public static final int CREATE_DATE_POSITION = 0;
/* 큐생성일 읽을 크기 */
public static final int CREATE_DATE_LENGTH = 10;
/* 큐 쓰기 카운트 읽을 위치값 */
public static final int PUSH_COUNT_POSITION = 10;
public static final int PUSH_COUNT_POSITION = CREATE_DATE_POSITION + CREATE_DATE_LENGTH;
/* 큐 쓰기 카운트 읽을 크기 */
public static final int PUSH_COUNT_LENGTH = 10;
/* Queue File Header Length - [Create Date:10 Byte, Push Count:10 Byte] */
public static final int QUEUE_HEADER_LENGTH = CREATE_DATE_LENGTH + PUSH_COUNT_LENGTH;
}

View File

@ -0,0 +1,10 @@
package com.munjaon.server.queue.config;
public final class SmsBodyConfig {
/* SMS Message (Length : 160 / Position : 161) */
public static final int SMS_MSG_BYTE_LENGTH = 160;
public static final int SMS_MSG_BYTE_POSITION = BodyCommonConfig.AGENT_CODE_BYTE_POSITION + BodyCommonConfig.AGENT_CODE_BYTE_LENGTH;
/* SMS Body 길이 */
public static final int SMS_SUM_BYTE_LENGTH = BodyCommonConfig.COMMON_SUM_BYTE_LENGTH + SMS_MSG_BYTE_LENGTH;
}

View File

@ -8,11 +8,20 @@ import lombok.ToString;
@Setter
@ToString
public class BasicMessageDto {
protected String userId = "";
protected String feeType = "";
protected String unitCost = "";
protected String msgGroupID = "0";
protected String userMsgID = "";
protected String serviceType = "";
protected String sendStatus = "0";
protected String userSender = "";
protected String userReceiver = "";
protected String reserveDt = "";
protected String requestDt;
protected String remoteIP = "127.0.0.1";
protected String routerSeq = "0";
protected String userMessage = "";
protected String userMsgType = "";
protected String userRequestDate = "";
protected String sendStatus = "0";
}

View File

@ -0,0 +1,423 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.munjaon.server.util;
/**
* bytes 관련 유틸리티 클래스
* @author JDS
*/
public final class ByteUtil {
public static final int BYTE_SIZE = 128;
/* 큐에 저장하기전에 바이트를 채울 문자 */
public static final byte SET_DEFAULT_BYTE = (byte) 0x00;
/**
* bytes 배열의 핵사값을 16자리씩 개행하여 반환한다.<BR>
* 핵사 로그 출력을 위해 사용한다.
* @param src
* @param isLine
* @return 16자리씩 개행된 핵사값
*/
public static String byteToHex(byte[] src, boolean isLine) {
String hex = "";
// if(src.length > 16)
hex = "";
for (int i = 0, j = 1; i < src.length; i++, j++) {
hex += pad0(Integer.toHexString(src[i] & 0xff), 2) + " ";
if (isLine && src.length > 16 && (j % 16) == 0) {
// hex += " " + new String(codes, j-16, 16);
hex += "\r\n";
}
}
return hex;
}
/**
* bytes 배열의 핵사값을 16자리씩 개행하여 반환한다.<BR>
* 핵사 로그 출력을 위해 사용한다.
* @param src
* @return 16자리씩 개행된 핵사값
*/
public static String byteToHex(byte[] src) {
String hex = "";
// if(src.length > 16)
//hex = "\r\n";
for (int i = 0, j = 1; i < src.length; i++, j++) {
hex += pad0(Integer.toHexString(src[i] & 0xff), 2) + " ";
if (src.length > 16 && (j % 16) == 0) {
// hex += " " + new String(codes, j-16, 16);
hex += "\r\n";
}
}
return hex;
}
/**
* bytes 배열의 지정된 위치값에 대해 16자리씩 개행된 핵사값으로 반환한다.<BR>
* 핵사 로그 출력을 위해 사용한다.
* @param src
* @param srcPos
* @param length
* @return 16자리씩 개행된 핵사값
*/
public static String byteToHex(byte[] src, int srcPos, int length) {
String hex = "";
//if(src.length > 16)
hex = "\r\n";
for (int i = srcPos, j = 1; i < srcPos + length; i++, j++) {
hex += pad0(Integer.toHexString(src[i] & 0xff), 2) + " ";
if (src.length > 16 && (j % 16) == 0) {
hex += "\r\n";
}
}
return hex;
}
public static String intToHex(int src) {
String hex = "0x";
byte[] bSrc = ByteUtil.intToByte(src);
for (int i = 0, j = 1; i < bSrc.length; i++, j++) {
hex += pad0(Integer.toHexString(bSrc[i] & 0xff), 2);
}
return hex;
}
public static byte[] shortToByte(short s) {
byte dest[] = new byte[2];
dest[1] = (byte) (s & 0xff);
dest[0] = (byte) (s >>> 8 & 0xff);
return dest;
}
public static byte[] intToByte(int i) {
byte dest[] = new byte[4];
dest[3] = (byte) (i & 0xff);
dest[2] = (byte) (i >>> 8 & 0xff);
dest[1] = (byte) (i >>> 16 & 0xff);
dest[0] = (byte) (i >>> 24 & 0xff);
return dest;
}
public static byte[] longToByte(long l) {
byte dest[] = new byte[8];
dest[7] = (byte) (int) (l & 255L);
dest[6] = (byte) (int) (l >>> 8 & 255L);
dest[5] = (byte) (int) (l >>> 16 & 255L);
dest[4] = (byte) (int) (l >>> 24 & 255L);
dest[3] = (byte) (int) (l >>> 32 & 255L);
dest[2] = (byte) (int) (l >>> 40 & 255L);
dest[1] = (byte) (int) (l >>> 48 & 255L);
dest[0] = (byte) (int) (l >>> 56 & 255L);
return dest;
}
public static byte[] floatToByte(float f) {
byte dest[] = new byte[4];
return setFloat(dest, 0, f);
}
public static byte[] doubleToByte(double d) {
byte dest[] = new byte[8];
return setDouble(dest, 0, d);
}
public static byte getByte(byte src[], int offset) {
return src[offset];
}
public static byte[] getBytes(String data) {
byte[] b = null;
b = data.getBytes();
return (b);
}
public static byte[] getBytes(byte src[], int offset, int length) {
byte dest[] = new byte[length];
System.arraycopy(src, offset, dest, 0, length);
return dest;
}
public static short getShort(byte src[], int offset) {
return (short) ((src[offset] & 0xff) << 8 | src[offset + 1] & 0xff);
}
public static int getInt(byte src[], int offset) {
return (src[offset] & 0xff) << 24 | (src[offset + 1] & 0xff) << 16
| (src[offset + 2] & 0xff) << 8 | src[offset + 3] & 0xff;
}
public static long getLong(byte src[], int offset) {
return (long) getInt(src, offset) << 32
| (long) getInt(src, offset + 4) & 0xffffffffL;
}
public static float getfloat(byte src[], int offset) {
return Float.intBitsToFloat(getInt(src, offset));
}
public static double getdouble(byte src[], int offset) {
return Double.longBitsToDouble(getLong(src, offset));
}
public static byte[] setByte(byte dest[], int offset, byte b) {
dest[offset] = b;
return dest;
}
public static void setBytes(byte[] dest, int offset, String s) {
setBytes(dest, offset, s.getBytes());
}
public static byte[] setBytes(byte dest[], int offset, byte src[]) {
System.arraycopy(src, 0, dest, offset, src.length);
return dest;
}
public static byte[] setBytes(byte dest[], int offset, byte src[],
int len) {
System.arraycopy(src, 0, dest, offset, len);
return dest;
}
public static byte[] setShort(byte dest[], int offset, short s) {
dest[offset] = (byte) (s >>> 8 & 0xff);
dest[offset + 1] = (byte) (s & 0xff);
return dest;
}
public static byte[] setInt(byte dest[], int offset, int i) {
dest[offset] = (byte) (i >>> 24 & 0xff);
dest[offset + 1] = (byte) (i >>> 16 & 0xff);
dest[offset + 2] = (byte) (i >>> 8 & 0xff);
dest[offset + 3] = (byte) (i & 0xff);
return dest;
}
public static byte[] setLong(byte dest[], int offset, long l) {
setInt(dest, offset, (int) (l >>> 32));
setInt(dest, offset + 4, (int) (l & 0xffffffffL));
return dest;
}
public static byte[] setFloat(byte dest[], int offset, float f) {
return setInt(dest, offset, Float.floatToIntBits(f));
}
public static byte[] setDouble(byte dest[], int offset, double d) {
return setLong(dest, offset, Double.doubleToLongBits(d));
}
public static boolean isEquals(byte b[], String s) {
if (b == null || s == null)
return false;
int slen = s.length();
if (b.length != slen)
return false;
for (int i = slen; i-- > 0;)
if (b[i] != s.charAt(i))
return false;
return true;
}
public static boolean isEquals(byte a[], byte b[]) {
if (a == null || b == null)
return false;
if (a.length != b.length)
return false;
for (int i = a.length; i-- > 0;)
if (a[i] != b[i])
return false;
return true;
}
public static int hexToInt(byte[] b) {
int sum = 0;
int len = 0;
int pos = 0;
if (b != null) {
len = b.length;
for (int i = len - 1; i > 0; i--) {
sum += sqrt(BYTE_SIZE, i) * (int) b[pos];
pos++;
}
sum += b[pos];
}
return (sum);
}
public static int hexToInt(byte[] b, int start, int len) {
int sum = 0;
int pos = start;
if (b != null) {
for (int i = len - 1; i > 0; i--) {
sum += sqrt(BYTE_SIZE, i) * (int) b[pos];
pos++;
}
sum += b[pos];
}
return (sum);
}
public static byte[] intToHex(int num, int digit) {
byte[] b = new byte[digit];
int[] intArr = makeFunction(num, digit, BYTE_SIZE);
for (int i = 0; i < digit; i++) {
b[i] = (byte) intArr[i];
}
return (b);
}
private static int[] makeFunction(int num, int digit, int jinso) {
int[] fun = new int[digit];
int restNum = num;
int pos = 0;
for (int i = digit - 1; i > 0; i--) {
int quotient = restNum / sqrt(jinso, i);
fun[pos++] = quotient;
restNum -= (quotient * sqrt(jinso, i));
}
fun[pos++] = restNum;
return (fun);
}
private static int sqrt(int num, int count) {
int sum = 0;
sum = (count >= 1) ? num : 0;
for (int i = 1; i < count; i++) {
sum = sum * num;
}
return (sum);
}
public static boolean arrayComp(byte[] src, byte[] obj) {
boolean isSame = true;
if (src.length != obj.length) {
isSame = false;
} else {
for (int i = 0; i < src.length; i++) {
if (src[i] != obj[i]) {
isSame = false;
break;
}
}
}
return (isSame);
}
public static String pad0(String str, int size) {
char[] zeros = new char[size - str.length()];
for (int i = 0; i < zeros.length; i++)
zeros[i] = '0';
return new String(zeros) + str;
}
public static byte[] convertCharArrayToByteArray(char[] ca) {
byte[] ba = new byte[ca.length*2];
java.nio.ByteBuffer.wrap(ba).asCharBuffer().put(ca);
return ba;
}
public static char[] convertByteArrayToCharArray(byte[] ba) {
char[] ca = new char[ba.length/2];
java.nio.ByteBuffer.wrap(ba).asCharBuffer().get(ca);
return ca;
}
public static byte[] setNull(byte[] b) {
for(int i=0; i<b.length; i++) {
b[i] = 0x00;
}
return b;
}
// Big Endian: network order
public static int toInt(byte[] value) {
return (int)(
(value[3] & 0xff) |
(value[2] & 0xff) << 8 |
(value[1] & 0xff) << 16 |
(value[0] & 0xff) << 24 );
}
// Big Endian: network order
public static byte[] toBytes(int value) {
byte[] ret = new byte[4];
ret[3] = (byte)(value & 0xff);
ret[2] = (byte)(value >> 8 & 0xff);
ret[1] = (byte)(value >> 16 & 0xff);
ret[0] = (byte)(value >> 24 & 0xff);
return ret;
}
// Little Endian
public static int toInt2(byte[] value) {
return (int)(
(value[0] & 0xff) |
(value[1] & 0xff) << 8 |
(value[2] & 0xff) << 16 |
(value[3] & 0xff) << 24 );
}
// Little Endian
public static byte[] toBytes2(int value) {
byte[] ret = new byte[4];
ret[0] = (byte)(value & 0xff);
ret[1] = (byte)(value >> 8 & 0xff);
ret[2] = (byte)(value >> 16 & 0xff);
ret[3] = (byte)(value >> 24 & 0xff);
return ret;
}
public static byte[] setSpaceAll(byte[] data) {
return setAll(data, (byte) ' ');
}
public static byte[] setAll(byte[] data, byte bt) {
int len = data.length;
for( int i=0; i<len; i++ ) {
data[i] = bt;
}
return data;
}
public static byte[] replaceAll(byte[] data, byte from, byte to) {
int len = data.length;
for( int i=0; i<len; i++ ) {
if( data[i] == from ) {
data[i] = to;
}
}
return data;
}
}

View File

@ -0,0 +1,89 @@
package com.munjaon.server.util;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
public final class MessageUtil {
public static String getDateFormat(String format) {
return LocalDateTime.now().format(DateTimeFormatter.ofPattern(format));
}
/**
* DateFormat : yyyyMMdd
* @return
*/
public static String getDate() {
return getDateFormat("yyyyMMdd");
}
/**
* DateFormat : yyyyMMddHHmmss
* @return
*/
public static String getTime() {
return getDateFormat("yyyyMMddHHmmss");
}
public static String doNumber(String spell){
String phoneNumber = "";
if(spell == null){
return phoneNumber;
}
spell = spell.trim();
int spell_Length = spell.length();
if(spell_Length < 1){
return phoneNumber;
}
for(int i=0;i<spell_Length;i++){
char eachChar = spell.charAt(i);
if( 0x30 <= eachChar && eachChar <= 0x39 ){
phoneNumber += eachChar;
}
}
return phoneNumber;
}
// 소수점 뒤에 해당하는 자리만큼 자르기
public static String cutFloatNumber(String srcNum, int digit){
String headNum = "";
String tailNum = "";
String retNum = "";
if(!(srcNum == null || srcNum.trim().equals(""))){
srcNum = srcNum.trim();
int index = srcNum.indexOf(".");
// 소수점 위치가 0보다 큰경우만 처리
if(index > 0){
headNum = srcNum.substring(0, index);
tailNum = srcNum.substring((index + 1), srcNum.length());
if(tailNum.length() == 0){
tailNum = "0";
}
if(tailNum.length() > digit){
tailNum = tailNum.substring(0, digit);
}
retNum = headNum + "." + tailNum;
}
}
return retNum;
}
// 수신번호 체크하기
public static boolean CheckPhone(String src) {
if(src == null || src.trim().length() < 10) {
return false;
}
if(!src.startsWith("0")) {
return false;
}
return true;
}
// 문자열 공백 제거
public static String trim(String obj) {
return StringUtil.trim(obj);
}
}

View File

@ -0,0 +1,167 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.munjaon.server.util;
import java.text.DecimalFormat;
import java.util.ArrayList;
/**
* 문자열 관련 유틸리티 클래스
* @author JDS
*/
public final class StringUtil {
public static final String SystemEncoding = getSystemEncoding();
public static String getSystemEncoding() {
return (new java.io.OutputStreamWriter(System.out)).getEncoding();
}
public static String trim(byte[] obj) {
if( obj == null || obj.length == 0 ) {
return "";
}
return (new String(obj)).trim();
}
public static String trim(Object obj) {
return trim(obj, "");
}
public static String trim(Object obj, String dflt) {
if( obj == null ) {
return dflt;
}
return ((String)obj).trim();
}
public static String ltrim(byte[] obj) {
return ltrim(new String(obj));
}
public static String ltrim(String obj) {
return ltrim(obj.toCharArray());
}
public static String ltrim(char[] obj) {
int len = obj.length;
int idx = 0;
while( idx < len && obj[idx] <= ' ' ) {
idx++;
}
return new String(obj, idx, len-idx);
}
public static String rtrim(byte[] obj) {
return rtrim(new String(obj));
}
public static String rtrim(String obj) {
return rtrim(obj.toCharArray());
}
public static String rtrim(char[] obj) {
int len = obj.length;
int idx = len-1;
while( idx >= 0 && obj[idx] <= ' ' ) {
idx--;
}
return new String(obj, 0, idx+1);
}
public static String replaceAll(String src, String from, String to) {
StringBuilder sbuf = new StringBuilder();
int len = from.length();
int idx = 0;
int stx = 0;
while( (idx=src.indexOf(from, stx)) > -1 ) {
sbuf.append(src.substring(stx, idx));
sbuf.append(to);
stx=idx+len;
}
sbuf.append(src.substring(stx));
return sbuf.toString();
}
public static String[] split(String sSrc, String sDelim) {
ArrayList aList = new ArrayList();
String sTmp;
int len = sDelim.length();
int idx = 0;
int stx = 0;
while( (idx=sSrc.indexOf(sDelim, stx)) > -1 ) {
sTmp = sSrc.substring(stx, idx);
aList.add(sTmp);
stx=idx+len;
}
if( stx <= sSrc.length() ) {
aList.add(sSrc.substring(stx));
}
String[] sRet = new String[aList.size()];
for( int i=0; i<aList.size(); i++ ) {
sRet[i] = (String) aList.get(i);
}
return sRet;
}
public static String substring(String obj, int idx, int length) {
if( obj.getBytes().length <= idx ) {
return "";
}
if( obj.getBytes().length <= length ) {
return obj;
}
int totallen=0;
int i=idx;
for( i=idx; i<obj.length(); i++ ) {
totallen += obj.substring(i, i+1).getBytes().length;
if( length < totallen ) {
break;
}
}
return obj.substring(idx, i);
}
public static String substring(String obj, int length) {
return substring(obj, 0, length);
}
public static String numFilter(String src) {
return src.replaceAll("[^0-9]", "");
}
public static String toNumberFormat(Object obj, String fmt) {
DecimalFormat df = new DecimalFormat(fmt);
return df.format(obj);
}
public static String pad0(String str, int size) {
char[] zeros = new char[size - str.length()];
for (int i = 0; i < zeros.length; i++)
zeros[i] = '0';
return new String(zeros) + str;
}
}