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

decodes.tsdb.algo.jep.OnErrorFunction Maven / Gradle / Ivy

Go to download

A collection of software for aggregatting and processing environmental data such as from NOAA GOES satellites.

The newest version!
package decodes.tsdb.algo.jep;

import ilex.util.Logger;

import java.util.Stack;

import org.nfunk.jep.ParseException;
import org.nfunk.jep.function.PostfixMathCommand;

/**
 * This sets the onErrorLabel in the context and then returns 0.
 * Subsequently, if any expression results in an error, execution jumps to the
 * specified label.
 */
public class OnErrorFunction
	extends PostfixMathCommand
{
	public static final String funcName = "onError";
	private JepContext ctx;
	
	public OnErrorFunction(JepContext ctx)
	{
		super();
		this.ctx = ctx;
		this.numberOfParameters = 1;
	}
	
	@Override
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public void run(Stack inStack)
		throws ParseException
	{
		checkStack(inStack);
		String label = inStack.pop().toString();
		ctx.setOnErrorLabel(label);
		inStack.push(Double.valueOf(0.0));
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy