1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.kernel.bi.reporting;
24  
25  import java.util.HashMap;
26  import java.util.Map;
27  
28  /**
29   * <a href="ReportDataSourceType.java.html"><b><i>View Source</i></b></a>
30   *
31   * @author Gavin Wan
32   */
33  public enum ReportDataSourceType {
34  
35      CSV("csv"), EMPTY("empty"), JDBC("jdbc"), PORTAL("portal"), XLS("xls"),
36      XML("xml");
37  
38      public static ReportDataSourceType parse(String value) {
39          ReportDataSourceType reportDataSourceType = _reportDataSourceTypes.get(
40              value);
41  
42          if (reportDataSourceType != null) {
43              return reportDataSourceType;
44          }
45  
46          if (CSV.toString().equalsIgnoreCase(value)) {
47              return CSV;
48          }
49          else if (EMPTY.toString().equalsIgnoreCase(value)) {
50              return EMPTY;
51          }
52          else if (JDBC.toString().equalsIgnoreCase(value)) {
53              return JDBC;
54          }
55          else if (PORTAL.toString().equalsIgnoreCase(value)) {
56              return PORTAL;
57          }
58          else if (XLS.toString().equalsIgnoreCase(value)) {
59              return XLS;
60          }
61          else if (XML.toString().equalsIgnoreCase(value)) {
62              return XML;
63          }
64          else {
65              throw new IllegalArgumentException(
66                  "Invalid data source type " + value);
67          }
68      }
69  
70      public String toString() {
71          return _value;
72      }
73  
74      private ReportDataSourceType(String value) {
75          _value = value;
76      }
77  
78      private static final Map<String, ReportDataSourceType>
79          _reportDataSourceTypes = new HashMap<String, ReportDataSourceType>();
80  
81      static {
82          _reportDataSourceTypes.put(CSV.toString(), CSV);
83          _reportDataSourceTypes.put(EMPTY.toString(), EMPTY);
84          _reportDataSourceTypes.put(JDBC.toString(), JDBC);
85          _reportDataSourceTypes.put(PORTAL.toString(), PORTAL);
86          _reportDataSourceTypes.put(XLS.toString(), XLS);
87          _reportDataSourceTypes.put(XML.toString(), XML);
88      }
89  
90      private String _value;
91  
92  }