1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
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  }