本文整理汇总了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);
}
}
示例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();
}
示例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();
}