001    package org.hackystat.sensorbase.uripattern;
002    
003    /**
004     * Atomic pattern.
005     * 
006     * @author (Cedric) Qin ZHANG
007     */
008    class AtomicPattern implements Pattern {
009    
010      private String pattern;
011      
012      /**
013       * Constructor.
014       * 
015       * @param pattern The pattern string.
016       */
017      AtomicPattern(String pattern) {
018        this.pattern = pattern;
019      }
020      
021      /**
022       * Tests whether the pattern matches a file path.
023       * 
024       * @param filePath The file path to match.
025       * @return True if there is a match.
026       */
027      public boolean matches(String filePath) {
028        if (this.pattern == null || "**".equals(this.pattern)) {
029          return true;
030        }
031        else {
032          return PatternMatcher.matchesFilePath(this.pattern, filePath, true);
033        }
034      }
035    }