View Javadoc

    1   /***
    2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
    3    */
    4   package net.sourceforge.pmd.cpd;
    5
    6   import java.io.File;
    7   import java.io.FilenameFilter;
    8
    9   public class AnyLanguage implements Language {
    10
    11      public static class AnyFileOrDirectoryFilter implements FilenameFilter {
    12          String extension;
    13
    14          public AnyFileOrDirectoryFilter(String extension) {
    15              this.extension = extension;
    16          }
    17
    18          public boolean accept(File dir, String filename) {
    19              return filename.endsWith(extension) || (new File(dir.getAbsolutePath() + fileSeparator + filename).isDirectory());
    20          }
    21      }
    22
    23      private AnyTokenizer tokenizer;
    24      private String extension;
    25
    26      public AnyLanguage(String extension) {
    27          this.extension = extension;
    28          tokenizer = new AnyTokenizer();
    29      }
    30
    31      public Tokenizer getTokenizer() {
    32          return tokenizer;
    33      }
    34
    35      public FilenameFilter getFileFilter() {
    36          return new AnyFileOrDirectoryFilter(this.extension);
    37      }
    38  }