KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > internal > preferences > AbstractScope


1 /*******************************************************************************
2  * Copyright (c) 2004, 2005 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.core.internal.preferences;
12
13 import org.eclipse.core.runtime.IPath;
14 import org.eclipse.core.runtime.preferences.IEclipsePreferences;
15 import org.eclipse.core.runtime.preferences.IScopeContext;
16
17 /**
18  * Abstract super-class for scope context object contributed
19  * by the Platform.
20  *
21  * @since 3.0
22  */

23 public abstract class AbstractScope implements IScopeContext {
24
25     /*
26      * @see org.eclipse.core.runtime.preferences.IScopeContext#getName()
27      */

28     public abstract String JavaDoc getName();
29
30     /*
31      * Default path hierarchy for nodes is /<scope>/<qualifier>.
32      *
33      * @see org.eclipse.core.runtime.preferences.IScopeContext#getNode(java.lang.String)
34      */

35     public IEclipsePreferences getNode(String JavaDoc qualifier) {
36         if (qualifier == null)
37             throw new IllegalArgumentException JavaDoc();
38         return (IEclipsePreferences) PreferencesService.getDefault().getRootNode().node(getName()).node(qualifier);
39     }
40
41     /*
42      * @see org.eclipse.core.runtime.preferences.IScopeContext#getLocation()
43      */

44     public abstract IPath getLocation();
45
46     /* (non-Javadoc)
47      * @see java.lang.Object#equals(java.lang.Object)
48      */

49     public boolean equals(Object JavaDoc obj) {
50         if (this == obj)
51             return true;
52         if (!(obj instanceof IScopeContext))
53             return false;
54         IScopeContext other = (IScopeContext) obj;
55         if (!getName().equals(other.getName()))
56             return false;
57         IPath location = getLocation();
58         return location == null ? other.getLocation() == null : location.equals(other.getLocation());
59     }
60
61     /* (non-Javadoc)
62      * @see java.lang.Object#hashCode()
63      */

64     public int hashCode() {
65         return getName().hashCode();
66     }
67 }
68
Popular Tags