1 9 10 package org.jboss.portal.common.context; 11 12 import java.util.HashMap ; 13 import java.util.Iterator ; 14 import java.util.Map ; 15 16 20 public class DelegateContext 21 implements Context 22 { 23 24 private ChildrenStrategy children; 25 26 27 private Map delegate; 28 29 32 public DelegateContext() 33 { 34 this(new HashMap (), new HashMap ()); 35 } 36 37 45 public DelegateContext(Map delegate, Map children) 46 { 47 this.delegate = delegate; 48 this.children = new ChildrenStrategy(children); 49 } 50 51 60 public static final DelegateContext createWithChildren(Map children) 61 { 62 return new DelegateContext(new HashMap (), children); 63 } 64 65 73 public static final DelegateContext createWithValues(Map values) 74 { 75 return new DelegateContext(values, new HashMap ()); 76 } 77 78 87 public void append(String name, Context ctx) 88 { 89 children.append(name, ctx); 90 } 91 92 95 public Iterator childIterator(String name) 96 { 97 return children.childIterator(name); 98 } 99 100 103 public String get(String key) 104 { 105 return (String ) delegate.get(key); 106 } 107 108 117 public DelegateContext next(String name) 118 { 119 DelegateContext ctx = new DelegateContext(); 120 append(name, ctx); 121 122 return ctx; 123 } 124 125 129 public Context put(String key, String value) 130 { 131 delegate.put(key, value); 132 133 return this; 134 } 135 136 public Context put(String key, Integer value) 137 { 138 put(key, value.toString()); 139 return this; 140 } 141 } | Popular Tags |