Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2014 Attila Szegedi, Daniel Dekany, Jonathan Revusky
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   * http://www.apache.org/licenses/LICENSE-2.0
   * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package freemarker.core;
 
Used by built-ins and other template language features that get a class based on a string. This can be handy both for implementing security restrictions and for working around local class-loader issues. The implementation should be thread-safe, unless an instance is always only used in a single Environment object.

 
 public interface TemplateClassResolver {
    
    
 
 
         public Class resolve(String classNameEnvironment envTemplate template)
         throws TemplateException {
             try {
                 return ClassUtil.forName(className);
             } catch (ClassNotFoundException e) {
                 throw new _MiscTemplateException(eenv);
             }
         }
         
     };
    
    
Same as UNRESTRICTED_RESOLVER, except that it doesn't allow resolving freemarker.template.utility.ObjectConstructor and freemarker.template.utility.Execute and freemarker.template.utility.JythonRuntime.
 
 
         public Class resolve(String classNameEnvironment envTemplate template)
         throws TemplateException {
             if (className.equals(ObjectConstructor.class.getName())
                     || className.equals(Execute.class.getName())
                     || className.equals("freemarker.template.utility.JythonRuntime")) {
                 throw MessageUtil.newInstantiatingClassNotAllowedException(classNameenv);
             }
             try {
                 return ClassUtil.forName(className);
             } catch (ClassNotFoundException e) {
                 throw new _MiscTemplateException(eenv);
             }
         }
         
     };
    
    
Doesn't allow resolving any classes.
 
 
         public Class resolve(String classNameEnvironment envTemplate template)
         throws TemplateException {
             throw MessageUtil.newInstantiatingClassNotAllowedException(classNameenv);
         }
         
     };

    
Gets a java.lang.Class based on the class name.

Parameters:
className the full-qualified class name
env the environment in which the template executes
template the template where the operation that require the class resolution resides in. This is null if the call doesn't come from a template.
Throws:
freemarker.template.TemplateException if the class can't be found or shouldn't be accessed from a template for security reasons.
    Class resolve(String classNameEnvironment envTemplate templatethrows TemplateException;
    
New to GrepCode? Check out our FAQ X