1 package org.andromda.core.translation.library;
2
3 import java.util.LinkedHashMap;
4 import java.util.Map;
5 import org.andromda.core.common.BasePlugin;
6 import org.andromda.core.common.ClassUtils;
7 import org.andromda.core.common.ComponentContainer;
8 import org.andromda.core.common.ExceptionUtils;
9 import org.andromda.core.translation.Translator;
10
11
12
13
14
15
16
17 public class Library
18 extends BasePlugin
19 {
20 private final Map<String, LibraryTranslation> libraryTranslations = new LinkedHashMap<String, LibraryTranslation>();
21
22
23
24
25 public Library()
26 {
27 super();
28 }
29
30
31
32
33
34
35 public void addLibraryTranslation(final LibraryTranslation libraryTranslation)
36 {
37 ExceptionUtils.checkNull("libraryTranslation", libraryTranslation);
38 libraryTranslation.setLibrary(this);
39 this.libraryTranslations.put(
40 libraryTranslation.getName(),
41 libraryTranslation);
42 }
43
44
45
46
47
48
49 public Map<String, LibraryTranslation> getLibraryTranslations()
50 {
51 return this.libraryTranslations;
52 }
53
54
55
56
57
58
59
60 public LibraryTranslation getLibraryTranslation(final String name)
61 {
62 ExceptionUtils.checkEmpty("name", name);
63 return this.libraryTranslations.get(name);
64 }
65
66
67
68
69
70
71 public void setTranslator(final String translatorClass)
72 {
73 try
74 {
75 ComponentContainer.instance().registerDefaultComponent(
76 Translator.class,
77 ClassUtils.loadClass(translatorClass));
78 }
79 catch (final Throwable throwable)
80 {
81 throw new LibraryException(throwable);
82 }
83 }
84
85
86
87
88 public void populateTemplateContext(final Map<String, Object> templateContext)
89 {
90 super.populateTemplateContext(templateContext);
91 }
92 }