View Javadoc

    1   package net.sourceforge.pmd;
    2
    3   import java.util.HashMap;
    4   import java.util.Map;
    5
    6   /***
    7    * Mapping of SourceType to RuleLanguage.
    8    *
    9    * @author pieter_van_raemdonck - Application Engineers NV/SA - www.ae.be
    10   */
    11  public class SourceTypeToRuleLanguageMapper {
    12      /***
    13       * Map of SourceType on RuleLanguage.
    14       */
    15      private static Map mapSourceTypeOnRuleLanguage = new HashMap();
    16
    17      static {
    18          mapSourceTypeOnRuleLanguage.put(SourceType.JAVA_13, Language.JAVA);
    19          mapSourceTypeOnRuleLanguage.put(SourceType.JAVA_14, Language.JAVA);
    20          mapSourceTypeOnRuleLanguage.put(SourceType.JAVA_15, Language.JAVA);
    21
    22          mapSourceTypeOnRuleLanguage.put(SourceType.JSP, Language.JSP);
    23      }
    24
    25      /***
    26       * Get the RuleLanguage that corresponds to the given SourceType.
    27       *
    28       * @param sourceType the SourceType
    29       * @return a RuleLanguage
    30       */
    31      public static Language getMappedLanguage(SourceType sourceType) {
    32          return (Language) mapSourceTypeOnRuleLanguage.get(sourceType);
    33      }
    34  }