01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.internal.expressions;
11:
12: import java.util.Iterator;
13:
14: import org.eclipse.core.expressions.EvaluationResult;
15: import org.eclipse.core.expressions.Expression;
16: import org.eclipse.core.expressions.IEvaluationContext;
17: import org.eclipse.core.runtime.CoreException;
18:
19: /**
20: * Copied from org.eclipse.core.internal.expressions.
21: */
22: public final class AndExpression extends CompositeExpression {
23:
24: /**
25: * The seed for the hash code for all schemes.
26: */
27: private static final int HASH_INITIAL = AndExpression.class
28: .getName().hashCode();
29:
30: protected final int computeHashCode() {
31: return HASH_INITIAL * HASH_FACTOR + hashCode(fExpressions);
32: }
33:
34: public final boolean equals(final Object object) {
35: if (object instanceof AndExpression) {
36: final AndExpression that = (AndExpression) object;
37: return equals(this .fExpressions, that.fExpressions);
38: }
39:
40: return false;
41: }
42:
43: public final EvaluationResult evaluate(
44: final IEvaluationContext context) throws CoreException {
45: return evaluateAnd(context);
46: }
47:
48: public final String toString() {
49: final StringBuffer buffer = new StringBuffer();
50: buffer.append("AndExpression("); //$NON-NLS-1$
51: if (fExpressions != null) {
52: final Iterator itr = fExpressions.iterator();
53: while (itr.hasNext()) {
54: final Expression expression = (Expression) itr.next();
55: buffer.append(expression.toString());
56: if (itr.hasNext()) {
57: buffer.append(',');
58: }
59: }
60: }
61: buffer.append(')');
62: return buffer.toString();
63: }
64: }
|