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


Java StringTemplate.write方法代码示例

本文整理汇总了Java中org.antlr.stringtemplate.StringTemplate.write方法的典型用法代码示例。如果您正苦于以下问题:Java StringTemplate.write方法的具体用法?Java StringTemplate.write怎么用?Java StringTemplate.write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.antlr.stringtemplate.StringTemplate的用法示例。


在下文中一共展示了StringTemplate.write方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeTemplate

import org.antlr.stringtemplate.StringTemplate; //导入方法依赖的package包/类
/**
 * Writes the populated template to an output writer by providing a closure with access to
 * the unpopulated template object.
 *
 * @param out Template output writer.
 * @param parameterSetter Consumer to populate the template.
 * @throws TemplateException If an exception was encountered while populating the template.
 */
public void writeTemplate(
    Writer out,
    Consumer<StringTemplate> parameterSetter) throws TemplateException {

  Preconditions.checkNotNull(out);
  Preconditions.checkNotNull(parameterSetter);

  StringTemplate stringTemplate = group.getInstanceOf(templatePath);
  try {
    parameterSetter.accept(stringTemplate);
    stringTemplate.write(new AutoIndentWriter(out));
  } catch (IOException e) {
    throw new TemplateException("Failed to write template: " + e, e);
  }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:24,代码来源:StringTemplateHelper.java

示例2: render

import org.antlr.stringtemplate.StringTemplate; //导入方法依赖的package包/类
public String render(Result result) throws Exception {
    final EnhancedStringTemplateGroup group = new EnhancedStringTemplateGroup(getClass());
    sequence(customRenderers).fold(group, registerRenderer());
    group.registerRenderer(instanceOf(JavaSource.class), callable(new JavaSourceRenderer()));
    group.registerRenderer(instanceOf(Notes.class), callable(new NotesRenderer()));
    final StringTemplate template = group.getInstanceOf("wiki");
    template.setAttribute("testResult", result);
    StringWriter writer = new StringWriter();
    template.write(new NoIndentWriter(writer));
    return writer.toString();
}
 
开发者ID:bodar,项目名称:yatspec,代码行数:12,代码来源:WikiResultRenderer.java

示例3: render

import org.antlr.stringtemplate.StringTemplate; //导入方法依赖的package包/类
public String render(Result result) throws Exception {
    final EnhancedStringTemplateGroup group = new EnhancedStringTemplateGroup(getClass());
    group.registerRenderer(always().and(not(instanceOf(Number.class))), Xml.escape());
    group.registerRenderer(instanceOf(ScenarioTableHeader.class), callable(new ScenarioTableHeaderRenderer()));
    group.registerRenderer(instanceOf(JavaSource.class), callable(new JavaSourceRenderer()));
    group.registerRenderer(instanceOf(Notes.class), callable(new NotesRenderer()));
    group.registerRenderer(instanceOf(LinkingNote.class), callable(new LinkingNoteRenderer(result.getTestClass())));
    group.registerRenderer(instanceOf(ContentAtUrl.class), asString());
    sequence(customRenderers).fold(group, registerRenderer());
    for (Class document : Creator.optionalClass("org.jdom.Document")) {
        group.registerRenderer(instanceOf(document), callable(Creator.<Renderer>create(Class.forName("com.googlecode.yatspec.plugin.jdom.DocumentRenderer"))));
    }

    final StringTemplate template = group.getInstanceOf("yatspec");
    template.setAttribute("script", loadContent("xregexp.js"));
    template.setAttribute("script", loadContent("yatspec.js"));
    for (Content customScript : customScripts) {
        template.setAttribute("script", customScript);
    }
    for (Content customHeaderContent : customHeaderContents) {
        template.setAttribute("customHeaderContent", customHeaderContent);
    }
    template.setAttribute("stylesheet", loadContent("yatspec.css"));
    template.setAttribute("cssClass", getCssMap());
    template.setAttribute("testResult", result);
    StringWriter writer = new StringWriter();
    template.write(new NoIndentWriter(writer));
    return writer.toString();
}
 
开发者ID:bodar,项目名称:yatspec,代码行数:30,代码来源:HtmlResultRenderer.java


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