home *** CD-ROM | disk | FTP | other *** search
- import java.io.FileInputStream;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.OutputStream;
- import java.util.Hashtable;
- import java.util.Properties;
- import java.util.zip.Deflater;
- import java.util.zip.DeflaterOutputStream;
- import java.util.zip.InflaterInputStream;
-
- class SearchEngineGenerator {
- Properties tab = new Properties();
- Hashtable docs = new Hashtable();
- Properties exclude = new Properties();
- int nextDoc = 0;
- static final String encoding = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
- static final int enclen = 62;
-
- SearchEngineGenerator() {
- try {
- FileInputStream var1 = new FileInputStream("exclude.dat");
- this.exclude.load(var1);
- ((InputStream)var1).close();
- } catch (IOException var2) {
- System.err.println("Ausschlussliste exclude.dat konnte nicht geladen werden");
- }
- }
-
- void clear() {
- this.tab.clear();
- this.docs.clear();
- this.nextDoc = 0;
- }
-
- void save(OutputStream var1) throws IOException {
- this.tab.save(var1, "SearchEngine");
- var1.close();
- }
-
- void saveZIP(OutputStream var1) throws IOException {
- this.save(new DeflaterOutputStream(var1, new Deflater(9)));
- }
-
- void load(InputStream var1) throws IOException {
- this.clear();
- this.tab.load(var1);
- var1.close();
-
- while(true) {
- String var2 = this.tab.getProperty("." + IntToString(this.nextDoc));
- if (var2 == null) {
- return;
- }
-
- SearchEngineResult var3 = new SearchEngineResult(var2);
- this.addDocument(var3.document, var3.caption);
- }
- }
-
- void loadZIP(InputStream var1) throws IOException {
- this.load(new InflaterInputStream(var1));
- }
-
- public int getSize() {
- return this.tab.size();
- }
-
- public int getDocs() {
- return this.docs.size();
- }
-
- public String getStatus() {
- return this.getDocs() + " Dokumente/" + this.getSize() + " Woerter";
- }
-
- public int addDocument(String var1, String var2) {
- Integer var3 = (Integer)this.docs.get(var1);
- if (var3 == null) {
- var3 = new Integer(this.nextDoc++);
- }
-
- this.docs.put(var1, var3);
- this.tab.put("." + IntToString(var3), var1 + "," + HTMLcvt.toHTML(var2));
- return var3;
- }
-
- public static char IntToChar(int var0) {
- return "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".charAt(var0);
- }
-
- public static int CharToInt(char var0) {
- return "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".indexOf(var0);
- }
-
- public static int StringToInt(String var0, int var1) {
- return CharToInt(var0.charAt(var1)) * 62 + CharToInt(var0.charAt(var1 + 1));
- }
-
- public static String IntToString(int var0) {
- return "" + IntToChar(var0 / 62) + IntToChar(var0 % 62);
- }
-
- public void addWord(int var1, String var2) {
- if (this.exclude == null || this.exclude.getProperty(var2) == null) {
- if (var2.length() >= 2) {
- String var3 = this.tab.getProperty(var2);
- if (var3 == null) {
- this.tab.put(var2, IntToString(var1));
- } else {
- boolean var4 = false;
-
- for(int var5 = 0; var5 < var3.length(); var5 += 2) {
- if (var1 == StringToInt(var3, var5)) {
- var4 = true;
- }
- }
-
- if (!var4) {
- this.tab.put(var2, var3 + IntToString(var1));
- }
-
- }
- }
- }
- }
- }
-