package com.eactive.eai.common.util.convert;

import java.util.Stack;

import org.nfunk.jep.ParseException;
import org.nfunk.jep.function.PostfixMathCommand;


/**
 * EBCDIC 값을 ASCII으로 변환하는 함수
 * 입력 값은 byte[], 결과는 byte[]임.
 */
public class EBCDIC2ASCII extends PostfixMathCommand {
    public EBCDIC2ASCII() {
        numberOfParameters = 1;
    }

    @SuppressWarnings({ "rawtypes", "unchecked" })
	public void run(Stack inStack) throws ParseException {
        checkStack(inStack);

        Object param = inStack.pop();

        try {
            byte[] value = (byte[]) param;

            inStack.push(IConv.ebcdicToASCII(value).getBytes());
        } catch (Exception e) {
            throw new ParseException(e.getMessage());
        }
    }
}
