1 20 package org.enhydra.barracuda.core.comp; 21 22 import java.util.*; 23 import javax.servlet.*; 24 import javax.servlet.http.*; 25 import org.w3c.dom.*; 26 27 import org.enhydra.barracuda.plankton.data.*; 28 import org.enhydra.barracuda.core.event.*; 29 import org.enhydra.barracuda.core.view.*; 30 31 37 public class DefaultViewContext implements ViewContext { 38 39 private StateMap statemap = new DefaultStateMap(); 41 42 46 public DefaultViewContext() {} 47 48 51 public DefaultViewContext(ViewCapabilities ivc, HttpServletRequest ireq, HttpServletResponse iresp) { 52 this.putState(ViewContext.VIEW_CAPABILITIES, ivc); 53 this.putState(ViewContext.REQUEST, ireq); 54 this.putState(ViewContext.RESPONSE, iresp); 55 } 56 57 60 public DefaultViewContext(ViewEventContext ivec) { 61 this.putState(ViewContext.VIEW_CAPABILITIES, ivec.getViewCapabilities()); 62 this.putState(ViewContext.EVENT_CONTEXT, ivec); 63 this.putState(ViewContext.REQUEST, ivec.getRequest()); 64 this.putState(ViewContext.RESPONSE, ivec.getResponse()); 65 } 66 67 68 69 75 public ViewCapabilities getViewCapabilities() { 76 return (ViewCapabilities) this.getState(ViewContext.VIEW_CAPABILITIES); 77 } 78 79 84 public EventContext getEventContext() { 85 return (EventContext) this.getState(ViewContext.EVENT_CONTEXT); 86 } 87 88 93 public ElementFactory getElementFactory() { 94 return (ElementFactory) this.getState(ViewContext.ELEMENT_FACTORY); 95 } 96 97 102 public Node getTemplateNode() { 103 return (Node) this.getState(ViewContext.TEMPLATE_NODE); 104 } 105 106 111 public HttpServletRequest getRequest() { 112 return (HttpServletRequest) this.getState(ViewContext.REQUEST); 113 } 114 115 120 public HttpServletResponse getResponse() { 121 return (HttpServletResponse) this.getState(ViewContext.RESPONSE); 122 } 123 124 125 126 133 public void putState(Object key, Object val) { 134 statemap.putState(key,val); 135 } 136 137 143 public Object getState(Object key) { 144 return statemap.getState(key); 145 } 146 147 153 public Object removeState(Object key) { 154 return statemap.removeState(key); 155 } 156 157 162 public List getStateKeys() { 163 return statemap.getStateKeys(); 164 } 165 166 171 public Map getStateValues() { 172 return statemap.getStateValues(); 173 } 174 175 179 public void clearState() { 180 statemap.clearState(); 181 } 182 183 } | Popular Tags |