1 /* 2 * File: Interval.java 3 * Copyright (c) 2004-2007 Peter Kliem (Peter.Kliem@jaret.de) 4 * A commercial license is available, see http://www.jaret.de. 5 * 6 * All rights reserved. This program and the accompanying materials 7 * are made available under the terms of the Common Public License v1.0 8 * which accompanies this distribution, and is available at 9 * http://www.eclipse.org/legal/cpl-v10.html 10 */ 11 package de.jaret.util.date; 12 13 import de.jaret.util.misc.PropertyObservable; 14 15 /** 16 * Interval with observable properties. 17 * 18 * @author Peter Kliem 19 * @version $Id: Interval.java 875 2009-09-03 22:07:04Z kliem $ 20 */ 21 public interface Interval extends PropertyObservable { 22 /** Constant defining the property name for end. */ 23 String PROP_END = "End"; 24 /** Constant defining the property name for begin. */ 25 String PROP_BEGIN = "Begin"; 26 27 /** 28 * Set the begin timestamp of the interval. 29 * 30 * @param begin the begin timestamp to be set. 31 */ 32 void setBegin(JaretDate begin); 33 34 /** 35 * Retrieve the begin timestamp of the interval. 36 * 37 * @return the begin timestamp of the interval. 38 */ 39 JaretDate getBegin(); 40 41 /** 42 * Set the end timestamp of the interval. 43 * 44 * @param end the end timestamp to be set. 45 */ 46 void setEnd(JaretDate end); 47 48 /** 49 * Retrieve the end timestamp of the interval. 50 * 51 * @return the end timestamp of the interval. 52 */ 53 JaretDate getEnd(); 54 55 /** 56 * Checks whether a given date is contained in the interval. 57 * 58 * @param date date to be checked 59 * @return true if the date is included in the interval 60 */ 61 boolean contains(JaretDate date); 62 63 /** 64 * Checks whether an interval is completely contained in the interval. 65 * 66 * @param interval interval to check 67 * @return <code>true</code> if the interval is completely contained in the interval 68 */ 69 boolean contains(Interval interval); 70 71 /** 72 * Retrieve the length of the interval in seconds. 73 * 74 * @return length of the interval in seconds 75 */ 76 int getSeconds(); 77 78 /** 79 * Check whether this intersects the given interval. 80 * 81 * @param interval interval to be checked for intersection. 82 * @return true if an intersection exists, false otherwise 83 */ 84 boolean intersects(Interval interval); 85 86 }