1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.plugins.wordtemplate.service;
35
36 import fr.paris.lutece.plugins.wordtemplate.business.IWordTemplateElement;
37 import fr.paris.lutece.plugins.wordtemplate.service.instruction.IInstructionManager;
38 import fr.paris.lutece.plugins.wordtemplate.service.instruction.InterpolationInstructionManager;
39 import java.util.ArrayList;
40 import java.util.List;
41 import java.util.Map;
42 import org.apache.poi.xwpf.usermodel.XWPFRun;
43
44
45
46
47 public class InstructionService
48 {
49 private static InstructionService _instructionService;
50 private List<IInstructionManager> _listInstructionManager;
51
52 private InstructionService( )
53 {
54 _listInstructionManager = new ArrayList<>( );
55 _listInstructionManager.add( new InterpolationInstructionManager( ) );
56 }
57
58
59
60
61
62 public static InstructionService init( )
63 {
64 if ( _instructionService == null )
65 {
66 _instructionService = new InstructionService( );
67 }
68
69 return _instructionService;
70 }
71
72
73
74
75
76
77
78 public IWordTemplateElement createInstruction( String expression, XWPFRun run )
79 {
80 for ( IInstructionManager instructionManager : _listInstructionManager )
81 {
82 if ( instructionManager.isOfType( expression ) )
83 {
84 IWordTemplateElement element = instructionManager.createInstruction( expression, run );
85 return element;
86 }
87 }
88 return null;
89 }
90
91
92
93
94
95
96 public void processInstruction( IWordTemplateElement instruction, Map<String, Object> model )
97 {
98 for ( IInstructionManager instructionManager : _listInstructionManager )
99 {
100 instructionManager.processInstruction( instruction, model );
101 }
102 }
103 }