001package biweekly.property;
002
003import java.util.List;
004
005import biweekly.ICalVersion;
006import biweekly.Warning;
007import biweekly.component.ICalComponent;
008import biweekly.util.ICalDate;
009import biweekly.util.UtcOffset;
010
011/**
012 * Represents daylight savings time information.
013 * @author Michael Angstadt
014 * @see <a href="http://www.imc.org/pdi/vcal-10.doc">vCal 1.0 p.23</a>
015 */
016public class Daylight extends ICalProperty {
017        private boolean daylight;
018        private UtcOffset offset;
019        private ICalDate start, end;
020        private String standardName, daylightName;
021
022        /**
023         * Creates a daylight savings property which states that the timezone does
024         * not observe daylight savings time.
025         */
026        public Daylight() {
027                this.daylight = false;
028        }
029
030        /**
031         * Creates a daylight savings property.
032         * @param daylight true if the timezone observes daylight savings time,
033         * false if not
034         * @param offset the UTC offset of daylight savings time
035         * @param start the start date of daylight savings time
036         * @param end the end date of daylight savings time
037         * @param standardName the timezone's name for standard time (e.g. "EST")
038         * @param daylightName the timezone's name for daylight savings time (e.g.
039         * "EDT")
040         */
041        public Daylight(boolean daylight, UtcOffset offset, ICalDate start, ICalDate end, String standardName, String daylightName) {
042                this.daylight = daylight;
043                this.offset = offset;
044                this.start = start;
045                this.end = end;
046                this.standardName = standardName;
047                this.daylightName = daylightName;
048        }
049
050        /**
051         * Gets whether this timezone observes daylight savings time.
052         * @return true if it observes daylight savings time, false if not
053         */
054        public boolean isDaylight() {
055                return daylight;
056        }
057
058        /**
059         * Sets whether this timezone observes daylight savings time.
060         * @param daylight true if it observes daylight savings time, false if not
061         */
062        public void setDaylight(boolean daylight) {
063                this.daylight = daylight;
064        }
065
066        /**
067         * Gets the UTC offset of daylight savings time.
068         * @return the UTC offset
069         */
070        public UtcOffset getOffset() {
071                return offset;
072        }
073
074        /**
075         * Sets the UTC offset of daylight savings time.
076         * @param offset the UTC offset
077         */
078        public void setOffset(UtcOffset offset) {
079                this.offset = offset;
080        }
081
082        /**
083         * Gets the start date of dayight savings time.
084         * @return the start date
085         */
086        public ICalDate getStart() {
087                return start;
088        }
089
090        /**
091         * Sets the start date of dayight savings time.
092         * @param start the start date
093         */
094        public void setStart(ICalDate start) {
095                this.start = start;
096        }
097
098        /**
099         * Gets the end date of daylight savings time.
100         * @return the end date
101         */
102        public ICalDate getEnd() {
103                return end;
104        }
105
106        /**
107         * Sets the end date of daylight savings time.
108         * @param end the end date
109         */
110        public void setEnd(ICalDate end) {
111                this.end = end;
112        }
113
114        /**
115         * Gets the name for standard time.
116         * @return the name (e.g. "EST")
117         */
118        public String getStandardName() {
119                return standardName;
120        }
121
122        /**
123         * Sets the name for standard time.
124         * @param name the name (e.g. "EST")
125         */
126        public void setStandardName(String name) {
127                this.standardName = name;
128        }
129
130        /**
131         * Gets the name of daylight savings time.
132         * @return the name (e.g. "EDT")
133         */
134        public String getDaylightName() {
135                return daylightName;
136        }
137
138        /**
139         * Sets the name of daylight savings time.
140         * @param name the name (e.g. "EDT")
141         */
142        public void setDaylightName(String name) {
143                this.daylightName = name;
144        }
145
146        @Override
147        protected void validate(List<ICalComponent> components, ICalVersion version, List<Warning> warnings) {
148                if (daylight && (offset == null || start == null || end == null || standardName == null || daylightName == null)) {
149                        warnings.add(Warning.validate(43));
150                }
151        }
152}