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