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.JarBean; 16 import org.contineo.core.LoggingManager; 17 import org.contineo.core.config.SettingConfigurator; 18 22 public class SXParser implements Parser { 23 24 27 private StringBuffer content = new StringBuffer (); 28 29 33 private Logger logger; 34 35 36 37 public SXParser(File file) { 38 logger = LoggingManager.getLogger(this.getClass()); 39 init(file); 40 } 41 42 protected void init(File file) { 43 try { 44 SettingConfigurator conf = new SettingConfigurator(); 45 JarBean.unjar(file.getAbsolutePath(),conf.getValue("userdir") + "unjar/",conf.getValue("sxcontent")); 46 File xmlfile = new File (conf.getValue("userdir") + "unjar/" + conf.getValue("sxcontent")); 47 InputStream in = new FileInputStream (xmlfile); 48 BufferedInputStream reader = new BufferedInputStream (in); 49 int ichar = 0; 50 boolean istag = false; 51 boolean isspec = false; 52 while ((ichar = reader.read()) != -1) { 53 if (ichar == 60) { 54 content.append((char)32); 55 istag = true; 56 } 57 if (!istag) { 58 if (ichar == 195) 59 isspec = true; 60 else { 61 if (isspec) { 62 switch (ichar) { 63 case 132: content.append('Ä');break; 64 case 164: content.append('ä');break; 65 case 150: content.append('Ö');break; 66 case 182: content.append('ö');break; 67 case 156: content.append('Ü');break; 68 case 188: content.append('ü');break; 69 case 159: content.append('ß');break; 70 } 71 isspec = false; 72 } 73 else 74 content.append((char)ichar); 75 } 76 } 77 if (ichar == 62) 78 istag = false; 79 } 80 in.close(); 81 reader.close(); 82 } 83 catch (Exception ex) { 84 if (logger.isEnabledFor(Level.ERROR)) 85 logger.error(ex.getMessage()); 86 } 87 } 88 89 93 public StringBuffer getContent() { 94 return content; 95 } 96 97 98 public String getVersion() { 99 return ""; 100 } 101 102 105 public String getAuthor() { 106 return ""; 107 } 108 109 112 public String getSourceDate() { 113 return ""; 114 } 115 116 119 public String getKeywords() { 120 return ""; 121 } 122 123 126 public String getTitle() { 127 return ""; 128 } 129 130 } 131 | Popular Tags |