KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > ide > registry > MarkerQueryResult


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.ide.registry;
12
13 /**
14  * Instances of this class represent the result of a specific marker
15  * query. Specifically they contain an ordered collection of marker
16  * attribute values.
17  */

18
19 public class MarkerQueryResult {
20     /**
21      * An ordered collection of marker attribute values.
22      */

23     private String JavaDoc[] values;
24
25     /**
26      * Cached hash code value
27      */

28     private int hashCode;
29
30     /**
31      * Creates a new marker query result with the given values.
32      * <p>
33      * The values may not be empty.
34      * </p>
35      *
36      * @param markerAttributeValues the target marker's attribute values
37      */

38     public MarkerQueryResult(String JavaDoc[] markerAttributeValues) {
39         if (markerAttributeValues == null) {
40             throw new IllegalArgumentException JavaDoc();
41         }
42         values = markerAttributeValues;
43         computeHashCode();
44     }
45
46     /* (non-Javadoc)
47      * Method declared on Object.
48      */

49     public boolean equals(Object JavaDoc o) {
50         if (!(o instanceof MarkerQueryResult)) {
51             return false;
52         }
53
54         if (o == this) {
55             return true;
56         }
57
58         MarkerQueryResult mqr = (MarkerQueryResult) o;
59         if (values.length != mqr.values.length) {
60             return false;
61         }
62
63         for (int i = 0; i < values.length; i++) {
64             if (!(values[i].equals(mqr.values[i]))) {
65                 return false;
66             }
67         }
68
69         return true;
70     }
71
72     /* (non-Javadoc)
73      * Method declared on Object.
74      */

75     public int hashCode() {
76         return hashCode;
77     }
78
79     /**
80      * Computes the hash code for this instance.
81      */

82     public void computeHashCode() {
83         hashCode = 19;
84
85         for (int i = 0; i < values.length; i++) {
86             hashCode = hashCode * 37 + values[i].hashCode();
87         }
88     }
89 }
90
Popular Tags