1 11 package org.eclipse.pde.internal.ui.model.plugin; 12 13 import java.util.*; 14 import org.eclipse.core.runtime.*; 15 import org.eclipse.pde.core.plugin.*; 16 17 public class FragmentNode extends PluginBaseNode implements IFragment { 18 21 private static final long serialVersionUID = 1L; 22 25 public String getPluginId() { 26 return getXMLAttributeValue(P_PLUGIN_ID); 27 } 28 31 public String getPluginVersion() { 32 return getXMLAttributeValue(P_PLUGIN_VERSION); 33 } 34 37 public int getRule() { 38 String match = getXMLAttributeValue("match"); if (match == null || match.trim().length() == 0) 40 return IMatchRules.NONE; 41 if (match.equals("compatible")) return IMatchRules.COMPATIBLE; 43 if (match.equals("perfect")) return IMatchRules.PERFECT; 45 if (match.equals("equivalent")) return IMatchRules.EQUIVALENT; 47 return IMatchRules.GREATER_OR_EQUAL; 48 } 49 52 public void setPluginId(String id) throws CoreException { 53 setXMLAttribute(P_PLUGIN_ID, id); 54 } 55 58 public void setPluginVersion(String version) throws CoreException { 59 setXMLAttribute(P_PLUGIN_VERSION, version); 60 } 61 64 public void setRule(int rule) throws CoreException { 65 String match = ""; switch (rule) { 67 case IMatchRules.COMPATIBLE: 68 match = "compatible"; break; 70 case IMatchRules.EQUIVALENT: 71 match = "equivalent"; break; 73 case IMatchRules.PERFECT: 74 match = "perfect"; break; 76 case IMatchRules.GREATER_OR_EQUAL: 77 match = "greaterOrEqual"; } 79 setXMLAttribute(P_RULE, match); 80 } 81 84 protected String [] getSpecificAttributes() { 85 ArrayList result = new ArrayList(); 86 87 String pluginID = getPluginId(); 88 if (pluginID != null && pluginID.trim().length() > 0) 89 result.add(" " + P_PLUGIN_ID + "=\"" + pluginID + "\""); 91 String pluginVersion = getPluginVersion(); 92 if (pluginVersion != null && pluginVersion.trim().length() > 0) 93 result.add(" " + P_PLUGIN_VERSION + "=\"" + pluginVersion + "\""); 95 String match = getXMLAttributeValue(P_RULE); 96 if (match != null && match.trim().length() > 0) 97 result.add(" " + P_RULE + "=\"" + match + "\""); 99 return (String []) result.toArray(new String [result.size()]); 100 } 101 } 102 | Popular Tags |