Java字符串复制

Java字符串复制

 1     public boolean topicFilterMatch(String topicFilter, String topic) {
 2         if (topicFilter == null || topic == null) {
 3             return false;
 4         }
 5 
 6         if (topicFilter.startsWith("$queue/"))
 7             topicFilter = topicFilter.substring(7);
 8         if (topicFilter.startsWith("$share/")) {
 9             int index = topicFilter.indexOf("/", 7);
10             topicFilter = topicFilter.substring(index + 1);
11         }
12 
13         String[] filterTokens = topicFilter.split("/");
14         String[] topicTokens = topic.split("/");
15         if (filterTokens.length > topicTokens.length) {
16             return false;
17         }
18 
19         for (int i = 0; i < filterTokens.length; i++) {
20             if (filterTokens[i].equals("#")) {
21                 // '#' must be the last character
22                 return ((i + 1) == filterTokens.length);
23             }
24 
25             if (!(filterTokens[i].equals(topicTokens[i]) || filterTokens[i].equals("+"))) {
26                 return false;
27             }
28         }
29 
30         return (filterTokens.length == topicTokens.length);
31     }
原文地址:https://www.cnblogs.com/myfrank/p/8514391.html