KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > expressions > AndExpression


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.ui.internal.expressions;
12
13 import java.util.Iterator JavaDoc;
14
15 import org.eclipse.core.expressions.EvaluationResult;
16 import org.eclipse.core.expressions.Expression;
17 import org.eclipse.core.expressions.IEvaluationContext;
18 import org.eclipse.core.runtime.CoreException;
19
20 /**
21  * Copied from org.eclipse.core.internal.expressions.
22  */

23 public final class AndExpression extends CompositeExpression {
24
25     /**
26      * The seed for the hash code for all schemes.
27      */

28     private static final int HASH_INITIAL = AndExpression.class.getName()
29             .hashCode();
30
31     protected final int computeHashCode() {
32         return HASH_INITIAL * HASH_FACTOR + hashCode(fExpressions);
33     }
34
35     public final boolean equals(final Object JavaDoc object) {
36         if (object instanceof AndExpression) {
37             final AndExpression that = (AndExpression) object;
38             return equals(this.fExpressions, that.fExpressions);
39         }
40
41         return false;
42     }
43
44     public final EvaluationResult evaluate(final IEvaluationContext context)
45             throws CoreException {
46         return evaluateAnd(context);
47     }
48
49     public final String JavaDoc toString() {
50         final StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
51         buffer.append("AndExpression("); //$NON-NLS-1$
52
if (fExpressions != null) {
53             final Iterator JavaDoc itr = fExpressions.iterator();
54             while (itr.hasNext()) {
55                 final Expression expression = (Expression) itr.next();
56                 buffer.append(expression.toString());
57                 if (itr.hasNext()) {
58                     buffer.append(',');
59                 }
60             }
61         }
62         buffer.append(')');
63         return buffer.toString();
64     }
65 }
66
Popular Tags