1
14
15 package com.liferay.portal.kernel.bi.reporting;
16
17 import java.util.HashMap;
18 import java.util.Map;
19
20
25 public enum ReportFormat {
26
27 CSV("csv"), EXCEL("excel"), HTML("html"), PDF("pdf"), RTF("rtf"),
28 TEXT("text"), XML("xml");
29
30 public static ReportFormat parse(String value) {
31 ReportFormat reportFormat = _reportFormats.get(value);
32
33 if (reportFormat != null) {
34 return reportFormat;
35 }
36
37 if (EXCEL.toString().equalsIgnoreCase(value)) {
38 return EXCEL;
39 }
40 else if (HTML.toString().equalsIgnoreCase(value)) {
41 return HTML;
42 }
43 else if (PDF.toString().equalsIgnoreCase(value)) {
44 return PDF;
45 }
46 else {
47 throw new IllegalArgumentException("Invalid format " + value);
48 }
49 }
50
51 public String toString() {
52 return _value;
53 }
54
55 private ReportFormat(String value) {
56 _value = value;
57 }
58
59 private static final Map<String, ReportFormat> _reportFormats =
60 new HashMap<String, ReportFormat>();
61
62 static {
63 _reportFormats.put(CSV.toString(), CSV);
64 _reportFormats.put(EXCEL.toString(), EXCEL);
65 _reportFormats.put(HTML.toString(), HTML);
66 _reportFormats.put(PDF.toString(), PDF);
67 _reportFormats.put(RTF.toString(), RTF);
68 _reportFormats.put(TEXT.toString(), TEXT);
69 _reportFormats.put(XML.toString(), XML);
70 }
71
72 private String _value;
73
74 }