1 11 package org.eclipse.pde.internal.core.text.plugin; 12 13 import java.util.ArrayList ; 14 15 import org.eclipse.core.runtime.CoreException; 16 import org.eclipse.pde.core.plugin.IFragment; 17 import org.eclipse.pde.core.plugin.IMatchRules; 18 19 public class FragmentNode extends PluginBaseNode implements IFragment { 20 23 private static final long serialVersionUID = 1L; 24 27 public String getPluginId() { 28 return getXMLAttributeValue(P_PLUGIN_ID); 29 } 30 33 public String getPluginVersion() { 34 return getXMLAttributeValue(P_PLUGIN_VERSION); 35 } 36 39 public int getRule() { 40 String match = getXMLAttributeValue("match"); if (match == null || match.trim().length() == 0) 42 return IMatchRules.NONE; 43 if (match.equals("compatible")) return IMatchRules.COMPATIBLE; 45 if (match.equals("perfect")) return IMatchRules.PERFECT; 47 if (match.equals("equivalent")) return IMatchRules.EQUIVALENT; 49 return IMatchRules.GREATER_OR_EQUAL; 50 } 51 54 public void setPluginId(String id) throws CoreException { 55 setXMLAttribute(P_PLUGIN_ID, id); 56 } 57 60 public void setPluginVersion(String version) throws CoreException { 61 setXMLAttribute(P_PLUGIN_VERSION, version); 62 } 63 66 public void setRule(int rule) throws CoreException { 67 String match = ""; switch (rule) { 69 case IMatchRules.COMPATIBLE: 70 match = "compatible"; break; 72 case IMatchRules.EQUIVALENT: 73 match = "equivalent"; break; 75 case IMatchRules.PERFECT: 76 match = "perfect"; break; 78 case IMatchRules.GREATER_OR_EQUAL: 79 match = "greaterOrEqual"; } 81 setXMLAttribute(P_RULE, match); 82 } 83 86 protected String [] getSpecificAttributes() { 87 ArrayList result = new ArrayList (); 88 89 String pluginID = getPluginId(); 90 if (pluginID != null && pluginID.trim().length() > 0) 91 result.add(" " + P_PLUGIN_ID + "=\"" + pluginID + "\""); 93 String pluginVersion = getPluginVersion(); 94 if (pluginVersion != null && pluginVersion.trim().length() > 0) 95 result.add(" " + P_PLUGIN_VERSION + "=\"" + pluginVersion + "\""); 97 String match = getXMLAttributeValue(P_RULE); 98 if (match != null && match.trim().length() > 0) 99 result.add(" " + P_RULE + "=\"" + match + "\""); 101 return (String []) result.toArray(new String [result.size()]); 102 } 103 } 104 | Popular Tags |