~brian-thomason/+junk/jasperreports3.7

« back to all changes in this revision

Viewing changes to src/net/sf/jasperreports/charts/type/TimePeriodEnum.java

  • Committer: Brian Thomason
  • Date: 2011-12-20 17:51:16 UTC
  • Revision ID: brian.thomason@canonical.com-20111220175116-apwo6unuaedvgzo3
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * JasperReports - Free Java Reporting Library.
 
3
 * Copyright (C) 2001 - 2009 Jaspersoft Corporation. All rights reserved.
 
4
 * http://www.jaspersoft.com
 
5
 *
 
6
 * Unless you have purchased a commercial license agreement from Jaspersoft,
 
7
 * the following license terms apply:
 
8
 *
 
9
 * This program is part of JasperReports.
 
10
 *
 
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.
 
15
 *
 
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.
 
20
 * 
 
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/>.
 
23
 */
 
24
package net.sf.jasperreports.charts.type;
 
25
 
 
26
import net.sf.jasperreports.engine.JRConstants;
 
27
import net.sf.jasperreports.engine.type.EnumUtil;
 
28
import net.sf.jasperreports.engine.type.JREnum;
 
29
 
 
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;
 
39
 
 
40
 
 
41
/**
 
42
 * @author Teodor Danciu (teodord@users.sourceforge.net)
 
43
 * @version $Id: PlotOrientationEnum.java 3609 2010-03-23 09:01:15Z teodord $
 
44
 */
 
45
public enum TimePeriodEnum implements JREnum
 
46
{
 
47
        /**
 
48
         *
 
49
         */
 
50
        YEAR(Year.class, "Year"),
 
51
 
 
52
        /**
 
53
         *
 
54
         */
 
55
        QUARTER(Quarter.class, "Quarter"),
 
56
        
 
57
        /**
 
58
         *
 
59
         */
 
60
        MONTH(Month.class, "Month"),
 
61
        
 
62
        /**
 
63
         *
 
64
         */
 
65
        WEEK(Week.class, "Week"),
 
66
        
 
67
        /**
 
68
         *
 
69
         */
 
70
        DAY(Day.class, "Day"),
 
71
        
 
72
        /**
 
73
         *
 
74
         */
 
75
        HOUR(Hour.class, "Hour"),
 
76
        
 
77
        /**
 
78
         *
 
79
         */
 
80
        MINUTE(Minute.class, "Minute"),
 
81
        
 
82
        /**
 
83
         *
 
84
         */
 
85
        SECOND(Second.class, "Second"),
 
86
        
 
87
        /**
 
88
         *
 
89
         */
 
90
        MILLISECOND(Millisecond.class, "Milisecond");//FIXMENOW should we fix this spelling error?
 
91
 
 
92
 
 
93
        /**
 
94
         *
 
95
         */
 
96
        private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;
 
97
        private final transient Class value;
 
98
        private final transient String name;
 
99
 
 
100
        private TimePeriodEnum(Class clazz, String name)
 
101
        {
 
102
                this.value = clazz;
 
103
                this.name = name;
 
104
        }
 
105
 
 
106
        /**
 
107
         *
 
108
         */
 
109
        public Byte getValueByte()
 
110
        {
 
111
                return new Byte(getValue());
 
112
        }
 
113
        
 
114
        /**
 
115
         *
 
116
         */
 
117
        public final byte getValue()
 
118
        {
 
119
                return (byte)-1;
 
120
        }
 
121
        
 
122
        /**
 
123
         *
 
124
         */
 
125
        public String getName()
 
126
        {
 
127
                return name;
 
128
        }
 
129
        
 
130
        /**
 
131
         *
 
132
         */
 
133
        public final Class getTimePeriod()
 
134
        {
 
135
                return this.value;
 
136
        }
 
137
        
 
138
        /**
 
139
         *
 
140
         */
 
141
        public static TimePeriodEnum getByName(String name)
 
142
        {
 
143
                return (TimePeriodEnum)EnumUtil.getByName(values(), name);
 
144
        }
 
145
        
 
146
        /**
 
147
         *
 
148
         */
 
149
        public static TimePeriodEnum getByValue(Class clazz)
 
150
        {
 
151
                TimePeriodEnum[] values = values();
 
152
                if (values != null && clazz != null)
 
153
                {
 
154
                        for(TimePeriodEnum e:values)
 
155
                        {
 
156
                                if (clazz.getName().equals(e.getTimePeriod().getName()))
 
157
                                {
 
158
                                        return e;
 
159
                                }
 
160
                        }
 
161
                }
 
162
                return null;
 
163
        }
 
164
        
 
165
}