1 26 package org.objectweb.util.explorer.core.common.lib; 27 28 import java.util.Enumeration ; 29 30 import org.objectweb.util.explorer.api.Entry; 31 import org.objectweb.util.explorer.core.common.api.ContextContainer; 32 33 41 public class DefaultContextContainer 42 extends DefaultContext 43 implements ContextContainer 44 { 45 46 52 58 64 69 protected void remove(Object name){ 70 Entry oldEntry = getEntry(name); 71 if (oldEntry != null) { 72 elements_.remove(oldEntry); 73 } 74 } 75 76 82 85 public void addEntry(Object name, Object value) { 86 if (value != null) { 87 remove(name); 88 elements_.add(createEntry(name, value)); 89 } 90 } 91 92 95 public void addEntry(Entry entry){ 96 if (entry != null) { 97 remove(entry.getName()); 98 elements_.add(entry); 99 } 100 } 101 102 105 public Entry getEntry(Object name) { 106 for (Enumeration e = elements_.elements(); e.hasMoreElements();) { 107 Entry entry = (Entry) e.nextElement(); 108 if (entry.getName().toString().equals(name)) { 109 return entry; 110 } 111 } 112 return null; 113 } 114 115 118 public void removeEntry(Object name) { 119 remove(name); 120 } 121 122 125 public void clear() { 126 elements_.clear(); 127 } 128 129 132 public int getSize() { 133 return elements_.size(); 134 } 135 136 } 137 138 | Popular Tags |