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

com.scudata.expression.operator.IntDivideAssign 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.operator;

import com.scudata.common.MessageManager;
import com.scudata.common.RQException;
import com.scudata.dm.Context;
import com.scudata.dm.Sequence;
import com.scudata.expression.Operator;
import com.scudata.resources.EngineMessage;
import com.scudata.util.Variant;

/**
 * ??????ֵ???????\=
 * @author RunQian
 *
 */
public class IntDivideAssign extends Operator {
	public IntDivideAssign() {
		priority = PRI_EVL;
	}

	/**
	 * ??????ʽ????Ч?ԣ???Ч???׳??쳣
	 */
	public void checkValidity() {
		if (left == null) {
			MessageManager mm = EngineMessage.get();
			throw new RQException("\"\\=\"" + mm.getMessage("operator.missingLeftOperation"));
		} else if (right == null) {
			MessageManager mm = EngineMessage.get();
			throw new RQException("\"\\=\"" + mm.getMessage("operator.missingRightOperation"));
		}
		
		left.checkValidity();
		right.checkValidity();
	}

	public Object calculate(Context ctx) {
		Object o1 = left.calculate(ctx);
		Object o2 = right.calculate(ctx);
		Object result = null;
		if (o1 == null) {
			if (o2 != null && !(o2 instanceof Sequence) && !(o2 instanceof Number)) {
				MessageManager mm = EngineMessage.get();
				throw new RQException("\"\\\"" + mm.getMessage("function.paramTypeError"));
			}
		} else if (o1 instanceof Sequence) {
			if (o2 == null) {
				result = o1;
			} else {
				if (o2 instanceof Sequence) {
					result = ((Sequence)o1).diff((Sequence)o2, false);
				} else {
					Sequence s2 = new Sequence(1);
					s2.add(o2);
					result = ((Sequence)o1).diff(s2, false);
				}
			}
		} else {
			result = Variant.intDivide(o1, o2);
		}
		
		return left.assign(result, ctx);
	}

	/**
	 * ?ж??Ƿ???Լ???ȫ????ֵ???и?ֵ????ʱֻ??һ???м???
	 * @return
	 */
	public boolean canCalculateAll() {
		return false;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy