1 9 package org.nfunk.jep.function; 10 11 import java.util.*; 12 import org.nfunk.jep.*; 13 import org.nfunk.jep.type.*; 14 15 20 public class Arg extends PostfixMathCommand 21 { 22 private static final Double ONE = new Double (1.0); 23 public Arg() 24 { 25 numberOfParameters = 1; 26 } 27 28 public void run(Stack inStack) 29 throws ParseException 30 { 31 checkStack(inStack); Object param = inStack.pop(); 33 inStack.push(arg(param)); return; 35 } 36 37 public Number arg(Object param) throws ParseException { 38 if (param instanceof Complex) { 39 return new Double (((Complex)param).arg()); 40 } 41 else if (param instanceof Number ) { 42 return (ONE); 43 } 44 throw new ParseException("Invalid parameter type"); 45 } 46 47 } 48 | Popular Tags |