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="ReportDataSourceType.java.html"><b><i>View Source</i></b></a>
22   *
23   * @author Gavin Wan
24   */
25  public enum ReportDataSourceType {
26  
27      CSV("csv"), EMPTY("empty"), JDBC("jdbc"), PORTAL("portal"), XLS("xls"),
28      XML("xml");
29  
30      public static ReportDataSourceType parse(String value) {
31          ReportDataSourceType reportDataSourceType = _reportDataSourceTypes.get(
32              value);
33  
34          if (reportDataSourceType != null) {
35              return reportDataSourceType;
36          }
37  
38          if (CSV.toString().equalsIgnoreCase(value)) {
39              return CSV;
40          }
41          else if (EMPTY.toString().equalsIgnoreCase(value)) {
42              return EMPTY;
43          }
44          else if (JDBC.toString().equalsIgnoreCase(value)) {
45              return JDBC;
46          }
47          else if (PORTAL.toString().equalsIgnoreCase(value)) {
48              return PORTAL;
49          }
50          else if (XLS.toString().equalsIgnoreCase(value)) {
51              return XLS;
52          }
53          else if (XML.toString().equalsIgnoreCase(value)) {
54              return XML;
55          }
56          else {
57              throw new IllegalArgumentException(
58                  "Invalid data source type " + value);
59          }
60      }
61  
62      public String toString() {
63          return _value;
64      }
65  
66      private ReportDataSourceType(String value) {
67          _value = value;
68      }
69  
70      private static final Map<String, ReportDataSourceType>
71          _reportDataSourceTypes = new HashMap<String, ReportDataSourceType>();
72  
73      static {
74          _reportDataSourceTypes.put(CSV.toString(), CSV);
75          _reportDataSourceTypes.put(EMPTY.toString(), EMPTY);
76          _reportDataSourceTypes.put(JDBC.toString(), JDBC);
77          _reportDataSourceTypes.put(PORTAL.toString(), PORTAL);
78          _reportDataSourceTypes.put(XLS.toString(), XLS);
79          _reportDataSourceTypes.put(XML.toString(), XML);
80      }
81  
82      private String _value;
83  
84  }