more final modifier

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6407 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 15 years ago
parent 0f6b011e1a
commit 6192205533

@ -141,7 +141,6 @@ public class MapView {
assert key.length() > 0;
assert newMap != null;
key = normalizeKey(key);
assert blob != null;
String s = map2string(newMap, "W" + DateFormatter.formatShortSecond() + " ");
assert s != null;
synchronized (this) {

@ -49,7 +49,7 @@ public abstract class AbstractReader implements Reader {
// derived methods:
public byte[] readFully() throws IOException {
public final byte[] readFully() throws IOException {
long a = this.available();
if (a <= 0) return null;
if (a > Integer.MAX_VALUE) throw new IOException("available too large for a single array");
@ -58,21 +58,21 @@ public abstract class AbstractReader implements Reader {
return buffer;
}
public short readShort() throws IOException {
public final short readShort() throws IOException {
byte[] b = new byte[2];
this.readFully(b, 0, 2);
//if ((b[0] | b[1]) < 0) throw new IOException("kelondroAbstractRA.readInt: wrong values; ch1=" + (b[0] & 0xFF) + ", ch2=" + (b[1] & 0xFF));
return (short) (((b[0] & 0xFF) << 8) | (b[1] & 0xFF));
}
public int readInt() throws IOException {
public final int readInt() throws IOException {
byte[] b = new byte[4];
this.readFully(b, 0, 4);
//if ((b[0] | b[1] | b[2] | b[3]) < 0) throw new IOException("kelondroAbstractRA.readInt: wrong values; ch1=" + (b[0] & 0xFF) + ", ch2=" + (b[1] & 0xFF) + ", ch3=" + (b[2] & 0xFF) + ", ch4=" + (b[3] & 0xFF));
return (((b[0] & 0xFF) << 24) | ((b[1] & 0xFF) << 16) | ((b[2] & 0xFF) << 8) | (b[3] & 0xFF));
}
public long readLong() throws IOException {
public final long readLong() throws IOException {
return ((long) (readInt()) << 32) | (readInt() & 0xFFFFFFFFL);
}

@ -45,14 +45,14 @@ public abstract class AbstractWriter extends AbstractReader implements Writer {
// derived methods:
public void writeShort(final int v) throws IOException {
public final void writeShort(final int v) throws IOException {
byte[] b = new byte[2];
b[0] = (byte) ((v >>> 8) & 0xFF);
b[1] = (byte) ( v & 0xFF);
this.write(b);
}
public void writeInt(final int v) throws IOException {
public final void writeInt(final int v) throws IOException {
this.write(int2array(v));
}
@ -65,7 +65,7 @@ public abstract class AbstractWriter extends AbstractReader implements Writer {
return b;
}
public void writeLong(final long v) throws IOException {
public final void writeLong(final long v) throws IOException {
byte[] b = new byte[8];
b[0] = (byte) ((v >>> 56) & 0xFF);
b[1] = (byte) ((v >>> 48) & 0xFF);
@ -78,14 +78,14 @@ public abstract class AbstractWriter extends AbstractReader implements Writer {
this.write(b);
}
public void write(final byte[] b) throws IOException {
public final void write(final byte[] b) throws IOException {
this.write(b, 0, b.length);
}
private static final byte cr = 13;
private static final byte lf = 10;
private final static byte cr = 13;
private final static byte lf = 10;
public void writeLine(final String line) throws IOException {
public final void writeLine(final String line) throws IOException {
final byte[] b = new byte[line.length() + 2];
System.arraycopy(line.getBytes(), 0, b, 0, line.length());
b[b.length - 2] = cr;
@ -93,7 +93,7 @@ public abstract class AbstractWriter extends AbstractReader implements Writer {
this.write(b);
}
public void writeLine(final byte[] line) throws IOException {
public final void writeLine(final byte[] line) throws IOException {
final byte[] b = new byte[line.length + 2];
System.arraycopy(line, 0, b, 0, line.length);
b[b.length - 2] = cr;
@ -101,7 +101,7 @@ public abstract class AbstractWriter extends AbstractReader implements Writer {
this.write(b);
}
public void writeMap(final Map<String, String> map, final String comment) throws IOException {
public final void writeMap(final Map<String, String> map, final String comment) throws IOException {
this.seek(0);
final Iterator<Map.Entry<String, String>> iter = map.entrySet().iterator();
Map.Entry<String, String> entry;
@ -118,7 +118,7 @@ public abstract class AbstractWriter extends AbstractReader implements Writer {
bb.close();
}
public HashMap<String, String> readMap() throws IOException {
public final HashMap<String, String> readMap() throws IOException {
this.seek(0);
final byte[] b = readFully();
final BufferedReader br = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(b)));
@ -136,7 +136,7 @@ public abstract class AbstractWriter extends AbstractReader implements Writer {
return map;
}
public void deleteOnExit() {
public final void deleteOnExit() {
if (this.file != null) this.file.deleteOnExit();
}

@ -39,9 +39,9 @@ import net.yacy.kelondro.util.FileUtils;
* That means, each time, an entry is written to the end of the file, it is NOT buffered here,
* but possibly buffered in the enclosed kelondroEcoFS
*/
public class BufferedRecords {
public final class BufferedRecords {
private Records efs;
private final Records efs;
private final int maxEntries;
private final TreeMap<Long, byte[]> buffer;
@ -61,7 +61,7 @@ public class BufferedRecords {
efs.flushBuffer();
}
private void flushBuffer0() throws IOException {
private final void flushBuffer0() throws IOException {
if (efs == null) return;
for (Map.Entry<Long, byte[]> entry: buffer.entrySet()) {
efs.put(entry.getKey().intValue(), entry.getValue(), 0);
@ -70,29 +70,28 @@ public class BufferedRecords {
efs.flushBuffer();
}
public synchronized long size() throws IOException {
public final synchronized long size() throws IOException {
return efs == null ? 0 : efs.size(); // stuck
}
public File filename() {
public final File filename() {
return efs.filename();
}
public synchronized void close() {
public final synchronized void close() {
try {
flushBuffer0();
} catch (final IOException e) {
e.printStackTrace();
}
if (efs != null) efs.close();
efs = null;
}
protected synchronized void finalize() {
protected final synchronized void finalize() {
if (this.efs != null) this.close();
}
public synchronized void get(final long index, final byte[] b, final int start) throws IOException {
public final synchronized void get(final long index, final byte[] b, final int start) throws IOException {
assert b.length - start >= efs.recordsize;
if (index >= size()) throw new IndexOutOfBoundsException("kelondroBufferedEcoFS.get(" + index + ") outside bounds (" + this.size() + ")");
final byte[] bb = buffer.get(Long.valueOf(index));
@ -103,7 +102,7 @@ public class BufferedRecords {
}
}
public synchronized void put(final long index, final byte[] b, final int start) throws IOException {
public final synchronized void put(final long index, final byte[] b, final int start) throws IOException {
assert b.length - start >= efs.recordsize;
final long s = size();
if (index > s) throw new IndexOutOfBoundsException("kelondroBufferedEcoFS.put(" + index + ") outside bounds (" + this.size() + ")");
@ -117,13 +116,13 @@ public class BufferedRecords {
}
}
public synchronized void add(final byte[] b, final int start) throws IOException {
public final synchronized void add(final byte[] b, final int start) throws IOException {
assert b.length - start >= efs.recordsize;
// index == size() == efs.size();
efs.add(b, start);
}
public synchronized void cleanLast(final byte[] b, final int start) throws IOException {
public final synchronized void cleanLast(final byte[] b, final int start) throws IOException {
assert b.length - start >= efs.recordsize;
final byte[] bb = buffer.remove(Long.valueOf(size() - 1));
if (bb == null) {
@ -134,12 +133,12 @@ public class BufferedRecords {
}
}
public synchronized void cleanLast() throws IOException {
public final synchronized void cleanLast() throws IOException {
buffer.remove(Long.valueOf(size() - 1));
efs.cleanLast();
}
public void deleteOnExit() {
public final void deleteOnExit() {
efs.deleteOnExit();
}

@ -31,10 +31,10 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
public class ByteCountInputStream extends FilterInputStream {
public final class ByteCountInputStream extends FilterInputStream {
private static final Object syncObject = new Object();
private static final HashMap<String, Long> byteCountInfo = new HashMap<String, Long>(2);
private final static Object syncObject = new Object();
private final static HashMap<String, Long> byteCountInfo = new HashMap<String, Long>(2);
private static long globalByteCount = 0;
private boolean finished = false;
@ -42,7 +42,7 @@ public class ByteCountInputStream extends FilterInputStream {
private String byteCountAccountName = null;
protected ByteCountInputStream(final InputStream inputStream) {
this(inputStream,null);
this(inputStream, null);
}
/**
@ -64,13 +64,13 @@ public class ByteCountInputStream extends FilterInputStream {
this.byteCountAccountName = accountName;
}
public int read(final byte[] b) throws IOException {
public final int read(final byte[] b) throws IOException {
final int readCount = super.read(b);
if (readCount > 0) this.byteCount += readCount;
return readCount;
}
public int read(final byte[] b, final int off, final int len) throws IOException {
public final int read(final byte[] b, final int off, final int len) throws IOException {
try {
final int readCount = super.read(b, off, len);
if (readCount > 0) this.byteCount += readCount;
@ -80,32 +80,32 @@ public class ByteCountInputStream extends FilterInputStream {
}
}
public int read() throws IOException {
public final int read() throws IOException {
this.byteCount++;
return super.read();
}
public long skip(final long len) throws IOException {
public final long skip(final long len) throws IOException {
final long skipCount = super.skip(len);
if (skipCount > 0) this.byteCount += skipCount;
return skipCount;
}
public long getCount() {
public final long getCount() {
return this.byteCount;
}
public String getAccountName() {
public final String getAccountName() {
return this.byteCountAccountName;
}
public static long getGlobalCount() {
public final static long getGlobalCount() {
synchronized (syncObject) {
return globalByteCount;
}
}
public static long getAccountCount(final String accountName) {
public final static long getAccountCount(final String accountName) {
synchronized (syncObject) {
if (byteCountInfo.containsKey(accountName)) {
return (byteCountInfo.get(accountName)).longValue();
@ -114,12 +114,12 @@ public class ByteCountInputStream extends FilterInputStream {
}
}
public void close() throws IOException {
public final void close() throws IOException {
super.close();
this.finish();
}
public void finish() {
public final void finish() {
if (this.finished) return;
this.finished = true;
@ -137,14 +137,14 @@ public class ByteCountInputStream extends FilterInputStream {
}
}
public static void resetCount() {
public final static void resetCount() {
synchronized (syncObject) {
globalByteCount = 0;
byteCountInfo.clear();
}
}
protected void finalize() throws Throwable {
protected final void finalize() throws Throwable {
if (!this.finished)
finish();
super.finalize();

@ -29,16 +29,16 @@ import java.io.IOException;
import java.io.OutputStream;
import java.util.HashMap;
public class ByteCountOutputStream extends BufferedOutputStream {
public final class ByteCountOutputStream extends BufferedOutputStream {
private static final Object syncObject = new Object();
private final static Object syncObject = new Object();
private static long globalByteCount = 0;
private boolean finished = false;
private final static HashMap<String, Long> byteCountInfo = new HashMap<String, Long>(2);
private static final HashMap<String, Long> byteCountInfo = new HashMap<String, Long>(2);
protected long byteCount;
protected String byteCountAccountName = null;
private boolean finished = false;
/**
* Constructor of this class
* @param outputStream the {@link OutputStream} to write to
@ -63,19 +63,19 @@ public class ByteCountOutputStream extends BufferedOutputStream {
}
/** @see java.io.OutputStream#write(byte[]) */
public void write(final byte[] b) throws IOException {
public final void write(final byte[] b) throws IOException {
super.write(b);
this.byteCount += b.length;
}
/** @see java.io.OutputStream#write(byte[], int, int) */
public synchronized void write(final byte[] b, final int off, final int len) throws IOException {
public final synchronized void write(final byte[] b, final int off, final int len) throws IOException {
super.write(b, off, len);
this.byteCount += len;
}
/** @see java.io.OutputStream#write(int) */
public synchronized void write(final int b) throws IOException {
public final synchronized void write(final int b) throws IOException {
super.write(b);
this.byteCount++;
}
@ -84,7 +84,7 @@ public class ByteCountOutputStream extends BufferedOutputStream {
* The number of bytes that have passed through this stream.
* @return the number of bytes accumulated
*/
public long getCount() {
public final long getCount() {
return this.byteCount;
}
@ -92,13 +92,13 @@ public class ByteCountOutputStream extends BufferedOutputStream {
return this.byteCountAccountName;
}
public static long getGlobalCount() {
public final static long getGlobalCount() {
synchronized (syncObject) {
return globalByteCount;
}
}
public static long getAccountCount(final String accountName) {
public final static long getAccountCount(final String accountName) {
synchronized (syncObject) {
if (byteCountInfo.containsKey(accountName)) {
return (byteCountInfo.get(accountName)).longValue();
@ -107,14 +107,14 @@ public class ByteCountOutputStream extends BufferedOutputStream {
}
}
public static void resetCount() {
public final static void resetCount() {
synchronized (syncObject) {
globalByteCount = 0;
byteCountInfo.clear();
}
}
public void finish() {
public final void finish() {
if (this.finished) return;
this.finished = true;
@ -132,7 +132,7 @@ public class ByteCountOutputStream extends BufferedOutputStream {
}
}
protected void finalize() throws Throwable {
protected final void finalize() throws Throwable {
if (!this.finished)
finish();
super.finalize();

@ -28,9 +28,9 @@ import java.io.RandomAccessFile;
import net.yacy.kelondro.util.MemoryControl;
public class CachedFileReader extends AbstractReader implements Reader {
public final class CachedFileReader extends AbstractReader implements Reader {
private RandomAccessFile RAFile;
private final RandomAccessFile RAFile;
private byte[] cache;
private int cachelen;
@ -48,15 +48,15 @@ public class CachedFileReader extends AbstractReader implements Reader {
this.cachelen = 0;
}
public synchronized long available() throws IOException {
public final synchronized long available() throws IOException {
return this.length() - RAFile.getFilePointer();
}
public synchronized long length() throws IOException {
public final synchronized long length() throws IOException {
return this.RAFile.length();
}
public synchronized final void readFully(final byte[] b, final int off, int len) throws IOException {
public final synchronized void readFully(final byte[] b, final int off, int len) throws IOException {
long seek = RAFile.getFilePointer();
if (cache != null && cachelen - seek >= len) {
// read from cache
@ -69,11 +69,11 @@ public class CachedFileReader extends AbstractReader implements Reader {
return;
}
public synchronized void seek(final long pos) throws IOException {
public final synchronized void seek(final long pos) throws IOException {
RAFile.seek(pos);
}
public synchronized void close() {
public final synchronized void close() {
if (RAFile != null) try {
try{RAFile.getChannel().close();} catch (IOException e) {}
RAFile.close();
@ -81,7 +81,6 @@ public class CachedFileReader extends AbstractReader implements Reader {
e.printStackTrace();
}
this.cache = null;
this.RAFile = null;
}
protected void finalize() throws Throwable {

@ -27,8 +27,6 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
public final class CachedFileWriter extends AbstractWriter implements Writer {
private RandomAccessFile RAFile;
@ -45,23 +43,23 @@ public final class CachedFileWriter extends AbstractWriter implements Writer {
this.cachelen = 0;
}
public synchronized long length() throws IOException {
public final synchronized long length() throws IOException {
checkReopen();
return this.RAFile.length();
}
public synchronized void setLength(long length) throws IOException {
public final synchronized void setLength(long length) throws IOException {
checkReopen();
cachelen = 0;
RAFile.setLength(length);
}
public synchronized long available() throws IOException {
public final synchronized long available() throws IOException {
checkReopen();
return this.length() - RAFile.getFilePointer();
}
public synchronized final void readFully(final byte[] b, final int off, int len) throws IOException {
public final synchronized void readFully(final byte[] b, final int off, int len) throws IOException {
checkReopen();
long seek = RAFile.getFilePointer();
if (cache != null && cachestart <= seek && cachelen - seek + cachestart >= len) {
@ -97,7 +95,7 @@ public final class CachedFileWriter extends AbstractWriter implements Writer {
}
public synchronized void write(final byte[] b, final int off, final int len) throws IOException {
public final synchronized void write(final byte[] b, final int off, final int len) throws IOException {
checkReopen();
//assert len > 0;
// write to file
@ -127,12 +125,12 @@ public final class CachedFileWriter extends AbstractWriter implements Writer {
RAFile.write(b, off, len);
}
public synchronized void seek(final long pos) throws IOException {
public final synchronized void seek(final long pos) throws IOException {
checkReopen();
RAFile.seek(pos);
}
public synchronized void close() {
public final synchronized void close() {
if (RAFile != null) try {
try{RAFile.getChannel().close();} catch (IOException e) {}
//System.out.println("***DEBUG*** closed file " + this.file + ", FD is " + ((RAFile.getFD().valid()) ? "VALID" : "VOID") + ", channel is " + ((RAFile.getChannel().isOpen()) ? "OPEN" : "CLOSE"));
@ -145,7 +143,7 @@ public final class CachedFileWriter extends AbstractWriter implements Writer {
this.RAFile = null;
}
private void checkReopen() {
private final void checkReopen() {
if (this.RAFile != null) return;
// re-open the file
try {
@ -158,7 +156,7 @@ public final class CachedFileWriter extends AbstractWriter implements Writer {
this.cachelen = 0;
}
protected void finalize() throws Throwable {
protected final void finalize() throws Throwable {
this.close();
super.finalize();
}

@ -28,66 +28,65 @@ import java.io.IOException;
public final class RandomAccessIO {
protected Writer ra;
protected final Writer ra;
protected final String name;
public RandomAccessIO(final Writer ra, final String name) {
this.name = name;
this.ra = ra;
}
public Writer getRA() {
public final Writer getRA() {
return this.ra;
}
public synchronized long length() throws IOException {
public final synchronized long length() throws IOException {
return ra.length();
}
public synchronized void readFully(long pos, final byte[] b, int off, int len) throws IOException {
public final synchronized void readFully(long pos, final byte[] b, int off, int len) throws IOException {
if (len == 0) return;
this.ra.seek(pos);
this.ra.readFully(b, off, len);
}
public synchronized void write(final long pos, final byte[] b, final int off, final int len) throws IOException {
public final synchronized void write(final long pos, final byte[] b, final int off, final int len) throws IOException {
if (len == 0) return;
this.ra.seek(pos);
this.ra.write(b, off, len);
}
// logging support
protected String name = null;
public String name() {
public final String name() {
return name;
}
public synchronized byte readByte(final long pos) throws IOException {
public final synchronized byte readByte(final long pos) throws IOException {
final byte[] b = new byte[1];
this.readFully(pos, b, 0, 1);
return b[0];
}
public synchronized void writeByte(final long pos, final int v) throws IOException {
public final synchronized void writeByte(final long pos, final int v) throws IOException {
this.write(pos, new byte[]{(byte) (v & 0xFF)});
}
public synchronized short readShort(final long pos) throws IOException {
public final synchronized short readShort(final long pos) throws IOException {
final byte[] b = new byte[2];
this.readFully(pos, b, 0, 2);
return (short) (((b[0] & 0xFF) << 8) | ((b[1] & 0xFF) << 0));
}
public synchronized void writeShort(final long pos, final int v) throws IOException {
public final synchronized void writeShort(final long pos, final int v) throws IOException {
this.write(pos, new byte[]{(byte) ((v >>> 8) & 0xFF), (byte) ((v >>> 0) & 0xFF)});
}
public synchronized int readInt(final long pos) throws IOException {
public final synchronized int readInt(final long pos) throws IOException {
final byte[] b = new byte[4];
this.readFully(pos, b, 0, 4);
return ((b[0] & 0xFF) << 24) | ((b[1] & 0xFF) << 16) | ((b[2] & 0xFF) << 8) | (b[3] & 0xFF);
}
public synchronized void writeInt(final long pos, final int v) throws IOException {
public final synchronized void writeInt(final long pos, final int v) throws IOException {
this.write(pos, new byte[]{
(byte) ((v >>> 24) & 0xFF),
(byte) ((v >>> 16) & 0xFF),
@ -96,13 +95,13 @@ public final class RandomAccessIO {
});
}
public synchronized long readLong(final long pos) throws IOException {
public final synchronized long readLong(final long pos) throws IOException {
final byte[] b = new byte[8];
this.readFully(pos, b, 0, 8);
return (((long) b[0] & 0xFF) << 56) | (((long) b[1] & 0xFF) << 48) | (((long) b[2]) << 40) | (((long) b[3] & 0xFF) << 32) | (((long) b[4] & 0xFF) << 24) | (((long) b[5] & 0xFF) << 16) | (((long) b[6] & 0xFF) << 8) | ((long) b[7] & 0xFF);
}
public synchronized void writeLong(final long pos, final long v) throws IOException {
public final synchronized void writeLong(final long pos, final long v) throws IOException {
this.write(pos, new byte[]{
(byte) ((v >>> 56) & 0xFF),
(byte) ((v >>> 48) & 0xFF),
@ -115,11 +114,11 @@ public final class RandomAccessIO {
});
}
public synchronized void write(final long pos, final byte[] b) throws IOException {
public final synchronized void write(final long pos, final byte[] b) throws IOException {
this.write(pos, b, 0, b.length);
}
public synchronized void writeSpace(long pos, int spaceCount) throws IOException {
public final synchronized void writeSpace(long pos, int spaceCount) throws IOException {
if (spaceCount < 512) {
write(pos, space(spaceCount));
return;
@ -135,23 +134,22 @@ public final class RandomAccessIO {
}
}
private byte[] space(int count) {
private final byte[] space(int count) {
byte[] s = new byte[count];
while (count-- > 0) s[count] = 0;
return s;
}
public synchronized void close() throws IOException {
public final synchronized void close() throws IOException {
if (this.ra != null) this.ra.close();
this.ra = null;
}
protected void finalize() throws Throwable {
protected final void finalize() throws Throwable {
if (this.ra != null) this.close();
super.finalize();
}
public void deleteOnExit() {
public final void deleteOnExit() {
this.ra.deleteOnExit();
}
}

@ -51,7 +51,7 @@ import net.yacy.kelondro.util.MemoryControl;
* All access to the file is made with byte[] that are generated outside of this class
* This class only references byte[] that are handed over to methods of this class.
*/
public class Records {
public final class Records {
private RandomAccessFile raf;
private final File tablefile;
@ -63,9 +63,11 @@ public class Records {
/**
* number of entries in buffer
*/
private int cachecount, buffercount;
private byte[] cache, buffer;
final byte[] zero;
private int cachecount;
private int buffercount;
private byte[] cache;
private byte[] buffer;
private final byte[] zero;
/**
* stay below hard disc cache (is that necessary?)
@ -115,8 +117,8 @@ public class Records {
//System.out.println("newmem nachher: cachesize = " + cachesize + ", buffersize = " + buffersize);
}
cache = new byte[cachesize];
buffer = new byte[buffersize];
this.cache = new byte[cachesize];
this.buffer = new byte[buffersize];
this.buffercount = 0;
// first-time read of cache
@ -128,7 +130,7 @@ public class Records {
* @param recordsize
* @return number of records in table
*/
public static long tableSize(final File tablefile, final long recordsize) throws IOException {
public final static long tableSize(final File tablefile, final long recordsize) throws IOException {
if (!tablefile.exists()) return 0;
final long size = tablefile.length();
if (size % recordsize != 0) throw new IOException("wrong file size: file = " + tablefile + ", size = " + size + ", recordsize = " + recordsize);
@ -139,11 +141,11 @@ public class Records {
* @return the number of records in file plus number of records in buffer
* @throws IOException
*/
public synchronized long size() throws IOException {
public final synchronized long size() throws IOException {
return filesize() + this.buffercount;
}
public File filename() {
public final File filename() {
return this.tablefile;
}
@ -151,7 +153,7 @@ public class Records {
* @return records in file
* @throws IOException
*/
private long filesize() throws IOException {
private final long filesize() throws IOException {
return raf.length() / recordsize;
}
@ -161,7 +163,7 @@ public class Records {
* @param index
* @return the index offset inside the cache or -1 if the index is not in the cache
*/
private int inCache(final long index) {
private final int inCache(final long index) {
if ((index >= this.cacheindex) && (index < this.cacheindex + this.cachecount)) {
return (int) (index - this.cacheindex);
}
@ -175,7 +177,7 @@ public class Records {
* @return the index offset inside the buffer or -1 if the index is not in the buffer
* @throws IOException
*/
private int inBuffer(final long index) throws IOException {
private final int inBuffer(final long index) throws IOException {
final long fs = filesize();
if ((index >= fs) && (index < fs + this.buffercount)) {
return (int) (index - fs);
@ -192,7 +194,7 @@ public class Records {
* @param index
* @throws IOException
*/
private void fillCache(long index) throws IOException {
private final void fillCache(long index) throws IOException {
//System.out.println("*** DEBUG FillCache " + this.tablefile.getName() + " at index " + index);
// first check if the index is inside the current cache
assert inCache(index) < 0;
@ -221,7 +223,7 @@ public class Records {
/**
* write buffer to end of file
*/
public void flushBuffer() {
public final void flushBuffer() {
try {
raf.seek(raf.length());
raf.write(this.buffer, 0, this.recordsize * this.buffercount);
@ -231,18 +233,18 @@ public class Records {
this.buffercount = 0;
}
public synchronized void close() {
public final synchronized void close() {
flushBuffer();
// then close the file
try {
if (raf != null) try {
raf.close();
} catch (final IOException e) {
e.printStackTrace();
}
raf = null;
buffer = null;
cache = null;
this.raf = null;
this.buffer = null;
this.cache = null;
}
/**
@ -251,7 +253,7 @@ public class Records {
* @param start offset in b to store data
* @throws IOException
*/
public synchronized void get(final long index, final byte[] b, final int start) throws IOException {
public final synchronized void get(final long index, final byte[] b, final int start) throws IOException {
assert b.length - start >= this.recordsize;
if (index >= size()) throw new IndexOutOfBoundsException("kelondroEcoFS.get(" + index + ") outside bounds (" + this.size() + ")");
// check if index is inside of cache
@ -276,7 +278,7 @@ public class Records {
assert false;
}
public synchronized void put(final long index, final byte[] b, final int start) throws IOException {
public final synchronized void put(final long index, final byte[] b, final int start) throws IOException {
assert b.length - start >= this.recordsize;
final long s = filesize() + this.buffercount;
if (index > s) throw new IndexOutOfBoundsException("kelondroEcoFS.put(" + index + ") outside bounds (" + this.size() + ")");
@ -327,7 +329,7 @@ public class Records {
}
}
public synchronized void add(final byte[] b, final int start) throws IOException {
public final synchronized void add(final byte[] b, final int start) throws IOException {
// index == size() == filesize() + (long) this.buffercount
assert b.length - start >= this.recordsize;
@ -356,14 +358,14 @@ public class Records {
assert this.buffercount <= this.buffer.length / this.recordsize;
}
private boolean isClean(final byte[] b, final int offset, final int length) {
private final boolean isClean(final byte[] b, final int offset, final int length) {
for (int i = 0; i < length; i++) {
if (b[i + offset] != 0) return false;
}
return true;
}
private boolean isClean(final long index) throws IOException {
private final boolean isClean(final long index) throws IOException {
assert index < size();
// check if index is inside of cache
int p = inCache(index);
@ -402,7 +404,7 @@ public class Records {
* @param start offset in record to start reading
* @throws IOException
*/
public synchronized void clean(final long index, final byte[] b, final int start) throws IOException {
public final synchronized void clean(final long index, final byte[] b, final int start) throws IOException {
assert b.length - start >= this.recordsize;
final long s = size();
if (index >= s) throw new IndexOutOfBoundsException("kelondroEcoFS.clean(" + index + ") outside bounds (" + s + ")");
@ -445,7 +447,7 @@ public class Records {
* @param index
* @throws IOException
*/
public synchronized void clean(final long index) throws IOException {
public final synchronized void clean(final long index) throws IOException {
final long s = size();
if (index >= s) throw new IndexOutOfBoundsException("kelondroEcoFS.clean(" + index + ") outside bounds (" + s + ")");
if (index == s - 1) {
@ -479,7 +481,7 @@ public class Records {
* @param start
* @throws IOException
*/
public synchronized void cleanLast(final byte[] b, final int start) throws IOException {
public final synchronized void cleanLast(final byte[] b, final int start) throws IOException {
cleanLast0(b, start);
long i;
while (((i = size()) > 0) && (isClean(i - 1))) {
@ -498,7 +500,7 @@ public class Records {
* @param start
* @throws IOException
*/
private synchronized void cleanLast0(final byte[] b, final int start) throws IOException {
private final synchronized void cleanLast0(final byte[] b, final int start) throws IOException {
assert b.length - start >= this.recordsize;
// check if index is inside of cache
final long s = this.size();
@ -534,7 +536,7 @@ public class Records {
* @see clean(long, byte[], int)
* @throws IOException
*/
public synchronized void cleanLast() throws IOException {
public final synchronized void cleanLast() throws IOException {
cleanLast0();
long i;
while (((i = size()) > 0) && (isClean(i - 1))) {
@ -544,7 +546,7 @@ public class Records {
}
}
private synchronized void cleanLast0() throws IOException {
private final synchronized void cleanLast0() throws IOException {
// check if index is inside of cache
final long s = this.size();
@ -568,7 +570,7 @@ public class Records {
this.raf.setLength((s - 1) * this.recordsize);
}
public void deleteOnExit() {
public final void deleteOnExit() {
this.tablefile.deleteOnExit();
}

@ -53,7 +53,7 @@ public final class ConsoleOutErrHandler extends Handler {
/**
* Get any configuration properties set
*/
private void configure() {
private final void configure() {
final LogManager manager = LogManager.getLogManager();
final String className = getClass().getName();
@ -84,7 +84,7 @@ public final class ConsoleOutErrHandler extends Handler {
}
private Level parseLevel(final String levelName) {
private final Level parseLevel(final String levelName) {
try {
return (levelName == null) ? Level.INFO : Level.parse(levelName);
} catch (final Exception e) {
@ -92,7 +92,7 @@ public final class ConsoleOutErrHandler extends Handler {
}
}
private Filter makeFilter(final String name) {
private final Filter makeFilter(final String name) {
if (name == null) return null;
Filter f = null;
@ -107,7 +107,7 @@ public final class ConsoleOutErrHandler extends Handler {
return f;
}
private Formatter makeFormatter(final String name) {
private final Formatter makeFormatter(final String name) {
if (name == null) return null;
Formatter f = null;
@ -121,7 +121,7 @@ public final class ConsoleOutErrHandler extends Handler {
}
public void publish(final LogRecord record) {
public final void publish(final LogRecord record) {
if (!isLoggable(record)) return;
if (this.ignoreCtrlChr) {
@ -171,7 +171,7 @@ public final class ConsoleOutErrHandler extends Handler {
}
}
public void setFilter(final Filter newFilter) throws SecurityException {
public final void setFilter(final Filter newFilter) throws SecurityException {
super.setFilter(newFilter);
if (newFilter == null) return;
try {

@ -38,12 +38,12 @@ public final class ConsoleOutHandler extends StreamHandler {
setOutputStream(System.out);
}
public synchronized void publish(final LogRecord record) {
public final synchronized void publish(final LogRecord record) {
super.publish(record);
flush();
}
public synchronized void close() {
public final synchronized void close() {
flush();
}
}

@ -52,7 +52,7 @@ public class GuiHandler extends Handler {
/**
* Get any configuration properties set
*/
private void configure() {
private final void configure() {
final LogManager manager = LogManager.getLogManager();
final String className = getClass().getName();
@ -69,7 +69,7 @@ public class GuiHandler extends Handler {
this.size = parseSize(sizeString);
}
private int parseSize(final String sizeString) {
private final int parseSize(final String sizeString) {
int newSize = DEFAULT_SIZE;
try {
newSize = Integer.parseInt(sizeString);
@ -79,7 +79,7 @@ public class GuiHandler extends Handler {
return newSize;
}
private Filter makeFilter(final String name) {
private final Filter makeFilter(final String name) {
if (name == null) return null;
Filter f = null;
@ -92,7 +92,7 @@ public class GuiHandler extends Handler {
return f;
}
private Formatter makeFormatter(final String name) {
private final Formatter makeFormatter(final String name) {
if (name == null) return null;
Formatter f = null;
@ -106,17 +106,17 @@ public class GuiHandler extends Handler {
}
// Initialize. Size is a count of LogRecords.
private void init() {
private final void init() {
this.buffer = new LogRecord[this.size];
this.start = 0;
this.count = 0;
}
public int getSize() {
public final int getSize() {
return this.size;
}
public void publish(final LogRecord record) {
public final void publish(final LogRecord record) {
if (!isLoggable(record)) return;
// write it to the buffer
@ -130,12 +130,12 @@ public class GuiHandler extends Handler {
flush();
}
public synchronized LogRecord[] getLogArray() {
public final synchronized LogRecord[] getLogArray() {
return this.getLogArray(null);
}
public synchronized LogRecord[] getLogArray(final Long sequenceNumberStart) {
public final synchronized LogRecord[] getLogArray(final Long sequenceNumberStart) {
final ArrayList<LogRecord> tempBuffer = new ArrayList<LogRecord>(this.count);
for (int i = 0; i < this.count; i++) {
@ -149,7 +149,7 @@ public class GuiHandler extends Handler {
return tempBuffer.toArray(new LogRecord[tempBuffer.size()]);
}
public synchronized String getLog(final boolean reversed, int lineCount) {
public final synchronized String getLog(final boolean reversed, int lineCount) {
if ((lineCount > this.count)||(lineCount < 0)) lineCount = this.count;
@ -175,7 +175,7 @@ public class GuiHandler extends Handler {
}
}
public synchronized String[] getLogLines(final boolean reversed, int lineCount) {
public final synchronized String[] getLogLines(final boolean reversed, int lineCount) {
if ((lineCount > this.count)||(lineCount < 0)) lineCount = this.count;
@ -202,12 +202,10 @@ public class GuiHandler extends Handler {
}
public void flush() {
// TODO Auto-generated method stub
}
public void close() throws SecurityException {
// TODO Auto-generated method stub
}

@ -61,51 +61,51 @@ public final class Log {
//this.theLogger.setLevel(Level.FINEST); // set a default level
}
public void setLevel(final Level newLevel) {
public final void setLevel(final Level newLevel) {
this.theLogger.setLevel(newLevel);
}
public void logSevere(final String message) {
public final void logSevere(final String message) {
enQueueLog(this.theLogger, Level.SEVERE, message);
}
public void logSevere(final String message, final Throwable thrown) {
public final void logSevere(final String message, final Throwable thrown) {
enQueueLog(this.theLogger, Level.SEVERE, message, thrown);
}
public boolean isSevere() {
public final boolean isSevere() {
return this.theLogger.isLoggable(Level.SEVERE);
}
public void logWarning(final String message) {
public final void logWarning(final String message) {
enQueueLog(this.theLogger, Level.WARNING, message);
}
public void logWarning(final String message, final Throwable thrown) {
public final void logWarning(final String message, final Throwable thrown) {
enQueueLog(this.theLogger, Level.WARNING, message, thrown);
}
public boolean isWarning() {
public final boolean isWarning() {
return this.theLogger.isLoggable(Level.WARNING);
}
public void logConfig(final String message) {
public final void logConfig(final String message) {
enQueueLog(this.theLogger, Level.CONFIG, message);
}
public void logConfig(final String message, final Throwable thrown) {
public final void logConfig(final String message, final Throwable thrown) {
enQueueLog(this.theLogger, Level.CONFIG, message, thrown);
}
public boolean isConfig() {
public final boolean isConfig() {
return this.theLogger.isLoggable(Level.CONFIG);
}
public void logInfo(final String message) {
public final void logInfo(final String message) {
enQueueLog(this.theLogger, Level.INFO, message);
}
public void logInfo(final String message, final Throwable thrown) {
public final void logInfo(final String message, final Throwable thrown) {
enQueueLog(this.theLogger, Level.INFO, message, thrown);
}
@ -113,104 +113,104 @@ public final class Log {
return this.theLogger.isLoggable(Level.INFO);
}
public void logFine(final String message) {
public final void logFine(final String message) {
enQueueLog(this.theLogger, Level.FINE, message);
}
public void logFine(final String message, final Throwable thrown) {
public final void logFine(final String message, final Throwable thrown) {
enQueueLog(this.theLogger, Level.FINE, message, thrown);
}
public boolean isFine() {
public final boolean isFine() {
return this.theLogger.isLoggable(Level.FINE);
}
public void logFiner(final String message) {
public final void logFiner(final String message) {
enQueueLog(this.theLogger, Level.FINER, message);
}
public void logFiner(final String message, final Throwable thrown) {
public final void logFiner(final String message, final Throwable thrown) {
enQueueLog(this.theLogger, Level.FINER, message, thrown);
}
public boolean isFiner() {
public final boolean isFiner() {
return this.theLogger.isLoggable(Level.FINER);
}
public void logFinest(final String message) {
public final void logFinest(final String message) {
enQueueLog(this.theLogger, Level.FINEST, message);
}
public void logFinest(final String message, final Throwable thrown) {
public final void logFinest(final String message, final Throwable thrown) {
enQueueLog(this.theLogger, Level.FINEST, message, thrown);
}
public boolean isFinest() {
public final boolean isFinest() {
return this.theLogger.isLoggable(Level.FINEST);
}
public boolean isLoggable(final Level level) {
public final boolean isLoggable(final Level level) {
return this.theLogger.isLoggable(level);
}
// static log messages
public static void logSevere(final String appName, final String message) {
public final static void logSevere(final String appName, final String message) {
enQueueLog(appName, Level.SEVERE, message);
}
public static void logSevere(final String appName, final String message, final Throwable thrown) {
public final static void logSevere(final String appName, final String message, final Throwable thrown) {
enQueueLog(appName, Level.SEVERE, message, thrown);
}
public static void logWarning(final String appName, final String message) {
public final static void logWarning(final String appName, final String message) {
enQueueLog(appName, Level.WARNING, message);
}
public static void logWarning(final String appName, final String message, final Throwable thrown) {
public final static void logWarning(final String appName, final String message, final Throwable thrown) {
enQueueLog(appName, Level.WARNING, message, thrown);
}
public static void logConfig(final String appName, final String message) {
public final static void logConfig(final String appName, final String message) {
enQueueLog(appName, Level.CONFIG, message);
}
public static void logConfig(final String appName, final String message, final Throwable thrown) {
public final static void logConfig(final String appName, final String message, final Throwable thrown) {
enQueueLog(appName, Level.CONFIG, message, thrown);
}
public static void logInfo(final String appName, final String message) {
public final static void logInfo(final String appName, final String message) {
enQueueLog(appName, Level.INFO, message);
}
public static void logInfo(final String appName, final String message, final Throwable thrown) {
public final static void logInfo(final String appName, final String message, final Throwable thrown) {
enQueueLog(appName, Level.INFO, message, thrown);
}
public static void logFine(final String appName, final String message) {
public final static void logFine(final String appName, final String message) {
enQueueLog(appName, Level.FINE, message);
}
public static void logFine(final String appName, final String message, final Throwable thrown) {
public final static void logFine(final String appName, final String message, final Throwable thrown) {
enQueueLog(appName, Level.FINE, message, thrown);
}
public static boolean isFine(final String appName) {
public final static boolean isFine(final String appName) {
return Logger.getLogger(appName).isLoggable(Level.FINE);
}
public static void logFiner(final String appName, final String message) {
public final static void logFiner(final String appName, final String message) {
enQueueLog(appName, Level.FINER, message);
}
public static void logFiner(final String appName, final String message, final Throwable thrown) {
public final static void logFiner(final String appName, final String message, final Throwable thrown) {
enQueueLog(appName, Level.FINER, message, thrown);
}
public static void logFinest(final String appName, final String message) {
public final static void logFinest(final String appName, final String message) {
enQueueLog(appName, Level.FINEST, message);
}
public static void logFinest(final String appName, final String message, final Throwable thrown) {
public final static void logFinest(final String appName, final String message, final Throwable thrown) {
enQueueLog(appName, Level.FINEST, message, thrown);
}
public static boolean isFinest(final String appName) {
public final static boolean isFinest(final String appName) {
return Logger.getLogger(appName).isLoggable(Level.FINEST);
}
private static void enQueueLog(Logger logger, Level level, String message, final Throwable thrown) {
private final static void enQueueLog(Logger logger, Level level, String message, final Throwable thrown) {
if (logRunnerThread == null || !logRunnerThread.isAlive()) {
logger.log(level, message, thrown);
} else {
@ -222,7 +222,7 @@ public final class Log {
}
}
private static void enQueueLog(Logger logger, Level level, String message) {
private final static void enQueueLog(Logger logger, Level level, String message) {
if (logRunnerThread == null || !logRunnerThread.isAlive()) {
logger.log(level, message);
} else {
@ -234,7 +234,7 @@ public final class Log {
}
}
private static void enQueueLog(String loggername, Level level, String message, final Throwable thrown) {
private final static void enQueueLog(String loggername, Level level, String message, final Throwable thrown) {
if (logRunnerThread == null || !logRunnerThread.isAlive()) {
Logger.getLogger(loggername).log(level, message, thrown);
} else {
@ -246,7 +246,7 @@ public final class Log {
}
}
private static void enQueueLog(String loggername, Level level, String message) {
private final static void enQueueLog(String loggername, Level level, String message) {
if (logRunnerThread == null || !logRunnerThread.isAlive()) {
Logger.getLogger(loggername).log(level, message);
} else {
@ -258,7 +258,7 @@ public final class Log {
}
}
protected static class logEntry {
protected final static class logEntry {
public final Logger logger;
public final String loggername;
public final Level level;
@ -301,11 +301,11 @@ public final class Log {
}
}
protected static logEntry poison = new logEntry();
protected static BlockingQueue<logEntry> logQueue = new LinkedBlockingQueue<logEntry>();
protected final static logEntry poison = new logEntry();
protected final static BlockingQueue<logEntry> logQueue = new LinkedBlockingQueue<logEntry>();
private static logRunner logRunnerThread = null;
protected static class logRunner extends Thread {
protected final static class logRunner extends Thread {
public logRunner() {
super("Log Runner");
}
@ -337,7 +337,7 @@ public final class Log {
}
}
public static final void configureLogging(final File homePath, final File loggingConfigFile) throws SecurityException, FileNotFoundException, IOException {
public final static void configureLogging(final File homePath, final File loggingConfigFile) throws SecurityException, FileNotFoundException, IOException {
FileInputStream fileIn = null;
try {
System.out.println("STARTUP: Trying to load logging configuration from file " + loggingConfigFile.toString());
@ -369,7 +369,7 @@ public final class Log {
}
}
public static void shutdown() {
public final static void shutdown() {
if (logRunnerThread == null || !logRunnerThread.isAlive()) return;
try {
logQueue.put(poison);
@ -378,7 +378,7 @@ public final class Log {
}
}
public static final String format(final String s, int n, final int fillChar) {
public final static String format(final String s, int n, final int fillChar) {
final int l = s.length();
if (l >= n) return s;
final StringBuilder sb = new StringBuilder(l + n);
@ -386,11 +386,11 @@ public final class Log {
return sb.toString();
}
public static final boolean allZero(final byte[] a) {
public final static boolean allZero(final byte[] a) {
return allZero(a, 0, a.length);
}
public static final boolean allZero(final byte[] a, final int astart, final int alength) {
public final static boolean allZero(final byte[] a, final int astart, final int alength) {
for (int i = 0; i < alength; i++) if (a[astart + i] != 0) return false;
return true;
}

@ -31,7 +31,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class LogParser {
public final class LogParser {
/** the version of the LogParser - <strong>Double</strong>*/
public static final String PARSER_VERSION = "version";
@ -191,7 +191,7 @@ public class LogParser {
private Matcher m;
//RegExp for advancedParser
//private Pattern adv1 = Pattern.compile("\\*Indexed (\\d*) words in URL [\\w:.&?/%-=]* \\[[\\w-_]{12}\\]\\n\\tDescription: ([\\w- ]*)\\n\\tMimeType: ([\\w-_/]*) \\| Size: (\\d*) bytes \\| Anchors: (\\d*)\\n\\tStackingTime: (\\d*) ms \\| ParsingTime: (\\d*) ms \\| IndexingTime: (\\d*) ms \\| StorageTime: (\\d*) ms");
private static Pattern adv1 = Pattern.compile(
private final static Pattern adv1 = Pattern.compile(
"\\*Indexed (\\d+) words in URL [\\w:.&/%-~;$\u00A7@=]* \\[[\\w_-]{12}\\]\\r?\\n?" +
"\\tDescription: +([\\w-\\.,:!='\"|/+@\\(\\) \\t]*)\\r?\\n?" +
"\\tMimeType: ([\\w_~/-]*) \\| Charset: ([\\w-]*) \\| Size: (\\d+) bytes \\| Anchors: (\\d+)\\r?\\n?" +
@ -241,7 +241,7 @@ public class LogParser {
private long totalParserTime = 0;
private int totalParserRuns = 0;
public int parse(final String logLevel, final String logLine) {
public final int parse(final String logLevel, final String logLine) {
final long start = System.currentTimeMillis();
if (logLevel.equals("INFO")){
m = i1.matcher (logLine);
@ -433,7 +433,7 @@ public class LogParser {
return -1;
}
public Hashtable<String, Object> getResults() {
public final Hashtable<String, Object> getResults() {
final Hashtable<String, Object> results = new Hashtable<String, Object>();
results.put(PARSER_VERSION , Double.valueOf(parserVersion));
results.put(URLS_RECEIVED , Integer.valueOf(urlSum));
@ -481,15 +481,15 @@ public class LogParser {
return results;
}
public String getParserType() {
public final String getParserType() {
return parserType;
}
public double getParserVersion() {
public final double getParserVersion() {
return parserVersion;
}
public void printResults() {
public final void printResults() {
if(rankingDistributionCount == 0) rankingDistributionCount = 1;
if(DHTSelectionWordsTimeCount == 0) DHTSelectionWordsTimeCount = 1;
if(indexedSites != 0) indexedSites++;

@ -31,7 +31,7 @@ import java.util.logging.LogManager;
import java.util.logging.LogRecord;
public class LogalizerHandler extends Handler {
public final class LogalizerHandler extends Handler {
public static boolean enabled=false;
public static boolean debug=false;
@ -46,7 +46,7 @@ public class LogalizerHandler extends Handler {
if(manager.getProperty(className + ".debug").equalsIgnoreCase("true")) debug = true;
}
public void publish(final LogRecord record) {
public final void publish(final LogRecord record) {
if (enabled) {
final LogParser temp = new LogParser();
if (temp != null) try {
@ -58,13 +58,13 @@ public class LogalizerHandler extends Handler {
flush();
}
public Hashtable<String, Object> getParserResults(final LogParser parsername) {
public final Hashtable<String, Object> getParserResults(final LogParser parsername) {
return (parsername == null) ? null : parsername.getResults();
}
public void close() throws SecurityException {
public final void close() throws SecurityException {
}
public void flush() {
public final void flush() {
}
}

@ -36,7 +36,7 @@ public final class MiniLogFormatter extends SimpleFormatter {
super();
}
public synchronized String format(final LogRecord record) {
public final synchronized String format(final LogRecord record) {
final StringBuilder buffer = this.buffer;
buffer.setLength(0);

@ -34,7 +34,7 @@ import java.util.logging.LogRecord;
import java.util.logging.SimpleFormatter;
public class SimpleLogFormatter extends SimpleFormatter {
public final class SimpleLogFormatter extends SimpleFormatter {
private final Date date = new Date();
@ -50,7 +50,7 @@ public class SimpleLogFormatter extends SimpleFormatter {
super();
}
public synchronized String format(final LogRecord record) {
public final synchronized String format(final LogRecord record) {
final StringBuffer buffer = this.buffer;
buffer.setLength(0);

Loading…
Cancel
Save