当前位置: 首页>>代码示例>>Java>>正文


Java Directive类代码示例

本文整理汇总了Java中org.apache.velocity.runtime.directive.Directive的典型用法代码示例。如果您正苦于以下问题:Java Directive类的具体用法?Java Directive怎么用?Java Directive使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Directive类属于org.apache.velocity.runtime.directive包,在下文中一共展示了Directive类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadDirective

import org.apache.velocity.runtime.directive.Directive; //导入依赖的package包/类
/**
     * instantiates and loads the directive with some basic checks
     * 
     * @param directiveClass
     *            classname of directive to load
     */
    private void loadDirective(String directiveClass, String caption)
    {
        try
        {
            Object o = Class.forName(directiveClass).newInstance();
            if (o instanceof Directive)
            {
                Directive directive = (Directive) o;
                fDirectives.put(directive.getName(), directive);
            } else
            {
        	
//                error(caption + " Directive " + directiveClass + " is not org.apache.velocity.runtime.directive.Directive." + " Ignoring. ");
            }
        }
        catch (Exception e)
        {
//            error("Exception Loading " + caption + " Directive: " + directiveClass + " : " + e);
        }
    }
 
开发者ID:ninneko,项目名称:velocity-edit,代码行数:27,代码来源:VelocityParser.java

示例2: CodeGenerator

import org.apache.velocity.runtime.directive.Directive; //导入依赖的package包/类
public CodeGenerator(CodeGeneratorContext context, M model, Writer writer, URL templateUrl, String templateResource, Set<Class<? extends Directive>> directives) {
    this.context = context != null ? context : new CodeGeneratorContext();
    this.model = model;
    this.writer = writer;
    this.templateResource = templateResource;
    this.templateUrl = templateUrl;
    this.directives = directives;

    StringResourceRepository repo = StringResourceLoader.getRepository();
    try {
        repo.putStringResource(TEMPLATE, templateUrl != null ? loadResource(templateUrl) : loadResource(templateResource));
    } catch (Exception e) {
        throw new RuntimeException(TEMPLATE_READER_FAILURE, e);
    }

    for (Class<? extends Directive> directive : directives) {
        context.getVelocityEngine().loadDirective(directive.getCanonicalName());
    }

    this.template = this.context.getVelocityEngine().getTemplate(TEMPLATE);
    this.context.getVelocityContext().put(MODEL, model);
}
 
开发者ID:sundrio,项目名称:sundrio,代码行数:23,代码来源:CodeGenerator.java

示例3: initialise

import org.apache.velocity.runtime.directive.Directive; //导入依赖的package包/类
/**
 * Initialise Velocity
 * 
 * @param templatePath the path to templates
 */
public static final void initialise(String templatePath)
{
	// Setup Velocity
	Properties velocityProperties = new Properties();

	// create a list of custom directives we're using
	List<Class<? extends Directive>> userDirectiveClasses = new ArrayList<Class<? extends Directive>>();
	userDirectiveClasses.add(Decorate.class);

	// build the user directive string
	StringBuilder userDirectiveStr = new StringBuilder();
	for (Class<? extends Directive> clz : userDirectiveClasses)
	{
		if (userDirectiveStr.length() > 0)
		{
			userDirectiveStr.append(",");
		}
		userDirectiveStr.append(clz.getName());
	}

	// wire in our custom directives
	velocityProperties.setProperty("userdirective", userDirectiveStr.toString());

	velocityProperties.setProperty("velocimacro.library", "");

	// wire in our custom resource loader
	velocityProperties.setProperty("resource.loader", "relativecp");
	velocityProperties.setProperty("relativecp.resource.loader.description", "Relative CP Loader");
	velocityProperties.setProperty("relativecp.resource.loader.class", RelativeClasspathResourceLoader.class.getName());
	velocityProperties.setProperty(RelativeClasspathResourceLoader.RELATIVE_PATH, templatePath);

	// initialise
	Velocity.init(velocityProperties);
}
 
开发者ID:simoncurd,项目名称:hula-web,代码行数:40,代码来源:VelocityInitialiser.java

示例4: initialise

import org.apache.velocity.runtime.directive.Directive; //导入依赖的package包/类
/**
 * Initialise Velocity
 * 
 * @param templatePath the path to templates
 */
public static final void initialise(String templatePath)
{
	// Setup Velocity
	Properties velocityProperties = new Properties();

	// create a list of custom directives we're using
	List<Class<? extends Directive>> userDirectiveClasses = new ArrayList<Class<? extends Directive>>();
	userDirectiveClasses.add(Decorate.class);

	// build the user directive string
	StringBuilder userDirectiveStr = new StringBuilder();
	for (Class<? extends Directive> clz : userDirectiveClasses)
	{
		if (userDirectiveStr.length() > 0)
		{
			userDirectiveStr.append(",");
		}
		userDirectiveStr.append(clz.getName());
	}

	// wire in our custom directives
	velocityProperties.setProperty("userdirective", userDirectiveStr.toString());
	velocityProperties.setProperty("velocimacro.library", "");

	// file resource loader
	velocityProperties.setProperty("resource.loader", "file");
	velocityProperties.setProperty("file.resource.loader.path", templatePath);
	Velocity.init(velocityProperties);
	
	// initialise
	Velocity.init(velocityProperties);
}
 
开发者ID:simoncurd,项目名称:signatory,代码行数:38,代码来源:VelocityInitialiser.java

示例5: getDirectives

import org.apache.velocity.runtime.directive.Directive; //导入依赖的package包/类
public Set<Class<? extends Directive>> getDirectives() {
    return directives;
}
 
开发者ID:sundrio,项目名称:sundrio,代码行数:4,代码来源:CodeGenerator.java


注:本文中的org.apache.velocity.runtime.directive.Directive类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。