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

com.scudata.expression.mfn.record.FieldNo Maven / Gradle / Ivy

Go to download

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

There is a newer version: 20240823
Show newest version
package com.scudata.expression.mfn.record;

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

/**
 * ȡ??¼ָ???ֶε???Ż??ֶ?????
 * r.fno(F) r.fno()
 * @author RunQian
 *
 */
public class FieldNo extends RecordFunction {
	public Object calculate(Context ctx) {
		if (param == null) {
			return srcRecord.getFieldCount();
		} else if (param.isLeaf()) {
			String fname = param.getLeafExpression().getIdentifierName();
			int findex = srcRecord.getFieldIndex(fname);

			if (findex < 0) {
				return null;
			} else {
				return new Integer(findex + 1);
			}
		} else {
			MessageManager mm = EngineMessage.get();
			throw new RQException("fno" + mm.getMessage("function.invalidParam"));
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy