View | Details | Raw Unified | Return to bug 114363 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/core/internal/expressions/AndExpression.java (-1 / +10 lines)
Lines 15-21 Link Here
15
import org.eclipse.core.expressions.EvaluationResult;
15
import org.eclipse.core.expressions.EvaluationResult;
16
import org.eclipse.core.expressions.IEvaluationContext;
16
import org.eclipse.core.expressions.IEvaluationContext;
17
17
18
public class AndExpression extends CompositeExpression { 
18
public class AndExpression extends CompositeExpression {
19
20
	public final boolean equals(final Object object) {
21
		if (object instanceof AndExpression) {
22
			final AndExpression that = (AndExpression) object;
23
			return equals(this.fExpressions, that.fExpressions);
24
		}
25
26
		return false;
27
	} 
19
28
20
	public EvaluationResult evaluate(IEvaluationContext context) throws CoreException {
29
	public EvaluationResult evaluate(IEvaluationContext context) throws CoreException {
21
		return evaluateAnd(context);
30
		return evaluateAnd(context);
(-)src/org/eclipse/core/internal/expressions/CountExpression.java (+26 lines)
Lines 29-34 Link Here
29
	private static final int NONE_OR_ONE= 	2;
29
	private static final int NONE_OR_ONE= 	2;
30
	private static final int NONE= 			1;
30
	private static final int NONE= 			1;
31
	private static final int UNKNOWN= 		0;
31
	private static final int UNKNOWN= 		0;
32
33
	/**
34
	 * The seed for the hash code for all count expressions.
35
	 */
36
	private static final int HASH_INITIAL = CountExpression.class.getName()
37
			.hashCode();
32
	
38
	
33
	private int fMode;
39
	private int fMode;
34
	private int fSize;
40
	private int fSize;
Lines 88-91 Link Here
88
	public void collectExpressionInfo(ExpressionInfo info) {
94
	public void collectExpressionInfo(ExpressionInfo info) {
89
		info.markDefaultVariableAccessed();
95
		info.markDefaultVariableAccessed();
90
	}
96
	}
97
98
	public final boolean equals(final Object object) {
99
		if (object instanceof CountExpression) {
100
			final CountExpression that = (CountExpression) object;
101
			return (this.fMode == that.fMode) && (this.fSize == that.fSize);
102
		}
103
104
		return false;
105
	}
106
107
	public final int hashCode() {
108
		if (hashCode == HASH_CODE_NOT_COMPUTED) {
109
			hashCode = HASH_INITIAL * HASH_FACTOR + fMode;
110
			hashCode = hashCode * HASH_FACTOR + fSize;
111
			if (hashCode == HASH_CODE_NOT_COMPUTED) {
112
				hashCode++;
113
			}
114
		}
115
		return hashCode;
116
	}
91
}
117
}
(-)src/org/eclipse/core/internal/expressions/EnablementExpression.java (+9 lines)
Lines 21-26 Link Here
21
	public EnablementExpression(IConfigurationElement configElement) {
21
	public EnablementExpression(IConfigurationElement configElement) {
22
		// config element not used yet.
22
		// config element not used yet.
23
	}
23
	}
24
25
	public final boolean equals(final Object object) {
26
		if (object instanceof EnablementExpression) {
27
			final EnablementExpression that = (EnablementExpression) object;
28
			return equals(this.fExpressions, that.fExpressions);
29
		}
30
31
		return false;
32
	} 
24
	
33
	
25
	public EvaluationResult evaluate(IEvaluationContext context) throws CoreException {
34
	public EvaluationResult evaluate(IEvaluationContext context) throws CoreException {
26
		long start= 0;
35
		long start= 0;
(-)src/org/eclipse/core/internal/expressions/WithExpression.java (+27 lines)
Lines 22-27 Link Here
22
22
23
	private String fVariable;
23
	private String fVariable;
24
	private static final String ATT_VARIABLE= "variable";  //$NON-NLS-1$
24
	private static final String ATT_VARIABLE= "variable";  //$NON-NLS-1$
25
26
	/**
27
	 * The seed for the hash code for all with expressions.
28
	 */
29
	private static final int HASH_INITIAL = WithExpression.class.getName()
30
			.hashCode();
25
	
31
	
26
	public WithExpression(IConfigurationElement configElement) throws CoreException {
32
	public WithExpression(IConfigurationElement configElement) throws CoreException {
27
		fVariable= configElement.getAttribute(ATT_VARIABLE);
33
		fVariable= configElement.getAttribute(ATT_VARIABLE);
Lines 32-37 Link Here
32
		fVariable= variable;
38
		fVariable= variable;
33
	}
39
	}
34
40
41
	public final boolean equals(final Object object) {
42
		if (object instanceof WithExpression) {
43
			final WithExpression that = (WithExpression) object;
44
			return equals(this.fExpressions, that.fExpressions)
45
					&& this.fVariable.equals(that.fVariable);
46
		}
47
48
		return false;
49
	}
50
	
51
	public final int hashCode() {
52
		if (hashCode == HASH_CODE_NOT_COMPUTED) {
53
			hashCode = HASH_INITIAL * HASH_FACTOR + hashCode(fExpressions);
54
			hashCode = hashCode * HASH_FACTOR + fVariable.hashCode();
55
			if (hashCode == HASH_CODE_NOT_COMPUTED) {
56
				hashCode++;
57
			}
58
		}
59
		return hashCode;
60
	}
61
35
	public EvaluationResult evaluate(IEvaluationContext context) throws CoreException {
62
	public EvaluationResult evaluate(IEvaluationContext context) throws CoreException {
36
		Object variable= context.getVariable(fVariable);
63
		Object variable= context.getVariable(fVariable);
37
		if (variable == null) {
64
		if (variable == null) {
(-)src/org/eclipse/core/internal/expressions/SystemTestExpression.java (+27 lines)
Lines 25-30 Link Here
25
	
25
	
26
	private static final String ATT_PROPERTY= "property"; //$NON-NLS-1$
26
	private static final String ATT_PROPERTY= "property"; //$NON-NLS-1$
27
	
27
	
28
	/**
29
	 * The seed for the hash code for all system test expressions.
30
	 */
31
	private static final int HASH_INITIAL = SystemTestExpression.class.getName()
32
			.hashCode();
33
	
28
	public SystemTestExpression(IConfigurationElement element) throws CoreException {
34
	public SystemTestExpression(IConfigurationElement element) throws CoreException {
29
		fProperty= element.getAttribute(ATT_PROPERTY);
35
		fProperty= element.getAttribute(ATT_PROPERTY);
30
		Expressions.checkAttribute(ATT_PROPERTY, fProperty);
36
		Expressions.checkAttribute(ATT_PROPERTY, fProperty);
Lines 47-52 Link Here
47
	public void collectExpressionInfo(ExpressionInfo info) {
53
	public void collectExpressionInfo(ExpressionInfo info) {
48
		info.markSystemPropertyAccessed();
54
		info.markSystemPropertyAccessed();
49
	}
55
	}
56
57
	public final boolean equals(final Object object) {
58
		if (object instanceof SystemTestExpression) {
59
			final SystemTestExpression that = (SystemTestExpression) object;
60
			return this.fExpectedValue.equals(that.fExpectedValue)
61
					&& this.fProperty.equals(that.fProperty);
62
		}
63
64
		return false;
65
	}
66
67
	public final int hashCode() {
68
		if (hashCode == HASH_CODE_NOT_COMPUTED) {
69
			hashCode = HASH_INITIAL * HASH_FACTOR + fExpectedValue.hashCode();
70
			hashCode = hashCode * HASH_FACTOR + fProperty.hashCode();
71
			if (hashCode == HASH_CODE_NOT_COMPUTED) {
72
				hashCode++;
73
			}
74
		}
75
		return hashCode;
76
	}
50
	
77
	
51
	//---- Debugging ---------------------------------------------------
78
	//---- Debugging ---------------------------------------------------
52
	
79
	
(-)src/org/eclipse/core/internal/expressions/ResolveExpression.java (+29 lines)
Lines 25-30 Link Here
25
	
25
	
26
	private static final String ATT_VARIABLE= "variable";  //$NON-NLS-1$
26
	private static final String ATT_VARIABLE= "variable";  //$NON-NLS-1$
27
	private static final String ATT_ARGS= "args";  //$NON-NLS-1$
27
	private static final String ATT_ARGS= "args";  //$NON-NLS-1$
28
29
	/**
30
	 * The seed for the hash code for all resolve expressions.
31
	 */
32
	private static final int HASH_INITIAL = ResolveExpression.class.getName()
33
			.hashCode();
28
	
34
	
29
	public ResolveExpression(IConfigurationElement configElement) throws CoreException {
35
	public ResolveExpression(IConfigurationElement configElement) throws CoreException {
30
		fVariable= configElement.getAttribute(ATT_VARIABLE);
36
		fVariable= configElement.getAttribute(ATT_VARIABLE);
Lines 56-59 Link Here
56
		}
62
		}
57
		info.mergeExceptDefaultVariable(other);
63
		info.mergeExceptDefaultVariable(other);
58
	}
64
	}
65
66
	public final boolean equals(final Object object) {
67
		if (object instanceof ResolveExpression) {
68
			final ResolveExpression that = (ResolveExpression) object;
69
			return equals(this.fExpressions, that.fExpressions)
70
					&& equals(this.fArgs, that.fArgs)
71
					&& this.fVariable.equals(that.fVariable);
72
		}
73
74
		return false;
75
	}
76
77
	public int hashCode() {
78
		if (hashCode == HASH_CODE_NOT_COMPUTED) {
79
			hashCode = HASH_INITIAL * HASH_FACTOR + hashCode(fExpressions);
80
			hashCode = hashCode * HASH_FACTOR + fArgs.hashCode();
81
			hashCode = hashCode * HASH_FACTOR + fVariable.hashCode();
82
			if (hashCode == HASH_CODE_NOT_COMPUTED) {
83
				hashCode++;
84
			}
85
		}
86
		return hashCode;
87
	} 
59
}
88
}
(-)src/org/eclipse/core/internal/expressions/EqualsExpression.java (+24 lines)
Lines 19-24 Link Here
19
import org.eclipse.core.expressions.ExpressionInfo;
19
import org.eclipse.core.expressions.ExpressionInfo;
20
20
21
public class EqualsExpression extends Expression {
21
public class EqualsExpression extends Expression {
22
	/**
23
	 * The seed for the hash code for all equals expressions.
24
	 */
25
	private static final int HASH_INITIAL = EqualsExpression.class.getName()
26
			.hashCode();
22
27
23
	private Object fExpectedValue; 
28
	private Object fExpectedValue; 
24
	
29
	
Lines 41-44 Link Here
41
	public void collectExpressionInfo(ExpressionInfo info) {
46
	public void collectExpressionInfo(ExpressionInfo info) {
42
		info.markDefaultVariableAccessed();
47
		info.markDefaultVariableAccessed();
43
	}
48
	}
49
50
	public final boolean equals(final Object object) {
51
		if (object instanceof EqualsExpression) {
52
			final EqualsExpression that = (EqualsExpression) object;
53
			return this.fExpectedValue.equals(that.fExpectedValue);
54
		}
55
56
		return false;
57
	}
58
59
	public final int hashCode() {
60
		if (hashCode == HASH_CODE_NOT_COMPUTED) {
61
			hashCode = HASH_INITIAL * HASH_FACTOR + fExpectedValue.hashCode();
62
			if (hashCode == HASH_CODE_NOT_COMPUTED) {
63
				hashCode++;
64
			}
65
		}
66
		return hashCode;
67
	}
44
}
68
}
(-)src/org/eclipse/core/internal/expressions/OrExpression.java (+9 lines)
Lines 17-22 Link Here
17
17
18
public class OrExpression extends CompositeExpression { 
18
public class OrExpression extends CompositeExpression { 
19
19
20
	public final boolean equals(final Object object) {
21
		if (object instanceof OrExpression) {
22
			final OrExpression that = (OrExpression) object;
23
			return equals(this.fExpressions, that.fExpressions);
24
		}
25
26
		return false;
27
	} 
28
20
	public EvaluationResult evaluate(IEvaluationContext context) throws CoreException {
29
	public EvaluationResult evaluate(IEvaluationContext context) throws CoreException {
21
		return evaluateOr(context);
30
		return evaluateOr(context);
22
	}	
31
	}	
(-)src/org/eclipse/core/internal/expressions/TestExpression.java (+30 lines)
Lines 27-32 Link Here
27
	
27
	
28
	private static final String ATT_PROPERTY= "property"; //$NON-NLS-1$
28
	private static final String ATT_PROPERTY= "property"; //$NON-NLS-1$
29
	private static final String ATT_ARGS= "args"; //$NON-NLS-1$
29
	private static final String ATT_ARGS= "args"; //$NON-NLS-1$
30
	/**
31
	 * The seed for the hash code for all test expressions.
32
	 */
33
	private static final int HASH_INITIAL = TestExpression.class.getName()
34
			.hashCode();
30
	
35
	
31
	private static final TypeExtensionManager fgTypeExtensionManager= new TypeExtensionManager("propertyTesters"); //$NON-NLS-1$
36
	private static final TypeExtensionManager fgTypeExtensionManager= new TypeExtensionManager("propertyTesters"); //$NON-NLS-1$
32
	
37
	
Lines 68-73 Link Here
68
	public void collectExpressionInfo(ExpressionInfo info) {
73
	public void collectExpressionInfo(ExpressionInfo info) {
69
		info.markDefaultVariableAccessed();
74
		info.markDefaultVariableAccessed();
70
	}
75
	}
76
77
	public final boolean equals(final Object object) {
78
		if (object instanceof TestExpression) {
79
			final TestExpression that = (TestExpression) object;
80
			return equals(this.fArgs, that.fArgs)
81
					&& equals(this.fExpectedValue, that.fExpectedValue)
82
					&& this.fNamespace.equals(that.fNamespace)
83
					&& this.fProperty.equals(that.fProperty);
84
		}
85
86
		return false;
87
	}
88
89
	public final int hashCode() {
90
		if (hashCode == HASH_CODE_NOT_COMPUTED) {
91
			hashCode = HASH_INITIAL * HASH_FACTOR + fArgs.hashCode();
92
			hashCode = hashCode * HASH_FACTOR + hashCode(fExpectedValue);
93
			hashCode = hashCode * HASH_FACTOR + fNamespace.hashCode();
94
			hashCode = hashCode * HASH_FACTOR + fProperty.hashCode();
95
			if (hashCode == HASH_CODE_NOT_COMPUTED) {
96
				hashCode++;
97
			}
98
		}
99
		return hashCode;
100
	}
71
	
101
	
72
	//---- Debugging ---------------------------------------------------
102
	//---- Debugging ---------------------------------------------------
73
	
103
	
(-)src/org/eclipse/core/internal/expressions/NotExpression.java (+24 lines)
Lines 18-23 Link Here
18
import org.eclipse.core.expressions.ExpressionInfo;
18
import org.eclipse.core.expressions.ExpressionInfo;
19
19
20
public class NotExpression extends Expression {
20
public class NotExpression extends Expression {
21
	/**
22
	 * The seed for the hash code for all not expressions.
23
	 */
24
	private static final int HASH_INITIAL = NotExpression.class.getName()
25
			.hashCode();
21
26
22
	private Expression fExpression;
27
	private Expression fExpression;
23
28
Lines 33-36 Link Here
33
	public void collectExpressionInfo(ExpressionInfo info) {
38
	public void collectExpressionInfo(ExpressionInfo info) {
34
		fExpression.collectExpressionInfo(info);
39
		fExpression.collectExpressionInfo(info);
35
	}
40
	}
41
42
	public final boolean equals(final Object object) {
43
		if (object instanceof NotExpression) {
44
			final NotExpression that = (NotExpression) object;
45
			return this.fExpression.equals(that.fExpression);
46
		}
47
48
		return false;
49
	}
50
51
	public final int hashCode() {
52
		if (hashCode == HASH_CODE_NOT_COMPUTED) {
53
			hashCode = HASH_INITIAL * HASH_FACTOR + fExpression.hashCode();
54
			if (hashCode == HASH_CODE_NOT_COMPUTED) {
55
				hashCode++;
56
			}
57
		}
58
		return hashCode;
59
	}
36
}
60
}
(-)src/org/eclipse/core/internal/expressions/IterateExpression.java (+27 lines)
Lines 68-73 Link Here
68
	private static final String ATT_OPERATOR= "operator"; //$NON-NLS-1$
68
	private static final String ATT_OPERATOR= "operator"; //$NON-NLS-1$
69
	private static final int OR= 1;
69
	private static final int OR= 1;
70
	private static final int AND= 2;
70
	private static final int AND= 2;
71
72
	/**
73
	 * The seed for the hash code for all iterate expressions.
74
	 */
75
	private static final int HASH_INITIAL = IterateExpression.class
76
			.getName().hashCode();
71
	
77
	
72
	private int fOperator;
78
	private int fOperator;
73
	
79
	
Lines 136-139 Link Here
136
		info.markDefaultVariableAccessed();
142
		info.markDefaultVariableAccessed();
137
		super.collectExpressionInfo(info);
143
		super.collectExpressionInfo(info);
138
	}
144
	}
145
146
	public final boolean equals(final Object object) {
147
		if (object instanceof IterateExpression) {
148
			final IterateExpression that = (IterateExpression) object;
149
			return equals(this.fExpressions, that.fExpressions)
150
					&& (this.fOperator == that.fOperator);
151
		}
152
153
		return false;
154
	} 
155
156
	public int hashCode() {
157
		if (hashCode == HASH_CODE_NOT_COMPUTED) {
158
			hashCode = HASH_INITIAL * HASH_FACTOR + hashCode(fExpressions);
159
			hashCode = hashCode * HASH_FACTOR + fOperator;
160
			if (hashCode == HASH_CODE_NOT_COMPUTED) {
161
				hashCode++;
162
			}
163
		}
164
		return hashCode;
165
	}
139
}
166
}
(-)src/org/eclipse/core/internal/expressions/CompositeExpression.java (-2 / +18 lines)
Lines 18-29 Link Here
18
18
19
import org.eclipse.core.expressions.EvaluationResult;
19
import org.eclipse.core.expressions.EvaluationResult;
20
import org.eclipse.core.expressions.Expression;
20
import org.eclipse.core.expressions.Expression;
21
import org.eclipse.core.expressions.IEvaluationContext;
22
import org.eclipse.core.expressions.ExpressionInfo;
21
import org.eclipse.core.expressions.ExpressionInfo;
22
import org.eclipse.core.expressions.IEvaluationContext;
23
23
24
public abstract class CompositeExpression extends Expression {
24
public abstract class CompositeExpression extends Expression {
25
25
26
	private static final Expression[] EMPTY_ARRAY= new Expression[0]; 
26
	private static final Expression[] EMPTY_ARRAY = new Expression[0];
27
28
	/**
29
	 * The seed for the hash code for all composite expressions.
30
	 */
31
	private static final int HASH_INITIAL = CompositeExpression.class.getName()
32
			.hashCode();
27
	
33
	
28
	protected List fExpressions;
34
	protected List fExpressions;
29
	
35
	
Lines 75-78 Link Here
75
			expression.collectExpressionInfo(info);
81
			expression.collectExpressionInfo(info);
76
		}
82
		}
77
	}
83
	}
84
85
	public int hashCode() {
86
		if (hashCode == HASH_CODE_NOT_COMPUTED) {
87
			hashCode = HASH_INITIAL * HASH_FACTOR + hashCode(fExpressions);
88
			if (hashCode == HASH_CODE_NOT_COMPUTED) {
89
				hashCode++;
90
			}
91
		}
92
		return hashCode;
93
	}
78
}
94
}
(-)src/org/eclipse/core/internal/expressions/AdaptExpression.java (-1 / +28 lines)
Lines 16-27 Link Here
16
import org.eclipse.core.runtime.Platform;
16
import org.eclipse.core.runtime.Platform;
17
17
18
import org.eclipse.core.expressions.EvaluationResult;
18
import org.eclipse.core.expressions.EvaluationResult;
19
import org.eclipse.core.expressions.IEvaluationContext;
20
import org.eclipse.core.expressions.ExpressionInfo;
19
import org.eclipse.core.expressions.ExpressionInfo;
20
import org.eclipse.core.expressions.IEvaluationContext;
21
21
22
public class AdaptExpression extends CompositeExpression {
22
public class AdaptExpression extends CompositeExpression {
23
23
24
	private static final String ATT_TYPE= "type"; //$NON-NLS-1$
24
	private static final String ATT_TYPE= "type"; //$NON-NLS-1$
25
26
	/**
27
	 * The seed for the hash code for all adapt expressions.
28
	 */
29
	private static final int HASH_INITIAL = AdaptExpression.class.getName()
30
			.hashCode();
25
	
31
	
26
	private String fTypeName;
32
	private String fTypeName;
27
	
33
	
Lines 34-39 Link Here
34
		Assert.isNotNull(typeName);
40
		Assert.isNotNull(typeName);
35
		fTypeName= typeName;
41
		fTypeName= typeName;
36
	}
42
	}
