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.util.Properties;
    7
    8   public class LanguageFactory {
    9
    10      public static final String JAVA_KEY = "java";
    11      public static final String JSP_KEY = "jsp";
    12      public static final String CPP_KEY = "cpp";
    13      public static final String C_KEY = "c";
    14      public static final String PHP_KEY = "php";
    15      public static final String RUBY_KEY = "ruby";
    16      public static final String EXTENSION = "extension";
    17      public static final String BY_EXTENSION = "by_extension";
    18
    19      public Language createLanguage(String language) {
    20          return createLanguage(language, new Properties());
    21      }
    22
    23      public Language createLanguage(String language, Properties properties) {
    24          if (language.equals(CPP_KEY) || language.equals(C_KEY)) {
    25              return new CPPLanguage();
    26          } else if (language.equals(JAVA_KEY)) {
    27              return new JavaLanguage(properties);
    28          } else if (language.equals(JSP_KEY)) {
    29              return new JSPLanguage();
    30          } else if (language.equals(BY_EXTENSION)) {
    31              return new AnyLanguage(properties.getProperty(EXTENSION));
    32          } else if (language.equals(PHP_KEY)) {
    33              return new PHPLanguage();
    34          } else if (language.equals(RUBY_KEY)) {
    35              return new RubyLanguage();
    36          }
    37          return new AnyLanguage(language);
    38      }
    39  }