001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/calendar/tags/sakai_2-4-1/calendar-impl/impl/src/java/org/sakaiproject/calendar/impl/MonthlyRecurrenceRule.java $
003: * $Id: MonthlyRecurrenceRule.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>MonthlyRecurrenceRule is a time range generating rule that is based on a monthly recurrence.</p>
031: */
032: public class MonthlyRecurrenceRule extends RecurrenceRuleBase {
033: /** The unique type / short frequency description. */
034: protected final static String FREQ = "month";
035:
036: /**
037: * Default constructor
038: */
039: public MonthlyRecurrenceRule() {
040: super ();
041: } // MonthlyRecurrenceRule
042:
043: /**
044: * Construct with no limits.
045: * @param interval Every this many number of months: 1 would be every month.
046: */
047: public MonthlyRecurrenceRule(int interval) {
048: super (interval);
049:
050: } // MonthlyRecurrenceRule
051:
052: /**
053: * Construct with count limit.
054: * @param interval Every this many number of months: 1 would be every month.
055: * @param count For this many occurrences - if 0, does not limit.
056: */
057: public MonthlyRecurrenceRule(int interval, int count) {
058: super (interval, count);
059: } // MonthlyRecurrenceRule
060:
061: /**
062: * Construct with time limit.
063: * @param interval Every this many number of months: 1 would be every month.
064: * @param until No time ranges past this time are generated - if null, does not limit.
065: */
066: public MonthlyRecurrenceRule(int interval, Time until) {
067: super (interval, until);
068: } // MonthlyRecurrenceRule
069:
070: /* (non-Javadoc)
071: * @see org.chefproject.service.calendar.RecurrenceRule#toXml(org.w3c.dom.Document, java.util.Stack)
072: */
073: public Element toXml(Document doc, Stack stack) {
074: // add the "rule" element to the stack'ed element
075: Element rule = doc.createElement("rule");
076: ((Element) stack.peek()).appendChild(rule);
077:
078: // set the class name - old style for CHEF 1.2.10 compatibility
079: rule.setAttribute("class",
080: "org.chefproject.osid.calendar.MonthlyRecurrenceRule");
081:
082: // set the rule class name w/o package, for modern usage
083: rule.setAttribute("name", "MonthlyRecurrenceRule");
084:
085: // Do the base class part.
086: setBaseClassXML(rule);
087:
088: return rule;
089: }
090:
091: /* (non-Javadoc)
092: * @see org.chefproject.service.calendar.RecurrenceRuleBase#getRecurrenceType()
093: */
094: protected int getRecurrenceType() {
095: return GregorianCalendar.MONTH;
096: }
097:
098: /**
099: * {@inheritDoc}
100: */
101: public String getFrequencyDescription() {
102: return FREQ;
103: }
104: }
|