1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.jxpath.ri.compiler;
17
18 import org.apache.commons.jxpath.ri.EvalContext;
19 import org.apache.commons.jxpath.ri.InfoSetUtil;
20
21 /***
22 * Implementation of Expression for the operation unary "-".
23 *
24 * @author Dmitri Plotnikov
25 * @version $Revision: 1.3 $ $Date: 2004/02/29 14:17:39 $
26 */
27 public class CoreOperationNegate extends CoreOperation {
28
29 public CoreOperationNegate(Expression arg) {
30 super(new Expression[] { arg });
31 }
32
33 public Object computeValue(EvalContext context) {
34 double a = InfoSetUtil.doubleValue(args[0].computeValue(context));
35 return new Double(-a);
36 }
37
38 protected int getPrecedence() {
39 return 6;
40 }
41
42 protected boolean isSymmetric() {
43 return false;
44 }
45
46 public String getSymbol() {
47 return "-";
48 }
49 }