KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > core > text > plugin > FragmentNode


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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.core.text.plugin;
12
13 import java.util.ArrayList JavaDoc;
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     /**
21      * Comment for <code>serialVersionUID</code>
22      */

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

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

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

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

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

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

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

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

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

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

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