1 package org.apache.velocity.context; 2 3 /* 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 */ 21 22 import org.apache.velocity.util.introspection.IntrospectionCacheData; 23 24 import org.apache.velocity.runtime.resource.Resource; 25 26 /** 27 * interface to encapsulate the 'stuff' for internal operation of velocity. 28 * We use the context as a thread-safe storage : we take advantage of the 29 * fact that it's a visitor of sorts to all nodes (that matter) of the 30 * AST during init() and render(). 31 * 32 * Currently, it carries the template name for namespace 33 * support, as well as node-local context data introspection caching. 34 * 35 * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a> 36 * @author <a href="mailto:Christoph.Reck@dlr.de">Christoph Reck</a> 37 * @version $Id: InternalHousekeepingContext.java 463298 2006-10-12 16:10:32Z henning $ 38 */ 39 interface InternalHousekeepingContext 40 { 41 /** 42 * set the current template name on top of stack 43 * 44 * @param s current template name 45 */ 46 void pushCurrentTemplateName( String s ); 47 48 /** 49 * remove the current template name from stack 50 */ 51 void popCurrentTemplateName(); 52 53 /** 54 * get the current template name 55 * 56 * @return String current template name 57 */ 58 String getCurrentTemplateName(); 59 60 /** 61 * Returns the template name stack in form of an array. 62 * 63 * @return Object[] with the template name stack contents. 64 */ 65 Object[] getTemplateNameStack(); 66 67 /** 68 * returns an IntrospectionCache Data (@see IntrospectionCacheData) 69 * object if exists for the key 70 * 71 * @param key key to find in cache 72 * @return cache object 73 */ 74 IntrospectionCacheData icacheGet( Object key ); 75 76 /** 77 * places an IntrospectionCache Data (@see IntrospectionCacheData) 78 * element in the cache for specified key 79 * 80 * @param key key 81 * @param o IntrospectionCacheData object to place in cache 82 */ 83 void icachePut( Object key, IntrospectionCacheData o ); 84 85 /** 86 * temporary fix to enable #include() to figure out 87 * current encoding. 88 * 89 * @return The current resource. 90 */ 91 Resource getCurrentResource(); 92 93 94 /** 95 * @param r 96 */ 97 void setCurrentResource( Resource r ); 98 99 100 /** 101 * Checks to see if rendering should be allowed. Defaults to true but will 102 * return false after a #stop directive. 103 * 104 * @return true if rendering is allowed, false if no rendering should occur 105 */ 106 boolean getAllowRendering(); 107 108 /** 109 * Set whether rendering is allowed. Defaults to true but is set to 110 * false after a #stop directive. 111 * @param v 112 */ 113 void setAllowRendering(boolean v); 114 115 }