2
* JasperReports - Free Java Reporting Library.
3
* Copyright (C) 2001 - 2009 Jaspersoft Corporation. All rights reserved.
4
* http://www.jaspersoft.com
6
* Unless you have purchased a commercial license agreement from Jaspersoft,
7
* the following license terms apply:
9
* This program is part of JasperReports.
11
* JasperReports is free software: you can redistribute it and/or modify
12
* it under the terms of the GNU Lesser General Public License as published by
13
* the Free Software Foundation, either version 3 of the License, or
14
* (at your option) any later version.
16
* JasperReports is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU Lesser General Public License for more details.
21
* You should have received a copy of the GNU Lesser General Public License
22
* along with JasperReports. If not, see <http://www.gnu.org/licenses/>.
24
package net.sf.jasperreports.charts.type;
26
import net.sf.jasperreports.engine.JRConstants;
27
import net.sf.jasperreports.engine.type.EnumUtil;
28
import net.sf.jasperreports.engine.type.JREnum;
30
import org.jfree.data.time.Day;
31
import org.jfree.data.time.Hour;
32
import org.jfree.data.time.Millisecond;
33
import org.jfree.data.time.Minute;
34
import org.jfree.data.time.Month;
35
import org.jfree.data.time.Quarter;
36
import org.jfree.data.time.Second;
37
import org.jfree.data.time.Week;
38
import org.jfree.data.time.Year;
42
* @author Teodor Danciu (teodord@users.sourceforge.net)
43
* @version $Id: PlotOrientationEnum.java 3609 2010-03-23 09:01:15Z teodord $
45
public enum TimePeriodEnum implements JREnum
50
YEAR(Year.class, "Year"),
55
QUARTER(Quarter.class, "Quarter"),
60
MONTH(Month.class, "Month"),
65
WEEK(Week.class, "Week"),
70
DAY(Day.class, "Day"),
75
HOUR(Hour.class, "Hour"),
80
MINUTE(Minute.class, "Minute"),
85
SECOND(Second.class, "Second"),
90
MILLISECOND(Millisecond.class, "Milisecond");//FIXMENOW should we fix this spelling error?
96
private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;
97
private final transient Class value;
98
private final transient String name;
100
private TimePeriodEnum(Class clazz, String name)
109
public Byte getValueByte()
111
return new Byte(getValue());
117
public final byte getValue()
125
public String getName()
133
public final Class getTimePeriod()
141
public static TimePeriodEnum getByName(String name)
143
return (TimePeriodEnum)EnumUtil.getByName(values(), name);
149
public static TimePeriodEnum getByValue(Class clazz)
151
TimePeriodEnum[] values = values();
152
if (values != null && clazz != null)
154
for(TimePeriodEnum e:values)
156
if (clazz.getName().equals(e.getTimePeriod().getName()))