本文整理了Java中freemarker.core.Environment.visit()
方法的一些代码示例,展示了Environment.visit()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Environment.visit()
方法的具体详情如下:
包路径:freemarker.core.Environment
类名称:Environment
方法名:visit
[英]"visit" an IteratorBlock
[中]“访问”迭代器锁
代码示例来源:origin: org.freemarker/freemarker
public void render(Writer newOut) throws TemplateException, IOException {
Writer prevOut = out;
out = newOut;
try {
visit(childBuffer);
} finally {
out = prevOut;
}
}
代码示例来源:origin: org.freemarker/freemarker
env.visit(getChildBuffer(), (TemplateDirectiveModel) tm, args, bodyParameterNames);
} else {
env.visitAndTransform(getChildBuffer(), (TemplateTransformModel) tm, args);
代码示例来源:origin: org.freemarker/freemarker
/**
* Visits the elements while temporarily using the parameter output {@link Writer}.
*
* @since 2.3.27
*/
final void visit(TemplateElement[] elementBuffer, Writer out) throws IOException, TemplateException {
Writer prevOut = this.out;
this.out = out;
try {
visit(elementBuffer);
} finally {
this.out = prevOut;
}
}
代码示例来源:origin: org.freemarker/freemarker
String renderElementToString(TemplateElement te) throws IOException, TemplateException {
Writer prevOut = out;
try {
StringWriter sw = new StringWriter();
this.out = sw;
visit(te);
return sw.toString();
} finally {
this.out = prevOut;
}
}
代码示例来源:origin: org.freemarker/freemarker
env.visit(cas);
processedCase = true;
env.visit(defaultCase);
代码示例来源:origin: org.freemarker/freemarker
try {
inAttemptBlock = true;
visit(attemptedSection);
} catch (TemplateException te) {
thrownException = te;
visit(recoverySection);
} finally {
recoveredErrorStack.remove(recoveredErrorStack.size() - 1);
代码示例来源:origin: org.freemarker/freemarker
/**
* Processes the template to which this environment belongs to.
*/
public void process() throws TemplateException, IOException {
Object savedEnv = threadEnv.get();
threadEnv.set(this);
try {
// Cached values from a previous execution are possibly outdated.
clearCachedValues();
try {
doAutoImportsAndIncludes(this);
visit(getTemplate().getRootTreeNode());
// It's here as we must not flush if there was an exception.
if (getAutoFlush()) {
out.flush();
}
} finally {
// It's just to allow the GC to free memory...
clearCachedValues();
}
} finally {
threadEnv.set(savedEnv);
}
}
代码示例来源:origin: org.freemarker/freemarker
/**
* "Visit" the template element.
*/
void visit(TemplateElement element) throws IOException, TemplateException {
// ATTENTION: This method body is manually "inlined" into visit(TemplateElement[]); keep them in sync!
pushElement(element);
try {
TemplateElement[] templateElementsToVisit = element.accept(this);
if (templateElementsToVisit != null) {
for (TemplateElement el : templateElementsToVisit) {
if (el == null) {
break; // Skip unused trailing buffer capacity
}
visit(el);
}
}
} catch (TemplateException te) {
handleTemplateException(te);
} finally {
popElement();
}
// ATTENTION: This method body above is manually "inlined" into visit(TemplateElement[]); keep them in sync!
}
代码示例来源:origin: org.freemarker/freemarker
void visit(final TemplateElement[] childBuffer,
TemplateDirectiveModel directiveModel, Map args,
final List bodyParameterNames) throws TemplateException, IOException {
TemplateDirectiveBody nested;
if (childBuffer == null) {
nested = null;
} else {
nested = new NestedElementTemplateDirectiveBody(childBuffer);
}
final TemplateModel[] outArgs;
if (bodyParameterNames == null || bodyParameterNames.isEmpty()) {
outArgs = NO_OUT_ARGS;
} else {
outArgs = new TemplateModel[bodyParameterNames.size()];
}
if (outArgs.length > 0) {
pushLocalContext(new LocalContext() {
public TemplateModel getLocalVariable(String name) {
int index = bodyParameterNames.indexOf(name);
return index != -1 ? outArgs[index] : null;
}
public Collection getLocalVariableNames() {
return bodyParameterNames;
}
});
}
try {
directiveModel.execute(this, args, outArgs, nested);
代码示例来源:origin: org.freemarker/freemarker
break; // Skip unused trailing buffer capacity
visit(el);
代码示例来源:origin: org.freemarker/freemarker
@Override
TemplateElement[] accept(Environment env) throws TemplateException, IOException {
TemplateElement[] children = getChildBuffer();
TemplateModel value;
if (children != null) {
StringWriter out = new StringWriter();
env.visit(children, out);
value = capturedStringToModel(out.toString());
} else {
value = capturedStringToModel("");
}
if (namespaceExp != null) {
((Environment.Namespace) namespaceExp.eval(env)).put(varName, value);
} else if (scope == Assignment.NAMESPACE) {
env.setVariable(varName, value);
} else if (scope == Assignment.GLOBAL) {
env.setGlobalVariable(varName, value);
} else if (scope == Assignment.LOCAL) {
env.setLocalVariable(varName, value);
} else {
throw new BugException("Unhandled scope");
}
return null;
}
代码示例来源:origin: org.freemarker/freemarker
hasNext = iterModel.hasNext();
try {
env.visit(childBuffer);
} catch (BreakOrContinueException br) {
if (br == BreakOrContinueException.BREAK_INSTANCE) {
env.visit(childBuffer);
hasNext = (size > index + 1);
try {
env.visit(childBuffer);
} catch (BreakOrContinueException br) {
if (br == BreakOrContinueException.BREAK_INSTANCE) {
env.visit(childBuffer);
env.visit(childBuffer);
} catch (BreakOrContinueException br) {
代码示例来源:origin: org.freemarker/freemarker
/**
* Processes a Template in the context of this <code>Environment</code>, including its output in the
* <code>Environment</code>'s Writer.
*
* @param includedTemplate
* the template to process. Note that it does <em>not</em> need to be a template returned by
* {@link #getTemplateForInclusion(String name, String encoding, boolean parse)}.
*/
public void include(Template includedTemplate)
throws TemplateException, IOException {
final Template prevTemplate;
final boolean parentReplacementOn = isBeforeIcI2322();
prevTemplate = getTemplate();
if (parentReplacementOn) {
setParent(includedTemplate);
} else {
legacyParent = includedTemplate;
}
importMacros(includedTemplate);
try {
visit(includedTemplate.getRootTreeNode());
} finally {
if (parentReplacementOn) {
setParent(prevTemplate);
} else {
legacyParent = prevTemplate;
}
}
}
代码示例来源:origin: org.freemarker/freemarker
visit(macro.getChildBuffer());
} catch (ReturnInstruction.Return re) {
代码示例来源:origin: org.freemarker/freemarker
hasNext = kvpIter.hasNext();
try {
env.visit(childBuffer);
} catch (BreakOrContinueException br) {
if (br == BreakOrContinueException.BREAK_INSTANCE) {
env.visit(childBuffer);
hasNext = keysIter.hasNext();
try {
env.visit(childBuffer);
} catch (BreakOrContinueException br) {
if (br == BreakOrContinueException.BREAK_INSTANCE) {
} while (hasNext);
} else {
env.visit(childBuffer);
代码示例来源:origin: org.freemarker/freemarker
if (tc == null || tc.onStart() != TransformControl.SKIP_BODY) {
do {
visit(elementBuffer);
} while (tc != null && tc.afterBody() == TransformControl.REPEAT_EVALUATION);
代码示例来源:origin: org.freemarker/freemarker
visit(nestedContentBuffer);
} finally {
if (invokingMacroContext.nestedContentParameterNames != null) {
代码示例来源:origin: org.freemarker/com.springsource.freemarker
void accept(Environment env)
throws TemplateException, IOException
{
if (nestedBlock != null) {
env.visit(nestedBlock);
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.freemarker
String renderElementToString(TemplateElement te) throws IOException, TemplateException {
Writer prevOut = out;
try {
StringWriter sw = new StringWriter();
this.out = sw;
visit(te);
return sw.toString();
} finally {
this.out = prevOut;
}
}
代码示例来源:origin: org.freemarker/com.springsource.freemarker
void accept(Environment env) throws TemplateException, IOException {
for (int i = 0; i<nestedElements.size(); i++) {
ConditionalBlock cblock = (ConditionalBlock) nestedElements.get(i);
Expression condition = cblock.condition;
if (condition == null || condition.isTrue(env)) {
if (cblock.nestedBlock != null) {
env.visit(cblock.nestedBlock);
}
return;
}
}
}
内容来源于网络,如有侵权,请联系作者删除!