cz.cuni.amis.pogamut.multi.utils.timekey
Class TimeKey

Package class diagram package TimeKey
java.lang.Object
  extended by cz.cuni.amis.pogamut.multi.utils.timekey.TimeKey
All Implemented Interfaces:
Comparable

public class TimeKey
extends Object
implements Comparable

the TimeKey class makes sure that for every integer time there is only one instance of the TimeKey object. The inner structure of active is implemented via a WeakHashMap. This means that if a process loses reference for the TimeKey object, it can be garbage collected.

Author:
srlok

Nested Class Summary
static class TimeKey.TimeKeyComparator
           
 
Field Summary
protected static Map<Long,WeakReference<TimeKey>> keys
           
 
Method Summary
static void clear()
          Wipes out case with time keys.
 int compareTo(Object key)
           
 boolean equals(Object other)
           
static boolean exists(long time)
          Checks if a TimeKey instance exists for the integer time.
protected  void finalize()
           
static TimeKey get(long time)
          Returns the TimeKey object for the required time.
static List<WeakReference<TimeKey>> getAllKeys()
           
static cz.cuni.amis.utils.flag.ImmutableFlag<Integer> getInstances()
           
 long getTime()
          returns the integer time for this timekey.
 int hashCode()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

keys

protected static Map<Long,WeakReference<TimeKey>> keys
Method Detail

getInstances

public static cz.cuni.amis.utils.flag.ImmutableFlag<Integer> getInstances()

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable

get

public static TimeKey get(long time)
Returns the TimeKey object for the required time. synchronized

Parameters:
time -
Returns:
always returns the same reference for the same time!

clear

public static void clear()
Wipes out case with time keys. Used by tests.


equals

public boolean equals(Object other)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

exists

public static boolean exists(long time)
Checks if a TimeKey instance exists for the integer time.

Parameters:
time -
Returns:

getTime

public long getTime()
returns the integer time for this timekey.

Returns:

compareTo

public int compareTo(Object key)
Specified by:
compareTo in interface Comparable

toString

public String toString()
Overrides:
toString in class Object

getAllKeys

public static List<WeakReference<TimeKey>> getAllKeys()


Copyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.