de.fhg.igd.logging
Class Chronometer

java.lang.Object
  extended byde.fhg.igd.logging.Chronometer

public final class Chronometer
extends Object

This is a factory for timestamps and interval anchor entries. Each Chronometer needs to be assigned to a URL, so it can be reused in case the underlying logging mechanism needs to be exchanged.

Version:
"$Id: Chronometer.java 1913 2007-08-08 02:41:53Z jpeters $"
Author:
Matthias Pressfreund

Field Summary
private static Set cache_
          The storage for all used Chronometer instances as WeakReference objects
protected  boolean first_
          This flag will be set to false as soon as the first interval has been requested
protected static Long interval_
          The length of an interval in milliseconds
protected static DateFormat TIMESTAMP_FORMAT_
          Contains the output pattern for a timestamp (actually uses SimpleDateFormat)
protected  URL url_
          The URL assignment for this Chronometer
protected  long zerotime_
          Timestamp of last interval
 
Constructor Summary
protected Chronometer(URL url)
          Hidden construction.
 
Method Summary
(package private) static void changeInterval(Long interval)
          Change the interval length
 boolean equals(Object obj)
           
 void finalize()
          Remove this instance and null references from the storage of deployed Chronometer objects.
 URL getURL()
          Get the URL this Chronometer instance has been assigned to.
 int hashCode()
           
protected static Chronometer instanceFor(URL url)
          Get the Chronometer instance for a given URL.
 StringBuffer nextInterval(long logtime)
          Get the current timestamp which is either a number of anchor timestamps for each interval followed by the number of milliseconds elapsed since the last interval or only the complete date and time info in case the interval has been set to zero.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TIMESTAMP_FORMAT_

protected static final DateFormat TIMESTAMP_FORMAT_
Contains the output pattern for a timestamp (actually uses SimpleDateFormat)


cache_

private static Set cache_
The storage for all used Chronometer instances as WeakReference objects


interval_

protected static Long interval_
The length of an interval in milliseconds


url_

protected URL url_
The URL assignment for this Chronometer


zerotime_

protected long zerotime_
Timestamp of last interval


first_

protected boolean first_
This flag will be set to false as soon as the first interval has been requested

Constructor Detail

Chronometer

protected Chronometer(URL url)
Hidden construction.

Parameters:
url - The assigned URL
Method Detail

instanceFor

protected static Chronometer instanceFor(URL url)
Get the Chronometer instance for a given URL. If there has no Chronometer instance assigned to the specified URL yet, a new instance will be created.

Parameters:
url - The URL to create the Chronometer for
Returns:
The Chronometer instance assigned to the given URL

changeInterval

static void changeInterval(Long interval)
Change the interval length

Parameters:
interval - The new interval length

getURL

public URL getURL()
Get the URL this Chronometer instance has been assigned to.

Returns:
The assigned URL

nextInterval

public StringBuffer nextInterval(long logtime)
Get the current timestamp which is either a number of anchor timestamps for each interval followed by the number of milliseconds elapsed since the last interval or only the complete date and time info in case the interval has been set to zero.

Parameters:
logtime - Timestamp of last log message
Returns:
The next timestamp formatted to be put into a log entry, if necessary with preceding anchor timestamps

finalize

public void finalize()
Remove this instance and null references from the storage of deployed Chronometer objects.


equals

public boolean equals(Object obj)

hashCode

public int hashCode()

toString

public String toString()


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.