43
44
	public final boolean equals(final Object object) {
45
		if (object instanceof AdaptExpression) {
46
			final AdaptExpression that = (AdaptExpression) object;
47
			return equals(this.fExpressions, that.fExpressions)
48
					&& this.fTypeName.equals(that.fTypeName);
49
		}
50
51
		return false;
52
	}
53
54
	public final int hashCode() {
55
		if (hashCode == HASH_CODE_NOT_COMPUTED) {
56
			hashCode = HASH_INITIAL * HASH_FACTOR + hashCode(fExpressions);
57
			hashCode = hashCode * HASH_FACTOR + fTypeName.hashCode();
58
			if (hashCode == HASH_CODE_NOT_COMPUTED) {
59
				hashCode++;
60
			}
61
		}
62
		return hashCode;
63
	}
37
	
64
	
38
	/* (non-Javadoc)
65
	/* (non-Javadoc)
39
	 * @see Expression#evaluate(IVariablePool)
66
	 * @see Expression#evaluate(IVariablePool)
(-)src/org/eclipse/core/internal/expressions/InstanceofExpression.java (+24 lines)
Lines 19-24 Link Here
19
import org.eclipse.core.expressions.ExpressionInfo;
19
import org.eclipse.core.expressions.ExpressionInfo;
20
20
21
public class InstanceofExpression extends Expression {
21
public class InstanceofExpression extends Expression {
22
	/**
23
	 * The seed for the hash code for all instance of expressions.
24
	 */
