KickJava   Java API By Example, From Geeks To Geeks.

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


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 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     /* (non-Javadoc)
21      * @see org.eclipse.pde.core.plugin.IPluginImport#isReexported()
22      */

23     public boolean isReexported() {
24         String JavaDoc value = getXMLAttributeValue(P_REEXPORTED);
25         return value != null && value.equals("true"); //$NON-NLS-1$
26
}
27     /* (non-Javadoc)
28      * @see org.eclipse.pde.core.plugin.IPluginImport#isOptional()
29      */

30     public boolean isOptional() {
31         String JavaDoc value = getXMLAttributeValue(P_OPTIONAL);
32         return value != null && value.equals("true"); //$NON-NLS-1$
33
}
34     /* (non-Javadoc)
35      * @see org.eclipse.pde.core.plugin.IPluginImport#setReexported(boolean)
36      */

37     public void setReexported(boolean value) throws CoreException {
38         setXMLAttribute(P_REEXPORTED, value ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
39
}
40     /* (non-Javadoc)
41      * @see org.eclipse.pde.core.plugin.IPluginImport#setOptional(boolean)
42      */

43     public void setOptional(boolean value) throws CoreException {
44         setXMLAttribute(P_OPTIONAL, value ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
45
}
46     /* (non-Javadoc)
47      * @see org.eclipse.pde.core.plugin.IPluginReference#getMatch()
48      */

49     public int getMatch() {
50         String JavaDoc match = getXMLAttributeValue(P_MATCH);
51         if (match == null || match.trim().length() == 0)
52             return IMatchRules.NONE;
53         if (match.equals("compatible")) //$NON-NLS-1$
54
return IMatchRules.COMPATIBLE;
55         if (match.equals("perfect")) //$NON-NLS-1$
56
return IMatchRules.PERFECT;
57         if (match.equals("equivalent")) //$NON-NLS-1$
58
return IMatchRules.EQUIVALENT;
59         return IMatchRules.GREATER_OR_EQUAL;
60     }
61     /* (non-Javadoc)
62      * @see org.eclipse.pde.core.plugin.IPluginReference#getVersion()
63      */

64     public String JavaDoc getVersion() {
65         return getXMLAttributeValue(P_VERSION);
66     }
67     /* (non-Javadoc)
68      * @see org.eclipse.pde.core.plugin.IPluginReference#setMatch(int)
69      */

70     public void setMatch(int match) throws CoreException {
71         switch(match) {
72             case IMatchRules.GREATER_OR_EQUAL:
73                 setXMLAttribute(P_MATCH, "greaterOrEqual"); //$NON-NLS-1$
74
break;
75             case IMatchRules.EQUIVALENT:
76                 setXMLAttribute(P_MATCH, "equivalent"); //$NON-NLS-1$
77
break;
78             case IMatchRules.COMPATIBLE:
79                 setXMLAttribute(P_MATCH, "compatible"); //$NON-NLS-1$
80
break;
81             case IMatchRules.PERFECT:
82                 setXMLAttribute(P_MATCH, "perfect"); //$NON-NLS-1$
83
break;
84             default:
85                 setXMLAttribute(P_MATCH, null);
86         }
87     }
88     /* (non-Javadoc)
89      * @see org.eclipse.pde.core.plugin.IPluginReference#setVersion(java.lang.String)
90      */

91     public void setVersion(String JavaDoc version) throws CoreException {
92         setXMLAttribute(P_VERSION, version);
93     }
94     /* (non-Javadoc)
95      * @see org.eclipse.pde.core.IIdentifiable#getId()
96      */

97     public String JavaDoc getId() {
98         return getXMLAttributeValue("plugin"); //$NON-NLS-1$
99
}
100     /* (non-Javadoc)
101      * @see org.eclipse.pde.core.IIdentifiable#setId(java.lang.String)
102      */

103     public void setId(String JavaDoc id) throws CoreException {
104         setXMLAttribute("plugin", id); //$NON-NLS-1$
105
}
106     
107     /* (non-Javadoc)
108      * @see org.eclipse.pde.internal.ui.model.plugin.PluginObjectNode#write()
109      */

110     public String JavaDoc write(boolean indent) {
111         return indent ? getIndent() + writeShallow(true) : writeShallow(true);
112     }
113     
114     /* (non-Javadoc)
115      * @see org.eclipse.pde.internal.ui.model.plugin.PluginObjectNode#writeShallow(boolean)
116      */

117     public String JavaDoc writeShallow(boolean terminate) {
118         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc("<import"); //$NON-NLS-1$
119
appendAttribute(buffer, "plugin"); //$NON-NLS-1$
120
appendAttribute(buffer, P_VERSION);
121         appendAttribute(buffer, P_MATCH);
122         appendAttribute(buffer, P_REEXPORTED, "false"); //$NON-NLS-1$
123
appendAttribute(buffer, P_OPTIONAL, "false"); //$NON-NLS-1$
124

125         if (terminate)
126             buffer.append("/"); //$NON-NLS-1$
127
buffer.append(">"); //$NON-NLS-1$
128
return buffer.toString();
129     }
130 }
131
Popular Tags