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

com.scudata.expression.mfn.string.SQLParse 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.string;

import com.scudata.common.MessageManager;
import com.scudata.common.RQException;
import com.scudata.dm.Context;
import com.scudata.dm.sql.SQLUtil;
import com.scudata.expression.StringFunction;
import com.scudata.resources.EngineMessage;

/**
 * ???SQL???ĸ??????ֹ??????з???
 * sql.sqlparse() sql.sqlparse(part)
 * @author RunQian
 *
 */
public class SQLParse extends StringFunction {
	public Object calculate(Context ctx) {
		if (srcStr == null || srcStr.length() == 0) {
			return null;
		}
		
		if (param == null) {
			return SQLUtil.parse(srcStr, option);
		} else if (param.isLeaf()) {
			Object obj = param.getLeafExpression().calculate(ctx);
			if (obj == null) {
				obj = "";
			} else if (!(obj instanceof String)) {
				MessageManager mm = EngineMessage.get();
				throw new RQException("sqlparse" + mm.getMessage("function.paramTypeError"));
			}
			
			return SQLUtil.replace(srcStr, (String)obj, option);
		} else {
			MessageManager mm = EngineMessage.get();
			throw new RQException("sqlparse" + mm.getMessage("function.invalidParam"));
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy