org.onemind.commons.java.datastructure
Class TrackedMap

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap
          extended by org.onemind.commons.java.datastructure.TrackedMap
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map

public class TrackedMap
extends java.util.HashMap

A map that has it's map values changes tracked. It uses an inner map to keep the unchanged value and itself to track the changes

Version:
$Id: TrackedMap.java,v 1.2 2004/08/26 12:33:16 thlee Exp $ $Name: $
Author:
TiongHiang Lee (thlee@onemindsoft.org)
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
 
Field Summary
private  java.util.Map _tracked
          the track inner map *
 
Constructor Summary
TrackedMap()
          
TrackedMap(int initialCapacity)
          
TrackedMap(int initialCapacity, float loadFactor)
          
TrackedMap(java.util.Map map)
          
 
Method Summary
 void clear()
          
 void clearChanges()
          Clear all the changes
 boolean containsKey(java.lang.Object key)
          
 boolean containsValue(java.lang.Object value)
          
 java.util.Set entrySet()
          
 java.lang.Object get(java.lang.Object key)
          
 java.util.Set getChangedKeySet()
          Return the key set of changed values
 boolean hasChanges()
          Return whether this map has been changes
 boolean isEmpty()
          
 java.util.Set keySet()
          
 void makeUpToDate()
          Make this map as up-to-date.
 java.lang.Object remove(java.lang.Object key)
          
 int size()
          
 java.util.Collection values()
          
 
Methods inherited from class java.util.HashMap
clone, put, putAll
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

_tracked

private java.util.Map _tracked
the track inner map *

Constructor Detail

TrackedMap

public TrackedMap()


TrackedMap

public TrackedMap(int initialCapacity)


TrackedMap

public TrackedMap(int initialCapacity,
                  float loadFactor)


TrackedMap

public TrackedMap(java.util.Map map)

Method Detail

hasChanges

public boolean hasChanges()
Return whether this map has been changes

Returns:
true if it has been changed

getChangedKeySet

public java.util.Set getChangedKeySet()
Return the key set of changed values

Returns:
the key set

get

public java.lang.Object get(java.lang.Object key)

Specified by:
get in interface java.util.Map
Overrides:
get in class java.util.HashMap

makeUpToDate

public void makeUpToDate()
Make this map as up-to-date.


clearChanges

public void clearChanges()
Clear all the changes


clear

public void clear()

Specified by:
clear in interface java.util.Map
Overrides:
clear in class java.util.HashMap

containsKey

public boolean containsKey(java.lang.Object key)

Specified by:
containsKey in interface java.util.Map
Overrides:
containsKey in class java.util.HashMap

containsValue

public boolean containsValue(java.lang.Object value)

Specified by:
containsValue in interface java.util.Map
Overrides:
containsValue in class java.util.HashMap

entrySet

public java.util.Set entrySet()

Specified by:
entrySet in interface java.util.Map
Overrides:
entrySet in class java.util.HashMap

isEmpty

public boolean isEmpty()

Specified by:
isEmpty in interface java.util.Map
Overrides:
isEmpty in class java.util.HashMap

keySet

public java.util.Set keySet()

Specified by:
keySet in interface java.util.Map
Overrides:
keySet in class java.util.HashMap

remove

public java.lang.Object remove(java.lang.Object key)

Specified by:
remove in interface java.util.Map
Overrides:
remove in class java.util.HashMap

size

public int size()

Specified by:
size in interface java.util.Map
Overrides:
size in class java.util.HashMap

values

public java.util.Collection values()

Specified by:
values in interface java.util.Map
Overrides:
values in class java.util.HashMap