电子邮件黑名单/白名单匹配的Java库:ListMatcher

jopen 10年前

一个Java库,用于电子邮件地址黑名单/白名单匹配。但也可以用于IP范围和URL等类似的内容。

    //load some patterns from a text file:      Set<String> whiteListPatterns = ListMatcher.readPatternsFromFile(new File("/tmp/someWhitelist.txt"));      Set<String> blackListPatterns = ListMatcher.readPatternsFromFile(new File("/tmp/someBlacklist.txt"));        //some options      boolean caseSensitive = false;        //If you have multiple lists to manage:      Map<String,PatternList> listByName = new HashMap<>();        listByName.put("email.whitelist", new PatternList(whiteListPatterns, "@", caseSensitive));      listByName.put("email.blacklist", new PatternList(whiteListPatterns, "@", caseSensitive));        ListMatcher listMatcher = new ListMatcher(listByName);        //do some matching:      boolean inWhitelist = listMatcher.matchesList("email.whitelist", "test@example.com");      boolean inBlacklist = listMatcher.matchesList("email.blacklist", "test@example.com");

项目主页:http://www.open-open.com/lib/view/home/1414736870059