01: package org.contineo.core.text.parser;
02:
03: import java.io.File;
04: import java.io.FileReader;
05: import java.io.Reader;
06:
07: import javax.swing.text.html.HTMLEditorKit;
08: import javax.swing.text.html.parser.ParserDelegator;
09:
10: import org.apache.commons.logging.Log;
11: import org.apache.commons.logging.LogFactory;
12:
13: /**
14: *
15: * @author Michael Scholz
16: */
17: public class HTMLParser implements Parser {
18: /**
19: * @uml.property name="content"
20: */
21: private final StringBuffer content = new StringBuffer();
22:
23: protected static Log logger = LogFactory.getLog(HTMLParser.class);
24:
25: public HTMLParser(File file) {
26: init(file);
27: }
28:
29: protected void init(File file) {
30: try {
31: HTMLEditorKit.ParserCallback callback = new HTMLEditorKit.ParserCallback() {
32: public void handleText(char[] data, int pos) {
33: content.append(data);
34: } // end method handleText
35: };
36:
37: Reader reader = new FileReader(file);
38: new ParserDelegator().parse(reader, callback, true);
39: } catch (Exception ex) {
40: logger.error(ex.getMessage(), ex);
41: }
42: }
43:
44: /**
45: *
46: * @uml.property name="content"
47: */
48: public StringBuffer getContent() {
49: return content;
50: }
51:
52: public String getVersion() {
53: return "";
54: }
55:
56: /*
57: * (non-Javadoc)
58: *
59: * @see org.contineo.core.text.parser.Parser#getAuthor()
60: */
61: public String getAuthor() {
62: return "";
63: }
64:
65: /*
66: * (non-Javadoc)
67: *
68: * @see org.contineo.core.text.parser.Parser#getSourceDate()
69: */
70: public String getSourceDate() {
71: return "";
72: }
73:
74: /*
75: * (non-Javadoc)
76: *
77: * @see org.contineo.core.text.parser.Parser#getKeywords()
78: */
79: public String getKeywords() {
80: return "";
81: }
82:
83: /*
84: * (non-Javadoc)
85: *
86: * @see org.contineo.core.text.parser.Parser#getTitle()
87: */
88: public String getTitle() {
89: return "";
90: }
91:
92: }
|