• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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$
30  */
31 
32 public interface RuntimeConstants extends DeprecatedRuntimeConstants
33 {
34     /*
35      * ----------------------------------------------------------------------
36      * These are public constants that are used as handles for the
37      * properties that can be specified in your typical
38      * velocity.properties file.
39      * ----------------------------------------------------------------------
40      */
41 
42     /*
43      * ----------------------------------------------------------------------
44      * L O G G I N G  C O N F I G U R A T I O N
45      * ----------------------------------------------------------------------
46      */
47 
48     /** externally provided logger. */
49     String RUNTIME_LOG_INSTANCE = "runtime.log.instance";
50 
51     /** externally provided logger name. */
52     String RUNTIME_LOG_NAME = "runtime.log.name";
53 
54     /** Logging of invalid references. */
55     String RUNTIME_LOG_REFERENCE_LOG_INVALID = "runtime.log.log_invalid_references";
56 
57     /** Logging of invalid method calls. */
58     String RUNTIME_LOG_METHOD_CALL_LOG_INVALID = "runtime.log.log_invalid_method_calls";
59 
60     /** <p>Whether to:</p>
61      *  <ul>
62      *      <li>populate slf4j's MDC with location in template file</li>
63      *      <li>display VTL stack trace on errors</li>
64      *  </ul>
65      *  @since 2.2
66      */
67     String RUNTIME_LOG_TRACK_LOCATION = "runtime.log.track_location";
68 
69     /*
70      * ----------------------------------------------------------------------
71      * D I R E C T I V E  C O N F I G U R A T I O N
72      * ----------------------------------------------------------------------
73      * Directive properties are of the form:
74      *
75      * directive.<directive-name>.<property>
76      * ----------------------------------------------------------------------
77      */
78 
79     /** Maximum allowed number of loops. */
80     String MAX_NUMBER_LOOPS = "directive.foreach.max_loops";
81 
82     /**
83      * Whether to throw an exception or just skip bad iterables. Default is true.
84      * @since 1.6
85      */
86     String SKIP_INVALID_ITERATOR = "directive.foreach.skip_invalid";
87 
88     /**
89      * An empty object (string, collection) or zero number is false.
90      * @since 2.0
91      */
92     String CHECK_EMPTY_OBJECTS = "directive.if.empty_check";
93 
94     /**
95      * Starting tag for error messages triggered by passing a parameter not allowed in the #include directive. Only string literals,
96      * and references are allowed.
97      * @deprecated if/how errors are displayed is not the concern of the engine, which should throw in all cases
98      */
99     String ERRORMSG_START = "directive.include.output_error_start";
100 
101     /**
102      * Ending tag for error messages triggered by passing a parameter not allowed in the #include directive. Only string literals,
103      * and references are allowed.
104      * @deprecated if/how errors are displayed is not the concern of the engine, which should throw in all cases
105      */
106     String ERRORMSG_END = "directive.include.output_error_end";
107 
108     /** Maximum recursion depth allowed for the #parse directive. */
109     String PARSE_DIRECTIVE_MAXDEPTH = "directive.parse.max_depth";
110 
111     /** Maximum recursion depth allowed for the #define directive. */
112     String DEFINE_DIRECTIVE_MAXDEPTH = "directive.define.max_depth";
113 
114     /**
115      * Used to suppress various scope control objects (property suffix).
116      * @since 1.7
117      * @deprecated use <code>context.scope_control.&lt;scope_name&gt; = true/false</code>
118      * @see #CONTEXT_SCOPE_CONTROL
119      */
120     @Deprecated
121     String PROVIDE_SCOPE_CONTROL = "provide.scope.control";
122 
123     /**
124      * Used to enable or disable a scope control (false by default):
125      * <code>context.scope_control.&lt;scope_name&gt; = true/false</code>
126      * where <i>scope_name</i> is one of: <code>template, evaluate, foreach, macro, define</code>
127      * or the name of a body macro.
128      * @since 2.1
129      */
130     String CONTEXT_SCOPE_CONTROL = "context.scope_control";
131 
132     /**
133      * Vector of custom directives
134      */
135     String CUSTOM_DIRECTIVES = "runtime.custom_directives";
136 
137     /*
138      * ----------------------------------------------------------------------
139      *  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
140      * ----------------------------------------------------------------------
141      */
142 
143     /**
144      * The <code>resource.manager.instance</code> property specifies an existing instance of a
145      * {@link org.apache.velocity.runtime.resource.ResourceManager} implementation to use
146      */
147     String RESOURCE_MANAGER_INSTANCE = "resource.manager.instance";
148 
149     /**
150     * The <code>resource.manager.class</code> property specifies the name of the
151     * {@link org.apache.velocity.runtime.resource.ResourceManager} implementation to use.
152     */
153     String RESOURCE_MANAGER_CLASS = "resource.manager.class";
154 
155     /**
156      * The <code>resource.manager.cache.class</code> property specifies the name of the
157      * {@link org.apache.velocity.runtime.resource.ResourceCache} implementation to use.
158      */
159     String RESOURCE_MANAGER_CACHE_CLASS = "resource.manager.cache.class";
160 
161     /** The <code>resource.manager.cache.size</code> property specifies the cache upper bound (if relevant). */
162     String RESOURCE_MANAGER_DEFAULTCACHE_SIZE = "resource.manager.cache.default_size";
163 
164     /*
165      * ----------------------------------------------------------------------
166      * 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
167      * ----------------------------------------------------------------------
168      */
169 
170     /** controls if the finding of a resource is logged. */
171     String RESOURCE_MANAGER_LOGWHENFOUND = "resource.manager.log_when_found";
172 
173     /**
174      * Key used to retrieve the names of the resource loaders to be used. In a properties file they may appear as the following:
175      *
176      * <p>resource.loaders = file,classpath</p>
177      */
178     String RESOURCE_LOADERS = "resource.loaders";
179 
180     /**
181      * Key prefix for a specific resource loader properties
182      *
183      * <p>resource.loader.file.path = ...</p>
184      */
185     String RESOURCE_LOADER = "resource.loader";
186 
187     /** The public handle for setting paths in the FileResourceLoader.
188      * (this constant is used by test cases only)
189      */
190     String FILE_RESOURCE_LOADER_PATH = "resource.loader.file.path";
191 
192     /** The public handle for turning the caching on in the FileResourceLoader. */
193     String FILE_RESOURCE_LOADER_CACHE = "resource.loader.file.cache";
194 
195     /**
196      * Resource loader class property suffix
197      */
198     String RESOURCE_LOADER_CLASS = "class";
199 
200     /**
201      * Resource loader instance property suffix
202      */
203     String RESOURCE_LOADER_INSTANCE = "instance";
204 
205     /**
206      * Resource loader cache property suffix
207      */
208     String RESOURCE_LOADER_CACHE = "cache";
209 
210     /**
211      * File resource loader paths property suffix
212      */
213     String RESOURCE_LOADER_PATHS = "path";
214 
215     /**
216      * Resource loader modification check interval property suffix
217      */
218     String RESOURCE_LOADER_CHECK_INTERVAL = "modification_check_interval";
219 
220     /**
221      * Datasource loader datasource url
222      */
223     String DS_RESOURCE_LOADER_DATASOURCE = "resource.loader.ds.resource.datasource_url";
224 
225     /**
226      * Datasource loader templates table
227      */
228     String DS_RESOURCE_LOADER_TABLE = "resource.loader.ds.resource.table";
229 
230     /**
231      * Datasource loader template key column
232      */
233     String DS_RESOURCE_LOADER_KEY_COLUMN = "resource.loader.ds.resource.key_column";
234 
235     /**
236      * Datasource loader template content column
237      */
238     String DS_RESOURCE_LOADER_TEMPLATE_COLUMN = "resource.loader.ds.resource.template_column";
239 
240     /**
241      * Datasource loader template timestamp column
242      */
243     String DS_RESOURCE_LOADER_TIMESTAMP_COLUMN = "resource.loader.ds.resource.timestamp_column";
244 
245     /** The default character encoding for the templates. Used by the parser in processing the input streams. */
246     String INPUT_ENCODING = "resource.default_encoding";
247 
248     /** Default Encoding is UTF-8. */
249     String ENCODING_DEFAULT = "UTF-8";
250 
251     /*
252      * ----------------------------------------------------------------------
253      *  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
254      * ----------------------------------------------------------------------
255      */
256 
257     /**
258      * The <code>event_handler.reference_insertion.class</code> property specifies a list of the
259      * {@link org.apache.velocity.app.event.ReferenceInsertionEventHandler} implementations to use.
260      */
261     String EVENTHANDLER_REFERENCEINSERTION = "event_handler.reference_insertion.class";
262 
263     /**
264      * The <code>event_handler.method_exception.class</code> property specifies a list of the
265      * {@link org.apache.velocity.app.event.MethodExceptionEventHandler} implementations to use.
266      */
267     String EVENTHANDLER_METHODEXCEPTION = "event_handler.method_exception.class";
268 
269     /**
270      * The <code>event_handler.include.class</code> property specifies a list of the
271      * {@link org.apache.velocity.app.event.IncludeEventHandler} implementations to use.
272      */
273     String EVENTHANDLER_INCLUDE = "event_handler.include.class";
274 
275     /**
276      * The <code>event_handler.invalid_references.class</code> property specifies a list of the
277      * {@link org.apache.velocity.app.event.InvalidReferenceEventHandler} implementations to use.
278      */
279     String EVENTHANDLER_INVALIDREFERENCES = "event_handler.invalid_references.class";
280 
281     /**
282      * The <code>event_handler.invalid_references.quiet</code> property specifies if invalid quiet references
283      * (as in <code>$!foo</code>) trigger events (defaults to false).
284      * {@link org.apache.velocity.app.event.InvalidReferenceEventHandler} implementations to use.
285      * @since 2.2
286      */
287     String EVENTHANDLER_INVALIDREFERENCES_QUIET = "event_handler.invalid_references.quiet";
288 
289     /**
290      * The <code>event_handler.invalid_references.null</code> property specifies if invalid null references
291      * (aka the value is present in the context or parent object but is null or a method returned null)
292      * trigger invalid reference events (defaults to false).
293      * {@link org.apache.velocity.app.event.InvalidReferenceEventHandler} implementations to use.
294      * @since 2.2
295      */
296     String EVENTHANDLER_INVALIDREFERENCES_NULL = "event_handler.invalid_references.null";
297 
298     /**
299      * The <code>event_handler.invalid_references.tested</code> property specifies if invalid tested references
300      * (as in <code>#if($foo)</code> ) trigger invalid reference events (defaults to false).
301      * {@link org.apache.velocity.app.event.InvalidReferenceEventHandler} implementations to use.
302      * @since 2.2
303      */
304     String EVENTHANDLER_INVALIDREFERENCES_TESTED = "event_handler.invalid_references.tested";
305 
306     /*
307      * ----------------------------------------------------------------------
308      * V E L O C I M A C R O  C O N F I G U R A T I O N
309      * ----------------------------------------------------------------------
310      */
311 
312     /** Filename of local Velocimacro library template. */
313     String VM_LIBRARY = "velocimacro.library.path";
314 
315     /** Default Velocimacro library template. */
316     String VM_LIBRARY_DEFAULT = "velocimacros.vtl";
317 
318     /** switch for autoloading library-sourced VMs (for development). */
319     String VM_LIBRARY_AUTORELOAD = "velocimacro.library.autoreload";
320 
321     /** boolean (true/false) default true: allow inline (in-template) macro definitions. */
322     String VM_PERM_ALLOW_INLINE = "velocimacro.inline.allow";
323 
324     /** boolean (true/false) default false: allow inline (in-template) macro definitions to replace existing. */
325     String VM_PERM_ALLOW_INLINE_REPLACE_GLOBAL = "velocimacro.inline.replace_global";
326 
327     /** Switch for forcing inline macros to be local: default false. */
328     String VM_PERM_INLINE_LOCAL = "velocimacro.inline.local_scope";
329 
330     /** if true, throw an exception for wrong number of arguments **/
331     String VM_ARGUMENTS_STRICT = "velocimacro.arguments.strict";
332 
333     /**
334      * This flag enable the 1.7 backward compatible mode for velocimacros (defaults to false):
335      * <ul>
336      *     <li>
337      *         preserve argument literals: when displaying null or invalid non-quiet references,
338      *         use the argument literal reference instead of the one in the macro block. Defaults to false.
339      *     </li>
340      *     <li>
341      *         use global values for missing arguments: when calling a macro with fewer arguments than declared,
342      *         if those arguments don't have an explicit default value in the macro definition, default values will
343      *         be looked for in the global context
344      *     </li>
345      * </ul>
346      * @since 2.2
347      */
348     String VM_ENABLE_BC_MODE = "velocimacro.enable_bc_mode";
349 
350     /**
351      * Specify the maximum depth for macro calls
352      * @since 1.6
353      */
354     String VM_MAX_DEPTH = "velocimacro.max_depth";
355 
356     /**
357      * Defines name of the reference that can be used to get the AST block passed to block macro calls.
358      * @since 1.7
359      */
360     String VM_BODY_REFERENCE = "velocimacro.body_reference";
361 
362     /**
363      * <p>Switch for VM blather: default true. Unused since 2.0.</p>
364      * @deprecated since 2.1
365      */
366     @Deprecated
367     String VM_MESSAGES_ON = "velocimacro.messages.on";
368 
369     /*
370      * ----------------------------------------------------------------------
371      * S T I C T   M O D E  B E H A V I O U R
372      * ----------------------------------------------------------------------
373      */
374 
375     /**
376      * Properties referenced in the template are required to exist the object
377      */
378     String RUNTIME_REFERENCES_STRICT = "runtime.strict_mode.enable";
379 
380     /**
381      * Indicates we are going to use modified escape behavior in strict mode
382      */
383     String RUNTIME_REFERENCES_STRICT_ESCAPE = "runtime.strict_mode.escape";
384 
385     /*
386      * ----------------------------------------------------------------------
387      * I N T R O S P E C T I O N  C O N F I G U R A T I O N
388      * ----------------------------------------------------------------------
389      */
390 
391     /** key name for uberspector. Multiple classnames can be specified,in which case uberspectors will be chained. */
392     String UBERSPECT_CLASSNAME = "introspector.uberspect.class";
393 
394     /** A comma separated list of packages to restrict access to in the SecureIntrospector. */
395     String INTROSPECTOR_RESTRICT_PACKAGES = "introspector.restrict.packages";
396 
397     /** A comma separated list of classes to restrict access to in the SecureIntrospector. */
398     String INTROSPECTOR_RESTRICT_CLASSES = "introspector.restrict.classes";
399 
400     /** key for Conversion Manager class */
401     String CONVERSION_HANDLER_CLASS = "introspector.conversion_handler.class";
402 
403     /** key for Conversion Manager instance */
404     String CONVERSION_HANDLER_INSTANCE = "introspector.conversion_handler.instance";
405 
406     /*
407      * ----------------------------------------------------------------------
408      * P A R S E R  C O N F I G U R A T I O N
409      * ----------------------------------------------------------------------
410      */
411 
412     /**
413      * Property specifying the parser class to use
414      * @since 2.2
415      */
416     String PARSER_CLASS = "parser.class";
417 
418     /**
419      * Default parser class
420      * @since 2.2
421      */
422     String DEFAULT_PARSER_CLASS = "org.apache.velocity.runtime.parser.StandardParser";
423 
424     /**
425      * The <code>parser.pool.class</code> property specifies the name of the {@link org.apache.velocity.util.SimplePool}
426      * implementation to use.
427      */
428     String PARSER_POOL_CLASS = "parser.pool.class";
429 
430     /**
431      * @see  #NUMBER_OF_PARSERS
432      */
433     String PARSER_POOL_SIZE = "parser.pool.size";
434 
435     /**
436      * Allow hyphen in identifiers (backward compatibility option)
437      * @since 2.1
438      */
439     String PARSER_HYPHEN_ALLOWED = "parser.allow_hyphen_in_identifiers";
440 
441     /*
442      * ----------------------------------------------------------------------
443      * 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
444      * ----------------------------------------------------------------------
445      */
446 
447     /** Whether to use string interning. */
448     String RUNTIME_STRING_INTERNING = "runtime.string_interning";
449 
450     /** Switch for the interpolation facility for string literals. */
451     String INTERPOLATE_STRINGLITERALS = "runtime.interpolate_string_literals";
452 
453     /** Switch for ignoring nulls in math equations vs throwing exceptions. */
454     String STRICT_MATH = "runtime.strict_math";
455 
456     /** Key upon which a context should be accessible within itself */
457     String CONTEXT_AUTOREFERENCE_KEY = "context.self_reference_key";
458 
459     /**
460      * Space gobbling mode
461      * @since 2.0
462      */
463     String SPACE_GOBBLING = "parser.space_gobbling";
464 
465     /**
466      * Space gobbling modes
467      * @since 2.0
468      */
469     enum SpaceGobbling
470     {
471         NONE, BC, LINES, STRUCTURED
472     }
473 
474     /*
475      * ----------------------------------------------------------------------
476      * These constants are used internally by the Velocity runtime i.e.
477      * the constants listed below are strictly used in the Runtime
478      * class itself.
479      * ----------------------------------------------------------------------
480      */
481 
482     /** Default Runtime properties. */
483     String DEFAULT_RUNTIME_PROPERTIES = "org/apache/velocity/runtime/defaults/velocity.properties";
484 
485     /** Default Runtime properties. */
486     String DEFAULT_RUNTIME_DIRECTIVES = "org/apache/velocity/runtime/defaults/directive.properties";
487 
488     /** externally provided logger name. */
489     String DEFAULT_RUNTIME_LOG_NAME = "org.apache.velocity";
490 
491     /** token used to identify the loader internally. */
492     String RESOURCE_LOADER_IDENTIFIER = "_RESOURCE_LOADER_IDENTIFIER_";
493 
494     /**
495      * The default number of parser instances to create. Configurable via the parameter named by the {@link #PARSER_POOL_SIZE}
496      * constant.
497      */
498     int NUMBER_OF_PARSERS = 20;
499 }
500