1 26 27 package org.objectweb.util.browser.core.naming; 28 29 30 import java.util.Enumeration ; 31 32 import org.objectweb.util.browser.api.Entry; 33 import org.objectweb.util.browser.core.api.ContextContainer; 34 35 41 public class DefaultContextContainer 42 extends DefaultContext 43 implements ContextContainer { 44 45 51 57 60 public DefaultContextContainer() { 61 super(); 62 } 63 64 70 75 protected void remove(String id){ 76 Entry oldEntry = getLocalEntry(id); 77 if (oldEntry != null) { 78 elts_.remove(oldEntry); 79 } 80 } 81 82 88 93 public Entry getLocalEntry(String name) { 94 for (Enumeration e = elts_.elements(); e.hasMoreElements();) { 95 Entry entry = (Entry) e.nextElement(); 96 if (entry.getName().toString().equals(name)) { 97 return entry; 98 } 99 } 100 return null; 101 } 102 103 108 public Object getLocalValue(String name){ 109 Entry entry = getLocalEntry(name); 110 return entry!=null ? entry.getValue() : null; 111 } 112 113 123 public void addEntry(String id, Object object) { 124 if (object != null) { 125 remove(id); 126 elts_.add(createEntry(object, id)); 127 } 128 } 129 130 135 public void removeEntry(String id) { 136 remove(id); 137 } 138 139 142 public void clear(){ 143 elts_.clear(); 144 } 145 146 150 public int 151 getSize(){ 152 return elts_.size(); 153 } 154 155 } 156 | Popular Tags |