KickJava   Java API By Example, From Geeks To Geeks.

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


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