org.openide.util.lookup
Class DelegatingStorage<Transaction>

java.lang.Object
  extended by org.openide.util.lookup.DelegatingStorage<Transaction>
All Implemented Interfaces:
java.io.Serializable, AbstractLookup.Storage<Transaction>

final class DelegatingStorage<Transaction>
extends java.lang.Object
implements java.io.Serializable, AbstractLookup.Storage<Transaction>

Storages that can switch between another storages.

Author:
Jaroslav Tulach

Constructor Summary
DelegatingStorage(AbstractLookup.Storage<Transaction> d)
           
 
Method Summary
 boolean add(AbstractLookup.Pair<?> item, Transaction transaction)
          Adds an item into the storage.
 Transaction beginTransaction(int ensure)
          Initializes a modification operation by creating an object that will be passsed to all add, remove, retainAll methods and should collect enough information about the change to notify listeners about the transaction later
 void checkForTreeModification()
          Method to check whether there is not multiple access from the same thread.
 AbstractLookup.ReferenceToResult cleanUpResult(Lookup.Template templ)
          Given the provided template, Do cleanup the results.
 void endTransaction(Transaction transaction, java.util.Set<AbstractLookup.R> modified)
          Collects all affected results R that were modified in the given transaction.
 AbstractLookup.Storage<Transaction> exitDelegate()
          Exits from the owners ship of the storage.
static boolean isSimple(AbstractLookup.Storage s)
          Checks whether we have simple behaviour or complex.
<T> java.util.Enumeration<AbstractLookup.Pair<T>>
lookup(java.lang.Class<T> clazz)
          Queries for instances of given class.
 AbstractLookup.ReferenceToResult registerReferenceToResult(AbstractLookup.ReferenceToResult newRef)
          Registers another reference to a result with the storage.
 void remove(AbstractLookup.Pair item, Transaction transaction)
          Removes an item.
 void retainAll(java.util.Map retain, Transaction transaction)
          Removes all items that are not present in the provided collection.
 java.lang.Object writeReplace()
          Never serialize yourself, always put there the delegate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DelegatingStorage

public DelegatingStorage(AbstractLookup.Storage<Transaction> d)
Method Detail

writeReplace

public java.lang.Object writeReplace()
Never serialize yourself, always put there the delegate


checkForTreeModification

public void checkForTreeModification()
Method to check whether there is not multiple access from the same thread.


isSimple

public static boolean isSimple(AbstractLookup.Storage s)
Checks whether we have simple behaviour or complex.


exitDelegate

public AbstractLookup.Storage<Transaction> exitDelegate()
Exits from the owners ship of the storage.


add

public boolean add(AbstractLookup.Pair<?> item,
                   Transaction transaction)
Description copied from interface: AbstractLookup.Storage
Adds an item into the storage.

Specified by:
add in interface AbstractLookup.Storage<Transaction>
Parameters:
item - to add
transaction - transaction token
Returns:
true if the Item has been added for the first time or false if some other item equal to this one already existed in the lookup

remove

public void remove(AbstractLookup.Pair item,
                   Transaction transaction)
Description copied from interface: AbstractLookup.Storage
Removes an item.

Specified by:
remove in interface AbstractLookup.Storage<Transaction>

retainAll

public void retainAll(java.util.Map retain,
                      Transaction transaction)
Description copied from interface: AbstractLookup.Storage
Removes all items that are not present in the provided collection.

Specified by:
retainAll in interface AbstractLookup.Storage<Transaction>
Parameters:
retain - collection of Pairs to keep them in
transaction - the transaction context

beginTransaction

public Transaction beginTransaction(int ensure)
Description copied from interface: AbstractLookup.Storage
Initializes a modification operation by creating an object that will be passsed to all add, remove, retainAll methods and should collect enough information about the change to notify listeners about the transaction later

Specified by:
beginTransaction in interface AbstractLookup.Storage<Transaction>
Parameters:
ensure - the amount of items that will appear in the storage after the modifications (-1 == remove one, -2 == add one, >= 0 the amount of objects at the end
Returns:
a token to identify the transaction

cleanUpResult

public AbstractLookup.ReferenceToResult cleanUpResult(Lookup.Template templ)
Description copied from interface: AbstractLookup.Storage
Given the provided template, Do cleanup the results.

Specified by:
cleanUpResult in interface AbstractLookup.Storage<Transaction>
Parameters:
templ - template of a result(s) that should be checked
Returns:
null if all references for this template were cleared or one of them

endTransaction

public void endTransaction(Transaction transaction,
                           java.util.Set<AbstractLookup.R> modified)
Description copied from interface: AbstractLookup.Storage
Collects all affected results R that were modified in the given transaction.

Specified by:
endTransaction in interface AbstractLookup.Storage<Transaction>
Parameters:
transaction - the transaction indentification

lookup

public <T> java.util.Enumeration<AbstractLookup.Pair<T>> lookup(java.lang.Class<T> clazz)
Description copied from interface: AbstractLookup.Storage
Queries for instances of given class.

Specified by:
lookup in interface AbstractLookup.Storage<Transaction>
Parameters:
clazz - the class to check
Returns:
enumeration of Item
See Also:
#unsorted

registerReferenceToResult

public AbstractLookup.ReferenceToResult registerReferenceToResult(AbstractLookup.ReferenceToResult newRef)
Description copied from interface: AbstractLookup.Storage
Registers another reference to a result with the storage. This method has also a special meaning.

Specified by:
registerReferenceToResult in interface AbstractLookup.Storage<Transaction>
Parameters:
newRef - the new reference to remember
Returns:
the previous reference that was kept (null if newRef is the first one) the applications is expected to link from newRef to this returned value to form a linked list