KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lsmp > djep > groupJep > function > GNot


1 /*****************************************************************************
2
3 JEP - Java Math Expression Parser 2.3.0
4       October 3 2004
5       (c) Copyright 2004, Nathan Funk and Richard Morris
6       See LICENSE.txt for license information.
7
8 *****************************************************************************/

9
10 package org.lsmp.djep.groupJep.function;
11 import org.nfunk.jep.function.*;
12
13 import java.util.*;
14 import org.nfunk.jep.*;
15
16 public class GNot extends PostfixMathCommand
17 {
18     public GNot()
19     {
20         numberOfParameters = 2;
21     }
22     
23     public void run(Stack inStack)
24         throws ParseException
25     {
26         checkStack(inStack);// check the stack
27

28         Object JavaDoc param = inStack.pop();
29
30         if (param instanceof Boolean JavaDoc)
31         {
32             boolean a = ((Boolean JavaDoc)param).booleanValue();
33             inStack.push(a ? Boolean.FALSE : Boolean.TRUE);//push the result on the inStack
34
}
35         else
36         {
37             throw new ParseException("Invalid parameter type");
38         }
39         return;
40     }
41 }
42
Popular Tags