KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > core > site > SiteArchive


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 java.io.PrintWriter JavaDoc;
14
15 import org.eclipse.core.runtime.CoreException;
16 import org.eclipse.pde.internal.core.isite.ISiteArchive;
17 import org.w3c.dom.Node JavaDoc;
18
19 public class SiteArchive extends SiteObject implements ISiteArchive {
20     private static final long serialVersionUID = 1L;
21     private String JavaDoc url;
22     private String JavaDoc path;
23     
24     public boolean isValid() {
25         return url!=null && path!=null;
26     }
27
28     public String JavaDoc getURL() {
29         return url;
30     }
31     public void setURL(String JavaDoc url) throws CoreException {
32         ensureModelEditable();
33         Object JavaDoc oldValue = this.url;
34         this.url = url;
35         firePropertyChanged(P_URL, oldValue, url);
36     }
37     public String JavaDoc getPath() {
38         return path;
39     }
40     public void setPath(String JavaDoc path) throws CoreException {
41         ensureModelEditable();
42         Object JavaDoc oldValue = this.path;
43         this.path = path;
44         firePropertyChanged(P_PATH, oldValue, path);
45     }
46     public void reset() {
47         super.reset();
48         url = null;
49         path = null;
50     }
51     protected void parse(Node JavaDoc node) {
52         super.parse(node);
53         path = getNodeAttribute(node, "path"); //$NON-NLS-1$
54
url = getNodeAttribute(node, "url"); //$NON-NLS-1$
55
}
56     public void write(String JavaDoc indent, PrintWriter JavaDoc writer) {
57         writer.print(indent);
58         writer.print("<archive"); //$NON-NLS-1$
59
if (path != null)
60             writer.print(" path=\"" + SiteObject.getWritableString(path) + "\""); //$NON-NLS-1$ //$NON-NLS-2$
61
if (url != null)
62             writer.print(" url=\"" + SiteObject.getWritableString(url) + "\""); //$NON-NLS-1$ //$NON-NLS-2$
63
writer.println("/>"); //$NON-NLS-1$
64
}
65     public void restoreProperty(String JavaDoc name, Object JavaDoc oldValue, Object JavaDoc newValue)
66         throws CoreException {
67         if (name.equals(P_PATH)) {
68             setPath(newValue != null ? newValue.toString() : null);
69         } else if (name.equals(P_URL)) {
70             setURL(newValue != null ? newValue.toString() : null);
71         } else
72             super.restoreProperty(name, oldValue, newValue);
73     }
74
75 }
76
Popular Tags