KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > pmd > sourcetypehandlers > SourceTypeHandlerBroker


1 package net.sourceforge.pmd.sourcetypehandlers;
2
3 import java.util.Map JavaDoc;
4
5 import net.sourceforge.pmd.SourceType;
6 import net.sourceforge.pmd.util.CollectionUtil;
7
8 /**
9  * Broker for SourceTypeHandler instances for specific SourceTypes.
10  *
11  * @author pieter_van_raemdonck - Application Engineers NV/SA - www.ae.be
12  */

13 public class SourceTypeHandlerBroker {
14
15     private static final Map JavaDoc mapSourceTypeOnSourceTypeHandler = CollectionUtil.mapFrom( new Object JavaDoc[][] {
16         { SourceType.JAVA_13, new Java13Handler()},
17         { SourceType.JAVA_14, new Java14Handler()},
18         { SourceType.JAVA_15, new Java15Handler()},
19         { SourceType.JAVA_16, new Java16Handler()},
20         { SourceType.JSP, new JspTypeHandler()},
21         });
22
23     /**
24      * Never create one
25      */

26     private SourceTypeHandlerBroker() { }
27
28     public static SourceTypeHandler getVisitorsFactoryForSourceType(SourceType sourceType) {
29         SourceTypeHandler handler = (SourceTypeHandler) mapSourceTypeOnSourceTypeHandler.get(sourceType);
30
31         if (handler == null) {
32             throw new IllegalArgumentException JavaDoc("No VisitorsFactory is registered for SourceType [" + sourceType + "].");
33         }
34         return handler;
35     }
36
37 }
38
Popular Tags