- correct length computation for BStringObject (bugfix suggested by

apfelmaennchen)
- using ASCII for string conversion for Strings generated from Integer
pull/1/head
orbiter 12 years ago
parent 6d03433cda
commit 2094df2e4e

@ -113,11 +113,11 @@ public class RobotsTxtEntry {
this.mem = new LinkedHashMap<String, byte[]>(10);
this.mem.put(HOST_NAME, UTF8.getBytes(this.hostName));
if (loadedDate != null) this.mem.put(LOADED_DATE, UTF8.getBytes(Long.toString(loadedDate.getTime())));
if (modDate != null) this.mem.put(MOD_DATE, UTF8.getBytes(Long.toString(modDate.getTime())));
if (loadedDate != null) this.mem.put(LOADED_DATE, ASCII.getBytes(Long.toString(loadedDate.getTime())));
if (modDate != null) this.mem.put(MOD_DATE, ASCII.getBytes(Long.toString(modDate.getTime())));
if (eTag != null) this.mem.put(ETAG, UTF8.getBytes(eTag));
if (sitemap != null) this.mem.put(SITEMAP, UTF8.getBytes(sitemap));
if (crawlDelayMillis > 0) this.mem.put(CRAWL_DELAY_MILLIS, UTF8.getBytes(Long.toString(crawlDelayMillis)));
if (crawlDelayMillis > 0) this.mem.put(CRAWL_DELAY_MILLIS, ASCII.getBytes(Long.toString(crawlDelayMillis)));
if (agentName != null) this.mem.put(AGENT_NAME, UTF8.getBytes(agentName));
if (allowPathList != null && !allowPathList.isEmpty()) {
@ -187,7 +187,7 @@ public class RobotsTxtEntry {
protected void setLoadedDate(final Date newLoadedDate) {
if (newLoadedDate != null) {
this.mem.put(LOADED_DATE, UTF8.getBytes(Long.toString(newLoadedDate.getTime())));
this.mem.put(LOADED_DATE, ASCII.getBytes(Long.toString(newLoadedDate.getTime())));
}
}

@ -37,6 +37,7 @@ import java.util.Map;
import java.util.TreeMap;
import net.yacy.cora.date.GenericFormatter;
import net.yacy.cora.document.ASCII;
import net.yacy.cora.document.UTF8;
import net.yacy.cora.protocol.http.HTTPClient;
import net.yacy.cora.storage.HandleSet;
@ -189,7 +190,7 @@ public class WorkTables extends Tables {
// insert APICALL attributes
data.put(TABLE_API_COL_APICALL_COUNT, UTF8.getBytes("1"));
data.put(TABLE_API_COL_APICALL_SCHEDULE_TIME, UTF8.getBytes(Integer.toString(time)));
data.put(TABLE_API_COL_APICALL_SCHEDULE_TIME, ASCII.getBytes(Integer.toString(time)));
data.put(TABLE_API_COL_APICALL_SCHEDULE_UNIT, UTF8.getBytes(unit));
calculateAPIScheduler(data, false); // set next execution time
pk = super.insert(TABLE_API_NAME, data);

@ -42,6 +42,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Pattern;
import net.yacy.cora.date.GenericFormatter;
import net.yacy.cora.document.ASCII;
import net.yacy.cora.document.UTF8;
import net.yacy.cora.util.SpaceExceededException;
import net.yacy.kelondro.logging.Log;
@ -434,11 +435,11 @@ public class Tables implements Iterable<String> {
}
public void put(final String colname, final int value) {
super.put(colname, UTF8.getBytes(Integer.toString(value)));
super.put(colname, ASCII.getBytes(Integer.toString(value)));
}
public void put(final String colname, final long value) {
super.put(colname, UTF8.getBytes(Long.toString(value)));
super.put(colname, ASCII.getBytes(Long.toString(value)));
}
public void put(final String colname, final Date value) {

@ -36,6 +36,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import net.yacy.cora.document.ASCII;
import net.yacy.cora.document.UTF8;
public class BDecoder {
@ -116,19 +117,20 @@ public class BDecoder {
return UTF8.String(this.b);
}
public void toStream(OutputStream os) throws IOException {
os.write(UTF8.getBytes(Integer.toString(this.b.length)));
os.write(ASCII.getBytes(Integer.toString(this.b.length)));
os.write(_p);
os.write(this.b);
}
public static void toStream(OutputStream os, byte[] b) throws IOException {
os.write(UTF8.getBytes(Integer.toString(b.length)));
os.write(ASCII.getBytes(Integer.toString(b.length)));
os.write(_p);
os.write(b);
}
public static void toStream(OutputStream os, String s) throws IOException {
os.write(UTF8.getBytes(Integer.toString(s.length())));
final byte[] b = UTF8.getBytes(s);
os.write(ASCII.getBytes(Integer.toString(b.length)));
os.write(_p);
os.write(UTF8.getBytes(s));
os.write(b);
}
}
@ -218,7 +220,7 @@ public class BDecoder {
}
public void toStream(OutputStream os) throws IOException {
os.write(_i);
os.write(UTF8.getBytes(Long.toString(this.i)));
os.write(ASCII.getBytes(Long.toString(this.i)));
os.write(_e);
}
}
@ -260,7 +262,7 @@ public class BDecoder {
int end = pos;
end++;
while (b[end] != ':') ++end;
final int len = Integer.parseInt(UTF8.String(b, pos, end - pos));
final int len = Integer.parseInt(ASCII.String(b, pos, end - pos));
final byte[] s = new byte[len];
System.arraycopy(b, end + 1, s, 0, len);
pos = end + len + 1;

Loading…
Cancel
Save