25
	private static final int HASH_INITIAL = InstanceofExpression.class
26
			.getName().hashCode();
22
27
23
	private String fTypeName;
28
	private String fTypeName;
24
	
29
	
Lines 43-48 Link Here
43
	public void collectExpressionInfo(ExpressionInfo info) {
48
	public void collectExpressionInfo(ExpressionInfo info) {
44
		info.markDefaultVariableAccessed();
49
		info.markDefaultVariableAccessed();
45
	}
50
	}
51
52
	public final boolean equals(final Object object) {
53
		if (object instanceof InstanceofExpression) {
54
			final InstanceofExpression that = (InstanceofExpression) object;
55
			return this.fTypeName.equals(that.fTypeName);
56
		}
57
58
		return false;
59
	}
60
61
	public final int hashCode() {
62
		if (hashCode == HASH_CODE_NOT_COMPUTED) {
63
			hashCode = HASH_INITIAL * HASH_FACTOR + fTypeName.hashCode();
64
			if (hashCode == HASH_CODE_NOT_COMPUTED) {
65
				hashCode++;
66
			}
67
		}
68
		return hashCode;
69
	}
46
	
70
	
47
	//---- Debugging ---------------------------------------------------
71
	//---- Debugging ---------------------------------------------------
48
	
72
	
