KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > util > OldConfigurationElementMemento


1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.ui.internal.util;
13
14 import org.eclipse.core.runtime.IConfigurationElement;
15
16 import org.eclipse.ui.IMemento;
17
18 public final class OldConfigurationElementMemento implements IMemento {
19
20     private IConfigurationElement configurationElement;
21
22     public OldConfigurationElementMemento(IConfigurationElement configurationElement) {
23         if (configurationElement == null)
24             throw new NullPointerException JavaDoc();
25
26         this.configurationElement = configurationElement;
27     }
28
29     public IMemento createChild(String JavaDoc type) {
30         return null;
31     }
32
33     public IMemento createChild(String JavaDoc type, String JavaDoc id) {
34         return null;
35     }
36
37     public IMemento getChild(String JavaDoc type) {
38         IConfigurationElement[] configurationElements =
39             configurationElement.getChildren(type);
40
41         if (configurationElements != null && configurationElements.length >= 1)
42             return new OldConfigurationElementMemento(configurationElements[0]);
43
44         return null;
45     }
46
47     public IMemento[] getChildren(String JavaDoc type) {
48         IConfigurationElement[] configurationElements =
49             configurationElement.getChildren(type);
50
51         if (configurationElements != null
52             && configurationElements.length >= 1) {
53             IMemento mementos[] =
54                 new OldConfigurationElementMemento[configurationElements
55                     .length];
56
57             for (int i = 0; i < configurationElements.length; i++)
58                 mementos[i] =
59                     new OldConfigurationElementMemento(configurationElements[i]);
60
61             return mementos;
62         }
63
64         return new IMemento[0];
65     }
66
67     public Float JavaDoc getFloat(String JavaDoc key) {
68         String JavaDoc string = configurationElement.getAttribute(key);
69
70         if (string != null)
71             try {
72                 return new Float JavaDoc(string);
73             } catch (NumberFormatException JavaDoc eNumberFormat) {
74             }
75
76         return null;
77     }
78
79     public String JavaDoc getID() {
80         return configurationElement.getAttribute(TAG_ID);
81     }
82
83     public Integer JavaDoc getInteger(String JavaDoc key) {
84         String JavaDoc string = configurationElement.getAttribute(key);
85
86         if (string != null)
87             try {
88                 return new Integer JavaDoc(string);
89             } catch (NumberFormatException JavaDoc eNumberFormat) {
90             }
91
92         return null;
93     }
94
95     public String JavaDoc getString(String JavaDoc key) {
96         return configurationElement.getAttribute(key);
97     }
98
99     public String JavaDoc getTextData() {
100         return configurationElement.getValue();
101     }
102
103     public void putFloat(String JavaDoc key, float value) {
104     }
105
106     public void putInteger(String JavaDoc key, int value) {
107     }
108
109     public void putMemento(IMemento memento) {
110     }
111
112     public void putString(String JavaDoc key, String JavaDoc value) {
113     }
114
115     public void putTextData(String JavaDoc data) {
116     }
117 }
118
Popular Tags