net.infonode.properties.propertymap
Class PropertyMapManager

java.lang.Object
  extended by net.infonode.properties.propertymap.PropertyMapManager

public class PropertyMapManager
extends java.lang.Object

Utility class for performing multiple modifications to PropertyMap's and merging change notifications to optimize performance.

Version:
$Revision: 1.16 $
Author:
$Author: jesper $

Field Summary
private  int batchCounter
           
private  java.util.HashMap changes
           
private static PropertyMapManager INSTANCE
           
 
Constructor Summary
PropertyMapManager()
           
 
Method Summary
(package private)  void addMapChanges(PropertyMapImpl propertyMap, ConstMap mapChanges)
           
private  void addTreeChanges(PropertyMapImpl map, PropertyMapImpl modifiedMap, java.util.HashMap changes, java.util.HashMap treeChanges)
           
 void beginBatch()
          Begins a batch operation.
 void endBatch()
          Ends a batch operation.
static PropertyMapManager getInstance()
          Returns the only instance of this class.
static void runBatch(java.lang.Runnable runnable)
          Executes a method inside a beginBatch() - endBatch() pair.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

private static final PropertyMapManager INSTANCE

changes

private java.util.HashMap changes

batchCounter

private int batchCounter
Constructor Detail

PropertyMapManager

public PropertyMapManager()
Method Detail

getInstance

public static PropertyMapManager getInstance()
Returns the only instance of this class.

Returns:
the only instance of this class

addMapChanges

void addMapChanges(PropertyMapImpl propertyMap,
                   ConstMap mapChanges)

runBatch

public static void runBatch(java.lang.Runnable runnable)
Executes a method inside a beginBatch() - endBatch() pair. See beginBatch() for more information. It's safe to call other batch methods from inside Runnable.run().

Parameters:
runnable - the runnable to invoke

beginBatch

public void beginBatch()
Begins a batch operation. This stores and merges all change notifications occuring in all property maps until endBatch() is called. Each call to this method MUST be followed by a call to endBatch(). This method can be called an unlimited number of times without calling endBatch() in between, but each call must have a corresponding call to endBatch(). Only when exiting from the outermost endBatch() the changes be propagated to the listeners.


addTreeChanges

private void addTreeChanges(PropertyMapImpl map,
                            PropertyMapImpl modifiedMap,
                            java.util.HashMap changes,
                            java.util.HashMap treeChanges)

endBatch

public void endBatch()
Ends a batch operation. See beginBatch() for more information.