KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > dialogs > PreferenceHistoryEntry


1 /*******************************************************************************
2  * Copyright (c) 2004, 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.dialogs;
12
13 import org.eclipse.core.runtime.Assert;
14
15 /**
16  * A preference history entry.
17  *
18  * @since 3.1
19  */

20 final class PreferenceHistoryEntry {
21     private String JavaDoc id;
22     private String JavaDoc label;
23     private Object JavaDoc argument;
24     
25     /**
26      * Creates a new entry.
27      *
28      * @param id the preference page id
29      * @param label the label to display, usually the preference page label
30      * @param argument an argument to pass to the preference page, may be
31      * <code>null</code>
32      */

33     public PreferenceHistoryEntry(String JavaDoc id, String JavaDoc label, Object JavaDoc argument) {
34         Assert.isLegal(id != null);
35         Assert.isLegal(label != null);
36         this.id= id;
37         this.label= label;
38         this.argument= argument;
39     }
40     /**
41      * Returns the preference page id.
42      *
43      * @return the preference page id
44      */

45     public String JavaDoc getId() {
46         return id;
47     }
48     /**
49      * Returns the preference page argument.
50      *
51      * @return the preference page argument
52      */

53     public Object JavaDoc getArgument() {
54         return argument;
55     }
56     /**
57      * Returns the preference page label.
58      *
59      * @return the preference page label
60      */

61     public String JavaDoc getLabel() {
62         return label;
63     }
64     /*
65      * @see java.lang.Object#toString()
66      */

67     public String JavaDoc toString() {
68         if (argument == null) {
69             return id;
70         }
71         return id + "(" + argument + ")"; //$NON-NLS-1$ //$NON-NLS-2$
72
}
73     /*
74      * @see java.lang.Object#equals(java.lang.Object)
75      */

76     public boolean equals(Object JavaDoc obj) {
77         if (obj instanceof PreferenceHistoryEntry) {
78             PreferenceHistoryEntry other= (PreferenceHistoryEntry) obj;
79             return id.equals(other.id)
80                     && (argument == null && other.argument == null
81                             || argument.equals(other.argument));
82         }
83         return super.equals(obj);
84     }
85     /*
86      * @see java.lang.Object#hashCode()
87      */

88     public int hashCode() {
89         int argHash= argument == null ? 0 : argument.hashCode() & 0x0000ffff;
90         return id.hashCode() << 16 | argHash;
91     }
92 }
93
Popular Tags