X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=crawler%2Fkiss%2Fsrc%2Forg%2Fwamblee%2Fcrawler%2Fkiss%2Fguide%2FTime.java;fp=crawler%2Fkiss%2Fsrc%2Forg%2Fwamblee%2Fcrawler%2Fkiss%2Fguide%2FTime.java;h=0000000000000000000000000000000000000000;hb=62f165891f08ae532b5a794af11d7338a93f9a43;hp=de206f557b5739204acceaec86ed26cd61f03eec;hpb=07cedd3f0730646ea35a7f668b3e1e872a4605d9;p=utils diff --git a/crawler/kiss/src/org/wamblee/crawler/kiss/guide/Time.java b/crawler/kiss/src/org/wamblee/crawler/kiss/guide/Time.java deleted file mode 100644 index de206f55..00000000 --- a/crawler/kiss/src/org/wamblee/crawler/kiss/guide/Time.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright 2005 the original author or authors. - * - * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0 - * - * 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.wamblee.crawler.kiss.guide; - -import java.text.DecimalFormat; -import java.text.NumberFormat; - -/** - * TIme at which a program starts or ends. - */ -public class Time implements Comparable { - - /** - * - */ - private static final int HOURS_PER_DAY = 24; - - /** - * - */ - private static final int EARLY_HOUR = 3; - - /** - * Number of seconds per minute. - */ - private static final double SECONDS_PER_MINUTE = 60.0; - - /** - * Hour of the time. - */ - private int _hour; - - /** - * Minute of the hour. - */ - private int _minute; - - /** - * Constructs the time. - * - * @param aHour - * Hour. - * @param aMinute - * Minute. - */ - public Time(int aHour, int aMinute) { - _hour = aHour; - _minute = aMinute; - } - - /** - * Gets the hour. - * - * @return Hour. - */ - public int getHour() { - return _hour; - } - - /** - * Gets te minute. - * - * @return Minute. - */ - public int getMinute() { - return _minute; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - NumberFormat format = new DecimalFormat("00"); - return format.format(_hour) + ":" + format.format(_minute); - } - - /** - * Convert time to floating point value. Useful for comparing two times. - * - * @return Converted value. - */ - float asFloat() { - int hour = _hour; - // Hack to make sure that programs appearing shortly after midnight are - // sorted - // after those running during the day. - if (hour <= EARLY_HOUR) { - hour += HOURS_PER_DAY; - } - return (float) hour + (float) _minute / (float) SECONDS_PER_MINUTE; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object aObject) { - if (!(aObject instanceof Time)) { - return false; - } - return toString().equals(aObject.toString()); - } - - /** - * Compares based on time. - * - * @param aObject - * Time object to compare to. - * @return See {@link Comparable#compareTo(T)}. - */ - public int compareTo(Object aObject) { - if (!(aObject instanceof Time)) { - throw new IllegalArgumentException("object not an instance of Time"); - } - Time time = (Time) aObject; - return new Float(asFloat()).compareTo(new Float(time.asFloat())); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - return toString().hashCode(); - } -}