Mercurial > hg > fulltextIndexer
diff src/de/mpiwg/dwinter/lucencetools/analyzer/XMLFilteredReader.java @ 0:dc7622afcfea default tip
initial
author | dwinter |
---|---|
date | Wed, 03 Nov 2010 12:33:16 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/de/mpiwg/dwinter/lucencetools/analyzer/XMLFilteredReader.java Wed Nov 03 12:33:16 2010 +0100 @@ -0,0 +1,72 @@ +/* */ package de.mpiwg.dwinter.lucencetools.analyzer; +/* */ +/* */ +/* */ import java.io.IOException; +/* */ import java.io.InputStream; +/* */ import java.io.InputStreamReader; +/* */ import java.io.UnsupportedEncodingException; +/* */ +/* */ public class XMLFilteredReader extends InputStreamReader +/* */ { +/* */ public XMLFilteredReader(InputStream in, String charsetName) +/* */ throws UnsupportedEncodingException +/* */ { +/* 12 */ super(in, charsetName); +/* */ } +/* */ +/* */ public int read() throws IOException +/* */ { +/* 17 */ int c = super.read(); +/* 18 */ if (c == -1) { +/* 19 */ return c; +/* */ } +/* 21 */ boolean isXML = false; +/* */ +/* 23 */ if (c == 60) +/* 24 */ isXML = true; +/* 25 */ while (isXML) { +/* 26 */ c = super.read(); +/* 27 */ if (c == -1) +/* 28 */ return c; +/* 29 */ if (c == 62) { +/* 30 */ isXML = false; +/* */ } +/* */ } +/* 33 */ return super.read(); +/* */ } +/* */ +/* */ public int read(char[] cbuf, int offset, int length) throws IOException +/* */ { +/* 38 */ char[] cbuf2 = new char[cbuf.length]; +/* 39 */ int i = 0; +/* 40 */ int retLen = super.read(cbuf2, offset, length); +/* 41 */ if (retLen <= 0) { +/* 42 */ cbuf = (char[])cbuf2.clone(); +/* 43 */ return retLen; +/* */ } +/* 45 */ boolean isXML = false; +/* 46 */ for (char c : cbuf2) { +/* 47 */ if (c == '<') { +/* 48 */ isXML = true; +/* */ } +/* 50 */ //if (c == '\0/7') { +/* */ // break; +/* */ //} +/* 53 */ if (!isXML) { +/* 54 */ cbuf[i] = c; +/* 55 */ ++i; +/* */ } +/* 57 */ if (c == '>') { +/* 58 */ isXML = false; +/* */ } +/* */ +/* */ } +/* */ +/* 63 */ return i; +/* */ } +/* */ } + +/* Location: /private/tmp/fulltextIndexer.jar + * Qualified Name: de.mpiwg.dwinter.lucencetools.analyzer.XMLFilteredReader + * JD-Core Version: 0.5.4 + */ \ No newline at end of file