MCPcopy Create free account
hub / github.com/diyhi/bbs / format

Method format

src/main/java/cms/utils/IpAddress.java:235–259  ·  view source on GitHub ↗

IP归属地格式化 @param ipAddress IP归属地 @return

(String ipAddress)

Source from the content-addressed store, hash-verified

233 * @return
234 */
235 private static String format(String ipAddress){
236 if(ipAddress != null && !ipAddress.trim().isEmpty()){
237 if(!Strings.CI.startsWith(ipAddress, "中国|0|0|0|")){//判断开始部分是否与二参数相同。不区分大小写
238 ipAddress = Strings.CS.replace(ipAddress, "中国|", "");//中国替换成空串
239 }
240
241
242 ipAddress = Strings.CS.replace(ipAddress, "|0", "");//0替换成空串
243 LinkedHashSet<String> hashSet = new LinkedHashSet<String>();
244 String [] regionGroup = ipAddress.split("\\|");
245
246 for(String info: regionGroup){
247 if(info !=null && !info.equals("0")){
248 hashSet.add(info);
249 }
250 }
251 if(hashSet.size() >0){
252 return StringUtils.join(hashSet.toArray(), " ");
253 }
254
255 //ipAddress = StringUtils.replace(ipAddress, "|0", " ");//0替换成空串
256 //ipAddress = StringUtils.replace(ipAddress, "|", " ");//竖线替换成空格
257 }
258 return "";
259 }
260}

Callers 15

queryAddressMethod · 0.95
staffIdRemainderMethod · 0.80
createStaffLoginLogIdMethod · 0.80
filePackMethod · 0.80
userIdRemainderMethod · 0.80
createPointLogIdMethod · 0.80
userIdRemainderMethod · 0.80
createUserLoginLogIdMethod · 0.80
userIdRemainderMethod · 0.80
createUserDynamicIdMethod · 0.80
createRunningNumberMethod · 0.80
userIdRemainderMethod · 0.80

Calls 6

toArrayMethod · 0.80
isEmptyMethod · 0.45
replaceMethod · 0.45
equalsMethod · 0.45
addMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected