* 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.wamblee.crawler.kiss;
/**
- *
+ * Time interval.
*/
public class TimeInterval {
-
- private Time _begin;
- private Time _end;
-
- public TimeInterval(Time aBegin, Time aEnd) {
- _begin = aBegin;
- _end = aEnd;
+
+ /**
+ * Begin time.
+ */
+ private Time _begin;
+
+ /**
+ * End time.
+ */
+ private Time _end;
+
+ /**
+ * Construts the interval.
+ * @param aBegin Start time.
+ * @param aEnd End time.
+ */
+ public TimeInterval(Time aBegin, Time aEnd) {
+ _begin = aBegin;
+ _end = aEnd;
}
-
- public Time getBegin() {
- return _begin;
+
+ /**
+ * Gets the begin time.
+ * @return Begin time.
+ */
+ public Time getBegin() {
+ return _begin;
}
-
- public Time getEnd() {
- return _end;
+
+ /**
+ * Gets the end time.
+ * @return End time.
+ */
+ public Time getEnd() {
+ return _end;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
- return _begin + " - " + _end;
+ return _begin + " - " + _end;
}
-
+
/**
- * Determines if there is an overlap between the current interval and given one.
+ * Determines if there is an overlap between the current interval and given
+ * one.
*
- * @param aInterval Interval to compare with.
+ * @param aInterval
+ * Interval to compare with.
* @return True iff there is overlap
*/
- public boolean overlap(TimeInterval aInterval) {
-
- if ( isUncertain() || aInterval.isUncertain()) {
- // Optimistic assume there is no overlap if one of the intervals is uncertain.
- return false;
+ public boolean overlap(TimeInterval aInterval) {
+
+ if (isUncertain() || aInterval.isUncertain()) {
+ // Optimistic assume there is no overlap if one of the intervals is
+ // uncertain.
+ return false;
}
-
- if ( _end.asFloat() <= aInterval._begin.asFloat() ||
- aInterval._end.asFloat() <= _begin.asFloat() ) {
- return false;
+
+ if (_end.asFloat() <= aInterval._begin.asFloat()
+ || aInterval._end.asFloat() <= _begin.asFloat()) {
+ return false;
}
-
+
return true;
}
-
+
/**
- * Determines if the actual time that the program corresponds to is uncertain due to
- * the representation of a period of more than 24 hours using a 24 hour clock.
- * @return True iff the interval is uncertain.
+ * Determines if the actual time that the program corresponds to is
+ * uncertain due to the representation of a period of more than 24 hours
+ * using a 24 hour clock.
+ *
+ * @return True iff the interval is uncertain.
*/
- boolean isUncertain() {
- return _begin.asFloat() > _end.asFloat();
+ boolean isUncertain() {
+ return _begin.asFloat() > _end.asFloat();
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)j
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if ( !(obj instanceof TimeInterval)) {
+ return false;
+ }
+ return obj.toString().equals(obj.toString());
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return _begin.hashCode();
}
}