1 17 18 19 20 package org.apache.lenya.lucene.parser; 21 22 import java.io.IOException ; 23 import java.io.Reader ; 24 import java.io.StringReader ; 25 26 import org.apache.log4j.Category; 27 28 32 public class PreParser { 33 34 private static Category log = Category.getInstance(PreParser.class); 35 36 37 public PreParser() { 38 log.debug("creating new object"); 39 } 40 41 44 public Reader parse(Reader reader) throws IOException { 45 StringBuffer buffer = new StringBuffer (); 46 boolean pending = false; 47 48 char[] chars = new char[1]; 49 50 while (reader.read(chars) != -1) { 51 int lastPosition = buffer.length() - 1; 52 53 if ((chars[0] == '>') && (buffer.charAt(lastPosition) == '/')) { 54 buffer.deleteCharAt(lastPosition); 55 } 56 57 buffer.append(chars[0]); 58 } 59 60 return new StringReader (buffer.toString()); 61 } 62 } 63 | Popular Tags |