mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-19 17:56:41 +10:00
[강운덕] [LUCYSUS-1744] 바인딩 변수 api 할당 api의 아규먼트를 문자열로 치환하는 로직 부분 개발.
git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-tomcat-profiler/trunk@626 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
package com.profiler.util;
|
||||
|
||||
|
||||
public class ArrayUtils {
|
||||
|
||||
public static String dropToString(byte[] bytes) {
|
||||
return dropToString(bytes, 10);
|
||||
}
|
||||
|
||||
public static String dropToString(byte[] bytes, int limit) {
|
||||
if (bytes == null) {
|
||||
return "null";
|
||||
}
|
||||
// TODO limit음수일 경우 예외처리 필요.
|
||||
// size 4인 배열의 경 3에서 멈춰야 하므로 -1
|
||||
int iMax = bytes.length - 1;
|
||||
int iLimit = limit - 1;
|
||||
if (iMax > iLimit) {
|
||||
iMax = iLimit;
|
||||
}
|
||||
if (iMax == -1) {
|
||||
if (bytes.length == 0) {
|
||||
return "[]";
|
||||
} else {
|
||||
return "[...(" + bytes.length + ")]";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append('[');
|
||||
for (int i = 0; ; i++) {
|
||||
sb.append(bytes[i]);
|
||||
if (i == iMax) {
|
||||
if (iMax < iLimit) {
|
||||
return sb.append(']').toString();
|
||||
} else {
|
||||
if (i > 0) {
|
||||
|
||||
}
|
||||
sb.append(", ");
|
||||
sb.append("...(");
|
||||
sb.append(bytes.length);
|
||||
sb.append(")]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
sb.append(", ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user