1 package org.lsst.ccs.command;
2
3 import java.lang.reflect.Method;
4 import java.util.HashMap;
5 import java.util.Map;
6
7
8
9
10
11 public class LocalBuilders {
12
13 private static Map<Class, LocalCommandDictionary> mapBuilders = new HashMap<>();
14 private static InputConversionEngine engine = new InputConversionEngine();
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 public static synchronized LocalCommandDictionary factory(Class clazz) {
30 return buildFor(clazz);
31 }
32
33 private static LocalCommandDictionary buildFor(Class clazz) {
34 LocalCommandDictionary res = mapBuilders.get(clazz);
35 if (res == null) {
36 res = new CommandDictionaryBuilder(clazz);
37 mapBuilders.put(clazz, res);
38 }
39 return res;
40
41 }
42
43
44
45
46
47
48
49
50 public static RawCommand toRawCommand(String string, Method meth) throws CommandInvocationException {
51 TokenizedCommand cmd = new TokenizedCommand(string) ;
52 return RawCommand.toRawCommand(cmd, meth, engine) ;
53 }
54
55 public static RawCommand toRawCommand(TokenizedCommand cmd, Method meth) throws CommandInvocationException {
56 return RawCommand.toRawCommand(cmd, meth, engine) ;
57 }
58 }