1 7 package fr.jayasoft.ivy.matcher; 8 9 10 public final class ExactOrRegexpPatternMatcher implements PatternMatcher { 11 public static class ExactOrRegexpMatcher implements Matcher { 12 private Matcher _exact; 13 private Matcher _regexp; 14 15 public ExactOrRegexpMatcher(String exp) { 16 _exact = ExactPatternMatcher.getInstance().getMatcher(exp); 17 _regexp = RegexpPatternMatcher.getInstance().getMatcher(exp); 18 } 19 20 public boolean matches(String str) { 21 return _exact.matches(str) || _regexp.matches(str); 22 } 23 24 public boolean isExact() { 25 return false; 26 } 27 } 28 private static final ExactOrRegexpPatternMatcher INSTANCE = new ExactOrRegexpPatternMatcher(); 29 public static PatternMatcher getInstance() { 30 return INSTANCE; 31 } 32 33 private ExactOrRegexpPatternMatcher() { 34 } 35 36 public String getName() { 37 return EXACT_OR_REGEXP; 38 } 39 40 public Matcher getMatcher(String exp) { 41 if (ANY_EXPRESSION.equals(exp)) { 42 return AnyMatcher.getInstance(); 43 } 44 return new ExactOrRegexpMatcher(exp); 45 } 46 } 47 | Popular Tags |