Author: j16sdiz
Date: 2008-12-22 11:31:16 +0000 (Mon, 22 Dec 2008)
New Revision: 24732
Modified:
trunk/plugins/XMLLibrarian/XMLLibrarian.java
Log:
less global variable
Modified: trunk/plugins/XMLLibrarian/XMLLibrarian.java
===================================================================
--- trunk/plugins/XMLLibrarian/XMLLibrarian.java 2008-12-22 11:30:59 UTC
(rev 24731)
+++ trunk/plugins/XMLLibrarian/XMLLibrarian.java 2008-12-22 11:31:16 UTC
(rev 24732)
@@ -92,10 +92,6 @@
private String DEFAULT_FILE = "index.xml";
private PluginRespirator pr;
- private boolean processingWord ;
-
- private String prefix_match;
- private int prefix;
private boolean test;
/**
@@ -697,16 +693,18 @@
try {
SAXParser saxParser = factory.newSAXParser();
InputStream is = res.asBucket().getInputStream();
- saxParser.parse(is, new LibrarianHandler(str, new
Vector<URIWrapper>()));
+ LibrarianHandler lib = new LibrarianHandler(str, new
Vector<URIWrapper>());
+ saxParser.parse(is, lib);
is.close();
+
+ return lib.getPrefix_match();
} catch (Throwable err) {
err.printStackTrace();
} finally {
res.asBucket().free();
}
- return prefix_match;
-
+ return null;
}
/**
@@ -756,7 +754,7 @@
this.test = true;
}
- private class URIWrapper implements Comparable<URIWrapper> {
+ private static class URIWrapper implements Comparable<URIWrapper> {
public String URI;
public String descr;
@@ -776,8 +774,12 @@
* @author swati
*
*/
- public class LibrarianHandler extends DefaultHandler {
+ public static class LibrarianHandler extends DefaultHandler {
private String word;
+ private int prefix;
+ private boolean processingWord;
+ private String prefix_match;
+
// now we need to adapt this to read subindexing
private boolean found_match ;
/** file id -> uri */
@@ -817,9 +819,9 @@
//here we need to match and see if any
of the subindices match the required substring of the word.
for(int i=0;i<prefix;i++){
if((md5.substring(0,prefix-i)).equals(attrs.getValue("key"))){
-
prefix_match=md5.substring(0, prefix-i);
- Logger.normal(this,
"match found "+prefix_match);
- Logger.minor(this,
"word searched = "+word+" prefix matcheed = "+prefix_match);
+
setPrefix_match(md5.substring(0, prefix - i));
+ Logger.normal(this,
"match found " + getPrefix_match());
+ Logger.minor(this,
"word searched = " + word + " prefix matcheed = " + getPrefix_match());
break;
}
}
@@ -903,7 +905,14 @@
}
}
}
+ public void setPrefix_match(String prefix_match) {
+ this.prefix_match = prefix_match;
+ }
+ public String getPrefix_match() {
+ return prefix_match;
+ }
+
}
private static String convertToHex(byte[] data) {
_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs