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. |