MCPcopy Create free account
hub / github.com/apache/freemarker / accept

Method accept

src/main/java/freemarker/core/VisitNode.java:71–95  ·  view source on GitHub ↗
(Environment env)

Source from the content-addressed store, hash-verified

69 }
70
71 void accept(Environment env) throws IOException, TemplateException {
72 TemplateModel node = targetNode.getAsTemplateModel(env);
73 assertNonNull(node, targetNode, env);
74 if (!(node instanceof TemplateNodeModel)) {
75 throw new TemplateException("Expecting an XML node here", env);
76 }
77 TemplateModel nss = namespaces == null ? null : namespaces.getAsTemplateModel(env);
78 if (namespaces instanceof StringLiteral) {
79 nss = env.importLib(((TemplateScalarModel) nss).getAsString(), null);
80 }
81 else if (namespaces instanceof ListLiteral) {
82 nss = ((ListLiteral) namespaces).evaluateStringsToNamespaces(env);
83 }
84 if (nss != null) {
85 if (nss instanceof Environment.Namespace) {
86 SimpleSequence ss = new SimpleSequence(1);
87 ss.add(nss);
88 nss = ss;
89 }
90 else if (!(nss instanceof TemplateSequenceModel)) {
91 throw new TemplateException("Expecting a sequence of namespaces after 'using'", env);
92 }
93 }
94 env.visit((TemplateNodeModel) node, (TemplateSequenceModel) nss);
95 }
96
97 public String getCanonicalForm() {
98 if (namespaces == null) {

Callers

nothing calls this directly

Calls 7

addMethod · 0.95
getAsTemplateModelMethod · 0.80
assertNonNullMethod · 0.80
importLibMethod · 0.80
visitMethod · 0.80
getAsStringMethod · 0.65

Tested by

no test coverage detected