freemarker.core.Environment.visit()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(159)

本文整理了Java中freemarker.core.Environment.visit()方法的一些代码示例,展示了Environment.visit()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Environment.visit()方法的具体详情如下:
包路径:freemarker.core.Environment
类名称:Environment
方法名:visit

Environment.visit介绍

[英]"visit" an IteratorBlock
[中]“访问”迭代器锁

代码示例

代码示例来源:origin: org.freemarker/freemarker

  1. public void render(Writer newOut) throws TemplateException, IOException {
  2. Writer prevOut = out;
  3. out = newOut;
  4. try {
  5. visit(childBuffer);
  6. } finally {
  7. out = prevOut;
  8. }
  9. }

代码示例来源:origin: org.freemarker/freemarker

  1. env.visit(getChildBuffer(), (TemplateDirectiveModel) tm, args, bodyParameterNames);
  2. } else {
  3. env.visitAndTransform(getChildBuffer(), (TemplateTransformModel) tm, args);

代码示例来源:origin: org.freemarker/freemarker

  1. /**
  2. * Visits the elements while temporarily using the parameter output {@link Writer}.
  3. *
  4. * @since 2.3.27
  5. */
  6. final void visit(TemplateElement[] elementBuffer, Writer out) throws IOException, TemplateException {
  7. Writer prevOut = this.out;
  8. this.out = out;
  9. try {
  10. visit(elementBuffer);
  11. } finally {
  12. this.out = prevOut;
  13. }
  14. }

代码示例来源:origin: org.freemarker/freemarker

  1. String renderElementToString(TemplateElement te) throws IOException, TemplateException {
  2. Writer prevOut = out;
  3. try {
  4. StringWriter sw = new StringWriter();
  5. this.out = sw;
  6. visit(te);
  7. return sw.toString();
  8. } finally {
  9. this.out = prevOut;
  10. }
  11. }

代码示例来源:origin: org.freemarker/freemarker

  1. env.visit(cas);
  2. processedCase = true;
  3. env.visit(defaultCase);

代码示例来源:origin: org.freemarker/freemarker

  1. try {
  2. inAttemptBlock = true;
  3. visit(attemptedSection);
  4. } catch (TemplateException te) {
  5. thrownException = te;
  6. visit(recoverySection);
  7. } finally {
  8. recoveredErrorStack.remove(recoveredErrorStack.size() - 1);

代码示例来源:origin: org.freemarker/freemarker

  1. /**
  2. * Processes the template to which this environment belongs to.
  3. */
  4. public void process() throws TemplateException, IOException {
  5. Object savedEnv = threadEnv.get();
  6. threadEnv.set(this);
  7. try {
  8. // Cached values from a previous execution are possibly outdated.
  9. clearCachedValues();
  10. try {
  11. doAutoImportsAndIncludes(this);
  12. visit(getTemplate().getRootTreeNode());
  13. // It's here as we must not flush if there was an exception.
  14. if (getAutoFlush()) {
  15. out.flush();
  16. }
  17. } finally {
  18. // It's just to allow the GC to free memory...
  19. clearCachedValues();
  20. }
  21. } finally {
  22. threadEnv.set(savedEnv);
  23. }
  24. }

代码示例来源:origin: org.freemarker/freemarker

  1. /**
  2. * "Visit" the template element.
  3. */
  4. void visit(TemplateElement element) throws IOException, TemplateException {
  5. // ATTENTION: This method body is manually "inlined" into visit(TemplateElement[]); keep them in sync!
  6. pushElement(element);
  7. try {
  8. TemplateElement[] templateElementsToVisit = element.accept(this);
  9. if (templateElementsToVisit != null) {
  10. for (TemplateElement el : templateElementsToVisit) {
  11. if (el == null) {
  12. break; // Skip unused trailing buffer capacity
  13. }
  14. visit(el);
  15. }
  16. }
  17. } catch (TemplateException te) {
  18. handleTemplateException(te);
  19. } finally {
  20. popElement();
  21. }
  22. // ATTENTION: This method body above is manually "inlined" into visit(TemplateElement[]); keep them in sync!
  23. }

代码示例来源:origin: org.freemarker/freemarker

  1. void visit(final TemplateElement[] childBuffer,
  2. TemplateDirectiveModel directiveModel, Map args,
  3. final List bodyParameterNames) throws TemplateException, IOException {
  4. TemplateDirectiveBody nested;
  5. if (childBuffer == null) {
  6. nested = null;
  7. } else {
  8. nested = new NestedElementTemplateDirectiveBody(childBuffer);
  9. }
  10. final TemplateModel[] outArgs;
  11. if (bodyParameterNames == null || bodyParameterNames.isEmpty()) {
  12. outArgs = NO_OUT_ARGS;
  13. } else {
  14. outArgs = new TemplateModel[bodyParameterNames.size()];
  15. }
  16. if (outArgs.length > 0) {
  17. pushLocalContext(new LocalContext() {
  18. public TemplateModel getLocalVariable(String name) {
  19. int index = bodyParameterNames.indexOf(name);
  20. return index != -1 ? outArgs[index] : null;
  21. }
  22. public Collection getLocalVariableNames() {
  23. return bodyParameterNames;
  24. }
  25. });
  26. }
  27. try {
  28. directiveModel.execute(this, args, outArgs, nested);

代码示例来源:origin: org.freemarker/freemarker

  1. break; // Skip unused trailing buffer capacity
  2. visit(el);

代码示例来源:origin: org.freemarker/freemarker

  1. @Override
  2. TemplateElement[] accept(Environment env) throws TemplateException, IOException {
  3. TemplateElement[] children = getChildBuffer();
  4. TemplateModel value;
  5. if (children != null) {
  6. StringWriter out = new StringWriter();
  7. env.visit(children, out);
  8. value = capturedStringToModel(out.toString());
  9. } else {
  10. value = capturedStringToModel("");
  11. }
  12. if (namespaceExp != null) {
  13. ((Environment.Namespace) namespaceExp.eval(env)).put(varName, value);
  14. } else if (scope == Assignment.NAMESPACE) {
  15. env.setVariable(varName, value);
  16. } else if (scope == Assignment.GLOBAL) {
  17. env.setGlobalVariable(varName, value);
  18. } else if (scope == Assignment.LOCAL) {
  19. env.setLocalVariable(varName, value);
  20. } else {
  21. throw new BugException("Unhandled scope");
  22. }
  23. return null;
  24. }

代码示例来源:origin: org.freemarker/freemarker

  1. hasNext = iterModel.hasNext();
  2. try {
  3. env.visit(childBuffer);
  4. } catch (BreakOrContinueException br) {
  5. if (br == BreakOrContinueException.BREAK_INSTANCE) {
  6. env.visit(childBuffer);
  7. hasNext = (size > index + 1);
  8. try {
  9. env.visit(childBuffer);
  10. } catch (BreakOrContinueException br) {
  11. if (br == BreakOrContinueException.BREAK_INSTANCE) {
  12. env.visit(childBuffer);
  13. env.visit(childBuffer);
  14. } catch (BreakOrContinueException br) {

代码示例来源:origin: org.freemarker/freemarker

  1. /**
  2. * Processes a Template in the context of this <code>Environment</code>, including its output in the
  3. * <code>Environment</code>'s Writer.
  4. *
  5. * @param includedTemplate
  6. * the template to process. Note that it does <em>not</em> need to be a template returned by
  7. * {@link #getTemplateForInclusion(String name, String encoding, boolean parse)}.
  8. */
  9. public void include(Template includedTemplate)
  10. throws TemplateException, IOException {
  11. final Template prevTemplate;
  12. final boolean parentReplacementOn = isBeforeIcI2322();
  13. prevTemplate = getTemplate();
  14. if (parentReplacementOn) {
  15. setParent(includedTemplate);
  16. } else {
  17. legacyParent = includedTemplate;
  18. }
  19. importMacros(includedTemplate);
  20. try {
  21. visit(includedTemplate.getRootTreeNode());
  22. } finally {
  23. if (parentReplacementOn) {
  24. setParent(prevTemplate);
  25. } else {
  26. legacyParent = prevTemplate;
  27. }
  28. }
  29. }

代码示例来源:origin: org.freemarker/freemarker

  1. visit(macro.getChildBuffer());
  2. } catch (ReturnInstruction.Return re) {

代码示例来源:origin: org.freemarker/freemarker

  1. hasNext = kvpIter.hasNext();
  2. try {
  3. env.visit(childBuffer);
  4. } catch (BreakOrContinueException br) {
  5. if (br == BreakOrContinueException.BREAK_INSTANCE) {
  6. env.visit(childBuffer);
  7. hasNext = keysIter.hasNext();
  8. try {
  9. env.visit(childBuffer);
  10. } catch (BreakOrContinueException br) {
  11. if (br == BreakOrContinueException.BREAK_INSTANCE) {
  12. } while (hasNext);
  13. } else {
  14. env.visit(childBuffer);

代码示例来源:origin: org.freemarker/freemarker

  1. if (tc == null || tc.onStart() != TransformControl.SKIP_BODY) {
  2. do {
  3. visit(elementBuffer);
  4. } while (tc != null && tc.afterBody() == TransformControl.REPEAT_EVALUATION);

代码示例来源:origin: org.freemarker/freemarker

  1. visit(nestedContentBuffer);
  2. } finally {
  3. if (invokingMacroContext.nestedContentParameterNames != null) {

代码示例来源:origin: org.freemarker/com.springsource.freemarker

  1. void accept(Environment env)
  2. throws TemplateException, IOException
  3. {
  4. if (nestedBlock != null) {
  5. env.visit(nestedBlock);
  6. }
  7. }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.freemarker

  1. String renderElementToString(TemplateElement te) throws IOException, TemplateException {
  2. Writer prevOut = out;
  3. try {
  4. StringWriter sw = new StringWriter();
  5. this.out = sw;
  6. visit(te);
  7. return sw.toString();
  8. } finally {
  9. this.out = prevOut;
  10. }
  11. }

代码示例来源:origin: org.freemarker/com.springsource.freemarker

  1. void accept(Environment env) throws TemplateException, IOException {
  2. for (int i = 0; i<nestedElements.size(); i++) {
  3. ConditionalBlock cblock = (ConditionalBlock) nestedElements.get(i);
  4. Expression condition = cblock.condition;
  5. if (condition == null || condition.isTrue(env)) {
  6. if (cblock.nestedBlock != null) {
  7. env.visit(cblock.nestedBlock);
  8. }
  9. return;
  10. }
  11. }
  12. }

相关文章

Environment类方法