/********************************
 *	프로젝트 : gargoyle-rax
 *	패키지   : com.kyj.fx.vbs.text
 *	작성일   : 2018. 10. 5.
 *	작성자   : KYJ (callakrsos@naver.com)
 *******************************/
package com.kyj.fx.vbs.text;

import java.io.File;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;

import com.kyj.fx.commons.utils.RuntimeClassUtil;


/**
 * @author KYJ (callakrsos@naver.com)
 *
 */
public class VbsRunner implements Runnable {

	private List<String> args;

	public VbsRunner(File vbsFile) {
		args = Arrays.asList("cscript", vbsFile.getAbsolutePath());
	}

	/**
	 * @최초생성일 2018. 10. 8.
	 */
	private Consumer<String> messageReceiver = str -> {

	};

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Runnable#run()
	 */
	public void run() {
		try {
			RuntimeClassUtil.exe(args, Charset.forName("EUC-KR"), messageReceiver);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * @return the messageReceiver
	 */
	public Consumer<String> getMessageReceiver() {
		return messageReceiver;
	}

	/**
	 * @param messageReceiver
	 *            the messageReceiver to set
	 */
	public void setMessageReceiver(Consumer<String> messageReceiver) {
		this.messageReceiver = messageReceiver;
	}

}
