01: /*******************************************************************************
02: * Copyright (c) 2005 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.product;
11:
12: import java.io.PrintWriter;
13:
14: import org.eclipse.pde.internal.core.iproduct.IConfigurationFileInfo;
15: import org.eclipse.pde.internal.core.iproduct.IProductModel;
16: import org.w3c.dom.Element;
17: import org.w3c.dom.Node;
18:
19: public class ConfigurationFileInfo extends ProductObject implements
20: IConfigurationFileInfo {
21:
22: private static final long serialVersionUID = 1L;
23:
24: private String fUse;
25:
26: private String fPath;
27:
28: public ConfigurationFileInfo(IProductModel model) {
29: super (model);
30: }
31:
32: /* (non-Javadoc)
33: * @see org.eclipse.pde.internal.core.iproduct.IConfigurationFileInfo#setPath(java.lang.String)
34: */
35: public void setPath(String path) {
36: String old = fPath;
37: fPath = path;
38: if (isEditable())
39: firePropertyChanged(P_PATH, old, fPath);
40: }
41:
42: /* (non-Javadoc)
43: * @see org.eclipse.pde.internal.core.iproduct.IConfigurationFileInfo#getPath()
44: */
45: public String getPath() {
46: return fPath;
47: }
48:
49: /* (non-Javadoc)
50: * @see org.eclipse.pde.internal.core.iproduct.IProductObject#parse(org.w3c.dom.Node)
51: */
52: public void parse(Node node) {
53: if (node.getNodeType() == Node.ELEMENT_NODE) {
54: Element element = (Element) node;
55: fPath = element.getAttribute(P_PATH);
56: fUse = element.getAttribute(P_USE);
57: }
58: }
59:
60: /* (non-Javadoc)
61: * @see org.eclipse.pde.core.IWritable#write(java.lang.String, java.io.PrintWriter)
62: */
63: public void write(String indent, PrintWriter writer) {
64: writer.print(indent + "<configIni"); //$NON-NLS-1$
65: if (fUse != null)
66: writer.print(" " + P_USE + "=\"" + fUse + "\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
67: if (fPath != null && fPath.trim().length() > 0)
68: writer
69: .print(" " + P_PATH + "=\"" + getWritableString(fPath.trim()) + "\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
70: writer.println("/>"); //$NON-NLS-1$
71: }
72:
73: /* (non-Javadoc)
74: * @see org.eclipse.pde.internal.core.iproduct.IConfigurationFileInfo#setUse(java.lang.String)
75: */
76: public void setUse(String use) {
77: String old = fUse;
78: fUse = use;
79: if (isEditable())
80: firePropertyChanged(P_USE, old, fUse);
81: }
82:
83: /* (non-Javadoc)
84: * @see org.eclipse.pde.internal.core.iproduct.IConfigurationFileInfo#getUse()
85: */
86: public String getUse() {
87: return fUse;
88: }
89:
90: }
|