1 9 package org.nfunk.jep.function; 10 11 import java.util.*; 12 import org.nfunk.jep.*; 13 14 public class Not extends PostfixMathCommand 15 { 16 public Not() 17 { 18 numberOfParameters = 1; 19 20 } 21 22 public void run(Stack inStack) 23 throws ParseException 24 { 25 checkStack(inStack); Object param = inStack.pop(); 27 if (param instanceof Number ) 28 { 29 int r = (((Number )param).doubleValue() == 0) ? 1 : 0; 30 inStack.push(new Double (r)); } 32 else 33 throw new ParseException("Invalid parameter type"); 34 return; 35 } 36 37 } 38 | Popular Tags |