⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 statuscommand.java

📁 jxta官方例程
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        if (LOG.isEnabledFor(Level.DEBUG)) {            LOG.debug("In open(String)");        }        return close(s, true);    }        private String close(String s, boolean hasContent) {        if (LOG.isEnabledFor(Level.DEBUG)) {            LOG.debug("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 (LOG.isEnabledFor(Level.DEBUG)) {            LOG.debug("In attribute(String, String)");        }        return n + EQUALS + quote(v);    }        private String attribute(String n, int v) {        if (LOG.isEnabledFor(Level.DEBUG)) {            LOG.debug("In attribute(String, int)");        }        return attribute(n, String.valueOf(v));    }    private String quote(String s) {        if (LOG.isEnabledFor(Level.DEBUG)) {            LOG.debug("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 (LOG.isEnabledFor(Level.DEBUG)) {            LOG.debug("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);        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 (LOG.isEnabledFor(Level.DEBUG)) {            LOG.debug("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 (LOG.isEnabledFor(Level.ERROR)) {                            LOG.error("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 (LOG.isEnabledFor(Level.ERROR)) {                            LOG.error("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 (LOG.isEnabledFor(Level.ERROR)) {                            LOG.error("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 (LOG.isEnabledFor(Level.ERROR)) {                            LOG.error("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 (LOG.isEnabledFor(Level.ERROR)) {                            LOG.error("Caught unexpected exception ", nfe);                        }                    }                    sb.delete(0, sb.length());                } else {                    sb.append(c);                }                break;            }        }        if (LOG.isEnabledFor(Level.DEBUG)) {            LOG.debug("End   PeerData(String) Constructor");        }    }    public String getName() {        if (LOG.isEnabledFor(Level.DEBUG)) {            LOG.debug("In getName()");        }        return this.name;    }        public boolean isAlive() {        if (LOG.isEnabledFor(Level.DEBUG)) {            LOG.debug("In isAlive()");        }        return this.isAlive;    }        public boolean isInPeerView() {        if (LOG.isEnabledFor(Level.DEBUG)) {            LOG.debug("In inPeerView()");        }        return this.isInPeerView;    }        public boolean isThrottling() {        if (LOG.isEnabledFor(Level.DEBUG)) {            LOG.debug("In isThrottling()");        }        return this.isThrottling;    }    public int getNumberOfConnectedPeers() {        if (LOG.isEnabledFor(Level.DEBUG)) {            LOG.debug("In getNumberOfConnectedPeers()");        }        return this.numberOfConnectedPeers;    }        public long getStartTime() {        if (LOG.isEnabledFor(Level.DEBUG)) {            LOG.debug("In getStartTime()");        }        return this.startTime;    }        public long getCreateTime() {        if (LOG.isEnabledFor(Level.DEBUG)) {            LOG.debug("In getCreateTime()");        }        return this.createTime;    }        public long getUpdateTime() {        if (LOG.isEnabledFor(Level.DEBUG)) {            LOG.debug("In getUpdateTime()");        }        return this.updateTime;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -