KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > core > site > 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.site;
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 SiteObject implements IIdentifiable {
18
19     private static final long serialVersionUID = 1L;
20     protected String JavaDoc id;
21
22     public String JavaDoc getId() {
23         return id;
24     }
25
26     protected void parse(Node JavaDoc node) {
27         super.parse(node);
28         id = getNodeAttribute(node, "id"); //$NON-NLS-1$
29
}
30     
31     public boolean isValid() {
32         return id!=null;
33     }
34
35     public void setId(String JavaDoc id) throws CoreException {
36         ensureModelEditable();
37         Object JavaDoc oldValue = this.id;
38         this.id = id;
39         firePropertyChanged(this, P_ID, oldValue, id);
40     }
41     
42     public void restoreProperty(String JavaDoc name, Object JavaDoc oldValue, Object JavaDoc newValue) throws CoreException {
43         if (name.equals(P_ID)) {
44             setId(newValue!=null ? newValue.toString() : null);
45         }
46         else super.restoreProperty(name, oldValue, newValue);
47     }
48
49     protected void reset() {
50         super.reset();
51         id = null;
52     }
53 }
54
Popular Tags