01: /*******************************************************************************
02: * Copyright (c) 2005, 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.target;
11:
12: import java.io.PrintWriter;
13:
14: import org.eclipse.pde.internal.core.itarget.ITargetFeature;
15: import org.eclipse.pde.internal.core.itarget.ITargetModel;
16: import org.w3c.dom.Element;
17: import org.w3c.dom.Node;
18:
19: public class TargetFeature extends TargetObject implements
20: ITargetFeature {
21:
22: private static final long serialVersionUID = 1L;
23: private String fId;
24: private boolean fOptional = false;
25:
26: public TargetFeature(ITargetModel model) {
27: super (model);
28: }
29:
30: public String getId() {
31: return fId.trim();
32: }
33:
34: public void setId(String id) {
35: fId = id;
36: }
37:
38: public void parse(Node node) {
39: if (node.getNodeType() == Node.ELEMENT_NODE) {
40: Element element = (Element) node;
41: fId = element.getAttribute("id"); //$NON-NLS-1$
42: fOptional = element
43: .getAttribute("optional").equalsIgnoreCase("true"); //$NON-NLS-1$ //$NON-NLS-2$
44: }
45: }
46:
47: public void write(String indent, PrintWriter writer) {
48: //TODO add support for optional
49: writer
50: .print(indent
51: + "<feature id=\"" + getWritableString(fId)); //$NON-NLS-1$
52: writer.println((fOptional) ? "\" optional=\"true\"/>" : "\"/>"); //$NON-NLS-1$ //$NON-NLS-2$
53: }
54:
55: public boolean isOptional() {
56: return fOptional;
57: }
58:
59: public void setOptional(boolean optional) {
60: fOptional = optional;
61: }
62:
63: }
|