1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.peaseplate.internal.chunk;
21
22 import java.io.IOException;
23 import java.io.Writer;
24
25 import org.peaseplate.TemplateException;
26 import org.peaseplate.chunk.AbstractBlock;
27 import org.peaseplate.internal.BuildContext;
28 import org.peaseplate.locator.TemplateLocator;
29
30 public final class MacroBlock extends AbstractBlock {
31
32 private final String qualifiedName;
33 private final String[] parameters;
34
35 public MacroBlock(TemplateLocator locator, int line, int column, String qualifiedName, String[] parameters) {
36 super(locator, line, column);
37
38 this.qualifiedName = qualifiedName;
39 this.parameters = parameters;
40 }
41
42 public String getQualifiedName() {
43 return qualifiedName;
44 }
45
46 public String[] getParameters() {
47 return parameters;
48 }
49
50
51
52
53 public boolean isVisible() {
54 return false;
55 }
56
57
58
59
60 public boolean isEssential() {
61 return true;
62 }
63
64
65
66
67 public void render(BuildContext context, Writer writer) throws TemplateException, IOException {
68
69 }
70
71
72
73
74 @Override
75 public String toString() {
76 StringBuilder builder = new StringBuilder("MacroBlock(");
77
78 builder.append(getLine()).append(":").append(getColumn());
79 builder.append(") [").append(getQualifiedName());
80
81 if (parameters != null) {
82 builder.append("(");
83
84 for (int i=0; i<parameters.length; i+=1)
85 builder.append((i > 0) ? ", " : "").append(parameters[i]);
86
87 builder.append(")");
88 }
89
90 builder.append("] ");
91 builder.append(super.toString());
92
93 return builder.toString();
94 }
95
96 }