(-)src/org/eclipse/core/expressions/Expression.java (+93 lines)
Lines 25-36 Link Here
25
 * @since 3.0
25
 * @since 3.0
26
 */
26
 */
27
public abstract class Expression {
27
public abstract class Expression {
28
29
	/**
30
	 * Checks whether two objects are equal using the
31
	 * <code>equals(Object)</code> method of the <code>left</code> object.
32
	 * This method handles <code>null</code> for either the <code>left</code>
33
	 * or <code>right</code> object.
34
	 * 
35
	 * @param left
36
	 *            The first object to compare; may be <code>null</code>.
37
	 * @param right
38
	 *            The second object to compare; may be <code>null</code>.
39
	 * @return <code>true</code> if the two objects are equivalent;
40
	 *         <code>false</code> otherwise.
41
	 */
42
    protected static final boolean equals(final Object left, final Object right) {
43
        return left == null ? right == null : ((right != null) && left
44
                .equals(right));
45
    }
46
47
	/**
48
	 * Tests whether two arrays of objects are equal to each other. The arrays
49
	 * must not be <code>null</code>, but their elements may be
50
	 * <code>null</code>.
51
	 * 
52
	 * @param leftArray
53
	 *            The left array to compare; may be <code>null</code>, and
54
	 *            may be empty and may contain <code>null</code> elements.
55
	 * @param rightArray
56
	 *            The right array to compare; may be <code>null</code>, and
57
	 *            may be empty and may contain <code>null</code> elements.
58
	 * @return <code>true</code> if the arrays are equal length and the
59
	 *         elements at the same position are equal; <code>false</code>
60
	 *         otherwise.
61
	 */
62
	protected static final boolean equals(final Object[] leftArray,
63
			final Object[] rightArray) {
64
		if (leftArray == rightArray) {
65
			return true;
66
		}
67
68
		if (leftArray == null) {
69
			return (rightArray == null);
70
		} else if (rightArray == null) {
71
			return false;
72
		}
73
74
		if (leftArray.length != rightArray.length) {
75
			return false;
76
		}
77
78
		for (int i = 0; i < leftArray.length; i++) {
79
			final Object left = leftArray[i];
80
			final Object right = rightArray[i];
81
			final boolean equal = (left == null) ? (right == null) : (left
82
					.equals(right));
83
			if (!equal) {
84
				return false;
85
			}
86
		}
87
88
		return true;
89
	}
90
91
    /**
92
	 * Returns the hash code for the given <code>object</code>. This method
93
	 * handles <code>null</code>.
94
	 * 
95
	 * @param object
96
	 *            The object for which the hash code is desired; may be
97
	 *            <code>null</code>.
98
	 * @return The hash code of the object; zero if the object is
99
	 *         <code>null</code>.
100
	 */
101
    protected static final int hashCode(final Object object) {
102
        return object != null ? object.hashCode() : 0;
103
    }
28
	
104
	
29
	/**
105
	/**
30
	 * Name of the value attribute of an expression (value is 
106
	 * Name of the value attribute of an expression (value is 
31
	 * <code>value</code>).
107
	 * <code>value</code>).
32
	 */ 
108
	 */ 
33
	protected static final String ATT_VALUE= "value"; //$NON-NLS-1$
109
	protected static final String ATT_VALUE= "value"; //$NON-NLS-1$
110
111
	/**
112
	 * The constant integer hash code value meaning the hash code has not yet
113
	 * been computed.
114
	 */
115
	protected static final int HASH_CODE_NOT_COMPUTED = -1;
116
117
	/**
118
	 * A factor for computing the hash code for all expressions.
119
	 */
120
	protected static final int HASH_FACTOR = 89;
34
	
121
	
35
	/**
122
	/**
36
	 * The expression corresponding to {@link EvaluationResult#TRUE}.
123
	 * The expression corresponding to {@link EvaluationResult#TRUE}.
Lines 53-58 Link Here
53
		public void collectExpressionInfo(ExpressionInfo info) {
140
		public void collectExpressionInfo(ExpressionInfo info) {
54
		}
141
		}
55
	};
142
	};
143
144
	/**
145
	 * The hash code for this object. This value is computed lazily.  If it is
146
	 * not yet computed, it is equal to {@link #HASH_CODE_NOT_COMPUTED}.
147
	 */
148
	protected transient int hashCode = HASH_CODE_NOT_COMPUTED;
56
	
149
	
57
	/**
150
	/**
58
	 * Evaluates this expression. 
151
	 * Evaluates this expression. 

Return to bug 114363