1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.kernel.bi.reporting;
16  
17  import java.util.HashMap;
18  import java.util.Map;
19  
20  /**
21   * <a href="ReportFormat.java.html"><b><i>View Source</i></b></a>
22   *
23   * @author Michael C. Han
24   */
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  }