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");
		}

	}
}
