1 package org.apache.velocity.context; 2 3 18 19 import org.apache.velocity.util.introspection.IntrospectionCacheData; 20 21 import org.apache.velocity.app.event.EventCartridge; 22 23 import org.apache.velocity.runtime.resource.Resource; 24 25 58 public final class InternalContextAdapterImpl implements InternalContextAdapter 59 { 60 63 Context context = null; 64 65 73 InternalHousekeepingContext icb = null; 74 75 82 InternalEventContext iec = null; 83 84 91 public InternalContextAdapterImpl( Context c ) 92 { 93 context = c; 94 95 if ( !( c instanceof InternalHousekeepingContext )) 96 { 97 icb = new InternalContextBase(); 98 } 99 else 100 { 101 icb = (InternalHousekeepingContext) context; 102 } 103 104 if ( c instanceof InternalEventContext) 105 { 106 iec = ( InternalEventContext) context; 107 } 108 } 109 110 111 112 public void pushCurrentTemplateName( String s ) 113 { 114 icb.pushCurrentTemplateName( s ); 115 } 116 117 public void popCurrentTemplateName() 118 { 119 icb.popCurrentTemplateName(); 120 } 121 122 public String getCurrentTemplateName() 123 { 124 return icb.getCurrentTemplateName(); 125 } 126 127 public Object [] getTemplateNameStack() 128 { 129 return icb.getTemplateNameStack(); 130 } 131 132 public IntrospectionCacheData icacheGet( Object key ) 133 { 134 return icb.icacheGet( key ); 135 } 136 137 public void icachePut( Object key, IntrospectionCacheData o ) 138 { 139 icb.icachePut( key, o ); 140 } 141 142 public void setCurrentResource( Resource r ) 143 { 144 icb.setCurrentResource(r); 145 } 146 147 public Resource getCurrentResource() 148 { 149 return icb.getCurrentResource(); 150 } 151 152 153 154 155 public Object put(String key, Object value) 156 { 157 return context.put( key , value ); 158 } 159 160 public Object get(String key) 161 { 162 return context.get( key ); 163 } 164 165 public boolean containsKey(Object key) 166 { 167 return context.containsKey( key ); 168 } 169 170 public Object [] getKeys() 171 { 172 return context.getKeys(); 173 } 174 175 public Object remove(Object key) 176 { 177 return context.remove( key ); 178 } 179 180 181 182 183 187 public Context getInternalUserContext() 188 { 189 return context; 190 } 191 192 198 public InternalContextAdapter getBaseContext() 199 { 200 return this; 201 } 202 203 204 205 public EventCartridge attachEventCartridge( EventCartridge ec ) 206 { 207 if (iec != null) 208 { 209 return iec.attachEventCartridge( ec ); 210 } 211 212 return null; 213 } 214 215 public EventCartridge getEventCartridge() 216 { 217 if ( iec != null) 218 { 219 return iec.getEventCartridge( ); 220 } 221 222 return null; 223 } 224 } 225 226 227 | Popular Tags |