KickJava   Java API By Example, From Geeks To Geeks.

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


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.ITargetModel;
16 import org.eclipse.pde.internal.core.itarget.ITargetPlugin;
17 import org.w3c.dom.Element JavaDoc;
18 import org.w3c.dom.Node JavaDoc;
19
20 public class TargetPlugin extends TargetObject implements ITargetPlugin {
21
22     private static final long serialVersionUID = 1L;
23     private String JavaDoc fId;
24     private boolean fOptional = false;
25
26     public TargetPlugin(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         writer.print(indent + "<plugin id=\"" + getWritableString(fId)); //$NON-NLS-1$
48
writer.println((fOptional) ? "\" optional=\"true\"/>" : "\"/>"); //$NON-NLS-1$ //$NON-NLS-2$
49
}
50
51     public boolean isOptional() {
52         return fOptional;
53     }
54
55     public void setOptional(boolean optional) {
56         fOptional = optional;
57     }
58
59 }
60
Popular Tags