HSRP(热备份路由选择协议)与VRRP(虚拟路由器冗余协议)
2014-02-23 01:12
295 查看
如果在windows下的编辑器中获取了一个编辑器的输入,则将编辑器的输入内容转换为Element的Text存储,在jdom中会做一个转换,里面主要做了一步操作,就是将原来文本的内容中回车换行转换为回车换行。(实际上是将“\n”转换为换行符,但是他这里没有考虑windows下平台的问题,因为windows前面还多了一个"\r")
看jdom中换行转换的代码:
看以上的代码可以看到,jdom只对"\n"认为是换行,但是'\r'却不做任何处理,这一点很奇怪。。。
看jdom中换行转换的代码:
public String escapeElementEntities(String str) { if (escapeOutput == false) return str; StringBuffer buffer; int ch, pos; String entity; EscapeStrategy strategy = currentFormat.escapeStrategy; buffer = null; for (int i = 0; i < str.length(); i++) { ch = str.charAt(i); pos = i; switch(ch) { case '<' : entity = "<"; break; case '>' : entity = ">"; break; case '&' : entity = "&"; break; case '\r' : entity = " "; break; case '\n' : entity = currentFormat.lineSeparator; break; default : if (strategy.shouldEscape((char) ch)) { //make sure what we are escaping is not the //beginning of a multi-byte character. if(Verifier.isHighSurrogate((char) ch)) { //this is a the high of a surrogate pair i++; if (i < str.length()) { char low = str.charAt(i); if(!Verifier.isLowSurrogate(low)) { throw new IllegalDataException("Could not decode surrogate pair 0x" + Integer.toHexString(ch) + " / 0x" + Integer.toHexString(low)); } ch = Verifier.decodeSurrogatePair((char) ch, low); } else { throw new IllegalDataException("Surrogate pair 0x" + Integer.toHexString(ch) + " truncated"); } } entity = "" + Integer.toHexString(ch) + ";"; } else { entity = null; } break; } if (buffer == null) { if (entity != null) { // An entity occurred, so we'll have to use StringBuffer // (allocate room for it plus a few more entities). buffer = new StringBuffer(str.length() + 20); // Copy previous skipped characters and fall through // to pickup current character buffer.append(str.substring(0, pos)); buffer.append(entity); } } else { if (entity == null) { buffer.append((char) ch); } else { buffer.append(entity); } } } // If there were any entities, return the escaped characters // that we put in the StringBuffer. Otherwise, just return // the unmodified input string. return (buffer == null) ? str : buffer.toString(); }
看以上的代码可以看到,jdom只对"\n"认为是换行,但是'\r'却不做任何处理,这一点很奇怪。。。
相关文章推荐
- 【思科】热备份路由选择协议HSRP+VRRP实战!
- 【思科】热备份路由选择协议HSRP+VRRP实战!
- 热备份路由选择协议(HSRP)和生成树协议(STP)
- HSRP和VRRP两大备份路由器协议比较
- HSRP和VRRP两大备份路由器协议比较
- HSRP和VRRP两大备份路由器协议比较
- HSRP和VRRP两大备份路由器协议比较
- 热备份路由选择协议(HSRP)、PVST+负载均衡的配置
- HSRP(热备份路由选择协议)---学习笔记
- VRRP与HSRP
- 链路冗余:HSRP/SLB/VRRP/GLBP
- 关于利用RouterOS的VRRP来配置路由器热备份
- 热备份路由选择协议(HSRP)
- 虚拟路由器冗余协议【原理篇】VRRP详解
- 笔记 VRRP基本原理 主备备份 负载均衡
- VRRP和HSRP 及之间的区别(精)
- 【图文详解】,热备份HSRP配置附视频
- HSRP与VRRP例配置实例
- VRRP路由器备份的协议
- CCNP学习之路之第一条冗余协议first-hop redundancy protocol(HSRP、VRRP、GLBP)