01: package de.java2html.plugin;
02:
03: import java.io.IOException;
04: import java.io.StringWriter;
05: import java.net.URL;
06:
07: import de.java2html.Java2Html;
08: import de.java2html.JavaSourceConversionSettings;
09: import de.java2html.converter.IJavaSourceConverter;
10: import de.java2html.javasource.JavaSource;
11: import de.java2html.javasource.JavaSourceParser;
12:
13: /**
14: * Abstract superclass for any kind of Wiki plugin.
15: *
16: * @author Markus Gebhard
17: */
18: public abstract class AbstractJava2HtmlPlugin {
19:
20: public static String convert(String source,
21: JavaSourceConversionSettings settings) {
22: return Java2Html.convertToHtml(source, settings);
23: }
24:
25: public static JavaSourceConversionSettings getDefaultSettings() {
26: return JavaSourceConversionSettings.getDefault();
27: }
28:
29: public String convert(URL url, JavaSourceConversionSettings settings)
30: throws IOException {
31: JavaSource source = new JavaSourceParser(settings
32: .getConversionOptions()).parse(url);
33: IJavaSourceConverter converter = settings.createConverter();
34: StringWriter writer = new StringWriter();
35: try {
36: converter.convert(source, settings.getConversionOptions(),
37: writer);
38: } catch (IOException e) {
39: return null;
40: }
41: return writer.toString();
42: }
43: }
|