All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.scudata.expression.mfn.op.AttachSelect Maven / Gradle / Ivy

Go to download

SPL(Structured Process Language) A programming language specially for structured data computing.

There is a newer version: 20241126
Show newest version
package com.scudata.expression.mfn.op;

import com.scudata.common.MessageManager;
import com.scudata.common.RQException;
import com.scudata.dm.Context;
import com.scudata.dm.FileObject;
import com.scudata.dm.op.Channel;
import com.scudata.dm.op.FilePipe;
import com.scudata.dm.op.IPipe;
import com.scudata.expression.Expression;
import com.scudata.expression.IParam;
import com.scudata.expression.OperableFunction;
import com.scudata.resources.EngineMessage;

/**
 * ???α??ܵ????ӹ???????
 * op.select(x) op.select(x;f) op.select(x;ch) op???α??ܵ???f???ļ???ch?ǹܵ???????????????д???ļ???ܵ?
 * @author RunQian
 *
 */
public class AttachSelect extends OperableFunction {
	public Object calculate(Context ctx) {
		if (param == null) {
			return operable;
		} else if (param.isLeaf()) {
			Expression fltExp = param.getLeafExpression();
			return operable.select(this, fltExp, option, ctx);
		} else {
			if (param.getSubSize() != 2) {
				MessageManager mm = EngineMessage.get();
				throw new RQException("select" + mm.getMessage("function.invalidParam"));
			}
			
			IParam sub0 = param.getSub(0);
			IParam sub1 = param.getSub(1);
			if (sub0 == null || sub1 == null) {
				MessageManager mm = EngineMessage.get();
				throw new RQException("select" + mm.getMessage("function.invalidParam"));
			}
			
			IPipe pipe;
			Object obj = sub1.getLeafExpression().calculate(ctx);
			if (obj instanceof Channel) {
				pipe = (Channel)obj;
			} else if (obj instanceof String) {
				FileObject fo = new FileObject((String)obj);
				pipe = new FilePipe(fo);
			} else if (obj instanceof FileObject) {
				pipe = new FilePipe((FileObject)obj);
			} else {
				MessageManager mm = EngineMessage.get();
				throw new RQException("select" + mm.getMessage("function.paramTypeError"));
			}
			
			Expression fltExp = sub0.getLeafExpression();
			return operable.select(this, fltExp, option, pipe, ctx);
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy