KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > omg > lifl > eclipse > plugin > project > utils > AttributeManager


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2003 USTL - LIFL - GOAL
5 Contact: openccm-team@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Jerome Offroy.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26 /*
27  * Created on 3 juin 2003 by jerome OFFROY (offroy@lifl.fr)
28  *
29  */

30
31 package org.omg.lifl.eclipse.plugin.project.utils;
32
33 import org.eclipse.core.runtime.IConfigurationElement;
34 import org.omg.lifl.eclipse.plugin.project.utils.SWT.SetterGroupPreference;
35
36 /**
37  * This class allow access of attributes of a configuration element which
38  * directly reflects the content and structure of the extension section
39  * within the declaring plug-in's manifest (<code>plugin.xml</code>) file.
40  *
41  * @author offroy@lifl.fr
42  *
43  * @version 0.1
44  */

45 public class AttributeManager {
46
47     private IConfigurationElement configurationElement;
48
49     /**
50      * @param elem the configuration element to use
51      */

52     public AttributeManager(IConfigurationElement elem) {
53         this.setConfigurationElement(elem);
54     }
55
56     /**
57      * @param elem configuration element to use
58      * @param property name of the wanted property
59      * @return value of the property
60      */

61     public static String JavaDoc getAttribute(IConfigurationElement elem, String JavaDoc property) {
62         String JavaDoc res = elem.getAttribute(property);
63         if (res == null) {
64             return '!' + property + '!';
65         }
66         return res;
67     }
68
69     /**
70      * @param elem configuration element to use
71      * @param preProperty prefix of the wanted property
72      * @return an object representing the Properties
73      */

74     public static SetterGroupPreference getAllAttribute(
75         IConfigurationElement elem,
76         String JavaDoc tag) {
77         //TODO make an array (more generic)
78
String JavaDoc _Group = elem.getAttribute(tag + "Group");
79         String JavaDoc _PathLabel = elem.getAttribute(tag + "PathLabel");
80         String JavaDoc _PathName = elem.getAttribute(tag + "PathName");
81
82         if (_Group == null || _PathName == null || _PathLabel == null)
83             return null;
84
85         return new SetterGroupPreference(_Group, _PathLabel, _PathName);
86     }
87
88     /**
89      * this method uses the internal configuration element
90      * @param property name of the wanted property
91      * @return
92      */

93     public String JavaDoc getAttribute(String JavaDoc property) {
94         if (elementSet())
95             return getAttribute(getConfigurationElement(),property);
96         else return null;
97     }
98
99     public boolean elementSet(){
100         return ( getConfigurationElement() != null ? true : false );
101     }
102
103     /**
104      * @return
105      */

106     public IConfigurationElement getConfigurationElement() {
107         return configurationElement;
108     }
109
110     /**
111      * @param element
112      */

113     public void setConfigurationElement(IConfigurationElement element) {
114         configurationElement = element;
115     }
116
117 }
118
Popular Tags