KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > core > feature > IdentifiableObject


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.pde.internal.core.feature;
12
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.pde.core.IIdentifiable;
15 import org.w3c.dom.Node JavaDoc;
16
17 public class IdentifiableObject extends FeatureObject implements IIdentifiable {
18     private static final long serialVersionUID = 1L;
19     protected String JavaDoc id;
20
21     public String JavaDoc getId() {
22         return id;
23     }
24
25     protected void parse(Node JavaDoc node) {
26         super.parse(node);
27         id = getNodeAttribute(node, "id"); //$NON-NLS-1$
28
}
29
30     public void setId(String JavaDoc id) throws CoreException {
31         ensureModelEditable();
32         Object JavaDoc oldValue = this.id;
33         this.id = id;
34         firePropertyChanged(this, P_ID, oldValue, id);
35     }
36     
37     public void restoreProperty(String JavaDoc name, Object JavaDoc oldValue, Object JavaDoc newValue) throws CoreException {
38         if (name.equals(P_ID)) {
39             setId(newValue!=null ? newValue.toString() : null);
40         }
41         else super.restoreProperty(name, oldValue, newValue);
42     }
43
44     protected void reset() {
45         super.reset();
46         id = null;
47     }
48 }
49
Popular Tags