|
|
|
@ -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;
|
|
|
|
|