1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.extremecomponents.table.model;
17
18 import java.util.ArrayList;
19 import java.util.Iterator;
20 import java.util.List;
21
22 import org.apache.commons.lang.StringUtils;
23
24 import org.apache.commons.logging.Log;
25 import org.apache.commons.logging.LogFactory;
26 import org.extremecomponents.table.bean.Export;
27
28
29
30 /***
31 * @author Jeff Johnston
32 */
33 public class ExportHandler
34 {
35 private static Log logger = LogFactory.getLog(ExportHandler.class);
36 public final static String PDF = "pdf";
37 public final static String XLS = "xls";
38 public final static String EXPORT_NAME = "export_name_";
39 public final static String EXPORT_DATA = "exportData";
40 private TableModel model;
41 private List exports = new ArrayList();
42
43 public ExportHandler(TableModel model)
44 {
45 this.model = model;
46 }
47
48 public void addExport(Export export)
49 {
50 exports.add(export);
51 }
52
53 public Export getExport(String view)
54 {
55 for (Iterator iter = exports.iterator(); iter.hasNext();)
56 {
57 Export export = (Export) iter.next();
58
59 if (export.getView().equals(view))
60 {
61 return export;
62 }
63 }
64
65 return null;
66 }
67
68 public boolean invokeExport()
69 {
70 String value = model.getRegistry().getParameter(ParameterRegistry.EXPORT);
71
72 if (StringUtils.isNotBlank(value))
73 {
74 return true;
75 }
76
77 return false;
78 }
79
80 public Export getCurrentExport()
81 {
82 return getExport(model.getRegistry().getParameter(ParameterRegistry.EXPORT));
83 }
84
85 public List getExports()
86 {
87 return exports;
88 }
89
90 public boolean hasExports()
91 {
92 return getExports().size() > 0;
93 }
94
95 public void destroy()
96 {
97 exports.clear();
98 exports = null;
99 }
100 }