| 1 | |
package org.webslinger.ext.template.freemarker; |
| 2 | |
|
| 3 | |
import java.io.IOException; |
| 4 | |
import java.io.StringWriter; |
| 5 | |
import java.util.Map; |
| 6 | |
import java.util.regex.Pattern; |
| 7 | |
|
| 8 | |
import org.webslinger.commons.vfs.FileResolver; |
| 9 | |
import org.webslinger.ext.wiki.WikiMacroOutput; |
| 10 | |
import org.webslinger.ext.wiki.parser.WikiNewline; |
| 11 | |
import org.webslinger.ext.wiki.parser.WikiVisitor; |
| 12 | |
|
| 13 | |
public class WikiFreemarkerMacroHandler extends WikiMacroOutput { |
| 14 | 1 | public static final Factory FACTORY = new Factory() { |
| 15 | |
public WikiVisitor newVisitor(String name, StringWriter writer, FileResolver resolver) { |
| 16 | 0 | return new WikiFreemarkerMacroHandler(name, writer); |
| 17 | |
} |
| 18 | |
}; |
| 19 | |
private WikiFreemarkerHelper helper; |
| 20 | |
|
| 21 | 0 | protected WikiFreemarkerMacroHandler(String name, StringWriter writer) { |
| 22 | 0 | helper = new WikiFreemarkerHelper(writer); |
| 23 | 0 | } |
| 24 | |
|
| 25 | |
protected void acceptMacro(String name, Object[] args) { |
| 26 | 0 | helper.acceptMacro(name, args); |
| 27 | 0 | } |
| 28 | |
|
| 29 | |
protected void endMacro(String name, Object[] args) { |
| 30 | 0 | helper.endMacro(name, args); |
| 31 | 0 | } |
| 32 | |
|
| 33 | |
protected void startMacro(String name, Object[] args) { |
| 34 | 0 | helper.startMacro(name, args); |
| 35 | 0 | } |
| 36 | |
|
| 37 | |
public Object visit(WikiNewline node, Object data) { |
| 38 | 0 | helper.acceptNewline(node.getCount()); |
| 39 | 0 | return super.visit(node, data); |
| 40 | |
} |
| 41 | |
|
| 42 | |
public void acceptText(String text) { |
| 43 | 0 | helper.acceptText(text); |
| 44 | 0 | } |
| 45 | |
|
| 46 | |
protected void blockNewline() { |
| 47 | 0 | helper.acceptNewline(1); |
| 48 | 0 | } |
| 49 | |
|
| 50 | |
protected void acceptXml(String name, Map attributes) { |
| 51 | 0 | throw new UnsupportedOperationException(); |
| 52 | |
} |
| 53 | |
|
| 54 | |
protected void startXml(String name, Map attributes) { |
| 55 | 0 | throw new UnsupportedOperationException(); |
| 56 | |
} |
| 57 | |
|
| 58 | |
protected void endXml(String name, Map attributes) { |
| 59 | 0 | throw new UnsupportedOperationException(); |
| 60 | |
} |
| 61 | |
|
| 62 | |
public void close() throws IOException { |
| 63 | 0 | helper.close(); |
| 64 | 0 | } |
| 65 | |
|
| 66 | |
public void flush() throws IOException { |
| 67 | 0 | } |
| 68 | |
} |