001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/calendar/tags/sakai_2-4-1/calendar-impl/impl/src/java/org/sakaiproject/calendar/impl/YearlyRecurrenceRule.java $
003: * $Id: YearlyRecurrenceRule.java 8050 2006-04-20 17:39:55Z ggolden@umich.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.calendar.impl;
021:
022: import java.util.GregorianCalendar;
023: import java.util.Stack;
024:
025: import org.sakaiproject.time.api.Time;
026: import org.w3c.dom.Document;
027: import org.w3c.dom.Element;
028:
029: /**
030: * <p>YearlyRecurrenceRule is a time range generating rule that is based on a yearly recurrence.</p>
031: */
032: public class YearlyRecurrenceRule extends RecurrenceRuleBase {
033: /** The unique type / short frequency description. */
034: protected final static String FREQ = "year";
035:
036: /**
037: * Default constructor
038: */
039: public YearlyRecurrenceRule() {
040: super ();
041: } // YearlyRecurrenceRule
042:
043: /**
044: * Construct with no limits.
045: * @param interval Every this many number of years: 1 would be every year.
046: */
047: public YearlyRecurrenceRule(int interval) {
048: super (interval);
049: } // YearlyRecurrenceRule
050:
051: /**
052: * Construct with count limit.
053: * @param interval Every this many number of years: 1 would be every year.
054: * @param count For this many occurrences - if 0, does not limit.
055: */
056: public YearlyRecurrenceRule(int interval, int count) {
057: super (interval, count);
058: } // YearlyRecurrenceRule
059:
060: /**
061: * Construct with time limit.
062: * @param interval Every this many number of years: 1 would be every year.
063: * @param until No time ranges past this time are generated - if null, does not limit.
064: */
065: public YearlyRecurrenceRule(int interval, Time until) {
066: super (interval, until);
067: } // YearlyRecurrenceRule
068:
069: /* (non-Javadoc)
070: * @see org.chefproject.service.calendar.RecurrenceRule#toXml(org.w3c.dom.Document, java.util.Stack)
071: */
072: public Element toXml(Document doc, Stack stack) {
073: // add the "rule" element to the stack'ed element
074: Element rule = doc.createElement("rule");
075: ((Element) stack.peek()).appendChild(rule);
076:
077: // set the class name - old style for CHEF 1.2.10 compatibility
078: rule.setAttribute("class",
079: "org.chefproject.osid.calendar.YearlyRecurrenceRule");
080:
081: // set the rule class name w/o package, for modern usage
082: rule.setAttribute("name", "YearlyRecurrenceRule");
083:
084: // Do the base class part.
085: setBaseClassXML(rule);
086:
087: return rule;
088: }
089:
090: /* (non-Javadoc)
091: * @see org.chefproject.service.calendar.RecurrenceRuleBase#getRecurrenceType()
092: */
093: protected int getRecurrenceType() {
094: return GregorianCalendar.YEAR;
095: }
096:
097: /**
098: * {@inheritDoc}
099: */
100: public String getFrequencyDescription() {
101: return FREQ;
102: }
103:
104: }
|