001    package org.hackystat.sensorbase.uripattern;
002    
003    /**
004     * Not logic operator for two patterns.
005     * 
006     * @author (Cedric) Qin ZHANG
007     */
008    class NotOperator implements Operator {
009    
010      /**
011       * Gets the arity of this operator.
012       * 
013       * @return The arity.
014       */
015      public int getArity() {
016        return 1;
017      }
018    
019      /**
020       * Perform operator operation.
021       * 
022       * @param patterns The operand.
023       * @param filePath The file path to match.
024       * 
025       * @return True if there is a match.
026       */
027      public boolean matches(Pattern[] patterns, String filePath) {
028        if (patterns.length != 1) {
029          throw new RuntimeException("NOT operator expects exactly 1 operand.");
030        }
031        return ! patterns[0].matches(filePath);
032      }
033    
034    }