1 6 7 package org.contineo.core.text.parser; 8 9 import java.io.File ; 10 import java.io.FileInputStream ; 11 import org.apache.log4j.Level; 12 import org.apache.log4j.Logger; 13 import org.contineo.core.LoggingManager; 14 import org.apache.poi.hwpf.HWPFDocument; 15 16 26 public class DOCParser implements Parser { 27 28 32 private StringBuffer content = new StringBuffer (); 33 34 38 private Logger logger; 39 40 43 public DOCParser(File file) { 44 logger = LoggingManager.getLogger(this.getClass()); 45 init(file); 46 } 47 48 53 protected void init(File file) { 54 try { 55 FileInputStream in = new FileInputStream (file); 58 HWPFDocument doc = new HWPFDocument(in); 59 60 String docText = doc.getRange().text(); 62 content.append(docText); 63 in.close(); 64 } 65 catch (Exception ex) { 66 if (logger.isEnabledFor(Level.ERROR)) 67 logger.error(ex.getMessage()); 68 } 69 } 70 71 75 public StringBuffer getContent() { 76 return content; 77 } 78 79 80 public String getVersion() { 81 return ""; 82 } 83 84 87 public String getAuthor() { 88 return ""; 89 } 90 91 94 public String getSourceDate() { 95 return ""; 96 } 97 98 101 public String getKeywords() { 102 return ""; 103 } 104 105 108 public String getTitle() { 109 return ""; 110 } 111 } 112 | Popular Tags |