001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.bi.reporting;
016    
017    /**
018     * @author Michael C. Han
019     */
020    public enum ReportFormat {
021    
022            CSV("csv"), HTML("html"), PDF("pdf"), RTF("rtf"), TXT("txt"), XLS("xls"),
023            XML("xml");
024    
025            public static ReportFormat parse(String value) {
026                    if (CSV.getValue().equals(value)) {
027                            return CSV;
028                    }
029                    else if (HTML.getValue().equals(value)) {
030                            return HTML;
031                    }
032                    else if (PDF.getValue().equals(value)) {
033                            return PDF;
034                    }
035                    else if (RTF.getValue().equals(value)) {
036                            return RTF;
037                    }
038                    else if (TXT.getValue().equals(value)) {
039                            return TXT;
040                    }
041                    else if (XLS.getValue().equals(value)) {
042                            return XLS;
043                    }
044                    else if (XML.getValue().equals(value)) {
045                            return XML;
046                    }
047    
048                    throw new IllegalArgumentException("Invalid value " + value);
049            }
050    
051            public String getValue() {
052                    return _value;
053            }
054    
055            @Override
056            public String toString() {
057                    return _value;
058            }
059    
060            private ReportFormat(String value) {
061                    _value = value;
062            }
063    
064            private String _value;
065    
066    }