decodes.tsdb.algo.jep.IsQuestionableFunction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of opendcs Show documentation
Show all versions of opendcs Show documentation
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 java.util.Stack;
import org.nfunk.jep.ParseException;
import org.nfunk.jep.function.PostfixMathCommand;
import decodes.cwms.CwmsFlags;
/**
* Returns true if the passed integer flags value is marked as QUESTIONABLE.
*/
public class IsQuestionableFunction
extends PostfixMathCommand
{
public static final String funcName = "isQuestionable";
private JepContext ctx;
public IsQuestionableFunction(JepContext ctx)
{
super();
this.ctx = ctx;
this.numberOfParameters = 1;
}
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public void run(Stack inStack)
throws ParseException
{
checkStack(inStack);
Object o = inStack.pop().toString();
if (!(o instanceof Number))
{
throw new ParseException(funcName + " must be passed parmname.flags.");
}
int flags = ((Number)o).intValue();
inStack.push(
Double.valueOf(
(flags & CwmsFlags.VALIDITY_MASK) == CwmsFlags.VALIDITY_QUESTIONABLE ? 1.0 : 0.0));
}
}