KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > pmd > cpd > LanguageFactory


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 JavaDoc;
7
8 public class LanguageFactory {
9
10     public static final String JavaDoc JAVA_KEY = "java";
11     public static final String JavaDoc JSP_KEY = "jsp";
12     public static final String JavaDoc CPP_KEY = "cpp";
13     public static final String JavaDoc C_KEY = "c";
14     public static final String JavaDoc PHP_KEY = "php";
15     public static final String JavaDoc RUBY_KEY = "ruby";
16     public static final String JavaDoc EXTENSION = "extension";
17     public static final String JavaDoc BY_EXTENSION = "by_extension";
18
19     public Language createLanguage(String JavaDoc language) {
20         return createLanguage(language, new Properties JavaDoc());
21     }
22
23     public Language createLanguage(String JavaDoc language, Properties JavaDoc 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 }
40
Popular Tags