01: package de.java2html.converter.demo;
02:
03: import java.io.IOException;
04: import java.io.StringReader;
05: import java.io.StringWriter;
06:
07: import de.java2html.converter.JavaSource2HTMLConverter;
08: import de.java2html.javasource.JavaSource;
09: import de.java2html.javasource.JavaSourceParser;
10: import de.java2html.javasource.JavaSourceType;
11: import de.java2html.options.JavaSourceConversionOptions;
12: import de.java2html.options.JavaSourceStyleEntry;
13: import de.java2html.util.RGB;
14:
15: public class Java2HtmlConversionDemo {
16:
17: public static void main(String[] args) {
18: StringReader stringReader = new StringReader(
19: "/** Simple Java2Html Demo */\r\n"
20: + "public static int doThis(String text){ return text.length() + 2; }");
21: JavaSource source = null;
22: try {
23: source = new JavaSourceParser().parse(stringReader);
24: } catch (IOException e) {
25: e.printStackTrace();
26: System.exit(1);
27: }
28: JavaSource2HTMLConverter converter = new JavaSource2HTMLConverter();
29:
30: JavaSourceConversionOptions options = JavaSourceConversionOptions
31: .getDefault();
32: options.getStyleTable().put(JavaSourceType.KEYWORD,
33: new JavaSourceStyleEntry(RGB.ORANGE, true, false));
34:
35: StringWriter writer = new StringWriter();
36: try {
37: converter.convert(source, options, writer);
38: } catch (IOException e) {
39: //can not happen
40: }
41: System.out.println(writer.toString());
42: }
43: }
|