/**********************************************************************************
 * $URL: https://source.sakaiproject.org/svn/calendar/tags/sakai_2-3-1/calendar-api/api/src/java/org/sakaiproject/calendar/api/RecurrenceRule.java $
 * $Id: RecurrenceRule.java 8050 2006-04-20 17:39:55Z ggolden@umich.edu $
 ***********************************************************************************
 *
 * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation.
 * 
 * Licensed under the Educational Community License, Version 1.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at
 * 
 *      http://www.opensource.org/licenses/ecl1.php
 * 
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and 
 * limitations under the License.
 *
 **********************************************************************************/

package org.sakaiproject.calendar.api;

import java.util.List;
import java.util.Stack;
import java.util.TimeZone;

import org.sakaiproject.time.api.Time;
import org.sakaiproject.time.api.TimeRange;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

/**
* <p>RecurrenceRule is the interface for objects which add or remove multiple occurrences of timeranges.</p>
*/
public interface RecurrenceRule
{
	/**
	 * Take values from this xml element
	 * @param el The xml element.
	 */
	void set(Element el);

	/**
	 * Serialize the resource into XML, adding an element to the doc under the top of the stack element.
	 * @param doc The DOM doc to contain the XML (or null for a string return).
	 * @param stack The DOM elements, the top of which is the containing element of the new "resource" element.
	 * @return The newly added element.
	 */
	Element toXml(Document doc, Stack stack);

	/**
	 * Return a List of all RecurrenceInstance objects generated by this rule within the given time range, based on the
	 * prototype first range, in time order.
	 * @param prototype The prototype first TimeRange.
	 * @param range A time range to limit the generated ranges.
	 * @return a List of RecurrenceInstance generated by this rule in this range.
	 */
	List generateInstances(TimeRange prototype, TimeRange range, TimeZone timeZone);

	/**
	 * Remove from the ranges list any RecurrenceInstance excluded by this rule.
	 * @param ranges The list (RecurrenceInstance) of ranges.
	 */
	void excludeInstances(List ranges);


	/**
	 * Access a short text describing the rule's frequency.
	 * @return A frequency description.
	 */
	String getFrequencyDescription();

	/**
	 * Access the end time for recurring events.
	 * @return The end time for recurring events.
	 */
	Time getUntil();

	/**
	 * Access the number of times that this event should repeat.
	 * @return The number of times that this event should repeat.
	 */
	int getCount();

	/**
	 * Access the number of natural frequency units between repeats.
	 * @return The number of natural frequency units between repeats.
	 */
	int getInterval();
}



