View Javadoc

1   package org.apache.velocity.runtime;
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  /**
23   * This class defines the keys that are used in the velocity.properties file so that they can be referenced as a constant within
24   * Java code.
25   *
26   * @author  <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
27   * @author  <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
28   * @author  <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
29   * @version  $Id: RuntimeConstants.java 806601 2009-08-21 15:30:38Z nbubna $
30   */
31  public interface RuntimeConstants
32  {
33      /*
34       * ----------------------------------------------------------------------
35       * These are public constants that are used as handles for the
36       * properties that can be specified in your typical
37       * velocity.properties file.
38       * ----------------------------------------------------------------------
39       */
40  
41      /*
42       * ----------------------------------------------------------------------
43       * L O G G I N G  C O N F I G U R A T I O N
44       * ----------------------------------------------------------------------
45       */
46  
47      /** Location of the velocity log file. */
48      String RUNTIME_LOG = "runtime.log";
49  
50      /** externally provided logger. */
51      String RUNTIME_LOG_LOGSYSTEM = "runtime.log.logsystem";
52  
53      /** class of log system to use. */
54      String RUNTIME_LOG_LOGSYSTEM_CLASS = "runtime.log.logsystem.class";
55  
56      /**
57       * Properties referenced in the template are required to exist the object
58       */
59      String RUNTIME_REFERENCES_STRICT = "runtime.references.strict";
60      
61      /**
62       * Indicates we are going to use modifed escape behavior in strict mode
63       */
64      String RUNTIME_REFERENCES_STRICT_ESCAPE = "runtime.references.strict.escape";
65         
66      /**
67       * @deprecated  This appears to have always been meaningless.
68       */
69      String RUNTIME_LOG_ERROR_STACKTRACE = "runtime.log.error.stacktrace";
70  
71      /**
72       * @deprecated  The functionality this controlled is confusing and no longer necessary.
73       */
74      String RUNTIME_LOG_WARN_STACKTRACE = "runtime.log.warn.stacktrace";
75  
76      /**
77       * @deprecated  This appears to have always been meaningless.
78       */
79      String RUNTIME_LOG_INFO_STACKTRACE = "runtime.log.info.stacktrace";
80  
81      /** Logging of invalid references. */
82      String RUNTIME_LOG_REFERENCE_LOG_INVALID = "runtime.log.invalid.references";
83  
84      /**
85       * @deprecated  Use LogChute.TRACE_PREFIX instead
86       */
87      String TRACE_PREFIX = " [trace] ";
88  
89      /**
90       * @deprecated  Use LogChute.DEBUG_PREFIX instead
91       */
92      String DEBUG_PREFIX = " [debug] ";
93  
94      /**
95       * @deprecated  Use LogChute.INFO_PREFIX instead
96       */
97      String INFO_PREFIX = "  [info] ";
98  
99      /**
100      * @deprecated  Use LogChute.WARN_PREFIX instead
101      */
102     String WARN_PREFIX = "  [warn] ";
103 
104     /**
105      * @deprecated  Use LogChute.ERROR_PREFIX instead
106      */
107     String ERROR_PREFIX = " [error] ";
108 
109     /**
110      * @deprecated  This will be removed in a future version
111      */
112     String UNKNOWN_PREFIX = " [unknown] ";
113 
114     /*
115      * ----------------------------------------------------------------------
116      * D I R E C T I V E  C O N F I G U R A T I O N
117      * ----------------------------------------------------------------------
118      * Directive properties are of the form:
119      *
120      * directive.<directive-name>.<property>
121      * ----------------------------------------------------------------------
122      */
123 
124     /** Counter reference name in #foreach directives. */
125     String COUNTER_NAME = "directive.foreach.counter.name";
126 
127     /**
128      * Iterator.hasNext() reference name in #foreach directives.
129      * @since 1.6
130      */
131     String HAS_NEXT_NAME = "directive.foreach.iterator.name";
132 
133     /** Initial counter value in #foreach directives. */
134     String COUNTER_INITIAL_VALUE = "directive.foreach.counter.initial.value";
135 
136     /** Maximum allowed number of loops. */
137     String MAX_NUMBER_LOOPS = "directive.foreach.maxloops";
138 
139     /**
140      * Whether to throw an exception or just skip bad iterables. Default is true.
141      * @since 1.6
142      */
143     String SKIP_INVALID_ITERATOR = "directive.foreach.skip.invalid";
144 
145     /** if set to true then allows #set to accept null values in the right hand side. */
146     String SET_NULL_ALLOWED = "directive.set.null.allowed";
147 
148     /**
149      * Indicates if toString() should be called during #if condition evaluation
150      * just to ensure it does not return null. Check is unnecessary if all
151      * toString() implementations are known to have non-null return values.
152      * Disabling the check (like Velocity 1.5 did) will can boost performance
153      * since toString() may be a complex operation on large objects.
154      * @since 1.6
155      */
156     String DIRECTIVE_IF_TOSTRING_NULLCHECK = "directive.if.tostring.nullcheck";
157 
158     /**
159      * Starting tag for error messages triggered by passing a parameter not allowed in the #include directive. Only string literals,
160      * and references are allowed.
161      */
162     String ERRORMSG_START = "directive.include.output.errormsg.start";
163 
164     /**
165      * Ending tag for error messages triggered by passing a parameter not allowed in the #include directive. Only string literals,
166      * and references are allowed.
167      */
168     String ERRORMSG_END = "directive.include.output.errormsg.end";
169 
170     /** Maximum recursion depth allowed for the #parse directive. */
171     String PARSE_DIRECTIVE_MAXDEPTH = "directive.parse.max.depth";
172 
173     /** Maximum recursion depth allowed for the #define directive. */
174     String DEFINE_DIRECTIVE_MAXDEPTH = "directive.define.max.depth";
175 
176     /**
177      * class to use for local context with #evaluate()
178      * @since 1.6
179      */
180     String EVALUATE_CONTEXT_CLASS = "directive.evaluate.context.class";
181 
182     /**
183      * Used to suppress various scope control objects.
184      * @since 1.7
185      */
186     String PROVIDE_SCOPE_CONTROL = "provide.scope.control";
187 
188     /*
189      * ----------------------------------------------------------------------
190      *  R E S O U R C E   M A N A G E R   C O N F I G U R A T I O N
191      * ----------------------------------------------------------------------
192      */
193 
194     /**  */
195     String RESOURCE_MANAGER_CLASS = "resource.manager.class";
196 
197     /**
198      * The <code>resource.manager.cache.class</code> property specifies the name of the
199      * {@link org.apache.velocity.runtime.resource.ResourceCache} implementation to use.
200      */
201     String RESOURCE_MANAGER_CACHE_CLASS = "resource.manager.cache.class";
202 
203     /** The <code>resource.manager.cache.size</code> property specifies the cache upper bound (if relevant). */
204     String RESOURCE_MANAGER_DEFAULTCACHE_SIZE = "resource.manager.defaultcache.size";
205 
206     /*
207      * ----------------------------------------------------------------------
208      * R E S O U R C E  L O A D E R  C O N F I G U R A T I O N
209      * ----------------------------------------------------------------------
210      */
211 
212     /** controls if the finding of a resource is logged. */
213     String RESOURCE_MANAGER_LOGWHENFOUND = "resource.manager.logwhenfound";
214 
215     /**
216      * Key used to retrieve the names of the resource loaders to be used. In a properties file they may appear as the following:
217      *
218      * <p>resource.loader = file,classpath</p>
219      */
220     String RESOURCE_LOADER = "resource.loader";
221 
222     /** The public handle for setting a path in the FileResourceLoader. */
223     String FILE_RESOURCE_LOADER_PATH = "file.resource.loader.path";
224 
225     /** The public handle for turning the caching on in the FileResourceLoader. */
226     String FILE_RESOURCE_LOADER_CACHE = "file.resource.loader.cache";
227 
228     /*
229      * ----------------------------------------------------------------------
230      *  E V E N T  H A N D L E R  C O N F I G U R A T I O N
231      * ----------------------------------------------------------------------
232      */
233 
234     /**
235      * The <code>eventhandler.referenceinsertion.class</code> property specifies a list of the
236      * {@link org.apache.velocity.app.event.ReferenceInsertionEventHandler} implementations to use.
237      */
238     String EVENTHANDLER_REFERENCEINSERTION = "eventhandler.referenceinsertion.class";
239 
240     /**
241      * The <code>eventhandler.nullset.class</code> property specifies a list of the
242      * {@link org.apache.velocity.app.event.NullSetEventHandler} implementations to use.
243      */
244     String EVENTHANDLER_NULLSET = "eventhandler.nullset.class";
245 
246     /**
247      * The <code>eventhandler.methodexception.class</code> property specifies a list of the
248      * {@link org.apache.velocity.app.event.MethodExceptionEventHandler} implementations to use.
249      */
250     String EVENTHANDLER_METHODEXCEPTION = "eventhandler.methodexception.class";
251 
252     /**
253      * The <code>eventhandler.include.class</code> property specifies a list of the
254      * {@link org.apache.velocity.app.event.IncludeEventHandler} implementations to use.
255      */
256     String EVENTHANDLER_INCLUDE = "eventhandler.include.class";
257 
258     /**
259      * The <code>eventhandler.invalidreferences.class</code> property specifies a list of the
260      * {@link org.apache.velocity.app.event.InvalidReferenceEventHandler} implementations to use.
261      */
262     String EVENTHANDLER_INVALIDREFERENCES = "eventhandler.invalidreferences.class";
263 
264 
265     /*
266      * ----------------------------------------------------------------------
267      * V E L O C I M A C R O  C O N F I G U R A T I O N
268      * ----------------------------------------------------------------------
269      */
270 
271     /** Name of local Velocimacro library template. */
272     String VM_LIBRARY = "velocimacro.library";
273 
274     /** Default Velocimacro library template. */
275     String VM_LIBRARY_DEFAULT = "VM_global_library.vm";
276 
277     /** switch for autoloading library-sourced VMs (for development). */
278     String VM_LIBRARY_AUTORELOAD = "velocimacro.library.autoreload";
279 
280     /** boolean (true/false) default true : allow inline (in-template) macro definitions. */
281     String VM_PERM_ALLOW_INLINE = "velocimacro.permissions.allow.inline";
282 
283     /** boolean (true/false) default false : allow inline (in-template) macro definitions to replace existing. */
284     String VM_PERM_ALLOW_INLINE_REPLACE_GLOBAL = "velocimacro.permissions.allow.inline.to.replace.global";
285 
286     /** Switch for forcing inline macros to be local : default false. */
287     String VM_PERM_INLINE_LOCAL = "velocimacro.permissions.allow.inline.local.scope";
288 
289     /** Switch for VM blather : default true. */
290     String VM_MESSAGES_ON = "velocimacro.messages.on";
291 
292     /** switch for local context in VM : default false. */
293     String VM_CONTEXT_LOCALSCOPE = "velocimacro.context.localscope";
294 
295     /** if true, throw an exception for wrong number of arguments **/
296     String VM_ARGUMENTS_STRICT = "velocimacro.arguments.strict";
297 
298     /**
299      * Specify the maximum depth for macro calls
300      * @since 1.6
301      */
302     String VM_MAX_DEPTH = "velocimacro.max.depth";
303 
304     /**
305      * Defines name of the reference that can be used to get the AST block passed to block macro calls.
306      * @since 1.7
307      */
308     String VM_BODY_REFERENCE = "velocimacro.body.reference";
309     
310     /*
311      * ----------------------------------------------------------------------
312      * G E N E R A L  R U N T I M E  C O N F I G U R A T I O N
313      * ----------------------------------------------------------------------
314      */
315 
316     /** Switch for the interpolation facility for string literals. */
317     String INTERPOLATE_STRINGLITERALS = "runtime.interpolate.string.literals";
318 
319     /** The character encoding for the templates. Used by the parser in processing the input streams. */
320     String INPUT_ENCODING = "input.encoding";
321 
322     /** Encoding for the output stream. Currently used by Anakia and VelocityServlet */
323     String OUTPUT_ENCODING = "output.encoding";
324 
325     /** Default Encoding is ISO-8859-1. */
326     String ENCODING_DEFAULT = "ISO-8859-1";
327 
328     /** key name for uberspector. Multiple classnames can be specified,in which case uberspectors will be chained. */
329     String UBERSPECT_CLASSNAME = "runtime.introspector.uberspect";
330 
331     /** A comma separated list of packages to restrict access to in the SecureIntrospector. */
332     String INTROSPECTOR_RESTRICT_PACKAGES = "introspector.restrict.packages";
333 
334     /** A comma separated list of classes to restrict access to in the SecureIntrospector. */
335     String INTROSPECTOR_RESTRICT_CLASSES = "introspector.restrict.classes";
336 
337     /** Switch for ignoring nulls in math equations vs throwing exceptions. */
338     String STRICT_MATH = "runtime.strict.math";
339 
340     /**
341      * The <code>parser.pool.class</code> property specifies the name of the {@link org.apache.velocity.util.SimplePool}
342      * implementation to use.
343      */
344     String PARSER_POOL_CLASS = "parser.pool.class";
345 
346     /**
347      * @see  #NUMBER_OF_PARSERS
348      */
349     String PARSER_POOL_SIZE = "parser.pool.size";
350     
351     /*
352      * ----------------------------------------------------------------------
353      * These constants are used internally by the Velocity runtime i.e.
354      * the constants listed below are strictly used in the Runtime
355      * class itself.
356      * ----------------------------------------------------------------------
357      */
358 
359     /** Default Runtime properties. */
360     String DEFAULT_RUNTIME_PROPERTIES = "org/apache/velocity/runtime/defaults/velocity.properties";
361 
362     /** Default Runtime properties. */
363     String DEFAULT_RUNTIME_DIRECTIVES = "org/apache/velocity/runtime/defaults/directive.properties";
364 
365     /**
366      * The default number of parser instances to create. Configurable via the parameter named by the {@link #PARSER_POOL_SIZE}
367      * constant.
368      */
369     int NUMBER_OF_PARSERS = 20;
370 
371     
372 
373 
374 
375 }