## org.opencyc.util
Class Timer

    java.lang.Object
      |
      +--org.opencyc.util.Timer

public class Timer
extends java.lang.Object

Implements A timer that can be set to a specified number of seconds or milliseconds before it times out, and can be checked for the time elapsed since the start or time remaining until the timeout.

Author:
  Eric E. Allen
  , Bjørn Aldag

  Copyright 2001 Cycorp, Inc., license is open source GNU LGPL.

  the license

  www.opencyc.org

  OpenCyc at SourceForge

  THIS SOFTWARE AND KNOWLEDGE BASE CONTENT ARE PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENCYC ORGANIZATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE AND KNOWLEDGE BASE CONTENT, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Field Summary
`static java.util.Date` `APOCALYPSE`

Constructor Summary
`Timer()` Creates and starts a new timer that will run forever.
`Timer(int timeAlloted)` Creates and starts a new timer that will run the specified number of seconds before timing out.
`Timer(long timeAlloted)` Creates and starts a new timer that will run the specified number of milliseconds before timing out.

Method Summary
`void` `checkForTimeOut()` Throws a @see TimeOutException if this timer has been running longer than the timeOut.
`long` `getElapsedMilliSeconds()` Returns the number of milliseconds that this timer has been running.
`int` `getElapsedSeconds()` Returns the number of seconds that this timer has been running.
`long` `getRemainingMilliSeconds()` Returns the number of milliseconds remaining till the timeout of this timer.
`int` `getRemainingSeconds()` Returns the number of seconds remaining till the timeout of this timer.
`boolean` `isTimedOut()` Returns `true` if this timer is timed out, `false` otherwise.
`void` `start()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### APOCALYPSE

    public static final java.util.Date APOCALYPSE

Constructor Detail

### Timer

    public Timer(int timeAlloted)

  Creates and starts a new timer that will run the specified number of seconds before timing out.
  Parameters:
    `timeAlloted` - the number of seconds the timer will run before timing out.

### Timer

    public Timer(long timeAlloted)

  Creates and starts a new timer that will run the specified number of milliseconds before timing out.
  Parameters:
    `timeAlloted` - the number of milliseconds the timer will run before timing out.

### Timer

    public Timer()

  Creates and starts a new timer that will run forever.

Method Detail

### start

    public void start()

### getElapsedSeconds

    public int getElapsedSeconds()

  Returns the number of seconds that this timer has been running.
  Returns:
    the number of seconds that this timer has been running.

### getElapsedMilliSeconds

    public long getElapsedMilliSeconds()

  Returns the number of milliseconds that this timer has been running.
  Returns:
    the number of milliseconds that this timer has been running.

### getRemainingSeconds

    public int getRemainingSeconds()

  Returns the number of seconds remaining till the timeout of this timer.
  Returns:
    the number of seconds remaining till the timeout of this timer.

### getRemainingMilliSeconds

    public long getRemainingMilliSeconds()

  Returns the number of milliseconds remaining till the timeout of this timer.
  Returns:
    the number of milliseconds remaining till the timeout of this timer.

### isTimedOut

    public boolean isTimedOut()

  Returns `true` if this timer is timed out, `false` otherwise.
  Returns:
    `true` if this timer is timed out, `false` otherwise.

### checkForTimeOut

    public void checkForTimeOut()
                         throws TimeOutException

  Throws a @see TimeOutException if this timer has been running longer than the timeOut.
  Throws:
    `TimeOutException` - if this timer has run the specifier number of seconds.