001
014
015 package com.liferay.portal.kernel.bi.reporting;
016
017 import java.util.HashMap;
018 import java.util.Map;
019
020
023 public enum ReportFormat {
024
025 CSV("csv"), EXCEL("excel"), HTML("html"), PDF("pdf"), RTF("rtf"),
026 TEXT("text"), XML("xml");
027
028 public static ReportFormat parse(String value) {
029 ReportFormat reportFormat = _reportFormats.get(value);
030
031 if (reportFormat != null) {
032 return reportFormat;
033 }
034
035 if (EXCEL.toString().equalsIgnoreCase(value)) {
036 return EXCEL;
037 }
038 else if (HTML.toString().equalsIgnoreCase(value)) {
039 return HTML;
040 }
041 else if (PDF.toString().equalsIgnoreCase(value)) {
042 return PDF;
043 }
044 else {
045 throw new IllegalArgumentException("Invalid format " + value);
046 }
047 }
048
049 public String toString() {
050 return _value;
051 }
052
053 private ReportFormat(String value) {
054 _value = value;
055 }
056
057 private static final Map<String, ReportFormat> _reportFormats =
058 new HashMap<String, ReportFormat>();
059
060 static {
061 _reportFormats.put(CSV.toString(), CSV);
062 _reportFormats.put(EXCEL.toString(), EXCEL);
063 _reportFormats.put(HTML.toString(), HTML);
064 _reportFormats.put(PDF.toString(), PDF);
065 _reportFormats.put(RTF.toString(), RTF);
066 _reportFormats.put(TEXT.toString(), TEXT);
067 _reportFormats.put(XML.toString(), XML);
068 }
069
070 private String _value;
071
072 }