mirror of
https://github.com/yacy/yacy_search_server.git
synced 2024-09-22 00:00:59 +02:00
01e0669264
and replaced old fist hash computation by new method that tries to find a gap in the current dht to do this, it is necessary that the network bootstraping is done before the own hash is computed this made further redesigns in peer initialization order necessary git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4117 6c8d7289-2bf4-0310-a012-ef5d649a1542
85 lines
2.9 KiB
Java
85 lines
2.9 KiB
Java
package de.anomic.data.wiki;
|
|
|
|
import java.io.BufferedReader;
|
|
import java.io.ByteArrayInputStream;
|
|
import java.io.IOException;
|
|
import java.io.InputStreamReader;
|
|
import java.io.StringReader;
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
import de.anomic.plasma.plasmaSwitchboard;
|
|
import de.anomic.yacy.yacyCore;
|
|
|
|
public abstract class abstractWikiParser implements wikiParser {
|
|
|
|
private plasmaSwitchboard sb;
|
|
|
|
public abstractWikiParser(plasmaSwitchboard sb) {
|
|
this.sb = sb;
|
|
}
|
|
|
|
protected abstract String transform(BufferedReader reader, int length, String publicAddress, plasmaSwitchboard sb) throws IOException;
|
|
|
|
public String transform(String content) {
|
|
return transform(content, this.sb);
|
|
}
|
|
|
|
public String transform(String content, plasmaSwitchboard sb) {
|
|
try {
|
|
return transform(
|
|
new BufferedReader(new StringReader(content)),
|
|
content.length(),
|
|
yacyCore.seedDB.mySeed().getPublicAddress(),
|
|
sb);
|
|
} catch (IOException e) {
|
|
return "internal error: " + e.getMessage();
|
|
}
|
|
}
|
|
|
|
public String transform(String content, String publicAddress) {
|
|
try {
|
|
return transform(
|
|
new BufferedReader(new StringReader(content)),
|
|
content.length(),
|
|
publicAddress,
|
|
null);
|
|
} catch (IOException e) {
|
|
return "internal error: " + e.getMessage();
|
|
}
|
|
}
|
|
|
|
public String transform(byte[] content) throws UnsupportedEncodingException {
|
|
return transform(content, "UTF-8", this.sb);
|
|
}
|
|
|
|
public String transform(byte[] content, String encoding) throws UnsupportedEncodingException {
|
|
return transform(content, encoding, this.sb);
|
|
}
|
|
|
|
public String transform(byte[] content, String encoding, String publicAddress) throws UnsupportedEncodingException {
|
|
ByteArrayInputStream bais = new ByteArrayInputStream(content);
|
|
try {
|
|
return transform(
|
|
new BufferedReader(new InputStreamReader(bais, encoding)),
|
|
content.length,
|
|
publicAddress,
|
|
null);
|
|
} catch (IOException e) {
|
|
return "internal error: " + e.getMessage();
|
|
}
|
|
}
|
|
|
|
public String transform(byte[] content, String encoding, plasmaSwitchboard switchboard) throws UnsupportedEncodingException {
|
|
ByteArrayInputStream bais = new ByteArrayInputStream(content);
|
|
try {
|
|
return transform(
|
|
new BufferedReader(new InputStreamReader(bais, encoding)),
|
|
content.length,
|
|
yacyCore.seedDB.mySeed().getPublicAddress(),
|
|
switchboard);
|
|
} catch (IOException e) {
|
|
return "internal error: " + e.getMessage();
|
|
}
|
|
}
|
|
}
|