finished core

This commit is contained in:
dev
2008-11-09 10:09:01 +00:00
parent 7bf57870d6
commit c9d9a83f73
29 changed files with 155 additions and 15 deletions

View File

@ -51,6 +51,7 @@ public class BufferedStatLog implements StatLog {
writer.start(); writer.start();
} }
@Override
public void addData(String scope, String stat, long value, long duration) { public void addData(String scope, String stat, long value, long duration) {
if (DISABLE_LOGGING) return; if (DISABLE_LOGGING) return;
if (!shouldLog(stat)) return; if (!shouldLog(stat)) return;
@ -122,6 +123,7 @@ public class BufferedStatLog implements StatLog {
private class StatLogWriter implements Runnable { private class StatLogWriter implements Runnable {
private SimpleDateFormat _fmt = new SimpleDateFormat("yyyyMMdd HH:mm:ss.SSS"); private SimpleDateFormat _fmt = new SimpleDateFormat("yyyyMMdd HH:mm:ss.SSS");
@Override
public void run() { public void run() {
int writeStart = -1; int writeStart = -1;
int writeEnd = -1; int writeEnd = -1;

View File

@ -436,6 +436,7 @@ public class Rate {
coalesce(); coalesce();
} }
@Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if ((obj == null) || (obj.getClass() != Rate.class)) return false; if ((obj == null) || (obj.getClass() != Rate.class)) return false;
if (obj == this) return true; if (obj == this) return true;
@ -451,6 +452,7 @@ public class Rate {
&& _lifetimeTotalEventTime == r.getLifetimeTotalEventTime(); && _lifetimeTotalEventTime == r.getLifetimeTotalEventTime();
} }
@Override
public String toString() { public String toString() {
StringBuffer buf = new StringBuffer(2048); StringBuffer buf = new StringBuffer(2048);
buf.append("\n\t total value: ").append(getLastTotalValue()); buf.append("\n\t total value: ").append(getLastTotalValue());

View File

@ -84,12 +84,14 @@ public class RateStat {
return null; return null;
} }
@Override
public int hashCode() { public int hashCode() {
return _statName.hashCode(); return _statName.hashCode();
} }
private final static String NL = System.getProperty("line.separator"); private final static String NL = System.getProperty("line.separator");
@Override
public String toString() { public String toString() {
StringBuffer buf = new StringBuffer(4096); StringBuffer buf = new StringBuffer(4096);
buf.append(getGroupName()).append('.').append(getName()).append(": ").append(getDescription()).append('\n'); buf.append(getGroupName()).append('.').append(getName()).append(": ").append(getDescription()).append('\n');
@ -104,6 +106,7 @@ public class RateStat {
return buf.toString(); return buf.toString();
} }
@Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if ((obj == null) || (obj.getClass() != RateStat.class)) return false; if ((obj == null) || (obj.getClass() != RateStat.class)) return false;
RateStat rs = (RateStat) obj; RateStat rs = (RateStat) obj;

View File

@ -328,6 +328,7 @@ public class NtpMessage {
/** /**
* Returns a string representation of a NtpMessage * Returns a string representation of a NtpMessage
*/ */
@Override
public String toString() { public String toString() {
String precisionStr = new DecimalFormat("0.#E0").format(Math.pow(2, precision)); String precisionStr = new DecimalFormat("0.#E0").format(Math.pow(2, precision));

View File

@ -110,6 +110,7 @@ public class Timestamper implements Runnable {
} catch (InterruptedException ie) {} } catch (InterruptedException ie) {}
} }
@Override
public void run() { public void run() {
try { Thread.sleep(1000); } catch (InterruptedException ie) {} try { Thread.sleep(1000); } catch (InterruptedException ie) {}
_log = _context.logManager().getLog(Timestamper.class); _log = _context.logManager().getLog(Timestamper.class);

View File

@ -113,6 +113,7 @@ public class BufferedRandomSource extends RandomSource {
} }
} }
@Override
public synchronized final void nextBytes(byte buf[]) { public synchronized final void nextBytes(byte buf[]) {
int outOffset = 0; int outOffset = 0;
while (outOffset < buf.length) { while (outOffset < buf.length) {
@ -128,6 +129,7 @@ public class BufferedRandomSource extends RandomSource {
} }
} }
@Override
public final int nextInt(int n) { public final int nextInt(int n) {
if (n <= 0) return 0; if (n <= 0) return 0;
int val = ((int)nextBits(countBits(n))) % n; int val = ((int)nextBits(countBits(n))) % n;
@ -137,12 +139,14 @@ public class BufferedRandomSource extends RandomSource {
return val; return val;
} }
@Override
public final int nextInt() { return nextInt(Integer.MAX_VALUE); } public final int nextInt() { return nextInt(Integer.MAX_VALUE); }
/** /**
* Like the modified nextInt, nextLong(n) returns a random number from 0 through n, * Like the modified nextInt, nextLong(n) returns a random number from 0 through n,
* including 0, excluding n. * including 0, excluding n.
*/ */
@Override
public final long nextLong(long n) { public final long nextLong(long n) {
if (n <= 0) return 0; if (n <= 0) return 0;
long val = nextBits(countBits(n)) % n; long val = nextBits(countBits(n)) % n;
@ -152,6 +156,7 @@ public class BufferedRandomSource extends RandomSource {
return val; return val;
} }
@Override
public final long nextLong() { return nextLong(Long.MAX_VALUE); } public final long nextLong() { return nextLong(Long.MAX_VALUE); }
static final int countBits(long val) { static final int countBits(long val) {
@ -172,22 +177,26 @@ public class BufferedRandomSource extends RandomSource {
* override as synchronized, for those JVMs that don't always pull via * override as synchronized, for those JVMs that don't always pull via
* nextBytes (cough ibm) * nextBytes (cough ibm)
*/ */
@Override
public final boolean nextBoolean() { public final boolean nextBoolean() {
return nextBits(1) != 0; return nextBits(1) != 0;
} }
private static final double DOUBLE_DENOMENATOR = (double)(1L << 53); private static final double DOUBLE_DENOMENATOR = (double)(1L << 53);
/** defined per javadoc ( ((nextBits(26)<<27) + nextBits(27)) / (1 << 53)) */ /** defined per javadoc ( ((nextBits(26)<<27) + nextBits(27)) / (1 << 53)) */
@Override
public final double nextDouble() { public final double nextDouble() {
long top = (((long)nextBits(26) << 27) + nextBits(27)); long top = (((long)nextBits(26) << 27) + nextBits(27));
return top / DOUBLE_DENOMENATOR; return top / DOUBLE_DENOMENATOR;
} }
private static final float FLOAT_DENOMENATOR = (float)(1 << 24); private static final float FLOAT_DENOMENATOR = (float)(1 << 24);
/** defined per javadoc (nextBits(24) / ((float)(1 << 24)) ) */ /** defined per javadoc (nextBits(24) / ((float)(1 << 24)) ) */
@Override
public float nextFloat() { public float nextFloat() {
long top = nextBits(24); long top = nextBits(24);
return top / FLOAT_DENOMENATOR; return top / FLOAT_DENOMENATOR;
} }
@Override
public double nextGaussian() { public double nextGaussian() {
// bah, unbuffered // bah, unbuffered
return super.nextGaussian(); return super.nextGaussian();

View File

@ -108,6 +108,7 @@ public final class ByteCache {
} }
private class Cleanup implements SimpleTimer.TimedEvent { private class Cleanup implements SimpleTimer.TimedEvent {
@Override
public void timeReached() { public void timeReached() {
if (System.currentTimeMillis() - _lastOverflow > EXPIRE_PERIOD) { if (System.currentTimeMillis() - _lastOverflow > EXPIRE_PERIOD) {
// we haven't exceeded the cache size in a few minutes, so lets // we haven't exceeded the cache size in a few minutes, so lets

View File

@ -110,6 +110,7 @@ public class Clock implements Timestamper.UpdateListener {
public boolean getUpdatedSuccessfully() { return _alreadyChanged; } public boolean getUpdatedSuccessfully() { return _alreadyChanged; }
@Override
public void setNow(long realTime) { public void setNow(long realTime) {
long diff = realTime - System.currentTimeMillis(); long diff = realTime - System.currentTimeMillis();
setOffset(diff); setOffset(diff);

View File

@ -206,6 +206,7 @@ public class DecayingBloomFilter {
} }
private class DecayEvent implements SimpleTimer.TimedEvent { private class DecayEvent implements SimpleTimer.TimedEvent {
@Override
public void timeReached() { public void timeReached() {
if (_keepDecaying) { if (_keepDecaying) {
decay(); decay();

View File

@ -262,6 +262,7 @@ public class EepGet {
_startedOn = _lastComplete; _startedOn = _lastComplete;
_firstTime = true; _firstTime = true;
} }
@Override
public void bytesTransferred(long alreadyTransferred, int currentWrite, long bytesTransferred, long bytesRemaining, String url) { public void bytesTransferred(long alreadyTransferred, int currentWrite, long bytesTransferred, long bytesRemaining, String url) {
if (_firstTime) { if (_firstTime) {
if (alreadyTransferred > 0) { if (alreadyTransferred > 0) {
@ -318,6 +319,7 @@ public class EepGet {
} }
} }
} }
@Override
public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile, boolean notModified) { public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile, boolean notModified) {
long transferred; long transferred;
if (_firstTime) if (_firstTime)
@ -356,6 +358,7 @@ public class EepGet {
System.out.println(buf.toString()); System.out.println(buf.toString());
} }
} }
@Override
public void attemptFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt, int numRetries, Exception cause) { public void attemptFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt, int numRetries, Exception cause) {
System.out.println(); System.out.println();
System.out.println("** " + new Date()); System.out.println("** " + new Date());
@ -366,6 +369,7 @@ public class EepGet {
_previousWritten += _written; _previousWritten += _written;
_written = 0; _written = 0;
} }
@Override
public void transferFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt) { public void transferFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt) {
System.out.println("== " + new Date()); System.out.println("== " + new Date());
System.out.println("== Transfer of " + url + " failed after " + currentAttempt + " attempts"); System.out.println("== Transfer of " + url + " failed after " + currentAttempt + " attempts");
@ -382,7 +386,9 @@ public class EepGet {
buf.append("KBps"); buf.append("KBps");
System.out.println(buf.toString()); System.out.println(buf.toString());
} }
@Override
public void attempting(String url) {} public void attempting(String url) {}
@Override
public void headerReceived(String url, int currentAttempt, String key, String val) {} public void headerReceived(String url, int currentAttempt, String key, String val) {}
} }
@ -418,6 +424,7 @@ public class EepGet {
timeout = new SocketTimeout(_fetchHeaderTimeout); timeout = new SocketTimeout(_fetchHeaderTimeout);
final SocketTimeout stimeout = timeout; // ugly final SocketTimeout stimeout = timeout; // ugly
timeout.setTimeoutCommand(new Runnable() { timeout.setTimeoutCommand(new Runnable() {
@Override
public void run() { public void run() {
if (_log.shouldLog(Log.DEBUG)) if (_log.shouldLog(Log.DEBUG))
_log.debug("timeout reached on " + _url + ": " + stimeout); _log.debug("timeout reached on " + _url + ": " + stimeout);

View File

@ -29,7 +29,12 @@ public class EepGetScheduler implements EepGet.StatusListener {
} }
public void fetch() { public void fetch() {
I2PThread t = new I2PThread(new Runnable() { public void run() { fetchNext(); } }, "EepGetScheduler"); I2PThread t = new I2PThread(new Runnable() {
@Override
public void run() {
fetchNext();
}
}, "EepGetScheduler");
t.setDaemon(true); t.setDaemon(true);
t.start(); t.start();
} }
@ -62,24 +67,30 @@ public class EepGetScheduler implements EepGet.StatusListener {
get.fetch(); get.fetch();
} }
@Override
public void attemptFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt, int numRetries, Exception cause) { public void attemptFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt, int numRetries, Exception cause) {
_listener.attemptFailed(url, bytesTransferred, bytesRemaining, currentAttempt, numRetries, cause); _listener.attemptFailed(url, bytesTransferred, bytesRemaining, currentAttempt, numRetries, cause);
} }
@Override
public void bytesTransferred(long alreadyTransferred, int currentWrite, long bytesTransferred, long bytesRemaining, String url) { public void bytesTransferred(long alreadyTransferred, int currentWrite, long bytesTransferred, long bytesRemaining, String url) {
_listener.bytesTransferred(alreadyTransferred, currentWrite, bytesTransferred, bytesRemaining, url); _listener.bytesTransferred(alreadyTransferred, currentWrite, bytesTransferred, bytesRemaining, url);
} }
@Override
public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile, boolean notModified) { public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile, boolean notModified) {
_listener.transferComplete(alreadyTransferred, bytesTransferred, bytesRemaining, url, outputFile, notModified); _listener.transferComplete(alreadyTransferred, bytesTransferred, bytesRemaining, url, outputFile, notModified);
fetchNext(); fetchNext();
} }
@Override
public void transferFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt) { public void transferFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt) {
_listener.transferFailed(url, bytesTransferred, bytesRemaining, currentAttempt); _listener.transferFailed(url, bytesTransferred, bytesRemaining, currentAttempt);
fetchNext(); fetchNext();
} }
@Override
public void attempting(String url) { _listener.attempting(url); } public void attempting(String url) { _listener.attempting(url); }
@Override
public void headerReceived(String url, int attemptNum, String key, String val) {} public void headerReceived(String url, int attemptNum, String key, String val) {}
} }

View File

@ -73,6 +73,7 @@ public class EepPost {
_fields = fields; _fields = fields;
_onCompletion = onCompletion; _onCompletion = onCompletion;
} }
@Override
public void run() { public void run() {
if (_log.shouldLog(Log.DEBUG)) _log.debug("Running the post task"); if (_log.shouldLog(Log.DEBUG)) _log.debug("Running the post task");
Socket s = null; Socket s = null;

View File

@ -38,10 +38,12 @@ public class EventDispatcherImpl implements EventDispatcher {
private HashMap _events = new HashMap(4); private HashMap _events = new HashMap(4);
private ArrayList _attached = new ArrayList(); private ArrayList _attached = new ArrayList();
@Override
public EventDispatcher getEventDispatcher() { public EventDispatcher getEventDispatcher() {
return this; return this;
} }
@Override
public void attachEventDispatcher(EventDispatcher ev) { public void attachEventDispatcher(EventDispatcher ev) {
if (ev == null) return; if (ev == null) return;
synchronized (_attached) { synchronized (_attached) {
@ -50,6 +52,7 @@ public class EventDispatcherImpl implements EventDispatcher {
} }
} }
@Override
public void detachEventDispatcher(EventDispatcher ev) { public void detachEventDispatcher(EventDispatcher ev) {
if (ev == null) return; if (ev == null) return;
synchronized (_attached) { synchronized (_attached) {
@ -63,6 +66,7 @@ public class EventDispatcherImpl implements EventDispatcher {
} }
} }
@Override
public void notifyEvent(String eventName, Object args) { public void notifyEvent(String eventName, Object args) {
if (_ignore) return; if (_ignore) return;
if (args == null) { if (args == null) {
@ -85,6 +89,7 @@ public class EventDispatcherImpl implements EventDispatcher {
} }
} }
@Override
public Object getEventValue(String name) { public Object getEventValue(String name) {
if (_ignore) return null; if (_ignore) return null;
Object val; Object val;
@ -107,6 +112,7 @@ public class EventDispatcherImpl implements EventDispatcher {
return set; return set;
} }
@Override
public void ignoreEvents() { public void ignoreEvents() {
_ignore = true; _ignore = true;
synchronized (_events) { synchronized (_events) {
@ -115,10 +121,12 @@ public class EventDispatcherImpl implements EventDispatcher {
_events = null; _events = null;
} }
@Override
public void unIgnoreEvents() { public void unIgnoreEvents() {
_ignore = false; _ignore = false;
} }
@Override
public Object waitEventValue(String name) { public Object waitEventValue(String name) {
if (_ignore) return null; if (_ignore) return null;
Object val; Object val;

View File

@ -16,6 +16,7 @@ class Executor implements Runnable {
runn = x; runn = x;
} }
@Override
public void run() { public void run() {
while(runn.getAnswer()) { while(runn.getAnswer()) {
SimpleTimer.TimedEvent evt = null; SimpleTimer.TimedEvent evt = null;

View File

@ -44,6 +44,7 @@ public class FortunaRandomSource extends RandomSource implements EntropyHarveste
_haveNextGaussian = false; _haveNextGaussian = false;
} }
@Override
public synchronized void setSeed(byte buf[]) { public synchronized void setSeed(byte buf[]) {
_fortuna.addRandomBytes(buf); _fortuna.addRandomBytes(buf);
} }
@ -56,6 +57,7 @@ public class FortunaRandomSource extends RandomSource implements EntropyHarveste
* thats what it has been used for. * thats what it has been used for.
* *
*/ */
@Override
public int nextInt(int n) { public int nextInt(int n) {
if (n == 0) return 0; if (n == 0) return 0;
int rv = signedNextInt(n); int rv = signedNextInt(n);
@ -65,6 +67,7 @@ public class FortunaRandomSource extends RandomSource implements EntropyHarveste
return rv; return rv;
} }
@Override
public int nextInt() { return signedNextInt(Integer.MAX_VALUE); } public int nextInt() { return signedNextInt(Integer.MAX_VALUE); }
/** /**
@ -107,6 +110,7 @@ public class FortunaRandomSource extends RandomSource implements EntropyHarveste
* Like the modified nextInt, nextLong(n) returns a random number from 0 through n, * Like the modified nextInt, nextLong(n) returns a random number from 0 through n,
* including 0, excluding n. * including 0, excluding n.
*/ */
@Override
public long nextLong(long n) { public long nextLong(long n) {
if (n == 0) return 0; if (n == 0) return 0;
long rv = signedNextLong(n); long rv = signedNextLong(n);
@ -116,6 +120,7 @@ public class FortunaRandomSource extends RandomSource implements EntropyHarveste
return rv; return rv;
} }
@Override
public long nextLong() { return signedNextLong(Long.MAX_VALUE); } public long nextLong() { return signedNextLong(Long.MAX_VALUE); }
/** /**
@ -125,12 +130,14 @@ public class FortunaRandomSource extends RandomSource implements EntropyHarveste
return ((long)nextBits(32) << 32) + nextBits(32); return ((long)nextBits(32) << 32) + nextBits(32);
} }
@Override
public synchronized boolean nextBoolean() { public synchronized boolean nextBoolean() {
// wasteful, might be worth caching the boolean byte later // wasteful, might be worth caching the boolean byte later
byte val = _fortuna.nextByte(); byte val = _fortuna.nextByte();
return ((val & 0x01) == 1); return ((val & 0x01) == 1);
} }
@Override
public synchronized void nextBytes(byte buf[]) { public synchronized void nextBytes(byte buf[]) {
_fortuna.nextBytes(buf); _fortuna.nextBytes(buf);
} }
@ -138,18 +145,21 @@ public class FortunaRandomSource extends RandomSource implements EntropyHarveste
/** /**
* Implementation from sun's java.util.Random javadocs * Implementation from sun's java.util.Random javadocs
*/ */
@Override
public double nextDouble() { public double nextDouble() {
return (((long)nextBits(26) << 27) + nextBits(27)) / (double)(1L << 53); return (((long)nextBits(26) << 27) + nextBits(27)) / (double)(1L << 53);
} }
/** /**
* Implementation from sun's java.util.Random javadocs * Implementation from sun's java.util.Random javadocs
*/ */
@Override
public float nextFloat() { public float nextFloat() {
return nextBits(24) / ((float)(1 << 24)); return nextBits(24) / ((float)(1 << 24));
} }
/** /**
* Implementation from sun's java.util.Random javadocs * Implementation from sun's java.util.Random javadocs
*/ */
@Override
public synchronized double nextGaussian() { public synchronized double nextGaussian() {
if (_haveNextGaussian) { if (_haveNextGaussian) {
_haveNextGaussian = false; _haveNextGaussian = false;
@ -185,14 +195,17 @@ public class FortunaRandomSource extends RandomSource implements EntropyHarveste
return (int)rv; return (int)rv;
} }
@Override
public EntropyHarvester harvester() { return this; } public EntropyHarvester harvester() { return this; }
/** reseed the fortuna */ /** reseed the fortuna */
@Override
public synchronized void feedEntropy(String source, long data, int bitoffset, int bits) { public synchronized void feedEntropy(String source, long data, int bitoffset, int bits) {
_fortuna.addRandomByte((byte)(data & 0xFF)); _fortuna.addRandomByte((byte)(data & 0xFF));
} }
/** reseed the fortuna */ /** reseed the fortuna */
@Override
public synchronized void feedEntropy(String source, byte[] data, int offset, int len) { public synchronized void feedEntropy(String source, byte[] data, int offset, int len) {
_fortuna.addRandomBytes(data, offset, len); _fortuna.addRandomBytes(data, offset, len);
} }

View File

@ -63,6 +63,7 @@ public class I2PThread extends Thread {
_log.log(level, msg, t); _log.log(level, msg, t);
} }
@Override
public void run() { public void run() {
_name = Thread.currentThread().getName(); _name = Thread.currentThread().getName();
log(Log.DEBUG, "New thread started: " + _name, _createdBy); log(Log.DEBUG, "New thread started: " + _name, _createdBy);
@ -81,6 +82,7 @@ public class I2PThread extends Thread {
log(Log.DEBUG, "Thread finished gracefully: " + _name); log(Log.DEBUG, "Thread finished gracefully: " + _name);
} }
@Override
protected void finalize() throws Throwable { protected void finalize() throws Throwable {
log(Log.DEBUG, "Thread finalized: " + _name); log(Log.DEBUG, "Thread finalized: " + _name);
super.finalize(); super.finalize();
@ -109,6 +111,7 @@ public class I2PThread extends Thread {
public static void main(String args[]) { public static void main(String args[]) {
I2PThread t = new I2PThread(new Runnable() { I2PThread t = new I2PThread(new Runnable() {
@Override
public void run() { public void run() {
throw new NullPointerException("blah"); throw new NullPointerException("blah");
} }

View File

@ -183,9 +183,11 @@ public class Log {
_scopeClass = cls; _scopeClass = cls;
_scopeCache = getScope(name, cls); _scopeCache = getScope(name, cls);
} }
@Override
public int hashCode() { public int hashCode() {
return _scopeCache.hashCode(); return _scopeCache.hashCode();
} }
@Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == null) throw new NullPointerException("Null object scope?"); if (obj == null) throw new NullPointerException("Null object scope?");
if (obj instanceof LogScope) { if (obj instanceof LogScope) {

View File

@ -655,6 +655,7 @@ public class LogManager {
public ShutdownHook() { public ShutdownHook() {
_id = ++__id; _id = ++__id;
} }
@Override
public void run() { public void run() {
setName("Log " + _id + " shutdown "); setName("Log " + _id + " shutdown ");
shutdown(); shutdown();

View File

@ -44,6 +44,7 @@ class LogWriter implements Runnable {
_write = false; _write = false;
} }
@Override
public void run() { public void run() {
_write = true; _write = true;
try { try {

View File

@ -38,6 +38,7 @@ public class LookaheadInputStream extends FilterInputStream {
boolean f = true; boolean f = true;
} }
@Override
public int read() throws IOException { public int read() throws IOException {
if (_eofReached) if (_eofReached)
return -1; //throw new IOException("Already past the EOF"); return -1; //throw new IOException("Already past the EOF");
@ -52,9 +53,11 @@ public class LookaheadInputStream extends FilterInputStream {
if (rv < 0) rv += 256; if (rv < 0) rv += 256;
return rv; return rv;
} }
@Override
public int read(byte buf[]) throws IOException { public int read(byte buf[]) throws IOException {
return read(buf, 0, buf.length); return read(buf, 0, buf.length);
} }
@Override
public int read(byte buf[], int off, int len) throws IOException { public int read(byte buf[], int off, int len) throws IOException {
if (_eofReached) if (_eofReached)
return -1; return -1;

View File

@ -221,18 +221,21 @@ public class NativeBigInteger extends BigInteger {
this(integer.toByteArray()); this(integer.toByteArray());
} }
@Override
public BigInteger modPow(BigInteger exponent, BigInteger m) { public BigInteger modPow(BigInteger exponent, BigInteger m) {
if (_nativeOk) if (_nativeOk)
return new NativeBigInteger(nativeModPow(toByteArray(), exponent.toByteArray(), m.toByteArray())); return new NativeBigInteger(nativeModPow(toByteArray(), exponent.toByteArray(), m.toByteArray()));
else else
return super.modPow(exponent, m); return super.modPow(exponent, m);
} }
@Override
public byte[] toByteArray(){ public byte[] toByteArray(){
if(cachedBa == null) //Since we are immutable it is safe to never update the cached ba after it has initially been generated if(cachedBa == null) //Since we are immutable it is safe to never update the cached ba after it has initially been generated
cachedBa = super.toByteArray(); cachedBa = super.toByteArray();
return cachedBa; return cachedBa;
} }
@Override
public double doubleValue() { public double doubleValue() {
if (_nativeOk) if (_nativeOk)
return nativeDoubleValue(toByteArray()); return nativeDoubleValue(toByteArray());

View File

@ -48,22 +48,26 @@ public class OrderedProperties extends Properties {
_data = new HashMap(); _data = new HashMap();
} }
@Override
public boolean contains(Object value) { public boolean contains(Object value) {
return containsValue(value); return containsValue(value);
} }
@Override
public boolean containsKey(Object key) { public boolean containsKey(Object key) {
synchronized (_lock) { synchronized (_lock) {
return _data.containsKey(key); return _data.containsKey(key);
} }
} }
@Override
public boolean containsValue(Object value) { public boolean containsValue(Object value) {
synchronized (_lock) { synchronized (_lock) {
return _data.containsValue(value); return _data.containsValue(value);
} }
} }
@Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if ((obj != null) && (obj instanceof OrderedProperties)) { if ((obj != null) && (obj instanceof OrderedProperties)) {
synchronized (_lock) { synchronized (_lock) {
@ -74,20 +78,24 @@ public class OrderedProperties extends Properties {
return false; return false;
} }
@Override
public int hashCode() { public int hashCode() {
synchronized (_lock) { synchronized (_lock) {
return _data.hashCode(); return _data.hashCode();
} }
} }
@Override
public boolean isEmpty() { public boolean isEmpty() {
return size() == 0; return size() == 0;
} }
@Override
public String getProperty(String key) { public String getProperty(String key) {
return getProperty((Object) key); return getProperty((Object) key);
} }
@Override
public Object get(Object key) { public Object get(Object key) {
return getProperty(key); return getProperty(key);
} }
@ -102,6 +110,7 @@ public class OrderedProperties extends Properties {
} }
} }
@Override
public Object setProperty(String key, String val) { public Object setProperty(String key, String val) {
if ((key == null) || (val == null)) throw new IllegalArgumentException("Null values are not supported"); if ((key == null) || (val == null)) throw new IllegalArgumentException("Null values are not supported");
synchronized (_lock) { synchronized (_lock) {
@ -111,6 +120,7 @@ public class OrderedProperties extends Properties {
} }
} }
@Override
public Object put(Object key, Object val) { public Object put(Object key, Object val) {
if ((key == null) || (val == null)) throw new NullPointerException("Null values or keys are not allowed"); if ((key == null) || (val == null)) throw new NullPointerException("Null values or keys are not allowed");
if (!(key instanceof String) || !(val instanceof String)) if (!(key instanceof String) || !(val instanceof String))
@ -118,6 +128,7 @@ public class OrderedProperties extends Properties {
return setProperty((String) key, (String) val); return setProperty((String) key, (String) val);
} }
@Override
public void putAll(Map data) { public void putAll(Map data) {
if (data == null) return; if (data == null) return;
for (Iterator iter = data.entrySet().iterator(); iter.hasNext();) { for (Iterator iter = data.entrySet().iterator(); iter.hasNext();) {
@ -128,6 +139,7 @@ public class OrderedProperties extends Properties {
} }
} }
@Override
public Object clone() { public Object clone() {
synchronized (_lock) { synchronized (_lock) {
OrderedProperties rv = new OrderedProperties(); OrderedProperties rv = new OrderedProperties();
@ -136,6 +148,7 @@ public class OrderedProperties extends Properties {
} }
} }
@Override
public void clear() { public void clear() {
synchronized (_lock) { synchronized (_lock) {
_order.clear(); _order.clear();
@ -143,12 +156,14 @@ public class OrderedProperties extends Properties {
} }
} }
@Override
public int size() { public int size() {
synchronized (_lock) { synchronized (_lock) {
return _order.size(); return _order.size();
} }
} }
@Override
public Object remove(Object key) { public Object remove(Object key) {
synchronized (_lock) { synchronized (_lock) {
_order.remove(key); _order.remove(key);
@ -157,18 +172,21 @@ public class OrderedProperties extends Properties {
} }
} }
@Override
public Set keySet() { public Set keySet() {
synchronized (_lock) { synchronized (_lock) {
return Collections.unmodifiableSortedSet((TreeSet) _order.clone()); return Collections.unmodifiableSortedSet((TreeSet) _order.clone());
} }
} }
@Override
public Set entrySet() { public Set entrySet() {
synchronized (_lock) { synchronized (_lock) {
return Collections.unmodifiableSet(buildEntrySet((TreeSet) _order.clone())); return Collections.unmodifiableSet(buildEntrySet((TreeSet) _order.clone()));
} }
} }
@Override
public Collection values() { public Collection values() {
synchronized (_lock) { synchronized (_lock) {
Collection values = new ArrayList(_data.size()); Collection values = new ArrayList(_data.size());
@ -179,28 +197,35 @@ public class OrderedProperties extends Properties {
} }
} }
@Override
public Enumeration elements() { public Enumeration elements() {
return Collections.enumeration(values()); return Collections.enumeration(values());
} }
@Override
public Enumeration keys() { public Enumeration keys() {
return Collections.enumeration(keySet()); return Collections.enumeration(keySet());
} }
@Override
public Enumeration propertyNames() { public Enumeration propertyNames() {
return Collections.enumeration(keySet()); return Collections.enumeration(keySet());
} }
@Override
public void list(PrintStream out) { // nop public void list(PrintStream out) { // nop
} }
@Override
public void list(PrintWriter out) { // nop public void list(PrintWriter out) { // nop
} }
@Override
public void load(InputStream in) { // nop public void load(InputStream in) { // nop
} }
//public void save(OutputStream out, String header) {} //public void save(OutputStream out, String header) {}
@Override
public void store(OutputStream out, String header) { // nop public void store(OutputStream out, String header) { // nop
} }
@ -223,20 +248,24 @@ public class OrderedProperties extends Properties {
_value = val; _value = val;
} }
@Override
public Object getKey() { public Object getKey() {
return _key; return _key;
} }
@Override
public Object getValue() { public Object getValue() {
return _value; return _value;
} }
@Override
public Object setValue(Object value) { public Object setValue(Object value) {
Object old = _value; Object old = _value;
_value = value; _value = value;
return old; return old;
} }
@Override
public int compareTo(Object o) { public int compareTo(Object o) {
if (o == null) return -1; if (o == null) return -1;
if (o instanceof StringMapEntry) return ((String) getKey()).compareTo((String)((StringMapEntry) o).getKey()); if (o instanceof StringMapEntry) return ((String) getKey()).compareTo((String)((StringMapEntry) o).getKey());
@ -244,6 +273,7 @@ public class OrderedProperties extends Properties {
return -2; return -2;
} }
@Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (o == null) return false; if (o == null) return false;
if (!(o instanceof StringMapEntry)) return false; if (!(o instanceof StringMapEntry)) return false;
@ -329,6 +359,7 @@ public class OrderedProperties extends Properties {
_props = props; _props = props;
} }
@Override
public void run() { public void run() {
int numRuns = 1000; int numRuns = 1000;
_log.debug("Begin thrashing " + numRuns + " times"); _log.debug("Begin thrashing " + numRuns + " times");

View File

@ -89,6 +89,7 @@ public class PooledRandomSource extends RandomSource {
* thats what it has been used for. * thats what it has been used for.
* *
*/ */
@Override
public int nextInt(int n) { public int nextInt(int n) {
RandomSource prng = pickPRNG(); RandomSource prng = pickPRNG();
synchronized (prng) { synchronized (prng) {
@ -100,6 +101,7 @@ public class PooledRandomSource extends RandomSource {
* Like the modified nextInt, nextLong(n) returns a random number from 0 through n, * Like the modified nextInt, nextLong(n) returns a random number from 0 through n,
* including 0, excluding n. * including 0, excluding n.
*/ */
@Override
public long nextLong(long n) { public long nextLong(long n) {
RandomSource prng = pickPRNG(); RandomSource prng = pickPRNG();
synchronized (prng) { synchronized (prng) {
@ -111,6 +113,7 @@ public class PooledRandomSource extends RandomSource {
* override as synchronized, for those JVMs that don't always pull via * override as synchronized, for those JVMs that don't always pull via
* nextBytes (cough ibm) * nextBytes (cough ibm)
*/ */
@Override
public boolean nextBoolean() { public boolean nextBoolean() {
RandomSource prng = pickPRNG(); RandomSource prng = pickPRNG();
synchronized (prng) { synchronized (prng) {
@ -121,6 +124,7 @@ public class PooledRandomSource extends RandomSource {
* override as synchronized, for those JVMs that don't always pull via * override as synchronized, for those JVMs that don't always pull via
* nextBytes (cough ibm) * nextBytes (cough ibm)
*/ */
@Override
public void nextBytes(byte buf[]) { public void nextBytes(byte buf[]) {
RandomSource prng = pickPRNG(); RandomSource prng = pickPRNG();
synchronized (prng) { synchronized (prng) {
@ -131,6 +135,7 @@ public class PooledRandomSource extends RandomSource {
* override as synchronized, for those JVMs that don't always pull via * override as synchronized, for those JVMs that don't always pull via
* nextBytes (cough ibm) * nextBytes (cough ibm)
*/ */
@Override
public double nextDouble() { public double nextDouble() {
RandomSource prng = pickPRNG(); RandomSource prng = pickPRNG();
synchronized (prng) { synchronized (prng) {
@ -141,6 +146,7 @@ public class PooledRandomSource extends RandomSource {
* override as synchronized, for those JVMs that don't always pull via * override as synchronized, for those JVMs that don't always pull via
* nextBytes (cough ibm) * nextBytes (cough ibm)
*/ */
@Override
public float nextFloat() { public float nextFloat() {
RandomSource prng = pickPRNG(); RandomSource prng = pickPRNG();
synchronized (prng) { synchronized (prng) {
@ -151,6 +157,7 @@ public class PooledRandomSource extends RandomSource {
* override as synchronized, for those JVMs that don't always pull via * override as synchronized, for those JVMs that don't always pull via
* nextBytes (cough ibm) * nextBytes (cough ibm)
*/ */
@Override
public double nextGaussian() { public double nextGaussian() {
RandomSource prng = pickPRNG(); RandomSource prng = pickPRNG();
synchronized (prng) { synchronized (prng) {
@ -161,6 +168,7 @@ public class PooledRandomSource extends RandomSource {
* override as synchronized, for those JVMs that don't always pull via * override as synchronized, for those JVMs that don't always pull via
* nextBytes (cough ibm) * nextBytes (cough ibm)
*/ */
@Override
public int nextInt() { public int nextInt() {
RandomSource prng = pickPRNG(); RandomSource prng = pickPRNG();
synchronized (prng) { synchronized (prng) {
@ -171,6 +179,7 @@ public class PooledRandomSource extends RandomSource {
* override as synchronized, for those JVMs that don't always pull via * override as synchronized, for those JVMs that don't always pull via
* nextBytes (cough ibm) * nextBytes (cough ibm)
*/ */
@Override
public long nextLong() { public long nextLong() {
RandomSource prng = pickPRNG(); RandomSource prng = pickPRNG();
synchronized (prng) { synchronized (prng) {
@ -178,6 +187,7 @@ public class PooledRandomSource extends RandomSource {
} }
} }
@Override
public EntropyHarvester harvester() { public EntropyHarvester harvester() {
RandomSource prng = pickPRNG(); RandomSource prng = pickPRNG();
return prng.harvester(); return prng.harvester();

View File

@ -49,6 +49,7 @@ public class RandomSource extends SecureRandom implements EntropyHarvester {
* thats what it has been used for. * thats what it has been used for.
* *
*/ */
@Override
public int nextInt(int n) { public int nextInt(int n) {
if (n == 0) return 0; if (n == 0) return 0;
int val = super.nextInt(n); int val = super.nextInt(n);
@ -72,45 +73,54 @@ public class RandomSource extends SecureRandom implements EntropyHarvester {
* override as synchronized, for those JVMs that don't always pull via * override as synchronized, for those JVMs that don't always pull via
* nextBytes (cough ibm) * nextBytes (cough ibm)
*/ */
@Override
public boolean nextBoolean() { return super.nextBoolean(); } public boolean nextBoolean() { return super.nextBoolean(); }
/** /**
* override as synchronized, for those JVMs that don't always pull via * override as synchronized, for those JVMs that don't always pull via
* nextBytes (cough ibm) * nextBytes (cough ibm)
*/ */
@Override
public void nextBytes(byte buf[]) { super.nextBytes(buf); } public void nextBytes(byte buf[]) { super.nextBytes(buf); }
/** /**
* override as synchronized, for those JVMs that don't always pull via * override as synchronized, for those JVMs that don't always pull via
* nextBytes (cough ibm) * nextBytes (cough ibm)
*/ */
@Override
public double nextDouble() { return super.nextDouble(); } public double nextDouble() { return super.nextDouble(); }
/** /**
* override as synchronized, for those JVMs that don't always pull via * override as synchronized, for those JVMs that don't always pull via
* nextBytes (cough ibm) * nextBytes (cough ibm)
*/ */
@Override
public float nextFloat() { return super.nextFloat(); } public float nextFloat() { return super.nextFloat(); }
/** /**
* override as synchronized, for those JVMs that don't always pull via * override as synchronized, for those JVMs that don't always pull via
* nextBytes (cough ibm) * nextBytes (cough ibm)
*/ */
@Override
public double nextGaussian() { return super.nextGaussian(); } public double nextGaussian() { return super.nextGaussian(); }
/** /**
* override as synchronized, for those JVMs that don't always pull via * override as synchronized, for those JVMs that don't always pull via
* nextBytes (cough ibm) * nextBytes (cough ibm)
*/ */
@Override
public int nextInt() { return super.nextInt(); } public int nextInt() { return super.nextInt(); }
/** /**
* override as synchronized, for those JVMs that don't always pull via * override as synchronized, for those JVMs that don't always pull via
* nextBytes (cough ibm) * nextBytes (cough ibm)
*/ */
@Override
public long nextLong() { return super.nextLong(); } public long nextLong() { return super.nextLong(); }
public EntropyHarvester harvester() { return _entropyHarvester; } public EntropyHarvester harvester() { return _entropyHarvester; }
@Override
public void feedEntropy(String source, long data, int bitoffset, int bits) { public void feedEntropy(String source, long data, int bitoffset, int bits) {
if (bitoffset == 0) if (bitoffset == 0)
setSeed(data); setSeed(data);
} }
@Override
public void feedEntropy(String source, byte[] data, int offset, int len) { public void feedEntropy(String source, byte[] data, int offset, int len) {
if ( (offset == 0) && (len == data.length) ) { if ( (offset == 0) && (len == data.length) ) {
setSeed(data); setSeed(data);

View File

@ -60,6 +60,7 @@ public class ResettableGZIPInputStream extends InflaterInputStream {
verifyHeader(); verifyHeader();
} }
@Override
public int read() throws IOException { public int read() throws IOException {
if (_complete) { if (_complete) {
// shortcircuit so the inflater doesn't try to refill // shortcircuit so the inflater doesn't try to refill
@ -73,9 +74,11 @@ public class ResettableGZIPInputStream extends InflaterInputStream {
return _buf1[0]; return _buf1[0];
} }
@Override
public int read(byte buf[]) throws IOException { public int read(byte buf[]) throws IOException {
return read(buf, 0, buf.length); return read(buf, 0, buf.length);
} }
@Override
public int read(byte buf[], int off, int len) throws IOException { public int read(byte buf[], int off, int len) throws IOException {
if (_complete) { if (_complete) {
// shortcircuit so the inflater doesn't try to refill // shortcircuit so the inflater doesn't try to refill

View File

@ -91,25 +91,30 @@ public class ResettableGZIPOutputStream extends DeflaterOutputStream {
} }
} }
@Override
public void close() throws IOException { public void close() throws IOException {
finish(); finish();
super.close(); super.close();
} }
@Override
public void finish() throws IOException { public void finish() throws IOException {
ensureHeaderIsWritten(); ensureHeaderIsWritten();
super.finish(); super.finish();
writeFooter(); writeFooter();
} }
@Override
public void write(int b) throws IOException { public void write(int b) throws IOException {
ensureHeaderIsWritten(); ensureHeaderIsWritten();
_crc32.update(b); _crc32.update(b);
_writtenSize++; _writtenSize++;
super.write(b); super.write(b);
} }
@Override
public void write(byte buf[]) throws IOException { public void write(byte buf[]) throws IOException {
write(buf, 0, buf.length); write(buf, 0, buf.length);
} }
@Override
public void write(byte buf[], int off, int len) throws IOException { public void write(byte buf[], int off, int len) throws IOException {
ensureHeaderIsWritten(); ensureHeaderIsWritten();
_crc32.update(buf, off, len); _crc32.update(buf, off, len);

View File

@ -47,6 +47,7 @@ public class ReusableGZIPOutputStream extends ResettableGZIPOutputStream {
_buffer = (ByteArrayOutputStream)out; _buffer = (ByteArrayOutputStream)out;
} }
/** clear the data so we can start again afresh */ /** clear the data so we can start again afresh */
@Override
public void reset() { public void reset() {
super.reset(); super.reset();
_buffer.reset(); _buffer.reset();

View File

@ -59,6 +59,7 @@ public class ShellCommand {
this.consumeOutput = consumeOutput; this.consumeOutput = consumeOutput;
} }
@Override
public void run() { public void run() {
_commandSuccessful = execute(shellCommand, consumeOutput, WAIT_FOR_EXIT_STATUS); _commandSuccessful = execute(shellCommand, consumeOutput, WAIT_FOR_EXIT_STATUS);
if (_isTimerRunning) { if (_isTimerRunning) {
@ -90,6 +91,7 @@ public class ShellCommand {
this.bufferedReader = new BufferedReader(inputStreamReader); this.bufferedReader = new BufferedReader(inputStreamReader);
} }
@Override
public void run() { public void run() {
String streamData; String streamData;
@ -123,6 +125,7 @@ public class ShellCommand {
this.bufferedReader = new BufferedReader(inputStreamReader); this.bufferedReader = new BufferedReader(inputStreamReader);
} }
@Override
public void run() { public void run() {
char[] buffer = new char[BUFFER_SIZE]; char[] buffer = new char[BUFFER_SIZE];
@ -159,6 +162,7 @@ public class ShellCommand {
this.bufferedWriter = new BufferedWriter(outputStreamWriter); this.bufferedWriter = new BufferedWriter(outputStreamWriter);
} }
@Override
public void run() { public void run() {
String input; String input;

View File

@ -56,6 +56,7 @@ public class SocketTimeout implements SimpleTimer.TimedEvent {
private static final SimpleDateFormat _fmt = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss.SSS"); private static final SimpleDateFormat _fmt = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss.SSS");
private static String ts(long when) { synchronized (_fmt) { return _fmt.format(new Date(when)); } } private static String ts(long when) { synchronized (_fmt) { return _fmt.format(new Date(when)); } }
@Override
public String toString() { public String toString() {
StringBuffer buf = new StringBuffer(); StringBuffer buf = new StringBuffer();
buf.append("started on "); buf.append("started on ");