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

com.scudata.expression.mfn.table.Paste 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.table;

import com.scudata.common.MessageManager;
import com.scudata.common.RQException;
import com.scudata.dm.Context;
import com.scudata.dm.Sequence;
import com.scudata.expression.IParam;
import com.scudata.expression.ParamInfo2;
import com.scudata.expression.TableFunction;
import com.scudata.resources.EngineMessage;

/**
 * ???Ƹ????????е??ֶ?ֵ????ǰ???
 * T.paste(Ai:Fi,??;k)
 * @author RunQian
 *
 */
public class Paste extends TableFunction {
	public Object calculate(Context ctx) {
		IParam param = this.param;
		if (param == null) {
			MessageManager mm = EngineMessage.get();
			throw new RQException("paste" + mm.getMessage("function.missingParam"));
		}
		
		int pos = 0;
		if (param.getType() == IParam.Semicolon) {
			IParam sub1 = param.getSub(1);
			if (sub1 != null) {
				Object val = sub1.getLeafExpression().calculate(ctx);
				if (val instanceof Number) {
					pos = ((Number)val).intValue();
				} else if (val != null) {
					MessageManager mm = EngineMessage.get();
					throw new RQException("paste" + mm.getMessage("function.paramTypeError"));
				}
			}
			
			param = param.getSub(0);
		}
		
		ParamInfo2 pi = ParamInfo2.parse(param, "paste", true, false);
		Object []vals = pi.getValues1(ctx);
		String []names = pi.getExpressionStrs2();
		
		int fcount = vals.length;
		Sequence []fvals = new Sequence[fcount];
		for (int f = 0; f < fcount; ++f) {
			if (vals[f] instanceof Sequence) {
				fvals[f] = (Sequence)vals[f];
			} else if (vals[f] != null) {
				MessageManager mm = EngineMessage.get();
				throw new RQException("paste" + mm.getMessage("function.paramTypeError"));
			}
		}
		
		srcTable.paste(fvals, names, pos, option);
		return srcTable;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy