1 16 package org.apache.commons.betwixt.expression; 17 18 import java.util.HashMap ; 19 import java.util.Map ; 20 21 import org.apache.commons.betwixt.BindingConfiguration; 22 import org.apache.commons.betwixt.strategy.ObjectStringConverter; 23 import org.apache.commons.logging.Log; 24 import org.apache.commons.logging.LogFactory; 25 26 47 public class Context { 48 49 50 private Object bean; 51 52 private Map variables; 53 57 private Log log; 58 59 private BindingConfiguration bindingConfiguration; 60 61 64 public Context() { 65 this( null, LogFactory.getLog( Context.class ) ); 66 } 67 68 74 public Context(Object bean, Log log) { 75 this( bean, log, new BindingConfiguration() ); 76 } 77 78 79 85 public Context(Object bean, Log log, BindingConfiguration bindingConfiguration) { 86 this( bean, new HashMap (), log, bindingConfiguration ); 87 } 88 89 94 public Context( Context context ) { 95 this(context.bean, context.variables, context.log, context.bindingConfiguration); 96 } 97 98 99 106 public Context(Object bean, Map variables, Log log) { 107 this( bean, variables, log, new BindingConfiguration() ); 108 } 109 110 117 public Context(Object bean, Map variables, Log log, BindingConfiguration bindingConfiguration) { 118 this.bean = bean; 119 this.variables = variables; 120 this.log = log; 121 this.bindingConfiguration = bindingConfiguration; 122 } 123 124 129 public Context newContext(Object newBean) { 132 Context context = new Context(this); 133 context.setBean( newBean ); 134 return context; 135 } 136 137 141 public Object getBean() { 142 return bean; 143 } 144 145 149 public void setBean(Object bean) { 150 this.bean = bean; 151 } 152 153 157 public Map getVariables() { 158 return variables; 159 } 160 161 165 public void setVariables(Map variables) { 166 this.variables = variables; 167 } 168 169 174 public Object getVariable(String name) { 175 return variables.get( name ); 176 } 177 178 183 public void setVariable(String name, Object value) { 184 variables.put( name, value ); 185 } 186 187 192 public Log getLog() { 193 return log; 194 } 195 196 201 public void setLog(Log log) { 202 this.log = log; 203 } 204 205 210 public ObjectStringConverter getObjectStringConverter() { 211 return bindingConfiguration.getObjectStringConverter(); 212 } 213 214 222 public boolean getMapIDs() { 223 return bindingConfiguration.getMapIDs(); 224 } 225 226 235 public String getClassNameAttribute() { 236 return bindingConfiguration.getClassNameAttribute(); 237 } 238 239 249 public void setClassNameAttribute(String classNameAttribute) { 250 bindingConfiguration.setClassNameAttribute( classNameAttribute ); 251 } 252 } 253 | Popular Tags |