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

com.scudata.expression.mfn.vdb.Move 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.vdb;

import com.scudata.common.MessageManager;
import com.scudata.common.RQException;
import com.scudata.dm.Context;
import com.scudata.expression.IParam;
import com.scudata.expression.VSFunction;
import com.scudata.resources.EngineMessage;

/**
 * ɾ??Ŀ¼???߰?Ŀ¼?ƶ?????һ??Ŀ¼??
 * h.move(ps,pd:F)
 * @author RunQian
 *
 */
public class Move extends VSFunction {
	public Object calculate(Context ctx) {
		if (param == null) {
			return vs.delete(option);
		} else if (param.isLeaf()) {
			Object path = param.getLeafExpression().calculate(ctx);
			return vs.delete(path, option);
		} else {
			if (param.getSubSize() != 2) {
				MessageManager mm = EngineMessage.get();
				throw new RQException("move" + 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("move" + mm.getMessage("function.invalidParam"));
			}
			
			Object srcPath = sub0.getLeafExpression().calculate(ctx);
			Object destPath;
			Object destName = null;
			if (sub1.isLeaf()) {
				destPath = sub1.getLeafExpression().calculate(ctx);
			} else {
				if (sub1.getSubSize() != 2) {
					MessageManager mm = EngineMessage.get();
					throw new RQException("move" + mm.getMessage("function.invalidParam"));
				}
				
				IParam path = sub1.getSub(0);
				IParam name = sub1.getSub(1);
				if (path == null || name == null) {
					MessageManager mm = EngineMessage.get();
					throw new RQException("move" + mm.getMessage("function.invalidParam"));
				}
				
				destPath = path.getLeafExpression().calculate(ctx);
				destName = name.getLeafExpression().calculate(ctx);
			}
			
			return vs.move(srcPath, destPath, destName);
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy