Files
i2p.i2p/apps/routerconsole/java/src/net/i2p/router/web/PeerHelper.java
jrandom a0f865fb99 2006-05-17 jrandom
* Make the peer page sortable
    * SSU modifications to cut down on unnecessary connection failures
2006-05-18 03:00:48 +00:00

53 lines
1.4 KiB
Java

package net.i2p.router.web;
import java.io.IOException;
import java.io.Writer;
import net.i2p.router.RouterContext;
public class PeerHelper {
private RouterContext _context;
private Writer _out;
private int _sortFlags;
private String _urlBase;
/**
* Configure this bean to query a particular router context
*
* @param contextId begging few characters of the routerHash, or null to pick
* the first one we come across.
*/
public void setContextId(String contextId) {
try {
_context = ContextHelper.getContext(contextId);
} catch (Throwable t) {
t.printStackTrace();
}
}
public PeerHelper() {}
public void setOut(Writer out) { _out = out; }
public void setSort(String flags) {
if (flags != null) {
try {
_sortFlags = Integer.parseInt(flags);
} catch (NumberFormatException nfe) {
_sortFlags = 0;
}
} else {
_sortFlags = 0;
}
}
public void setUrlBase(String base) { _urlBase = base; }
public String getPeerSummary() {
try {
_context.commSystem().renderStatusHTML(_out, _urlBase, _sortFlags);
_context.bandwidthLimiter().renderStatusHTML(_out);
} catch (IOException ioe) {
ioe.printStackTrace();
}
return "";
}
}