01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.core.site;
11:
12: import java.io.PrintWriter;
13:
14: import org.eclipse.core.runtime.CoreException;
15: import org.eclipse.pde.internal.core.isite.ISiteArchive;
16: import org.w3c.dom.Node;
17:
18: public class SiteArchive extends SiteObject implements ISiteArchive {
19: private static final long serialVersionUID = 1L;
20: private String url;
21: private String path;
22:
23: public boolean isValid() {
24: return url != null && path != null;
25: }
26:
27: public String getURL() {
28: return url;
29: }
30:
31: public void setURL(String url) throws CoreException {
32: ensureModelEditable();
33: Object oldValue = this .url;
34: this .url = url;
35: firePropertyChanged(P_URL, oldValue, url);
36: }
37:
38: public String getPath() {
39: return path;
40: }
41:
42: public void setPath(String path) throws CoreException {
43: ensureModelEditable();
44: Object oldValue = this .path;
45: this .path = path;
46: firePropertyChanged(P_PATH, oldValue, path);
47: }
48:
49: public void reset() {
50: super .reset();
51: url = null;
52: path = null;
53: }
54:
55: protected void parse(Node node) {
56: super .parse(node);
57: path = getNodeAttribute(node, "path"); //$NON-NLS-1$
58: url = getNodeAttribute(node, "url"); //$NON-NLS-1$
59: }
60:
61: public void write(String indent, PrintWriter writer) {
62: writer.print(indent);
63: writer.print("<archive"); //$NON-NLS-1$
64: if (path != null)
65: writer
66: .print(" path=\"" + SiteObject.getWritableString(path) + "\""); //$NON-NLS-1$ //$NON-NLS-2$
67: if (url != null)
68: writer
69: .print(" url=\"" + SiteObject.getWritableString(url) + "\""); //$NON-NLS-1$ //$NON-NLS-2$
70: writer.println("/>"); //$NON-NLS-1$
71: }
72:
73: public void restoreProperty(String name, Object oldValue,
74: Object newValue) throws CoreException {
75: if (name.equals(P_PATH)) {
76: setPath(newValue != null ? newValue.toString() : null);
77: } else if (name.equals(P_URL)) {
78: setURL(newValue != null ? newValue.toString() : null);
79: } else
80: super.restoreProperty(name, oldValue, newValue);
81: }
82:
83: }
|