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