1 11 package org.eclipse.pde.internal.ui.model.plugin; 12 13 import org.eclipse.core.runtime.*; 14 import org.eclipse.pde.core.plugin.*; 15 16 public class PluginImportNode extends PluginObjectNode implements IPluginImport { 17 18 private static final long serialVersionUID = 1L; 19 20 23 public boolean isReexported() { 24 String value = getXMLAttributeValue(P_REEXPORTED); 25 return value != null && value.equals("true"); } 27 30 public boolean isOptional() { 31 String value = getXMLAttributeValue(P_OPTIONAL); 32 return value != null && value.equals("true"); } 34 37 public void setReexported(boolean value) throws CoreException { 38 setXMLAttribute(P_REEXPORTED, value ? "true" : "false"); } 40 43 public void setOptional(boolean value) throws CoreException { 44 setXMLAttribute(P_OPTIONAL, value ? "true" : "false"); } 46 49 public int getMatch() { 50 String match = getXMLAttributeValue(P_MATCH); 51 if (match == null || match.trim().length() == 0) 52 return IMatchRules.NONE; 53 if (match.equals("compatible")) return IMatchRules.COMPATIBLE; 55 if (match.equals("perfect")) return IMatchRules.PERFECT; 57 if (match.equals("equivalent")) return IMatchRules.EQUIVALENT; 59 return IMatchRules.GREATER_OR_EQUAL; 60 } 61 64 public String getVersion() { 65 return getXMLAttributeValue(P_VERSION); 66 } 67 70 public void setMatch(int match) throws CoreException { 71 switch(match) { 72 case IMatchRules.GREATER_OR_EQUAL: 73 setXMLAttribute(P_MATCH, "greaterOrEqual"); break; 75 case IMatchRules.EQUIVALENT: 76 setXMLAttribute(P_MATCH, "equivalent"); break; 78 case IMatchRules.COMPATIBLE: 79 setXMLAttribute(P_MATCH, "compatible"); break; 81 case IMatchRules.PERFECT: 82 setXMLAttribute(P_MATCH, "perfect"); break; 84 default: 85 setXMLAttribute(P_MATCH, null); 86 } 87 } 88 91 public void setVersion(String version) throws CoreException { 92 setXMLAttribute(P_VERSION, version); 93 } 94 97 public String getId() { 98 return getXMLAttributeValue("plugin"); } 100 103 public void setId(String id) throws CoreException { 104 setXMLAttribute("plugin", id); } 106 107 110 public String write(boolean indent) { 111 return indent ? getIndent() + writeShallow(true) : writeShallow(true); 112 } 113 114 117 public String writeShallow(boolean terminate) { 118 StringBuffer buffer = new StringBuffer ("<import"); appendAttribute(buffer, "plugin"); appendAttribute(buffer, P_VERSION); 121 appendAttribute(buffer, P_MATCH); 122 appendAttribute(buffer, P_REEXPORTED, "false"); appendAttribute(buffer, P_OPTIONAL, "false"); 125 if (terminate) 126 buffer.append("/"); buffer.append(">"); return buffer.toString(); 129 } 130 } 131 | Popular Tags |