cleanup: annotated a bunch of files

This commit is contained in:
dev
2008-11-08 22:46:42 +00:00
parent e0926b8ccd
commit c634e5005d
22 changed files with 117 additions and 41 deletions

View File

@ -32,17 +32,20 @@ public class I2PException extends Exception {
super(msg);
_source = source;
}
@Override
public void printStackTrace() {
if (_source != null) _source.printStackTrace();
super.printStackTrace();
}
@Override
public void printStackTrace(PrintStream ps) {
if (_source != null) _source.printStackTrace(ps);
super.printStackTrace(ps);
}
@Override
public void printStackTrace(PrintWriter pw) {
if (_source != null) _source.printStackTrace(pw);
super.printStackTrace(pw);

View File

@ -131,6 +131,7 @@ public class ATalk implements I2PSessionListener, Runnable {
* application is complete.
*
*/
@Override
public void run() {
try {
connect();
@ -241,6 +242,7 @@ public class ATalk implements I2PSessionListener, Runnable {
* message to the user.
*
*/
@Override
public void messageAvailable(I2PSession session, int msgId, long size) {
_log.debug("Message available: id = " + msgId + " size = " + size);
try {
@ -351,16 +353,19 @@ public class ATalk implements I2PSessionListener, Runnable {
}
/** required by {@link I2PSessionListener I2PSessionListener} to notify of disconnect */
@Override
public void disconnected(I2PSession session) {
_log.debug("Disconnected");
}
/** required by {@link I2PSessionListener I2PSessionListener} to notify of error */
@Override
public void errorOccurred(I2PSession session, String message, Throwable error) {
_log.debug("Error occurred: " + message, error);
}
/** required by {@link I2PSessionListener I2PSessionListener} to notify of abuse */
@Override
public void reportAbuse(I2PSession session, int severity) {
_log.debug("Abuse reported of severity " + severity);
}

View File

@ -22,7 +22,8 @@ class DisconnectMessageHandler extends HandlerImpl {
public DisconnectMessageHandler(I2PAppContext context) {
super(context, DisconnectMessage.MESSAGE_TYPE);
}
@Override
public void handleMessage(I2CPMessage message, I2PSessionImpl session) {
_log.debug("Handle message " + message);
session.destroySession(false);

View File

@ -27,7 +27,8 @@ abstract class HandlerImpl implements I2CPMessageHandler {
_type = type;
_log = new Log(getClass());
}
@Override
public int getType() {
return _type;
}

View File

@ -33,6 +33,7 @@ class I2PClientImpl implements I2PClient {
/**
* Create the destination with a null payload
*/
@Override
public Destination createDestination(OutputStream destKeyStream) throws I2PException, IOException {
Certificate cert = new Certificate();
cert.setCertificateType(Certificate.CERTIFICATE_TYPE_NULL);
@ -45,6 +46,7 @@ class I2PClientImpl implements I2PClient {
* the PrivateKey and SigningPrivateKey to the destKeyStream
*
*/
@Override
public Destination createDestination(OutputStream destKeyStream, Certificate cert) throws I2PException, IOException {
Destination d = new Destination();
d.setCertificate(cert);
@ -69,6 +71,7 @@ class I2PClientImpl implements I2PClient {
* Create a new session (though do not connect it yet)
*
*/
@Override
public I2PSession createSession(InputStream destKeyStream, Properties options) throws I2PSessionException {
return createSession(I2PAppContext.getGlobalContext(), destKeyStream, options);
}

View File

@ -231,6 +231,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
* @throws I2PSessionException if there is a configuration error or the router is
* not reachable
*/
@Override
public void connect() throws I2PSessionException {
_closed = false;
_availabilityNotifier.stopNotifying();
@ -303,6 +304,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
* notified the user that its available.
*
*/
@Override
public byte[] receiveMessage(int msgId) throws I2PSessionException {
int remaining = 0;
MessagePayloadMessage msg = null;
@ -321,6 +323,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
/**
* Report abuse with regards to the given messageId
*/
@Override
public void reportAbuse(int msgId, int severity) throws I2PSessionException {
if (isClosed()) throw new I2PSessionException(getPrefix() + "Already closed");
_producer.reportAbuse(this, msgId, severity);
@ -332,8 +335,10 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
* delivered successfully. make this wait for at least ACCEPTED
*
*/
@Override
public abstract boolean sendMessage(Destination dest, byte[] payload) throws I2PSessionException;
@Override
public abstract boolean sendMessage(Destination dest, byte[] payload, SessionKey keyUsed,
Set tagsSent) throws I2PSessionException;
@ -374,6 +379,8 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
private class VerifyUsage implements SimpleTimer.TimedEvent {
private Long _msgId;
public VerifyUsage(Long id) { _msgId = id; }
@Override
public void timeReached() {
MessagePayloadMessage removed = null;
int remaining = 0;
@ -412,6 +419,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
AvailabilityNotifier.this.notifyAll();
}
}
@Override
public void run() {
_alive = true;
while (_alive) {
@ -453,6 +461,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
* Recieve notification of some I2CP message and handle it if possible
*
*/
@Override
public void messageReceived(I2CPMessageReader reader, I2CPMessage message) {
I2CPMessageHandler handler = _handlerMap.getHandler(message.getType());
if (handler == null) {
@ -471,6 +480,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
* Recieve notifiation of an error reading the I2CP stream
*
*/
@Override
public void readError(I2CPMessageReader reader, Exception error) {
propogateError("There was an error reading data", error);
disconnect();
@ -479,16 +489,19 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
/**
* Retrieve the destination of the session
*/
@Override
public Destination getMyDestination() { return _myDestination; }
/**
* Retrieve the decryption PrivateKey
*/
@Override
public PrivateKey getDecryptionKey() { return _privateKey; }
/**
* Retrieve the signing SigningPrivateKey
*/
@Override
public SigningPrivateKey getPrivateKey() { return _signingPrivateKey; }
/**
@ -508,9 +521,11 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
void setSessionId(SessionId id) { _sessionId = id; }
/** configure the listener */
@Override
public void setSessionListener(I2PSessionListener lsnr) { _sessionListener = lsnr; }
/** has the session been closed (or not yet connected)? */
@Override
public boolean isClosed() { return _closed; }
/**
@ -560,6 +575,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
/**
* Tear down the session, and do NOT reconnect
*/
@Override
public void destroySession() {
destroySession(true);
}
@ -607,6 +623,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
/**
* Recieve notification that the I2CP connection was disconnected
*/
@Override
public void disconnected(I2CPMessageReader reader) {
if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Disconnected", new Exception("Disconnected"));
disconnect();

View File

@ -69,22 +69,27 @@ class I2PSessionImpl2 extends I2PSessionImpl {
protected long getTimeout() {
return SEND_TIMEOUT;
}
@Override
public void destroySession(boolean sendDisconnect) {
clearStates();
super.destroySession(sendDisconnect);
}
@Override
public boolean sendMessage(Destination dest, byte[] payload) throws I2PSessionException {
return sendMessage(dest, payload, 0, payload.length);
}
@Override
public boolean sendMessage(Destination dest, byte[] payload, int offset, int size) throws I2PSessionException {
return sendMessage(dest, payload, offset, size, new SessionKey(), new HashSet(64));
}
@Override
public boolean sendMessage(Destination dest, byte[] payload, SessionKey keyUsed, Set tagsSent) throws I2PSessionException {
return sendMessage(dest, payload, 0, payload.length, keyUsed, tagsSent);
}
@Override
public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set tagsSent)
throws I2PSessionException {
if (_log.shouldLog(Log.DEBUG)) _log.debug("sending message");
@ -97,6 +102,7 @@ class I2PSessionImpl2 extends I2PSessionImpl {
/**
* pull the unencrypted AND DECOMPRESSED data
*/
@Override
public byte[] receiveMessage(int msgId) throws I2PSessionException {
byte compressed[] = super.receiveMessage(msgId);
if (compressed == null) {
@ -266,7 +272,8 @@ class I2PSessionImpl2 extends I2PSessionImpl {
}
return found;
}
@Override
public void receiveStatus(int msgId, long nonce, int status) {
if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Received status " + status + " for msgId " + msgId + " / " + nonce);
MessageState state = null;
@ -335,6 +342,7 @@ class I2PSessionImpl2 extends I2PSessionImpl {
* to override this to clear out the message state
*
*/
@Override
protected boolean reconnect() {
// even if we succeed in reconnecting, we want to clear the old states,
// since this will be a new sessionId

View File

@ -28,7 +28,8 @@ class MessagePayloadMessageHandler extends HandlerImpl {
public MessagePayloadMessageHandler(I2PAppContext context) {
super(context, MessagePayloadMessage.MESSAGE_TYPE);
}
@Override
public void handleMessage(I2CPMessage message, I2PSessionImpl session) {
if (_log.shouldLog(Log.DEBUG))
_log.debug("Handle message " + message);

View File

@ -25,7 +25,8 @@ class MessageStatusMessageHandler extends HandlerImpl {
public MessageStatusMessageHandler(I2PAppContext context) {
super(context, MessageStatusMessage.MESSAGE_TYPE);
}
@Override
public void handleMessage(I2CPMessage message, I2PSessionImpl session) {
boolean skipStatus = true;
if (_log.shouldLog(Log.DEBUG))

View File

@ -39,7 +39,8 @@ class RequestLeaseSetMessageHandler extends HandlerImpl {
super(context, RequestLeaseSetMessage.MESSAGE_TYPE);
_existingLeaseSets = new HashMap(32);
}
@Override
public void handleMessage(I2CPMessage message, I2PSessionImpl session) {
if (_log.shouldLog(Log.DEBUG))
_log.debug("Handle message " + message);
@ -121,12 +122,14 @@ class RequestLeaseSetMessageHandler extends HandlerImpl {
public SigningPrivateKey getSigningPrivateKey() {
return _signingPrivKey;
}
@Override
public int hashCode() {
return DataHelper.hashCode(_pubKey) + 7 * DataHelper.hashCode(_privKey) + 7 * 7
* DataHelper.hashCode(_signingPubKey) + 7 * 7 * 7 * DataHelper.hashCode(_signingPrivKey);
}
@Override
public boolean equals(Object obj) {
if ((obj == null) || !(obj instanceof LeaseInfo)) return false;
LeaseInfo li = (LeaseInfo) obj;

View File

@ -23,7 +23,8 @@ class SessionStatusMessageHandler extends HandlerImpl {
public SessionStatusMessageHandler(I2PAppContext context) {
super(context, SessionStatusMessage.MESSAGE_TYPE);
}
@Override
public void handleMessage(I2CPMessage message, I2PSessionImpl session) {
_log.debug("Handle message " + message);
SessionStatusMessage msg = (SessionStatusMessage) message;

View File

@ -23,7 +23,8 @@ class SetDateMessageHandler extends HandlerImpl {
public SetDateMessageHandler(I2PAppContext ctx) {
super(ctx, SetDateMessage.MESSAGE_TYPE);
}
@Override
public void handleMessage(I2CPMessage message, I2PSessionImpl session) {
_log.debug("Handle message " + message);
SetDateMessage msg = (SetDateMessage) message;

View File

@ -18,7 +18,8 @@ public class AddressDBNamingService extends NamingService {
private AddressDBNamingService() {
super(null);
}
@Override
public Destination lookup(String hostname) {
Address addr = _addressdb.get(hostname);
if (addr != null) {
@ -28,7 +29,8 @@ public class AddressDBNamingService extends NamingService {
return lookupBase64(hostname);
}
}
@Override
public String reverseLookup(Destination dest) {
Iterator iter = _addressdb.hostnames().iterator();
while (iter.hasNext()) {

View File

@ -10,31 +10,38 @@ public class DummyAddressDB extends AddressDB {
public DummyAddressDB(I2PAppContext context) {
super(context);
}
@Override
public Address get(String hostname) {
return null;
}
@Override
public Address put(Address address) {
return null;
}
@Override
public Address remove(String hostname) {
return null;
}
@Override
public Address remove(Address address) {
return null;
}
@Override
public boolean contains(Address address) {
return false;
}
@Override
public boolean contains(String hostname) {
return false;
}
@Override
public Collection hostnames() {
return null;
}

View File

@ -23,10 +23,12 @@ class DummyNamingService extends NamingService {
protected DummyNamingService(I2PAppContext context) { super(context); }
private DummyNamingService() { super(null); }
@Override
public Destination lookup(String hostname) {
return lookupBase64(hostname);
}
@Override
public String reverseLookup(Destination dest) {
return null;
}

View File

@ -57,7 +57,8 @@ public class EepGetNamingService extends NamingService {
rv.add(tok.nextToken());
return rv;
}
@Override
public Destination lookup(String hostname) {
// If it's long, assume it's a key.
if (hostname.length() >= DEST_SIZE)
@ -135,7 +136,8 @@ public class EepGetNamingService extends NamingService {
_log.error("Caught from: " + url + hostname);
return null;
}
@Override
public String reverseLookup(Destination dest) {
return null;
}

View File

@ -57,7 +57,8 @@ public class ExecNamingService extends NamingService {
public ExecNamingService(I2PAppContext context) {
super(context);
}
@Override
public Destination lookup(String hostname) {
// If it's long, assume it's a key.
if (hostname.length() >= DEST_SIZE)
@ -125,7 +126,8 @@ public class ExecNamingService extends NamingService {
}
return null;
}
@Override
public String reverseLookup(Destination dest) {
return null;
}

View File

@ -50,7 +50,8 @@ public class FilesystemAddressDB extends AddressDB {
}
}
}
@Override
public Address get(String hostname) {
String dir = _context.getProperty(PROP_ADDRESS_DIR, DEFAULT_ADDRESS_DIR);
File f = new File(dir, hostname);
@ -73,7 +74,8 @@ public class FilesystemAddressDB extends AddressDB {
return null;
}
}
@Override
public Address put(Address address) {
Address previous = get(address.getHostname());
@ -86,7 +88,8 @@ public class FilesystemAddressDB extends AddressDB {
}
return previous;
}
@Override
public Address remove(String hostname) {
Address previous = get(hostname);
@ -95,7 +98,8 @@ public class FilesystemAddressDB extends AddressDB {
f.delete();
return previous;
}
@Override
public Address remove(Address address) {
if (contains(address)) {
return remove(address.getHostname());
@ -103,16 +107,19 @@ public class FilesystemAddressDB extends AddressDB {
return null;
}
}
@Override
public boolean contains(Address address) {
Address inDb = get(address.getHostname());
return inDb.equals(address);
}
@Override
public boolean contains(String hostname) {
return hostnames().contains(hostname);
}
@Override
public Collection hostnames() {
String dir = _context.getProperty(PROP_ADDRESS_DIR, DEFAULT_ADDRESS_DIR);
File f = new File(dir);

View File

@ -54,7 +54,8 @@ public class HostsTxtNamingService extends NamingService {
rv.add(tok.nextToken());
return rv;
}
@Override
public Destination lookup(String hostname) {
Destination d = getCache(hostname);
if (d != null)
@ -94,7 +95,8 @@ public class HostsTxtNamingService extends NamingService {
}
return null;
}
@Override
public String reverseLookup(Destination dest) {
String destkey = dest.toBase64();
List filenames = getFilenames();

View File

@ -33,6 +33,7 @@ public class MetaNamingService extends NamingService {
}
}
@Override
public Destination lookup(String hostname) {
Iterator iter = _services.iterator();
while (iter.hasNext()) {
@ -44,7 +45,8 @@ public class MetaNamingService extends NamingService {
}
return lookupBase64(hostname);
}
@Override
public String reverseLookup(Destination dest) {
Iterator iter = _services.iterator();
while (iter.hasNext()) {

View File

@ -122,6 +122,7 @@ public class PetName {
return false;
}
@Override
public String toString() {
StringBuffer buf = new StringBuffer(256);
if (_name != null) buf.append(_name.trim());
@ -142,6 +143,7 @@ public class PetName {
return buf.toString();
}
@Override
public boolean equals(Object obj) {
if ( (obj == null) || !(obj instanceof PetName) ) return false;
PetName pn = (PetName)obj;
@ -150,6 +152,7 @@ public class PetName {
DataHelper.eq(_network, pn._network) &&
DataHelper.eq(_protocol, pn._protocol);
}
@Override
public int hashCode() {
int rv = 0;
rv += DataHelper.hashCode(_name);

View File

@ -45,7 +45,8 @@ public class PetNameNamingService extends NamingService {
} catch (IOException ioe) {
}
}
@Override
public Destination lookup(String hostname) {
PetName name = _petnameDb.getByName(hostname);
if (name != null && name.getNetwork().equalsIgnoreCase("i2p")) {
@ -54,7 +55,8 @@ public class PetNameNamingService extends NamingService {
return lookupBase64(hostname);
}
}
@Override
public String reverseLookup(Destination dest) {
return _petnameDb.getByLocation(dest.toBase64()).getName();
}