1 26 27 package org.objectweb.util.browser.core.naming; 28 29 30 import org.objectweb.util.browser.api.Entry; 31 import org.objectweb.util.browser.api.Wrapper; 32 import org.objectweb.util.browser.core.api.ContextContainer; 33 import org.objectweb.util.browser.core.api.Decoder; 34 35 41 42 public class ContextContainerDecoderManager 43 implements ContextContainer { 44 45 51 52 protected Decoder decoder_; 53 54 55 protected ContextContainer delegate_; 56 57 63 69 78 protected Entry createEntry(Object value, String id) { 79 return new DefaultEntry(value, new DefaultName(id), this); 80 } 81 82 88 93 public Entry getLocalEntry(String name) { 94 Entry e = delegate_.getLocalEntry(name); 95 return (e != null) ? createEntry(decoder_.decode(e.getValue()),e.getName().toString()): null; 96 } 97 98 103 public Object getLocalValue(String name){ 104 Entry entry = getLocalEntry(name); 105 return entry!=null ? entry.getValue() : null; 106 } 107 108 112 public Entry[] getEntries(){ 113 Entry[] entries = delegate_.getEntries(); 114 Entry[] decodedEntries = new Entry[entries.length]; 115 for (int i = 0; i < entries.length; i++) { 116 if (entries[i] != null) 117 decodedEntries[i] = createEntry(decoder_.decode(entries[i].getValue()),entries[i].getName().toString()); 118 } 119 return decodedEntries; 120 } 121 122 125 public void clear() { 126 delegate_.clear(); 127 } 128 129 132 public int getSize() { 133 return delegate_.getSize(); 134 } 135 136 142 148 public void setWrapped(Object object) { 149 ((Wrapper) delegate_).setWrapped(object); 151 } 152 153 159 public Object getWrapped() { 160 return ((Wrapper) delegate_).getWrapped(); 161 } 162 163 169 180 public void addEntry(String id, Object object) { 181 delegate_.addEntry(id, decoder_.decode(object)); 182 } 183 184 189 public void removeEntry(String id) { 190 delegate_.removeEntry(id); 191 } 192 193 199 202 public void setDelegate(ContextContainer context) { 203 delegate_ = context; 204 } 205 206 209 public void setDecoder(Decoder decoder) { 210 decoder_ = decoder; 211 } 212 213 } 214 | Popular Tags |