-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHTMLTextProcessor.java
More file actions
76 lines (60 loc) · 1.95 KB
/
Copy pathHTMLTextProcessor.java
File metadata and controls
76 lines (60 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import javax.swing.text.Document;
/*
* Created on 31-10-2003 by jesper
* This class should
*/
/**
* @author jesper
*/
public class HTMLTextProcessor {
private ArrayList codeIn = null;
private StringBuffer codeOut = null;
private File codeFile = null;
private final String[] keywords = new String[]{"abstract", "double", "int", "strictfp",
"boolean", "else", "interface", "super",
"break", "extends", "long", "switch",
"byte", "final", "native", "synchronized",
"case", "finally", "new", "this",
"catch", "float", "package", "throw",
"char", "for", "private", "throws",
"class", "goto", "protected", "transient",
"const", "if", "public", "try",
"continue", "implements", "return", "void",
"default", "import", "short", "volatile",
"do", "instanceof", "static", "while"
};
public HTMLTextProcessor (ArrayList buf){
codeIn = buf;
codeOut = new StringBuffer();
}
public HTMLTextProcessor (File buf){
codeFile = buf;
codeOut = new StringBuffer();
}
public StringBuffer getSyntaxHighlighting() {
ArrayList allWords = new ArrayList(Arrays.asList(keywords));
for (Iterator iter = codeIn.iterator(); iter.hasNext();) {
String element = (String) iter.next();
codeOut.append(
"<b><font color=\"blue\">" + " " + element + "</font></b>");
/*String[] wordsInLine = element.split(" ");
for (int i = 0; i < wordsInLine.length; i++) {
String singleWord = (String) wordsInLine[i];
System.out.println(singleWord + " ");
if (allWords.contains(singleWord)) {
codeOut.append(
"<b><font color=\"blue\">" + " " + singleWord + "</font></b>");
} else {
codeOut.append(" " + singleWord );
}
}*/
codeOut.append("<br>");
}
return codeOut;
}
}