KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > core > target > TargetFeature


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