1 package org.apache.velocity; 2 3 18 19 import java.util.HashMap ; 20 import java.util.Map ; 21 22 import org.apache.velocity.context.AbstractContext; 23 import org.apache.velocity.context.Context; 24 25 48 public class VelocityContext extends AbstractContext implements Cloneable 49 { 50 53 private Map context = null; 54 55 58 public VelocityContext() 59 { 60 this(null, null); 61 } 62 63 67 public VelocityContext(Map context) 68 { 69 this(context, null); 70 } 71 72 82 public VelocityContext( Context innerContext ) 83 { 84 this(null, innerContext); 85 } 86 87 95 public VelocityContext(Map context, Context innerContext) 96 { 97 super(innerContext); 98 this.context = (context == null ? new HashMap () : context); 99 } 100 101 108 public Object internalGet( String key ) 109 { 110 return context.get( key ); 111 } 112 113 121 public Object internalPut( String key, Object value ) 122 { 123 return context.put( key, value ); 124 } 125 126 133 public boolean internalContainsKey(Object key) 134 { 135 return context.containsKey( key ); 136 } 137 138 143 public Object [] internalGetKeys() 144 { 145 return context.keySet().toArray(); 146 } 147 148 155 public Object internalRemove(Object key) 156 { 157 return context.remove( key ); 158 } 159 160 165 public Object clone() 166 { 167 VelocityContext clone = null; 168 try 169 { 170 clone = (VelocityContext) super.clone(); 171 clone.context = new HashMap (context); 172 } 173 catch (CloneNotSupportedException ignored) 174 { 175 } 176 return clone; 177 } 178 } 179 | Popular Tags |