1 11 package org.eclipse.pde.internal.core.target; 12 13 import java.io.PrintWriter ; 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 ; 18 import org.w3c.dom.Node ; 19 20 public class TargetFeature extends TargetObject implements 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"); fOptional = element.getAttribute("optional").equalsIgnoreCase("true"); } 44 } 45 46 public void write(String indent, PrintWriter writer) { 47 writer.print(indent + "<feature id=\"" + getWritableString(fId)); writer.println((fOptional) ? "\" optional=\"true\"/>" : "\"/>"); } 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 |