매핑변환함수 추가(KJB 이상욱D 요청)
This commit is contained in:
+37
@@ -0,0 +1,37 @@
|
||||
package com.eactive.eai.custom.transformer.function.userdefined;
|
||||
|
||||
import java.util.Stack;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.nfunk.jep.ParseException;
|
||||
import org.nfunk.jep.function.PostfixMathCommand;
|
||||
|
||||
|
||||
public class BooleanToFlag extends PostfixMathCommand {
|
||||
public BooleanToFlag() {
|
||||
numberOfParameters = -1;
|
||||
}
|
||||
|
||||
public void run(Stack inStack) throws ParseException {
|
||||
checkStack(inStack);
|
||||
|
||||
Object p1 = inStack.pop();
|
||||
|
||||
String strInStack = "";
|
||||
String resultStr = "";
|
||||
if (p1 instanceof byte[]) {
|
||||
strInStack = new String((byte[]) p1);
|
||||
} else if (p1 instanceof String) {
|
||||
strInStack = (String) p1;
|
||||
} else {
|
||||
throw new ParseException("Invalid parameter type, p1 is not string/bytes");
|
||||
}
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(strInStack, "TRUE")) {
|
||||
resultStr = "Y";
|
||||
} else {
|
||||
resultStr = "N";
|
||||
}
|
||||
inStack.push(resultStr);
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
package com.eactive.eai.custom.transformer.function.userdefined;
|
||||
|
||||
import java.util.Stack;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.nfunk.jep.ParseException;
|
||||
import org.nfunk.jep.function.PostfixMathCommand;
|
||||
|
||||
|
||||
public class ContainsString extends PostfixMathCommand {
|
||||
public ContainsString() {
|
||||
numberOfParameters = -1;
|
||||
}
|
||||
|
||||
public void run(Stack inStack) throws ParseException {
|
||||
checkStack(inStack);
|
||||
|
||||
if (curNumberOfParameters == 4) {
|
||||
Object p4 = inStack.pop();
|
||||
if (p4 instanceof String) {
|
||||
String falseVal = (String) p4;
|
||||
Object p3 = inStack.pop();
|
||||
if (p3 instanceof String) {
|
||||
String trueVal = (String) p3;
|
||||
Object p2 = inStack.pop();
|
||||
if (p2 instanceof String) {
|
||||
String str = (String) p2;
|
||||
Object p1 = inStack.pop();
|
||||
if (p1 instanceof String) {
|
||||
String originStr = (String) p1;
|
||||
if (StringUtils.contains(originStr, str)) {
|
||||
inStack.push(trueVal);
|
||||
} else {
|
||||
inStack.push(falseVal);
|
||||
}
|
||||
} else if (p1 instanceof byte[]) {
|
||||
String originStr = new String((byte[]) p1);
|
||||
if (StringUtils.contains(originStr, str)) {
|
||||
inStack.push(trueVal);
|
||||
} else {
|
||||
inStack.push(falseVal);
|
||||
}
|
||||
} else {
|
||||
throw new ParseException("Invalid parameter type, p1 is not string/bytes");
|
||||
}
|
||||
} else {
|
||||
throw new ParseException("Invalid parameter type, p2 is not String");
|
||||
}
|
||||
} else {
|
||||
throw new ParseException("Invalid parameter type, p3 is not String");
|
||||
}
|
||||
} else {
|
||||
throw new ParseException("Invalid parameter type, p4 is String");
|
||||
}
|
||||
} else {
|
||||
throw new ParseException("invalid parameter count : " + curNumberOfParameters + " - parameter count must be 4");
|
||||
}
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.eactive.eai.custom.transformer.function.userdefined;
|
||||
|
||||
import java.util.Stack;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.nfunk.jep.ParseException;
|
||||
import org.nfunk.jep.function.PostfixMathCommand;
|
||||
|
||||
|
||||
public class FlagToBoolean extends PostfixMathCommand {
|
||||
public FlagToBoolean() {
|
||||
numberOfParameters = -1;
|
||||
}
|
||||
|
||||
public void run(Stack inStack) throws ParseException {
|
||||
checkStack(inStack);
|
||||
|
||||
Object p1 = inStack.pop();
|
||||
|
||||
String strInStack = "";
|
||||
String resultStr = "";
|
||||
if (p1 instanceof byte[]) {
|
||||
strInStack = new String((byte[]) p1);
|
||||
} else if (p1 instanceof String) {
|
||||
strInStack = (String) p1;
|
||||
} else {
|
||||
throw new ParseException("Invalid parameter type, p1 is not string/bytes");
|
||||
}
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(strInStack, "Y")) {
|
||||
resultStr = "True";
|
||||
} else {
|
||||
resultStr = "False";
|
||||
}
|
||||
inStack.push(resultStr);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user