MCPcopy Create free account
hub / github.com/Qihoo360/poseidon / Util

Class Util

builder/index/src/main/java/InvertedIndex/plugin/Util.java:29–617  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27
28
29public class Util {
30 static Set<String> domains_ = new HashSet<String>();
31
32 static {
33 domains_.add("com");
34 domains_.add("edu");
35 domains_.add("gov");
36 domains_.add("net");
37 domains_.add("org");
38 domains_.add("cn");
39 domains_.add("hk");
40
41 }
42
43 public static final int BUFFER = 1024;
44
45
46 /*
47 * 字符串中是否包含特殊字符
48 String str = decoderStr("hDGkN4QxpDeBMOk3", false);
49 true: System.out.println(Util.IsUnReadable(str));
50 false: System.out.println(Util.IsUnReadable("weoirus..&*^&*230 ??"));
51 false: System.out.println(Util.IsUnReadable("蠙~搦%"));
52 false: System.out.println(Util.IsUnReadable("a?LR--蔔sdfe"));
53 false: System.out.println(Util.IsUnReadable("as嘦fa3謪 er"));
54 false: System.out.println(Util.IsUnReadable("eddds"));
55 false: System.out.println(Util.IsUnReadable("遍历分词数据"));
56 * */
57 public static boolean IsUnReadable(String str) {
58 //System.out.println("len: "+str.length()+", enc: "+enc+", len: "+buf.length);
59 String str2 = new String(str.replace('?', ' '));
60 try {
61 byte[] buf = str2.getBytes("gbk");
62 for (byte b : buf)
63 if (b == 0x3f /* '?' */)
64 return true;
65 } catch (/*UnsupportedEncodingException*/Exception e) {
66 return true;
67 }
68 return false;
69 }
70
71
72 /* *
73 test_str(" 324abc123abc75 ");
74 test_str(" 876");
75 test_str("111");
76 * */
77 public static boolean IsDigit(String str) {
78 for (int i = str.length(); --i >= 0; ) {
79 if (!Character.isDigit(str.charAt(i))) {
80 return false;
81 }
82 }
83 return true;
84 }
85
86 public static boolean IsHexadecimal(String str) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected