KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > model > plugin > FragmentNode


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 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.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     /**
19      * Comment for <code>serialVersionUID</code>
20      */

21     private static final long serialVersionUID = 1L;
22     /* (non-Javadoc)
23      * @see org.eclipse.pde.core.plugin.IFragment#getPluginId()
24      */

25     public String JavaDoc getPluginId() {
26         return getXMLAttributeValue(P_PLUGIN_ID);
27     }
28     /* (non-Javadoc)
29      * @see org.eclipse.pde.core.plugin.IFragment#getPluginVersion()
30      */

31     public String JavaDoc getPluginVersion() {
32         return getXMLAttributeValue(P_PLUGIN_VERSION);
33     }
34     /* (non-Javadoc)
35      * @see org.eclipse.pde.core.plugin.IFragment#getRule()
36      */

37     public int getRule() {
38         String JavaDoc match = getXMLAttributeValue("match"); //$NON-NLS-1$
39
if (match == null || match.trim().length() == 0)
40             return IMatchRules.NONE;
41         if (match.equals("compatible")) //$NON-NLS-1$
42
return IMatchRules.COMPATIBLE;
43         if (match.equals("perfect")) //$NON-NLS-1$
44
return IMatchRules.PERFECT;
45         if (match.equals("equivalent")) //$NON-NLS-1$
46
return IMatchRules.EQUIVALENT;
47         return IMatchRules.GREATER_OR_EQUAL;
48     }
49     /* (non-Javadoc)
50      * @see org.eclipse.pde.core.plugin.IFragment#setPluginId(java.lang.String)
51      */

52     public void setPluginId(String JavaDoc id) throws CoreException {
53         setXMLAttribute(P_PLUGIN_ID, id);
54     }
55     /* (non-Javadoc)
56      * @see org.eclipse.pde.core.plugin.IFragment#setPluginVersion(java.lang.String)
57      */

58     public void setPluginVersion(String JavaDoc version) throws CoreException {
59         setXMLAttribute(P_PLUGIN_VERSION, version);
60     }
61     /* (non-Javadoc)
62      * @see org.eclipse.pde.core.plugin.IFragment#setRule(int)
63      */

64     public void setRule(int rule) throws CoreException {
65         String JavaDoc match = ""; //$NON-NLS-1$
66
switch (rule) {
67             case IMatchRules.COMPATIBLE:
68                 match = "compatible"; //$NON-NLS-1$
69
break;
70             case IMatchRules.EQUIVALENT:
71                 match = "equivalent"; //$NON-NLS-1$
72
break;
73             case IMatchRules.PERFECT:
74                 match = "perfect"; //$NON-NLS-1$
75
break;
76             case IMatchRules.GREATER_OR_EQUAL:
77                 match = "greaterOrEqual"; //$NON-NLS-1$
78
}
79         setXMLAttribute(P_RULE, match);
80     }
81     /* (non-Javadoc)
82      * @see org.eclipse.pde.internal.ui.model.plugin.PluginBaseNode#getSpecificAttributes()
83      */

84     protected String JavaDoc[] getSpecificAttributes() {
85         ArrayList result = new ArrayList();
86         
87         String JavaDoc pluginID = getPluginId();
88         if (pluginID != null && pluginID.trim().length() > 0)
89             result.add(" " + P_PLUGIN_ID + "=\"" + pluginID + "\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
90

91         String JavaDoc pluginVersion = getPluginVersion();
92         if (pluginVersion != null && pluginVersion.trim().length() > 0)
93             result.add(" " + P_PLUGIN_VERSION + "=\"" + pluginVersion + "\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
94

95         String JavaDoc match = getXMLAttributeValue(P_RULE);
96         if (match != null && match.trim().length() > 0)
97             result.add(" " + P_RULE + "=\"" + match + "\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
98

99         return (String JavaDoc[]) result.toArray(new String JavaDoc[result.size()]);
100     }
101 }
102
Popular Tags