1 package org.apache.velocity.context; 2 3 18 19 import java.util.HashMap ; 20 import java.util.Stack ; 21 import java.io.Serializable ; 22 23 import org.apache.velocity.util.introspection.IntrospectionCacheData; 24 25 import org.apache.velocity.app.event.EventCartridge; 26 import org.apache.velocity.runtime.resource.Resource; 27 28 43 class InternalContextBase implements InternalHousekeepingContext, InternalEventContext, Serializable 44 { 45 48 private HashMap introspectionCache = new HashMap (33); 49 50 53 private Stack templateNameStack = new Stack (); 54 55 58 private EventCartridge eventCartridge = null; 59 60 64 private Resource currentResource = null; 65 66 71 public void pushCurrentTemplateName( String s ) 72 { 73 templateNameStack.push(s); 74 return; 75 } 76 77 80 public void popCurrentTemplateName() 81 { 82 templateNameStack.pop(); 83 return; 84 } 85 86 91 public String getCurrentTemplateName() 92 { 93 if ( templateNameStack.empty() ) 94 return "<undef>"; 95 else 96 return (String ) templateNameStack.peek(); 97 } 98 99 104 public Object [] getTemplateNameStack() 105 { 106 return templateNameStack.toArray(); 107 } 108 109 116 public IntrospectionCacheData icacheGet( Object key ) 117 { 118 return ( IntrospectionCacheData ) introspectionCache.get( key ); 119 } 120 121 128 public void icachePut( Object key, IntrospectionCacheData o ) 129 { 130 introspectionCache.put( key, o ); 131 } 132 133 public void setCurrentResource( Resource r ) 134 { 135 currentResource = r; 136 } 137 138 public Resource getCurrentResource() 139 { 140 return currentResource; 141 } 142 143 public EventCartridge attachEventCartridge( EventCartridge ec ) 144 { 145 EventCartridge temp = eventCartridge; 146 147 eventCartridge = ec; 148 149 return temp; 150 } 151 152 public EventCartridge getEventCartridge() 153 { 154 return eventCartridge; 155 } 156 } 157 158 | Popular Tags |