KickJava   Java API By Example, From Geeks To Geeks.

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


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.preferences.IExportedPreferences;
14
15 /**
16  * @since 3.0
17  */

18 public class ExportedPreferences extends EclipsePreferences implements IExportedPreferences {
19
20     private boolean isExportRoot = false;
21     private String JavaDoc version;
22
23     public static IExportedPreferences newRoot() {
24         return new ExportedPreferences(null, ""); //$NON-NLS-1$
25
}
26
27     protected ExportedPreferences(EclipsePreferences parent, String JavaDoc name) {
28         super(parent, name);
29     }
30
31     /*
32      * @see org.eclipse.core.runtime.preferences.IExportedPreferences#isExportRoot()
33      */

34     public boolean isExportRoot() {
35         return isExportRoot;
36     }
37
38     /*
39      * Internal method called only by the import/export mechanism.
40      */

41     public void setExportRoot() {
42         isExportRoot = true;
43     }
44
45     /*
46      * Internal method called only by the import/export mechanism to
47      * validate bundle versions.
48      */

49     public String JavaDoc getVersion() {
50         return version;
51     }
52
53     /*
54      * Internal method called only by the import/export mechanism to
55      * validate bundle versions.
56      */

57     public void setVersion(String JavaDoc version) {
58         this.version = version;
59     }
60
61     protected EclipsePreferences internalCreate(EclipsePreferences nodeParent, String JavaDoc nodeName, Object JavaDoc context) {
62         return new ExportedPreferences(nodeParent, nodeName);
63     }
64
65     /*
66      * Return a string representation of this object. To be used for
67      * debugging purposes only.
68      */

69     public String JavaDoc toString() {
70         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
71         if (isExportRoot)
72             buffer.append("* "); //$NON-NLS-1$
73
buffer.append(absolutePath());
74         if (version != null)
75             buffer.append(" (" + version + ')'); //$NON-NLS-1$
76
return buffer.toString();
77     }
78 }
79
Popular Tags