1 9 10 package org.jboss.portal.format.template; 11 12 import java.util.HashMap ; 13 import java.util.Iterator ; 14 import java.util.Map ; 15 16 17 21 public class DelegateContext 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 43 public DelegateContext(Map delegate, Map children) 44 { 45 this.delegate = delegate; 46 this.children = new ChildrenStrategy(children); 47 } 48 49 57 public static final DelegateContext createWithChildren(Map children) 58 { 59 return new DelegateContext(new HashMap (), children); 60 } 61 62 69 public static final DelegateContext createWithValues(Map values) 70 { 71 return new DelegateContext(values, new HashMap ()); 72 } 73 74 81 public void append(String name, Context ctx) 82 { 83 children.append(name, ctx); 84 } 85 86 89 public Iterator childIterator(String name) 90 { 91 return children.childIterator(name); 92 } 93 94 97 public String get(String key) 98 { 99 return (String ) delegate.get(key); 100 } 101 102 112 public DelegateContext next(String name) 113 { 114 DelegateContext ctx = new DelegateContext(); 115 append(name, ctx); 116 117 return ctx; 118 } 119 120 124 public Context put(String key, String value) 125 { 126 delegate.put(key, value); 127 128 return this; 129 } 130 } 131 | Popular Tags |