1 5 package org.contineo.core.text.parser; 6 7 import java.io.BufferedInputStream ; 8 import java.io.File ; 9 import java.io.FileInputStream ; 10 import java.io.InputStream ; 11 import org.apache.log4j.Level; 12 import org.apache.log4j.Logger; 13 import org.contineo.core.JarBean; 14 import org.contineo.core.LoggingManager; 15 import org.contineo.core.config.SettingConfigurator; 16 17 21 public class KOParser implements Parser { 22 23 26 private StringBuffer content = new StringBuffer (); 27 28 32 private Logger logger; 33 34 35 public KOParser(File file) { 36 logger = LoggingManager.getLogger(this.getClass()); 37 init(file); 38 } 39 40 protected void init(File file) { 41 try { 42 SettingConfigurator conf = new SettingConfigurator(); 43 JarBean.unjar(file.getAbsolutePath(),conf.getValue("userdir") + "unjar/",conf.getValue("kocontent")); 44 File xmlfile = new File (conf.getValue("userdir") + "unjar/" + conf.getValue("kocontent")); 45 InputStream in = new FileInputStream (xmlfile); 46 BufferedInputStream reader = new BufferedInputStream (in); 47 int ichar = 0; 48 boolean istag = false; 49 boolean isspec = false; 50 while ((ichar = reader.read()) != -1) { 51 if (ichar == 60) { 52 content.append((char)32); 53 istag = true; 54 } 55 if (!istag) { 56 if (ichar == 195) 57 isspec = true; 58 else { 59 if (isspec) { 60 switch (ichar) { 61 case 132: content.append('Ä');break; 62 case 164: content.append('ä');break; 63 case 150: content.append('Ö');break; 64 case 182: content.append('ö');break; 65 case 156: content.append('Ü');break; 66 case 188: content.append('ü');break; 67 case 159: content.append('ß');break; 68 } 69 isspec = false; 70 } 71 else 72 content.append((char)ichar); 73 } 74 } 75 if (ichar == 62) 76 istag = false; 77 } 78 in.close(); 79 reader.close(); 80 } 81 catch (Exception ex) { 82 if (logger.isEnabledFor(Level.ERROR)) 83 logger.error(ex.getMessage()); 84 } 85 } 86 87 90 public String getVersion() { 91 return ""; 92 } 93 94 98 101 public StringBuffer getContent() { 102 return content; 103 } 104 105 108 public String getAuthor() { 109 return ""; 110 } 111 112 115 public String getSourceDate() { 116 return ""; 117 } 118 119 122 public String getKeywords() { 123 return ""; 124 } 125 126 129 public String getTitle() { 130 return ""; 131 } 132 133 } 134 | Popular Tags |