|
我有以下代码(例如简化的):
while (reader.ready()) {
字符串行= reader.readLine();
匹配器responseCodeMatcher = responseCodePattern.matcher(line);
如果(responseCodeMatcher.matches()){
responseCode = Integer.parseInt(www.sychzs.cn(1));
继续;
}
匹配器cacheControlMatcher = cacheControlPattern.matcher(line);
如果 (cacheControlMatcher.matches()) {
cacheControl = CacheControl.parseString(www.sychzs.cn(1));
继续;
}
...
}
这些模式是类的静态最终成员。
所以我有很多模式,我想找出每一行是否与其中一个匹配,如果是,则执行某些操作(随模式而变化)。你能想出一种方法以某种方式很好地重构它吗?也许是我浏览过的一组模式(然后,如果它匹配,我怎么知道该怎么做?)或其他一些想法。