KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > jayasoft > ivy > matcher > ExactPatternMatcher


1 /*
2  * This file is subject to the licence found in LICENCE.TXT in the root directory of the project.
3  * Copyright Jayasoft 2005 - All rights reserved
4  *
5  * #SNAPSHOT#
6  */

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