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