📄 statuscommand.java
字号:
LOG.fine("peerName = \'" + pn + "\'"); LOG.fine("End getPeerName(MessageTransport, String)"); } return pn != null ? pn : UNKNOWN; } private String open(String s) { if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) { LOG.fine("In open(String)"); } return ELEMENT_OPEN_PREAMBLE + s; } private String close(String s) { if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) { LOG.fine("In open(String)"); } return close(s, true); } private String close(String s, boolean hasContent) { if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) { LOG.fine("In open(String, boolean)"); } return hasContent ? ELEMENT_CLOSE_PREAMBLE + s + ELEMENT_CLOSE_POSTAMBLE : ELEMENT_OPEN_EMPTY_POSTAMBLE; } private String attribute(String n, String v) { if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) { LOG.fine("In attribute(String, String)"); } return n + EQUALS + quote(v); } private String attribute(String n, int v) { if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) { LOG.fine("In attribute(String, int)"); } return attribute(n, String.valueOf(v)); } private String quote(String s) { if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) { LOG.fine("In quote(String)"); } StringBuffer sb = new StringBuffer(); for (int i = 0; i < (s != null ? s.length() : 0); i++) { char c = s.charAt(i); if (c == QUOTE) { sb.append(SLASH); } sb.append(c); } return QUOTE + sb.toString() + QUOTE; } private String toUnicodeEncoded(String s) { if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) { LOG.fine("In toUnicodeEncoded(String)"); } StringBuffer b = null; if (s != null) { b = new StringBuffer(); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (c <= MAX_ASCII) { b.append(c); } else { b.append(UNICODE_ESCAPE); b.append(Integer.toHexString(c)); } } } return b != null ? b.toString() : null; }}class PeerData { private static final char QUOTE = '\"'; private static final char SLASH = '/'; private static final char SPACE = ' '; private static final char OPEN_BRACKET = '['; private static final char CLOSE_BRACKET = ']'; private static final char OPEN_PARENTHESIS = '('; private static final char CLOSE_PARENTHESIS = ')'; private static final char IS_ALIVE = 'A'; private static final char IS_IN_PEER_VIEW = 'P'; private static final char IS_THROTTLING = 'T'; private static final Logger LOG = Logger.getLogger(PeerData.class.getName()); private String name = null; private boolean isAlive = false; private boolean isInPeerView = false; private boolean isThrottling = false; private int numberOfConnectedPeers = 0; private long startTime = 0; private long createTime = 0; private long updateTime = 0; public PeerData(String s) { if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) { LOG.fine("Begin PeerData(String) Constructor"); } int index = 0; StringBuffer sb = new StringBuffer(); for (int i = 0; s != null && i < s.length(); i++) { char c = s.charAt(i); switch (index) { case 0: if (c == QUOTE) { index++; } break; case 1: if (c != QUOTE || (c == QUOTE && s.charAt(i - 1) == SLASH)) { sb.append(c); } else { index++; this.name = sb.toString(); sb.delete(0, sb.length()); } break; case 2: if (c != SPACE) { index++; this.isAlive = c == IS_ALIVE; } break; case 3: if (c != SPACE) { index++; this.isInPeerView = c == IS_IN_PEER_VIEW; } break; case 4: if (c != SPACE) { index++; this.isThrottling = c == IS_THROTTLING; } break; case 5: if (c == OPEN_PARENTHESIS) { index++; } else if (c == OPEN_BRACKET) { index += 2; } break; case 6: if (c == CLOSE_PARENTHESIS) { index--; try { this.numberOfConnectedPeers = Integer.valueOf(sb.toString()).intValue(); } catch (NumberFormatException nfe) { if (Logging.SHOW_SEVERE && LOG.isLoggable(Level.SEVERE)) { LOG.log(Level.SEVERE, "Caught unexpected exception ", nfe); } } sb.delete(0, sb.length()); } else { sb.append(c); } break; case 7: if (c == SLASH) { index++; try { this.startTime = Long.valueOf(sb.toString()).longValue(); } catch (NumberFormatException nfe) { if (Logging.SHOW_SEVERE && LOG.isLoggable(Level.SEVERE)) { LOG.log(Level.SEVERE, "Caught unexpected exception ", nfe); } } sb.delete(0, sb.length()); } else { sb.append(c); } break; case 8: if (c == CLOSE_BRACKET) { index += 2; try { this.updateTime = Long.valueOf(sb.toString()).longValue(); } catch (NumberFormatException nfe) { if (Logging.SHOW_SEVERE && LOG.isLoggable(Level.SEVERE)) { LOG.log(Level.SEVERE, "Caught unexpected exception ", nfe); } } this.createTime = this.startTime; this.startTime = 0; sb.delete(0, sb.length()); } else if (c == SLASH) { index++; try { this.createTime = Long.valueOf(sb.toString()).longValue(); } catch (NumberFormatException nfe) { if (Logging.SHOW_SEVERE && LOG.isLoggable(Level.SEVERE)) { LOG.log(Level.SEVERE, "Caught unexpected exception ", nfe); } } sb.delete(0, sb.length()); } else { sb.append(c); } break; case 9: if (c == CLOSE_BRACKET) { index++; try { this.updateTime = Long.valueOf(sb.toString()).longValue(); } catch (NumberFormatException nfe) { if (Logging.SHOW_SEVERE && LOG.isLoggable(Level.SEVERE)) { LOG.log(Level.SEVERE, "Caught unexpected exception ", nfe); } } sb.delete(0, sb.length()); } else { sb.append(c); } break; } } if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) { LOG.fine("End PeerData(String) Constructor"); } } public String getName() { if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) { LOG.fine("In getName()"); } return this.name; } public boolean isAlive() { if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) { LOG.fine("In isAlive()"); } return this.isAlive; } public boolean isInPeerView() { if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) { LOG.fine("In inPeerView()"); } return this.isInPeerView; } public boolean isThrottling() { if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) { LOG.fine("In isThrottling()"); } return this.isThrottling; } public int getNumberOfConnectedPeers() { if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) { LOG.fine("In getNumberOfConnectedPeers()"); } return this.numberOfConnectedPeers; } public long getStartTime() { if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) { LOG.fine("In getStartTime()"); } return this.startTime; } public long getCreateTime() { if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) { LOG.fine("In getCreateTime()"); } return this.createTime; } public long getUpdateTime() { if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) { LOG.fine("In getUpdateTime()"); } return this.updateTime; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -