init
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package com.eactive.eai.common.tas;
|
||||
|
||||
public class TASUtil {
|
||||
private static int TAS_HEADER_LENGTH = 3;
|
||||
|
||||
public static byte[] removeTasHeader(byte[] srcBytes) {
|
||||
if (srcBytes == null) {
|
||||
return null;
|
||||
}
|
||||
byte[] result = new byte[srcBytes.length - TAS_HEADER_LENGTH];
|
||||
System.arraycopy(srcBytes, 3, result, 0, result.length);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static byte[] addTasHeader(byte[] srcBytes, String bizCode) {
|
||||
if (srcBytes == null) {
|
||||
return null;
|
||||
}
|
||||
byte[] result = new byte[srcBytes.length + TAS_HEADER_LENGTH];
|
||||
System.arraycopy(bizCode.getBytes(), 0, result, 0, TAS_HEADER_LENGTH);
|
||||
System.arraycopy(srcBytes, 0, result, TAS_HEADER_LENGTH, srcBytes.length);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String getTasHeader(byte[] srcBytes) {
|
||||
if (srcBytes == null) {
|
||||
return null;
|
||||
}
|
||||
return new String((byte[])srcBytes,0,TAS_HEADER_LENGTH);
|
||||
|
||||
}
|
||||
|
||||
// public static void main(String[] argv) {
|
||||
// String bizCode = "";
|
||||
// byte[] message = "ABC1234567890".getBytes();
|
||||
//
|
||||
// bizCode = getTasHeader(message);
|
||||
// message = removeTasHeader(message);
|
||||
//
|
||||
// System.out.println(bizCode + ":" +new String(message));
|
||||
//
|
||||
// System.out.println(new String(addTasHeader(message, bizCode)) );
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user