001: package org.apache.velocity.context;
002:
003: /*
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021:
022: import org.apache.velocity.util.introspection.IntrospectionCacheData;
023:
024: import org.apache.velocity.runtime.resource.Resource;
025:
026: /**
027: * interface to encapsulate the 'stuff' for internal operation of velocity.
028: * We use the context as a thread-safe storage : we take advantage of the
029: * fact that it's a visitor of sorts to all nodes (that matter) of the
030: * AST during init() and render().
031: *
032: * Currently, it carries the template name for namespace
033: * support, as well as node-local context data introspection caching.
034: *
035: * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
036: * @author <a href="mailto:Christoph.Reck@dlr.de">Christoph Reck</a>
037: * @version $Id: InternalHousekeepingContext.java 463298 2006-10-12 16:10:32Z henning $
038: */
039: interface InternalHousekeepingContext {
040: /**
041: * set the current template name on top of stack
042: *
043: * @param s current template name
044: */
045: void pushCurrentTemplateName(String s);
046:
047: /**
048: * remove the current template name from stack
049: */
050: void popCurrentTemplateName();
051:
052: /**
053: * get the current template name
054: *
055: * @return String current template name
056: */
057: String getCurrentTemplateName();
058:
059: /**
060: * Returns the template name stack in form of an array.
061: *
062: * @return Object[] with the template name stack contents.
063: */
064: Object[] getTemplateNameStack();
065:
066: /**
067: * returns an IntrospectionCache Data (@see IntrospectionCacheData)
068: * object if exists for the key
069: *
070: * @param key key to find in cache
071: * @return cache object
072: */
073: IntrospectionCacheData icacheGet(Object key);
074:
075: /**
076: * places an IntrospectionCache Data (@see IntrospectionCacheData)
077: * element in the cache for specified key
078: *
079: * @param key key
080: * @param o IntrospectionCacheData object to place in cache
081: */
082: void icachePut(Object key, IntrospectionCacheData o);
083:
084: /**
085: * temporary fix to enable #include() to figure out
086: * current encoding.
087: *
088: * @return The current resource.
089: */
090: Resource getCurrentResource();
091:
092: /**
093: * @param r
094: */
095: void setCurrentResource(Resource r);
096:
097: /**
098: * Checks to see if rendering should be allowed. Defaults to true but will
099: * return false after a #stop directive.
100: *
101: * @return true if rendering is allowed, false if no rendering should occur
102: */
103: boolean getAllowRendering();
104:
105: /**
106: * Set whether rendering is allowed. Defaults to true but is set to
107: * false after a #stop directive.
108: * @param v
109: */
110: void setAllowRendering(boolean v);
111:
112: }
|