| ReportDataSourceType.java |
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 JASPER_CSV("jasper_csv"), JASPER_EMPTY("jasper_empty"),
36 JASPER_XML("jasper_xml"), JDBC("jdbc"), PORTAL("portal");
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 (JASPER_CSV.toString().equalsIgnoreCase(value)) {
47 return JASPER_CSV;
48 }
49 else if (JASPER_EMPTY.toString().equalsIgnoreCase(value)) {
50 return JASPER_EMPTY;
51 }
52 else if (JASPER_XML.toString().equalsIgnoreCase(value)) {
53 return JASPER_XML;
54 }
55 else if (JDBC.toString().equalsIgnoreCase(value)) {
56 return JDBC;
57 }
58 else if (PORTAL.toString().equalsIgnoreCase(value)) {
59 return PORTAL;
60 }
61 else {
62 throw new IllegalArgumentException(
63 "Invalid data source type " + value);
64 }
65 }
66
67 public String toString() {
68 return _value;
69 }
70
71 private ReportDataSourceType(String value) {
72 _value = value;
73 }
74
75 private static final Map<String, ReportDataSourceType>
76 _reportDataSourceTypes = new HashMap<String, ReportDataSourceType>();
77
78 static {
79 _reportDataSourceTypes.put(JASPER_CSV.toString(), JASPER_CSV);
80 _reportDataSourceTypes.put(JASPER_EMPTY.toString(), JASPER_EMPTY);
81 _reportDataSourceTypes.put(JASPER_XML.toString(), JASPER_XML);
82 _reportDataSourceTypes.put(JDBC.toString(), JDBC);
83 _reportDataSourceTypes.put(PORTAL.toString(), PORTAL);
84 }
85
86 private String _value;
87
88 }