View Javadoc

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  import java.util.List;
27  
28  /**
29   *  interface to encapsulate the 'stuff' for internal operation of velocity.
30   *  We use the context as a thread-safe storage : we take advantage of the
31   *  fact that it's a visitor  of sorts  to all nodes (that matter) of the
32   *  AST during init() and render().
33   *
34   *  Currently, it carries the template name for namespace
35   *  support, as well as node-local context data introspection caching.
36   *
37   *  @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
38   *  @author <a href="mailto:Christoph.Reck@dlr.de">Christoph Reck</a>
39   *  @version $Id: InternalHousekeepingContext.java 731266 2009-01-04 15:11:20Z byron $
40   */
41  interface InternalHousekeepingContext
42  {
43      /**
44       *  set the current template name on top of stack
45       *
46       *  @param s current template name
47       */
48      void pushCurrentTemplateName( String s );
49  
50      /**
51       *  remove the current template name from stack
52       */
53      void popCurrentTemplateName();
54  
55      /**
56       *  get the current template name
57       *
58       *  @return String current template name
59       */
60      String getCurrentTemplateName();
61  
62      /**
63       *  Returns the template name stack in form of an array.
64       *
65       *  @return Object[] with the template name stack contents.
66       */
67      Object[] getTemplateNameStack();
68  
69      /**
70       *  set the current macro name on top of stack
71       *
72       *  @param s current macro name
73       */
74      void pushCurrentMacroName( String s );
75  
76      /**
77       *  remove the current macro name from stack
78       */
79      void popCurrentMacroName();
80  
81      /**
82       *  get the current macro name
83       *
84       *  @return String current macro name
85       */
86      String getCurrentMacroName();
87  
88      /**
89       *  get the current macro call depth
90       *
91       *  @return int current macro call depth
92       */
93      int getCurrentMacroCallDepth();
94  
95      /**
96       *  Returns the macro name stack in form of an array.
97       *
98       *  @return Object[] with the macro name stack contents.
99       */
100     Object[] getMacroNameStack();
101 
102     /**
103      *  returns an IntrospectionCache Data (@see IntrospectionCacheData)
104      *  object if exists for the key
105      *
106      *  @param key  key to find in cache
107      *  @return cache object
108      */
109     IntrospectionCacheData icacheGet( Object key );
110 
111     /**
112      *  places an IntrospectionCache Data (@see IntrospectionCacheData)
113      *  element in the cache for specified key
114      *
115      *  @param key  key
116      *  @param o  IntrospectionCacheData object to place in cache
117      */
118     void icachePut( Object key, IntrospectionCacheData o );
119 
120     /**
121      *  temporary fix to enable #include() to figure out
122      *  current encoding.
123      *
124      * @return The current resource.
125      */
126     Resource getCurrentResource();
127 
128 
129     /**
130      * @param r
131      */
132     void setCurrentResource( Resource r );
133 
134     /**
135      * Set the macro library list for the current template.
136      *
137      * @param macroLibraries list of macro libraries to set
138      */
139      void setMacroLibraries(List macroLibraries);
140 
141     /**
142      * Get the macro library list for the current template.
143      *
144      * @return List of macro library names
145      */
146      List getMacroLibraries();
147 
148 }