KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > internal > expressions > NotExpression


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.core.internal.expressions;
12
13 import org.eclipse.core.runtime.Assert;
14 import org.eclipse.core.runtime.CoreException;
15
16 import org.eclipse.core.expressions.EvaluationResult;
17 import org.eclipse.core.expressions.Expression;
18 import org.eclipse.core.expressions.ExpressionInfo;
19 import org.eclipse.core.expressions.IEvaluationContext;
20
21 public class NotExpression extends Expression {
22     /**
23      * The seed for the hash code for all not expressions.
24      */

25     private static final int HASH_INITIAL= NotExpression.class.getName().hashCode();
26
27     private Expression fExpression;
28
29     public NotExpression(Expression expression) {
30         Assert.isNotNull(expression);
31         fExpression= expression;
32     }
33     
34     public EvaluationResult evaluate(IEvaluationContext context) throws CoreException {
35         return fExpression.evaluate(context).not();
36     }
37     
38     public void collectExpressionInfo(ExpressionInfo info) {
39         fExpression.collectExpressionInfo(info);
40     }
41
42     public boolean equals(final Object JavaDoc object) {
43         if (!(object instanceof NotExpression))
44             return false;
45         
46         final NotExpression that= (NotExpression)object;
47         return this.fExpression.equals(that.fExpression);
48     }
49
50     protected int computeHashCode() {
51         return HASH_INITIAL * HASH_FACTOR + fExpression.hashCode();
52     }
53 }
54
Popular Tags