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