ElinkTransactionContext에 최초요청데이터 저장 및 가져다 쓰는 함수 추가
This commit is contained in:
+44
@@ -0,0 +1,44 @@
|
||||
package com.eactive.eai.custom.transformer.function.userdefined;
|
||||
|
||||
import com.eactive.eai.common.context.ElinkTransactionContext;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.nfunk.jep.ParseException;
|
||||
import org.nfunk.jep.function.PostfixMathCommand;
|
||||
|
||||
import java.util.Stack;
|
||||
|
||||
public class SubStringRequestMessage extends PostfixMathCommand {
|
||||
public SubStringRequestMessage() {
|
||||
numberOfParameters = -1;
|
||||
}
|
||||
|
||||
public void run(Stack inStack) throws ParseException {
|
||||
checkStack(inStack);
|
||||
|
||||
String bizData = ElinkTransactionContext.getRequestBizData();
|
||||
|
||||
Object p1 = inStack.pop();
|
||||
Object p2 = inStack.pop();
|
||||
|
||||
int start = toInt(p2);
|
||||
int end = toInt(p1);
|
||||
|
||||
String resultStr = bizData.substring(start, end);
|
||||
|
||||
if(inStack.size() > 0){
|
||||
inStack.pop();
|
||||
}
|
||||
|
||||
inStack.push(resultStr);
|
||||
}
|
||||
|
||||
public static int toInt(Object obj) {
|
||||
if (obj instanceof Number) {
|
||||
return ((Number) obj).intValue();
|
||||
}
|
||||
if (obj instanceof String) {
|
||||
return Integer.parseInt(((String) obj).trim());
|
||||
}
|
||||
throw new IllegalArgumentException("Cannot convert to int: " + obj);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user