1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.mycore.csl;
20
21 import java.io.IOException;
22
23 import org.mycore.common.config.MCRConfigurationException;
24
25 import de.undercouch.citeproc.CSL;
26
27 public class MCRCSLTransformerInstance implements AutoCloseable {
28
29 private final AutoCloseable closeable;
30
31 private final CSL citationProcessor;
32
33 private final MCRItemDataProvider dataProvider;
34
35 public MCRCSLTransformerInstance(String style, String format, AutoCloseable closeable,
36 MCRItemDataProvider dataProvider) {
37 this.closeable = closeable;
38 this.dataProvider = dataProvider;
39 try {
40 this.citationProcessor = new CSL(this.dataProvider, style);
41 } catch (IOException e) {
42 throw new MCRConfigurationException("Error while creating CSL with Style " + style, e);
43 }
44 this.citationProcessor.setOutputFormat(format);
45
46 }
47
48 public CSL getCitationProcessor() {
49 return citationProcessor;
50 }
51
52 public MCRItemDataProvider getDataProvider() {
53 return dataProvider;
54 }
55
56 @Override
57 public void close() throws Exception {
58 this.closeable.close();
59 }
60 }