X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=crawler%2Fkiss%2Fsrc%2Forg%2Fwamblee%2Fcrawler%2Fkiss%2FTimeInterval.java;h=d56e54e17cb65ebcf374494a2c676acb1a3268de;hb=8c0b0a2d230139dff25630954e170e3c082395a6;hp=1e0e5151f6acb1fcbf013ae197b825b890ded6f8;hpb=abee5af7177fb97dab546e49d1790c918b9a466e;p=utils diff --git a/crawler/kiss/src/org/wamblee/crawler/kiss/TimeInterval.java b/crawler/kiss/src/org/wamblee/crawler/kiss/TimeInterval.java index 1e0e5151..d56e54e1 100644 --- a/crawler/kiss/src/org/wamblee/crawler/kiss/TimeInterval.java +++ b/crawler/kiss/src/org/wamblee/crawler/kiss/TimeInterval.java @@ -12,66 +12,112 @@ * 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(); } }