1 6 7 package org.contineo.core.text.parser; 8 9 import java.io.BufferedInputStream ; 10 import java.io.File ; 11 import java.io.FileInputStream ; 12 import java.io.InputStream ; 13 import org.apache.log4j.Level; 14 import org.apache.log4j.Logger; 15 import org.contineo.core.LoggingManager; 16 20 public class XMLParser implements Parser { 21 22 25 private StringBuffer content = new StringBuffer (); 26 27 31 private Logger logger; 32 33 34 35 public XMLParser(File file) { 36 logger = LoggingManager.getLogger(this.getClass()); 37 init(file); 38 } 39 40 protected void init(File file) { 41 try 42 { 43 InputStream in = new FileInputStream (file); 44 BufferedInputStream reader = new BufferedInputStream (in); 45 int ichar = 0; 46 boolean istag = false; 47 while ((ichar = reader.read()) != -1) { 48 if (ichar == 60) { 49 content.append((char)32); 50 istag = true; 51 } 52 if (!istag) 53 content.append((char)ichar); 54 if (ichar == 62) { 55 istag = false; 56 } 57 } 58 in.close(); 59 reader.close(); 60 } 61 catch (Exception ex) { 62 if (logger.isEnabledFor(Level.ERROR)) 63 logger.error(ex.getMessage()); 64 } 65 } 66 67 71 public StringBuffer getContent() { 72 return content; 73 } 74 75 76 public String getVersion() { 77 return ""; 78 } 79 80 83 public String getAuthor() { 84 return ""; 85 } 86 87 90 public String getSourceDate() { 91 return ""; 92 } 93 94 97 public String getKeywords() { 98 return ""; 99 } 100 101 104 public String getTitle() { 105 return ""; 106 } 107 108 } 109 | Popular Tags |