header relay위한 Concat user function추가
This commit is contained in:
@@ -0,0 +1,37 @@
|
|||||||
|
package com.eactive.eai.transformer.function.generic;
|
||||||
|
|
||||||
|
import java.util.Stack;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.nfunk.jep.ParseException;
|
||||||
|
import org.nfunk.jep.function.PostfixMathCommand;
|
||||||
|
|
||||||
|
public class Concat extends PostfixMathCommand {
|
||||||
|
public Concat() {
|
||||||
|
numberOfParameters = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run(Stack inStack) throws ParseException {
|
||||||
|
|
||||||
|
checkStack(inStack);
|
||||||
|
|
||||||
|
Object p2 = inStack.pop();
|
||||||
|
|
||||||
|
if (p2 instanceof String) {
|
||||||
|
String str2 = (String) p2;
|
||||||
|
Object p1 = inStack.pop();
|
||||||
|
|
||||||
|
if (p1 instanceof String) {
|
||||||
|
String str1 = (String) p1;
|
||||||
|
|
||||||
|
inStack.push(str1 + str2);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
throw new ParseException("Invalid parameter type, p1 is not string");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new ParseException("Invalid parameter type, p2 is not string");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,13 +8,15 @@ import org.nfunk.jep.function.PostfixMathCommand;
|
|||||||
|
|
||||||
public class Trim extends PostfixMathCommand {
|
public class Trim extends PostfixMathCommand {
|
||||||
public Trim() {
|
public Trim() {
|
||||||
numberOfParameters = 1;
|
numberOfParameters = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(Stack inStack) throws ParseException {
|
public void run(Stack inStack) throws ParseException {
|
||||||
checkStack(inStack);
|
checkStack(inStack);
|
||||||
|
|
||||||
Object p1 = inStack.pop();
|
Object p1 = inStack.pop();
|
||||||
|
|
||||||
|
Object p2 = inStack.pop();
|
||||||
|
|
||||||
if (p1 instanceof byte[]) {
|
if (p1 instanceof byte[]) {
|
||||||
inStack.push(new String((byte[]) p1).trim());
|
inStack.push(new String((byte[]) p1).trim());
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.eactive.eai.transformer.function.validate;
|
||||||
|
|
||||||
|
import java.util.Stack;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.nfunk.jep.ParseException;
|
||||||
|
import org.nfunk.jep.function.PostfixMathCommand;
|
||||||
|
|
||||||
|
public class isBlank extends PostfixMathCommand {
|
||||||
|
|
||||||
|
public isBlank() {
|
||||||
|
numberOfParameters = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run(Stack inStack) throws ParseException {
|
||||||
|
|
||||||
|
checkStack(inStack);
|
||||||
|
|
||||||
|
Object p1 = inStack.pop();
|
||||||
|
|
||||||
|
if (p1 instanceof String) {
|
||||||
|
String str1 = (String) p1;
|
||||||
|
|
||||||
|
inStack.push(StringUtils.isBlank(str1));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
throw new ParseException("Invalid parameter type, p1 is not string");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -9,7 +9,7 @@ public class ConcatFunction extends PostfixMathCommand {
|
|||||||
|
|
||||||
public ConcatFunction() {
|
public ConcatFunction() {
|
||||||
numberOfParameters = 2;
|
numberOfParameters = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(Stack inStack) throws ParseException {
|
public void run(Stack inStack) throws ParseException {
|
||||||
checkStack(inStack);
|
checkStack(inStack);
|
||||||
@@ -20,5 +20,6 @@ public class ConcatFunction extends PostfixMathCommand {
|
|||||||
String value = param1 + param2;
|
String value = param1 + param2;
|
||||||
|
|
||||||
inStack.push(value);
|
inStack.push(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user