01: package vqwiki.lex;
02:
03: import java.io.IOException;
04: import java.io.Reader;
05: import java.util.List;
06: import org.apache.log4j.Logger;
07:
08: /**
09: * Abstract class to be used when implementing new lexers. New lexers
10: * should extend this class and override any methods that need to be
11: * implemented differently.
12: */
13: public abstract class AbstractParser {
14:
15: private static final Logger logger = Logger
16: .getLogger(AbstractParser.class);
17: private vqwiki.lex.ParserInfo parserInfo;
18:
19: /**
20: * Sets the basics for this parser.
21: *
22: * @param parserInfo General information about this parser.
23: */
24: protected AbstractParser(ParserInfo parserInfo) {
25: this .parserInfo = parserInfo;
26: }
27:
28: /**
29: * For getting general information about this parser.
30: *
31: * @return General information about this parser.
32: */
33: public ParserInfo getParserInfo() {
34: return parserInfo;
35: }
36:
37: /**
38: * Returns a HTML representation of the given wiki raw text for online representation.
39: *
40: * @param raw The raw Wiki syntax to be converted into HTML.
41: * @param virtualwiki A virtual wiki prefix (if any).
42: * @return HTML representation of the text for online.
43: */
44: public abstract String parseHTML(String raw, String virtualwiki)
45: throws IOException;
46:
47: /**
48: * Returns a HTML representation of the given wiki raw text for the HTML-exporter.
49: * This has mainly effect to the links. All links will be on HTML-files and not
50: * on a Wiki-Servlet. The HTML-files will all be stored flat into the same directory.
51: *
52: * @param raw The raw Wiki syntax to be converted into HTML suitable for export.
53: * @param virtualwiki A virtual wiki prefix (if any).
54: * @return HTML representation of the text for HTML export.
55: */
56: public abstract String parseExportHTML(String raw,
57: String virtualwiki) throws IOException;
58:
59: /**
60: * Get a list of Topics from a raw text (used for backlinks, todo-Topics)
61: *
62: * @param raw The raw Wiki syntax to be converted into HTML.
63: * @param virtualwiki A virtual wiki prefix (if any).
64: * @return a List of all Topic names found in the text.
65: */
66: public abstract List getTopics(String rawtext, String virtualwiki)
67: throws Exception;
68: }
|